MDL-66648 user: consistent checks for linking to full profile.

The access checks for displaying a link to a users' full profile
now match the checks performed on the full profile page itself.
This commit is contained in:
Paul Holden
2020-09-14 20:22:03 +01:00
parent ccd4ef8ddd
commit 070454489f
2 changed files with 11 additions and 5 deletions
+1 -3
View File
@@ -62,9 +62,7 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
// Add core nodes.
// Full profile node.
if (!empty($course)) {
if (empty($CFG->forceloginforprofiles) || $iscurrentuser ||
has_capability('moodle/user:viewdetails', $usercontext)
|| has_coursecontact_role($user->id)) {
if (user_can_view_profile($user, null, $usercontext)) {
$url = new moodle_url('/user/profile.php', array('id' => $user->id));
$node = new core_user\output\myprofile\node('miscellaneous', 'fullprofile', get_string('fullprofile'), null, $url);
$tree->add_node($node);
+10 -2
View File
@@ -26,11 +26,11 @@ Feature: Access to full profiles of users
Scenario: Viewing full profiles with default settings
When I log in as "student1"
# Another student's full profile is visible
And I am on "Course 1" course homepage
# Another student's full profile is not visible
And I navigate to course participants
And I follow "Student 2"
Then I should not see "Full profile"
Then I should see "Full profile"
# Teacher's full profile is visible
And I am on "Course 1" course homepage
And I navigate to course participants
@@ -66,6 +66,14 @@ Feature: Access to full profiles of users
And I follow "Full profile"
Then I should see "First access to site"
Scenario: Viewing full profiles of students as a teacher
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to course participants
And I follow "Student 1"
And I follow "Full profile"
Then I should see "First access to site"
Scenario: Viewing own full profile
Given I log in as "student1"
When I follow "Profile" in the user menu