Merge branch 'MDL-40854_25' of git://github.com/timhunt/moodle into MOODLE_25_STABLE
This commit is contained in:
@@ -365,7 +365,8 @@ class grade_report_user extends grade_report {
|
||||
$cm = $instances[$grade_object->iteminstance];
|
||||
if (!$cm->uservisible) {
|
||||
// Further checks are required to determine whether the activity is entirely hidden or just greyed out.
|
||||
if ($cm->is_user_access_restricted_by_group() || $cm->is_user_access_restricted_by_conditional_access()) {
|
||||
if ($cm->is_user_access_restricted_by_group() || $cm->is_user_access_restricted_by_conditional_access() ||
|
||||
$cm->is_user_access_restricted_by_capability()) {
|
||||
$hide = true;
|
||||
}
|
||||
}
|
||||
|
||||
+19
-1
@@ -1203,7 +1203,8 @@ class cm_info extends stdClass {
|
||||
}
|
||||
|
||||
// Check group membership.
|
||||
if ($this->is_user_access_restricted_by_group()) {
|
||||
if ($this->is_user_access_restricted_by_group() ||
|
||||
$this->is_user_access_restricted_by_capability()) {
|
||||
|
||||
$this->uservisible = false;
|
||||
// Ensure activity is completely hidden from the user.
|
||||
@@ -1234,6 +1235,23 @@ class cm_info extends stdClass {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether mod/...:view capability restricts the current user's access.
|
||||
*
|
||||
* @return bool True if the user access is restricted.
|
||||
*/
|
||||
public function is_user_access_restricted_by_capability() {
|
||||
$capability = 'mod/' . $this->modname . ':view';
|
||||
$capabilityinfo = get_capability_info($capability);
|
||||
if (!$capabilityinfo) {
|
||||
// Capability does not exist, no one is prevented from seeing the activity.
|
||||
return false;
|
||||
}
|
||||
|
||||
// You are blocked if you don't have the capability.
|
||||
return !has_capability($capability, context_module::instance($this->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the module's conditional access settings mean that the user cannot see the activity at all
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user