Permalink
Browse files

MDL-34459 course: changing strictness of context calls as needed

  • Loading branch information...
1 parent 9a5e297 commit 1f364c87e37f446a7fb537828055e1a48121c7b0 @ankitagarwal ankitagarwal committed Jul 24, 2012
Showing with 6 additions and 8 deletions.
  1. +1 −1 course/completion_form.php
  2. +3 −3 course/externallib.php
  3. +1 −1 course/lib.php
  4. +1 −3 course/switchrole.php
@@ -134,7 +134,7 @@ function definition() {
// Role completion criteria
$mform->addElement('header', 'roles', get_string('manualcompletionby', 'completion'));
- $roles = get_roles_with_capability('moodle/course:markcomplete', CAP_ALLOW, context_course::instance($course->id));
+ $roles = get_roles_with_capability('moodle/course:markcomplete', CAP_ALLOW, context_course::instance($course->id, IGNORE_MISSING));
if (!empty($roles)) {
$mform->addElement('select', 'role_aggregation', get_string('aggregationmethod', 'completion'), $aggregation_methods);
View
@@ -85,7 +85,7 @@ public static function get_course_contents($courseid, $options = array()) {
}
// now security checks
- $context = context_course::instance($course->id);
+ $context = context_course::instance($course->id, IGNORE_MISSING);
try {
self::validate_context($context);
} catch (Exception $e) {
@@ -297,7 +297,7 @@ public static function get_courses($options = array()) {
foreach ($courses as $course) {
// now security checks
- $context = context_course::instance($course->id);
+ $context = context_course::instance($course->id, IGNORE_MISSING);
try {
self::validate_context($context);
} catch (Exception $e) {
@@ -511,7 +511,7 @@ public static function create_courses($courses) {
foreach ($params['courses'] as $course) {
// Ensure the current user is allowed to run this function
- $context = context_coursecat::instance($course['categoryid']);
+ $context = context_coursecat::instance($course['categoryid'], IGNORE_MISSING);
try {
self::validate_context($context);
} catch (Exception $e) {
View
@@ -4340,7 +4340,7 @@ public function approve() {
$data->lang = $courseconfig->lang;
$course = create_course($data);
- $context = context_course(course->id, MUST_EXIST);
+ $context = context_course::instance($course->id, MUST_EXIST);
// add enrol instances
if (!$DB->record_exists('enrol', array('courseid'=>$course->id, 'enrol'=>'manual'))) {
View
@@ -47,9 +47,7 @@
print_error('invalidcourseid', 'error');
}
-if (!$context = context_course::instance($course->id)) {
- print_error('nocontext');
-}
+$context = context_course::instance($course->id);
// Remove any switched roles before checking login
if ($switchrole == 0) {

0 comments on commit 1f364c8

Please sign in to comment.