Skip to content

Commit

Permalink
MDL-25575 fix broken block support in get_courseid_from_context()
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 13, 2011
1 parent d911c72 commit 28765cf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,10 @@ function get_context_info_array($contextid) {
* @return int|bool related course id or false
*/
function get_courseid_from_context($context) {
if (empty($context->contextlevel)) {
debugging('Invalid context object specified in get_courseid_from_context() call');
return false;
}
if ($context->contextlevel == CONTEXT_COURSE) {
return $context->instanceid;
}
Expand All @@ -2370,7 +2374,7 @@ function get_courseid_from_context($context) {
if ($context->contextlevel == CONTEXT_BLOCK) {
$parentcontexts = get_parent_contexts($context, false);
$parent = reset($parentcontexts);
return get_courseid_from_context($parent);
return get_courseid_from_context(get_context_instance_by_id($parent));
}

return false;
Expand Down

0 comments on commit 28765cf

Please sign in to comment.