Skip to content
Permalink
Browse files

Merge branch 'MDL-40854_24' of git://github.com/timhunt/moodle into M…

…OODLE_24_STABLE
  • Loading branch information...
Sam Hemelryk
Sam Hemelryk committed Jul 28, 2013
2 parents 9da794f + f30c928 commit aa713f26bdbf763aa688aa5a6b7f7c032448ff67
Showing with 21 additions and 2 deletions.
  1. +2 −1 grade/report/user/lib.php
  2. +19 −1 lib/modinfolib.php
@@ -365,7 +365,8 @@ private function fill_table_recursive(&$element) {
$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;
}
}
@@ -1151,7 +1151,8 @@ private function update_user_visible() {
}
// 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.
@@ -1182,6 +1183,23 @@ public function is_user_access_restricted_by_group() {
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
*

0 comments on commit aa713f2

Please sign in to comment.
You can’t perform that action at this time.