Skip to content

Commit dba3769

Browse files
committedAug 16, 2010
MDL-23797 fixed some problems discovered by the new PAGE->context diag code
1 parent eb5bdb3 commit dba3769

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎course/edit.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
}
4343

4444
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
45-
require_login($course->id);
45+
require_login($course);
4646
$category = $DB->get_record('course_categories', array('id'=>$course->category), '*', MUST_EXIST);
4747
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
4848
require_capability('moodle/course:update', $coursecontext);
@@ -52,8 +52,10 @@
5252
$course = null;
5353
require_login();
5454
$category = $DB->get_record('course_categories', array('id'=>$categoryid), '*', MUST_EXIST);
55-
require_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $category->id));
55+
$catcontext = get_context_instance(CONTEXT_COURSECAT, $category->id);
56+
require_capability('moodle/course:create', $catcontext);
5657
$PAGE->url->param('category',$categoryid);
58+
$PAGE->set_context($catcontext);
5759

5860
} else {
5961
require_login();

‎course/editcategory.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
}
2020
$PAGE->set_url('/course/editcategory.php', array('id' => $id));
2121
$categorycontext = get_context_instance(CONTEXT_COURSECAT, $id);
22+
$PAGE->set_context($categorycontext);
2223
require_capability('moodle/category:manage', $categorycontext);
2324
$strtitle = get_string('editcategorysettings');
2425
$editorcontext = $categorycontext;
@@ -33,6 +34,7 @@
3334
} else {
3435
$context = get_system_context();
3536
}
37+
$PAGE->set_context($context);
3638
$category = new stdClass();
3739
$category->id = 0;
3840
$category->parent = $parent;

0 commit comments

Comments
 (0)
Please sign in to comment.