mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-10945 fixed block capability checks in switch role mode
This commit is contained in:
parent
57a260d9a5
commit
c331cf23c5
1 changed files with 8 additions and 11 deletions
|
@ -613,13 +613,9 @@ function has_capability($capability, $context=NULL, $userid=NULL, $doanything=tr
|
|||
$capcache[$cachekey] = $result;
|
||||
return $result;
|
||||
}
|
||||
} else { // if not course-view type of blocks, check site
|
||||
if (isset($capabilities[$sitecontext->id]['do_anything'])) {
|
||||
$result = (0 < $capabilities[$sitecontext->id]['do_anything']);
|
||||
$capcache[$cachekey] = $result;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
// blocks that do not have course as parent do not need to do any more checks - already done above
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -726,7 +722,8 @@ function capability_search($capability, $context, $capabilities, $switchroleacti
|
|||
} else {
|
||||
$parentcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
}
|
||||
$permission = capability_search($capability, $parentcontext, $capabilities, $switchroleactive);
|
||||
// ignore the $switchroleactive beause we want the real block view capability defined in system context
|
||||
$permission = capability_search($capability, $parentcontext, $capabilities, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1361,7 +1358,7 @@ function capability_prohibits($capability, $context, $sum='', $array='') {
|
|||
break;
|
||||
|
||||
case CONTEXT_BLOCK:
|
||||
// 1 to 1 to course.
|
||||
// not necessarily 1 to 1 to course.
|
||||
if (!$block = get_record('block_instance','id',$context->instanceid)) {
|
||||
$prohibits[$capability][$context->id] = false;
|
||||
return false;
|
||||
|
@ -2831,7 +2828,7 @@ function print_context_name($context, $withprefix = true, $short = false) {
|
|||
}
|
||||
break;
|
||||
|
||||
case CONTEXT_BLOCK: // 1 to 1 to course
|
||||
case CONTEXT_BLOCK: // not necessarily 1 to 1 to course
|
||||
if ($blockinstance = get_record('block_instance','id',$context->instanceid)) {
|
||||
if ($block = get_record('block','id',$blockinstance->blockid)) {
|
||||
global $CFG;
|
||||
|
@ -3121,7 +3118,7 @@ function get_parent_contexts($context) {
|
|||
}
|
||||
break;
|
||||
|
||||
case CONTEXT_BLOCK: // 1 to 1 to course
|
||||
case CONTEXT_BLOCK: // not necessarily 1 to 1 to course
|
||||
if (!$block = get_record('block_instance','id',$context->instanceid)) {
|
||||
return array();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue