MDL-70439 Profile: Indicate user email address settings on own profile

This commit is contained in:
hiendinh 2020-12-11 16:11:01 +07:00
parent fd840ab59c
commit c3b7e5fe16
3 changed files with 33 additions and 2 deletions

View File

@ -648,6 +648,9 @@ $string['emaildisableclick'] = 'Click here to disable all email from being sent
$string['emaildisplay'] = 'Email display';
$string['emaildisplay_help'] = 'Privileged users (such as teachers and managers) will always be able to see your email address.';
$string['emaildisplaycourse'] = 'Allow only other course members to see my email address';
$string['emaildisplaycoursemembersonly'] = '(Visible to other course participants)';
$string['emaildisplayeveryone'] = '(Visible to everyone)';
$string['emaildisplayhide'] = '(Hidden from all non-privileged users)';
$string['emaildisplayno'] = 'Hide my email address from non-privileged users';
$string['emaildisplayyes'] = 'Allow everyone to see my email address';
$string['emailenable'] = 'This email address is enabled';

View File

@ -158,8 +158,18 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
))
or (isset($identityfields['email']) and $canviewuseridentity)
) {
$node = new core_user\output\myprofile\node('contact', 'email', get_string('email'), null, null,
obfuscate_mailto($user->email, ''));
$maildisplay = obfuscate_mailto($user->email, '');
if ($iscurrentuser) {
if ($user->maildisplay == core_user::MAILDISPLAY_EVERYONE) {
$maildisplay .= ' ' . get_string('emaildisplayeveryone');
} else if ($user->maildisplay == core_user::MAILDISPLAY_COURSE_MEMBERS_ONLY) {
$maildisplay .= ' ' . get_string('emaildisplaycoursemembersonly');
} else {
$maildisplay .= ' ' . get_string('emaildisplayhide');
}
}
$node = new core_user\output\myprofile\node('contact', 'email', get_string('email'),
null, null, $maildisplay);
$tree->add_node($node);
}

View File

@ -28,6 +28,7 @@ Feature: Set email display preference
Given I log in as "studentp"
When I follow "Profile" in the user menu
Then I should see "studentP@example.com"
And I should see "(Visible to other course participants)"
@javascript
Scenario: Student peer on the same course viewing profiles
@ -76,3 +77,20 @@ Feature: Set email display preference
And I navigate to course participants
When I follow "Student MEMBERS"
Then I should see "studentM@example.com"
@javascript
Scenario: User can see user's email address settings on own profile
Given I log in as "studentp"
And I follow "Profile" in the user menu
Then I should see "studentP@example.com"
And I should see "(Visible to other course participants)"
When I click on "Edit profile" "link" in the "region-main" "region"
And I set the following fields to these values:
| maildisplay | 0 |
And I click on "Update profile" "button"
Then I should see "(Hidden from all non-privileged users)"
When I click on "Edit profile" "link" in the "region-main" "region"
And I set the following fields to these values:
| maildisplay | 1 |
And I click on "Update profile" "button"
Then I should see "(Visible to everyone)"