Merge branch 'MDL-59172-32' of https://github.com/snake/moodle into MOODLE_32_STABLE
This commit is contained in:
@@ -4,6 +4,7 @@ information provided here is intended especially for developers.
|
||||
=== 3.2.4 ===
|
||||
|
||||
* The caching option 'immutable' has been added to send_stored_file() and send_file().
|
||||
* user_can_view_profile() now also checks the moodle/user:viewalldetails capability.
|
||||
|
||||
=== 3.2.3 ===
|
||||
|
||||
|
||||
+1
-2
@@ -135,8 +135,7 @@ if (empty($result->posts)) {
|
||||
// In either case we need to decide whether we can show personal information
|
||||
// about the requested user to the current user so we will execute some checks
|
||||
|
||||
// TODO - Remove extra cap check once MDL-59172 is resolved.
|
||||
$canviewuser = user_can_view_profile($user, null, $usercontext) || has_capability('moodle/user:viewalldetails', $usercontext);
|
||||
$canviewuser = user_can_view_profile($user, null, $usercontext);
|
||||
|
||||
// Prepare the page title
|
||||
$pagetitle = get_string('noposts', 'mod_forum');
|
||||
|
||||
+1
-1
@@ -1143,7 +1143,7 @@ function user_can_view_profile($user, $course = null, $usercontext = null) {
|
||||
$usercontext = context_user::instance($user->id);
|
||||
}
|
||||
// Number 3.
|
||||
if (has_capability('moodle/user:viewdetails', $usercontext)) {
|
||||
if (has_capability('moodle/user:viewdetails', $usercontext) || has_capability('moodle/user:viewalldetails', $usercontext)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -576,6 +576,15 @@ class core_userliblib_testcase extends advanced_testcase {
|
||||
$this->setUser($user5);
|
||||
$this->assertTrue(user_can_view_profile($user4));
|
||||
|
||||
// Test the user:viewalldetails cap check using the course creator role which, by default, can't see student profiles.
|
||||
$this->setUser($user7);
|
||||
$this->assertFalse(user_can_view_profile($user4));
|
||||
assign_capability('moodle/user:viewalldetails', CAP_ALLOW, $coursecreatorrole->id, context_system::instance()->id, true);
|
||||
reload_all_capabilities();
|
||||
$this->assertTrue(user_can_view_profile($user4));
|
||||
unassign_capability('moodle/user:viewalldetails', $coursecreatorrole->id, $coursecontext->id);
|
||||
reload_all_capabilities();
|
||||
|
||||
$CFG->coursecontact = null;
|
||||
|
||||
// Visitor (Not a guest user, userid=0).
|
||||
|
||||
Reference in New Issue
Block a user