MDL-67672 user: Display name in user menu as elsewhere.
This commit is contained in:
+4
-3
@@ -3520,11 +3520,12 @@ function ismoving($courseid) {
|
||||
* Returns a persons full name
|
||||
*
|
||||
* Given an object containing all of the users name values, this function returns a string with the full name of the person.
|
||||
* The result may depend on system settings or language. 'override' will force both names to be used even if system settings
|
||||
* specify one.
|
||||
* The result may depend on system settings or language. 'override' will force the alternativefullnameformat to be used. In
|
||||
* English, fullname as well as alternativefullnameformat is set to 'firstname lastname' by default. But you could have
|
||||
* fullname set to 'firstname lastname' and alternativefullnameformat set to 'firstname middlename alternatename lastname'.
|
||||
*
|
||||
* @param stdClass $user A {@link $USER} object to get full name of.
|
||||
* @param bool $override If true then the name will be firstname followed by lastname rather than adhering to fullnamedisplay.
|
||||
* @param bool $override If true then the alternativefullnameformat format rather than fullnamedisplay format will be used.
|
||||
* @return string
|
||||
*/
|
||||
function fullname($user, $override=false) {
|
||||
|
||||
+2
-2
@@ -853,7 +853,7 @@ function user_get_user_navigation_info($user, $page, $options = array()) {
|
||||
|
||||
// Get basic user metadata.
|
||||
$returnobject->metadata['userid'] = $user->id;
|
||||
$returnobject->metadata['userfullname'] = fullname($user, true);
|
||||
$returnobject->metadata['userfullname'] = fullname($user);
|
||||
$returnobject->metadata['userprofileurl'] = new moodle_url('/user/profile.php', array(
|
||||
'id' => $user->id
|
||||
));
|
||||
@@ -925,7 +925,7 @@ function user_get_user_navigation_info($user, $page, $options = array()) {
|
||||
// Save values for the real user, as $user will be full of data for the
|
||||
// user the user is disguised as.
|
||||
$returnobject->metadata['realuserid'] = $realuser->id;
|
||||
$returnobject->metadata['realuserfullname'] = fullname($realuser, true);
|
||||
$returnobject->metadata['realuserfullname'] = fullname($realuser);
|
||||
$returnobject->metadata['realuserprofileurl'] = new moodle_url('/user/profile.php', array(
|
||||
'id' => $realuser->id
|
||||
));
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
@core @core_user
|
||||
Feature: Users' names are displayed across the site according to the user policy settings
|
||||
In order to control the way students and teachers see users' names
|
||||
As a teacher or admin
|
||||
I need to be able to configure the name display formats 'fullnamedisplay' and 'alternativefullnameformat'
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email | middlename | alternatename | firstnamephonetic | lastnamephonetic |
|
||||
| user1 | Grainne | Beauchamp | one@example.com | Ann | Jill | Gronya | Beecham |
|
||||
| user2 | Niamh | Cholmondely | two@example.com | Jane | Nina | Nee | Chumlee |
|
||||
| user3 | Siobhan | Desforges | three@example.com | Sarah | Sev | Shevon | De-forjay |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com | | | | |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| user1 | C1 | student |
|
||||
| user2 | C1 | student |
|
||||
And the following config values are set as admin:
|
||||
| fullnamedisplay | firstnamephonetic,lastnamephonetic |
|
||||
| alternativefullnameformat | middlename, alternatename, firstname, lastname |
|
||||
|
||||
Scenario: As a student, 'fullnamedisplay' should be used in the participants list and when viewing my own course profile
|
||||
Given I log in as "user1"
|
||||
And I am on "Course 1" course homepage
|
||||
When I navigate to course participants
|
||||
And I click on "Gronya,Beecham" "link" in the "Gronya,Beecham" "table_row"
|
||||
Then I should see "Gronya,Beecham" in the "region-main" "region"
|
||||
And I log out
|
||||
|
||||
Scenario: As a student, 'fullnamedisplay' should be used in the participants list and when viewing another user's course profile
|
||||
Given I log in as "user2"
|
||||
And I am on "Course 1" course homepage
|
||||
When I navigate to course participants
|
||||
And I click on "Gronya,Beecham" "link" in the "Gronya,Beecham" "table_row"
|
||||
Then I should see "Gronya,Beecham" in the "region-main" "region"
|
||||
And I log out
|
||||
|
||||
Scenario: As a teacher, 'alternativefullnameformat' should be used in the participants list but 'fullnamedisplay' used on the course profile
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
When I navigate to course participants
|
||||
Then I should see "Ann, Jill, Grainne, Beauchamp" in the "Ann, Jill, Grainne, Beauchamp" "table_row"
|
||||
And I click on "Ann, Jill, Grainne, Beauchamp" "link" in the "Ann, Jill, Grainne, Beauchamp" "table_row"
|
||||
And I should see "Gronya,Beecham" in the "region-main" "region"
|
||||
And I log out
|
||||
|
||||
Scenario: As an authenticated user, 'fullnamedisplay' should be used in the navigation and when viewing my profile
|
||||
Given I log in as "user1"
|
||||
When I follow "Profile" in the user menu
|
||||
Then I should see "Gronya,Beecham" in the ".usermenu" "css_element"
|
||||
And I should see "Gronya,Beecham" in the ".page-context-header" "css_element"
|
||||
And I log out
|
||||
|
||||
Scenario: As an admin, 'fullnamedisplay' should be used when using the 'log in as' function
|
||||
Given I log in as "admin"
|
||||
When I navigate to "Users > Accounts > Browse list of users" in site administration
|
||||
And I follow "Jane, Nina, Niamh, Cholmondely"
|
||||
And I follow "Log in as"
|
||||
Then I should see "You are logged in as Nee,Chumlee"
|
||||
And I log out
|
||||
|
||||
Scenario: As an admin, 'fullnamedisplay' should be used when viewing another user's site profile
|
||||
Given I log in as "admin"
|
||||
When I navigate to "Users > Accounts > Browse list of users" in site administration
|
||||
And I follow "Ann, Jill, Grainne, Beauchamp"
|
||||
Then I should see "Gronya,Beecham" in the ".page-header-headings" "css_element"
|
||||
And I log out
|
||||
|
||||
@javascript
|
||||
Scenario: As a teacher, the 'alternativefullnameformat' should be used when searching for and enrolling a user
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
When I navigate to course participants
|
||||
And I press "Enrol users"
|
||||
And I set the field "Select users" to "three@example.com"
|
||||
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
|
||||
Then I should see "Sarah, Sev, Siobhan, Desforges"
|
||||
|
||||
Reference in New Issue
Block a user