MDL-23797 fixed some problems discovered by the new PAGE->context diag code

This commit is contained in:
Petr Skoda
2010-08-16 19:11:50 +00:00
parent eb5bdb3510
commit dba37691c5
2 changed files with 6 additions and 2 deletions
+4 -2
View File
@@ -42,7 +42,7 @@ if ($id) { // editing course
}
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
require_login($course->id);
require_login($course);
$category = $DB->get_record('course_categories', array('id'=>$course->category), '*', MUST_EXIST);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:update', $coursecontext);
@@ -52,8 +52,10 @@ if ($id) { // editing course
$course = null;
require_login();
$category = $DB->get_record('course_categories', array('id'=>$categoryid), '*', MUST_EXIST);
require_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $category->id));
$catcontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
require_capability('moodle/course:create', $catcontext);
$PAGE->url->param('category',$categoryid);
$PAGE->set_context($catcontext);
} else {
require_login();
+2
View File
@@ -19,6 +19,7 @@ if ($id) {
}
$PAGE->set_url('/course/editcategory.php', array('id' => $id));
$categorycontext = get_context_instance(CONTEXT_COURSECAT, $id);
$PAGE->set_context($categorycontext);
require_capability('moodle/category:manage', $categorycontext);
$strtitle = get_string('editcategorysettings');
$editorcontext = $categorycontext;
@@ -33,6 +34,7 @@ if ($id) {
} else {
$context = get_system_context();
}
$PAGE->set_context($context);
$category = new stdClass();
$category->id = 0;
$category->parent = $parent;