Skip to content

Commit

Permalink
fix for MDL-9656, blocks parents can be system context
Browse files Browse the repository at this point in the history
  • Loading branch information
toyomoyo committed May 7, 2007
1 parent 6f45d05 commit c9dc3ac
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,11 @@ function capability_prohibits($capability, $context, $sum='', $array='') {
$prohibits[$capability][$context->id] = false;
return false;
}
$parent = get_context_instance(CONTEXT_COURSE, $block->pageid); // needs check
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;
Expand Down Expand Up @@ -2982,12 +2986,19 @@ 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;
} else {
return array();
return array();
}
break;

Expand Down Expand Up @@ -3880,7 +3891,6 @@ function insert_context_rel($context, $deletechild=true, $deleteparent=true) {
}
}


/**
* rebuild context_rel table without deleting
*/
Expand Down

0 comments on commit c9dc3ac

Please sign in to comment.