Skip to content

Commit

Permalink
MDL-23613 fixed one more wrong PAGE->context
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Aug 2, 2010
1 parent 07f7954 commit daf0f79
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions filter/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
$contextid = required_param('contextid',PARAM_INT);
$forfilter = optional_param('filter', '', PARAM_SAFEPATH);

$context = get_context_instance_by_id($contextid, MUST_EXIST);
list($context, $course, $cm) = get_context_info_array($contextid);

/// Check login and permissions.
require_login($course, false, $cm);
require_capability('moodle/filter:manage', $context);

$args = array('contextid'=>$contextid);
$baseurl = new moodle_url('/filter/manage.php', $args);
Expand All @@ -44,30 +48,24 @@
}

$isfrontpage = ($context->contextlevel == CONTEXT_COURSE && $context->instanceid == SITEID);

$contextname = print_context_name($context);

$cm = null;
if ($context->contextlevel == CONTEXT_COURSECAT) {
$course = clone($SITE);
$heading = "$SITE->fullname: ".get_string("categories");
$PAGE->set_heading();
} else if ($context->contextlevel == CONTEXT_COURSE) {
$course = $DB->get_record('course', array('id' => $context->instanceid), '*', MUST_EXIST);
$heading = $course->fullname;
} else {
} else if ($context->contextlevel == CONTEXT_MODULE) {
// Must be module context.
$cm = get_coursemodule_from_id(null, $context->instanceid, false, 0, MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
$heading = $PAGE->activityrecord->name;
} else {
$heading = '';
}

/// Check login and permissions.
require_login($course, false, $cm);
require_capability('moodle/filter:manage', $context);

if ($cm) {
$heading = $PAGE->activityrecord->name;
}

$PAGE->set_context($context);
$PAGE->set_heading($heading);

Expand Down

0 comments on commit daf0f79

Please sign in to comment.