From 4d4dc7bf1d436ec0ad31dc89f350d15947478d94 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Thu, 24 Apr 2008 08:35:47 +0000 Subject: [PATCH] MDL-14460, fix get_context_instance --- course/category.php | 4 ++-- course/editcategory.php | 2 +- course/lib.php | 6 +++--- course/pending.php | 2 +- course/search.php | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/course/category.php b/course/category.php index 3cfa531ab29..32430f93b59 100644 --- a/course/category.php +++ b/course/category.php @@ -45,7 +45,7 @@ } $navbaritem = update_category_button($category->id); $creatorediting = !empty($USER->categoryediting); - $adminediting = (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $creatorediting); + $adminediting = (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and $creatorediting); } else { if (!$category->visible) { @@ -482,7 +482,7 @@ } echo '
'; - if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $numcourses > 1) { /// Print button to re-sort courses by name + if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM)) and $numcourses > 1) { /// Print button to re-sort courses by name unset($options); $options['id'] = $category->id; $options['resort'] = 'name'; diff --git a/course/editcategory.php b/course/editcategory.php index f139413834c..9e43af45e30 100644 --- a/course/editcategory.php +++ b/course/editcategory.php @@ -113,7 +113,7 @@ if ($id && !$categoryadd && !$categoryupdate && false) { } $navbaritem = update_category_button($category->id); $creatorediting = !empty($USER->categoryediting); - $adminediting = (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $creatorediting); + $adminediting = (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and $creatorediting); } else { if (!$category->visible) { diff --git a/course/lib.php b/course/lib.php index 25acbbe7fcd..19f58c741df 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1639,7 +1639,7 @@ function print_whole_category_list($category=NULL, $displaylist=NULL, $parentsli } if ($category) { - if ($category->visible or has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if ($category->visible or has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM))) { print_category_info($category, $depth, $files); } else { return; // Don't bother printing children of invisible categories @@ -1819,7 +1819,7 @@ function print_courses($category) { echo "\n"; } else { print_heading(get_string("nocoursesyet")); - $context = get_context_instance(CONTEXT_SYSTEM, SITEID); + $context = get_context_instance(CONTEXT_SYSTEM); if (has_capability('moodle/course:create', $context)) { $options = array(); $options['category'] = $category->id; @@ -2660,7 +2660,7 @@ function course_allowed_module($course,$mod) { // Admins and admin-like people who can edit everything can also add anything. // This is a bit wierd, really. I debated taking it out but it's enshrined in help for the setting. - if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM))) { return true; } diff --git a/course/pending.php b/course/pending.php index 31c5640e8c9..8934c7c1ee6 100644 --- a/course/pending.php +++ b/course/pending.php @@ -8,7 +8,7 @@ require_login(); - require_capability('moodle/site:approvecourse', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:approvecourse', get_context_instance(CONTEXT_SYSTEM)); $approve = optional_param('approve', 0, PARAM_INT); $reject = optional_param('reject', 0, PARAM_INT); diff --git a/course/search.php b/course/search.php index a497cee6985..bfe4d8d93c6 100644 --- a/course/search.php +++ b/course/search.php @@ -33,7 +33,7 @@ require_login(); } - if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM))) { if ($edit !== -1) { $USER->categoryediting = $edit; // If the edit mode we are leaving has higher per page than the one we are entering, @@ -45,7 +45,7 @@ /// Editing functions - if (has_capability('moodle/course:visibility', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (has_capability('moodle/course:visibility', get_context_instance(CONTEXT_SYSTEM))) { /// Hide or show a course @@ -66,7 +66,7 @@ } - if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID)) && $perpage != 99999) { + if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM)) && $perpage != 99999) { $perpage = 30; } @@ -171,7 +171,7 @@ $searchform = print_course_search($search, true, "navbar"); - if (!empty($courses) && has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!empty($courses) && has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM))) { $searchform .= update_categories_search_button($search,$page,$perpage); }