From 92111f008f0d6c1f55aa999434e637a454e24c33 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Wed, 9 Sep 2020 07:15:48 +0100 Subject: [PATCH] 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. --- lib/myprofilelib.php | 4 +--- user/tests/behat/view_full_profile.feature | 12 ++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/myprofilelib.php b/lib/myprofilelib.php index 87c792dbcd160..680fa29ed26ef 100644 --- a/lib/myprofilelib.php +++ b/lib/myprofilelib.php @@ -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); diff --git a/user/tests/behat/view_full_profile.feature b/user/tests/behat/view_full_profile.feature index c235b7b2c5748..e6cc8dfa8376a 100644 --- a/user/tests/behat/view_full_profile.feature +++ b/user/tests/behat/view_full_profile.feature @@ -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