From b3d5f7bc50eb72baaa5d05b2047e9ac9244ebf69 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 16 Sep 2014 10:58:05 +0800 Subject: [PATCH] MDL-40356 lib: New setting to display full names. This adds a new setting to display more name information for users with the viewfullnames capability. --- admin/settings/users.php | 3 +++ lang/en/admin.php | 2 ++ lib/moodlelib.php | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/admin/settings/users.php b/admin/settings/users.php index 2e613e7122d..f8d5b74f9fd 100644 --- a/admin/settings/users.php +++ b/admin/settings/users.php @@ -190,6 +190,9 @@ 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'), + 'language', 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')); diff --git a/lang/en/admin.php b/lang/en/admin.php index 8176a337d2e..4503afb56f1 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -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'; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index c57d8ab09c9..4b97eeadfe6 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3602,11 +3602,22 @@ 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); } + // Check to see if we are displaying according to the alternative full name format. + if ($override) { + if (empty($CFG->alternativefullnameformat) || $CFG->alternativefullnameformat == 'language') { + // Default to show just the user names according to the fullnamedisplay string. + return get_string('fullnamedisplay', null, $user); + } else { + // If the override is true, then change the template to use the complete name. + $template = $CFG->alternativefullnameformat; + } + } + $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) {