mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
merged fix for MDL-9656, blocks parents can be system context
This commit is contained in:
parent
6eaa3f09ce
commit
6ceebc1f32
@ -1344,7 +1344,11 @@ function capability_prohibits($capability, $context, $sum='', $array='') {
|
||||
$prohibits[$capability][$context->id] = false;
|
||||
return false;
|
||||
}
|
||||
if ($block->pagetype == 'course-view') {
|
||||
$parent = get_context_instance(CONTEXT_COURSE, $block->pageid); // needs check
|
||||
} else {
|
||||
$parent = get_context_instance(CONTEXT_SYSTEM);
|
||||
}
|
||||
$prohibits[$capability][$context->id] = capability_prohibits($capability, $parent);
|
||||
return $prohibits[$capability][$context->id];
|
||||
break;
|
||||
@ -2982,7 +2986,14 @@ function get_parent_contexts($context) {
|
||||
if (!$block = get_record('block_instance','id',$context->instanceid)) {
|
||||
return array();
|
||||
}
|
||||
if ($parent = get_context_instance(CONTEXT_COURSE, $block->pageid)) {
|
||||
// fix for MDL-9656, block parents are not necessarily courses
|
||||
if ($block->pagetype == 'course-view') {
|
||||
$parent = get_context_instance(CONTEXT_COURSE, $block->pageid);
|
||||
} else {
|
||||
$parent = get_context_instance(CONTEXT_SYSTEM);
|
||||
}
|
||||
|
||||
if ($parent) {
|
||||
$res = array_merge(array($parent->id), get_parent_contexts($parent));
|
||||
$pcontexts[$context->id] = $res;
|
||||
return $res;
|
||||
@ -3880,7 +3891,6 @@ function insert_context_rel($context, $deletechild=true, $deleteparent=true) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* rebuild context_rel table without deleting
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user