Skip to content

Commit

Permalink
MDL-23797 fixed some problems discovered by the new PAGE->context dia…
Browse files Browse the repository at this point in the history
…g code
  • Loading branch information
skodak committed Aug 16, 2010
1 parent eb5bdb3 commit dba3769
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions course/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}

$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);
Expand All @@ -52,8 +52,10 @@
$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();
Expand Down
2 changes: 2 additions & 0 deletions course/editcategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
}
$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;
Expand All @@ -33,6 +34,7 @@
} else {
$context = get_system_context();
}
$PAGE->set_context($context);
$category = new stdClass();
$category->id = 0;
$category->parent = $parent;
Expand Down

0 comments on commit dba3769

Please sign in to comment.