Skip to content

Commit

Permalink
Revert "Merge branch 'wip-MDL-40356-master' of git://github.com/abgre…
Browse files Browse the repository at this point in the history
…eve/moodle"

This reverts commit 4b5fd6e, reversing
changes made to a788aad.
  • Loading branch information
marinaglancy committed Sep 11, 2014
1 parent 54e6e19 commit e0dfc38
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 47 deletions.
4 changes: 0 additions & 4 deletions admin/settings/users.php
Expand Up @@ -190,10 +190,6 @@
'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'));
Expand Down
3 changes: 1 addition & 2 deletions lang/en/admin.php
Expand Up @@ -56,8 +56,6 @@
$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';
Expand Down Expand Up @@ -538,6 +536,7 @@
$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';
Expand Down
16 changes: 2 additions & 14 deletions lib/moodlelib.php
Expand Up @@ -3602,23 +3602,11 @@ function fullname($user, $override=false) {
if (isset($CFG->fullnamedisplay)) {
$template = $CFG->fullnamedisplay;
}
// If the template is empty, or set to language, return the language string.
if ((empty($template) || $template == 'language') && !$override) {
// If the template is empty, or set to language, or $override is set, 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) {
Expand Down
27 changes: 0 additions & 27 deletions lib/tests/moodlelib_test.php
Expand Up @@ -2321,7 +2321,6 @@ public function test_fullname() {
// Back up config settings for restore later.
$originalcfg = new stdClass();
$originalcfg->fullnamedisplay = $CFG->fullnamedisplay;
$originalcfg->alternativefullnameformat = $CFG->alternativefullnameformat;

// Testing existing fullnamedisplay settings.
$CFG->fullnamedisplay = 'firstname';
Expand All @@ -2345,35 +2344,10 @@ public function test_fullname() {

// Test override parameter.
$CFG->fullnamedisplay = 'firstname';
$expectedname = "$user->firstname $user->lastname $user->firstnamephonetic $user->lastnamephonetic $user->middlename $user->alternatename";
$testname = fullname($user, true);
$this->assertSame($expectedname, $testname);

// Test alternativefullnameformat setting.
// Test alternativefullnameformat that has been set to nothing.
$CFG->alternativefullnameformat = '';
$expectedname = "$user->firstname $user->lastname $user->firstnamephonetic $user->lastnamephonetic $user->middlename $user->alternatename";
$testname = fullname($user, true);
$this->assertSame($expectedname, $testname);

// Test alternativefullnameformat that has been set to 'language'.
$CFG->alternativefullnameformat = 'language';
$expectedname = "$user->firstname $user->lastname $user->firstnamephonetic $user->lastnamephonetic $user->middlename $user->alternatename";
$testname = fullname($user, true);
$this->assertSame($expectedname, $testname);

// Test customising the alternativefullnameformat setting with a basic configuration.
$CFG->alternativefullnameformat = 'firstname lastname';
$expectedname = "$user->firstname $user->lastname";
$testname = fullname($user, true);
$this->assertSame($expectedname, $testname);

// Test customising the alternativefullnameformat setting with a more advanced configuration.
$CFG->alternativefullnameformat = 'firstname firstnamephonetic lastname lastnamephonetic, middlename';
$expectedname = "$user->firstname $user->firstnamephonetic $user->lastname $user->lastnamephonetic, $user->middlename";
$testname = fullname($user, true);
$this->assertSame($expectedname, $testname);

// Test additional name fields.
$CFG->fullnamedisplay = 'lastname lastnamephonetic firstname firstnamephonetic';
$expectedname = "$user->lastname $user->lastnamephonetic $user->firstname $user->firstnamephonetic";
Expand Down Expand Up @@ -2454,7 +2428,6 @@ public function test_fullname() {

// Tidy up after we finish testing.
$CFG->fullnamedisplay = $originalcfg->fullnamedisplay;
$CFG->alternativefullnameformat = $originalcfg->alternativefullnameformat;
}

public function test_get_all_user_name_fields() {
Expand Down

0 comments on commit e0dfc38

Please sign in to comment.