MDL-40356 lib: Added a new setting to display more information from the fullname...
authorAdrian Greeve <adrian@moodle.com>
Mon, 21 Jul 2014 04:24:57 +0000 (12:24 +0800)
committerAdrian Greeve <adrian@moodle.com>
Tue, 9 Sep 2014 01:22:43 +0000 (09:22 +0800)
admin/settings/users.php
lang/en/admin.php
lib/moodlelib.php

index 2e613e7..9260178 100644 (file)
@@ -190,6 +190,10 @@ if ($hassiteconfig
                     'institution' => new lang_string('institution'),
                 )));
         $temp->add(new admin_setting_configtext('fullnamedisplay', new lang_string('fullnamedisplay', 'admin'), new lang_string('configfullnamedisplay', 'admin'), 'language', PARAM_TEXT, 50));
+        $temp->add(new admin_setting_configtext('alternativefullnameformat', new lang_string('alternativefullnameformat', 'admin'),
+                new lang_string('alternativefullnameformat_desc', 'admin'),
+                'firstname lastname firstnamephonetic lastnamephonetic middlename alternatename',
+                PARAM_RAW, 50));
         $temp->add(new admin_setting_configtext('maxusersperpage', new lang_string('maxusersperpage','admin'), new lang_string('configmaxusersperpage','admin'), 100, PARAM_INT));
         $temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
         $temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm'));
index 8176a33..41defde 100644 (file)
@@ -56,6 +56,8 @@ $string['allowthemechangeonurl'] = 'Allow theme changes in the URL';
 $string['allowuserblockhiding'] = 'Allow users to hide blocks';
 $string['allowuserswitchrolestheycantassign'] = 'Allow users without the assign roles capability to switch roles';
 $string['allowuserthemes'] = 'Allow user themes';
+$string['alternativefullnameformat'] = 'Alternative full name format';
+$string['alternativefullnameformat_desc'] = 'This defines how names are shown to users with the viewfullnames capability (by default users with the role of manager, teacher or non-editing teacher). Placeholders that can be used are as for the "Full name format" setting.';
 $string['antivirus'] = 'Anti-Virus';
 $string['appearance'] = 'Appearance';
 $string['aspellpath'] = 'Path to aspell';
@@ -536,7 +538,6 @@ $string['frontpagerestore'] = 'Front page restore';
 $string['frontpageroles'] = 'Front page roles';
 $string['frontpagesettings'] = 'Front page settings';
 $string['fullnamedisplay'] = 'Full name format';
-$string['fullnamedisplayprivate'] = 'Full name format - private';
 $string['gdrequired'] = 'The GD extension is now required by Moodle for image conversion.';
 $string['generalsettings'] = 'General settings';
 $string['geoipfile'] = 'GeoIP city data file';
index c57d8ab..f337155 100644 (file)
@@ -3602,11 +3602,23 @@ function fullname($user, $override=false) {
     if (isset($CFG->fullnamedisplay)) {
         $template = $CFG->fullnamedisplay;
     }
-    // If the template is empty, or set to language, or $override is set, return the language string.
-    if (empty($template) || $template == 'language' || $override) {
+    // If the template is empty, or set to language, return the language string.
+    if ((empty($template) || $template == 'language') && !$override) {
         return get_string('fullnamedisplay', null, $user);
     }
 
+    $admindisplay = null;
+    // Language isn't actually a valid value for alternativefullnameformat, but people might enter it in anyway.
+    if (empty($CFG->alternativefullnameformat) || $CFG->alternativefullnameformat == 'language') {
+        // Default to show all names if the setting is empty.
+        $admindisplay = 'firstname lastname firstnamephonetic lastnamephonetic middlename alternatename';
+    } else {
+        $admindisplay = $CFG->alternativefullnameformat;
+    }
+
+    // If the override is true, then change the template to use the complete name.
+    $template = ($override) ? $admindisplay : $template;
+
     $requirednames = array();
     // With each name, see if it is in the display name template, and add it to the required names array if it is.
     foreach ($allnames as $allname) {