From: toyomoyo Date: Tue, 21 Nov 2006 03:26:31 +0000 (+0000) Subject: merged fix for MDL-7540, wrong usage of context levels X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4827a1d19f3f8528ed23309cef11c5dbd777317a;p=moodle.git merged fix for MDL-7540, wrong usage of context levels --- diff --git a/course/category.php b/course/category.php index a5f91a0658..1094f78e61 100644 --- a/course/category.php +++ b/course/category.php @@ -32,7 +32,7 @@ error("Category not known!"); } - if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (has_capability('moodle/course:create', $context)) { if ($categoryedit !== -1) { $USER->categoryediting = $categoryedit; } @@ -50,7 +50,7 @@ } - if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (has_capability('moodle/category:update', $context)) { /// Rename the category if requested if (!empty($rename) and confirm_sesskey()) { $category->name = $rename; @@ -217,7 +217,7 @@ if ($subcategories = get_records("course_categories", "parent", $category->id, "sortorder ASC")) { $firstentry = true; foreach ($subcategories as $subcategory) { - if ($subcategory->visible or has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if ($subcategory->visible or has_capability('moodle/course:create', $context)) { $subcategorieswereshown = true; if ($firstentry) { echo ''; @@ -304,7 +304,7 @@ foreach ($courses as $acourse) { - $context = get_context_instance(CONTEXT_COURSE, $acourse->id); + $coursecontext = get_context_instance(CONTEXT_COURSE, $acourse->id); $count++; $up = ($count > 1 || !$atfirstpage); @@ -315,22 +315,22 @@ echo ''; if ($creatorediting) { echo "
'.$acourse->fullname.'"; - if (has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $acourse->id))) { + if (has_capability('moodle/course:update', $coursecontext)) { echo ''. ''.$stredit.' '; } // role assignment link - if (has_capability('moodle/role:assign', $context)) { - echo''.get_string('assignroles', 'role').''; + if (has_capability('moodle/role:assign', $coursecontext)) { + echo''.get_string('assignroles', 'role').''; } - if (has_capability('moodle/course:delete', $context)) { + if (has_capability('moodle/course:delete', $coursecontext)) { echo ''. ''.$strdelete.' '; } - if (has_capability('moodle/course:visibility', $context)) { + if (has_capability('moodle/course:visibility', $coursecontext)) { if (!empty($acourse->visible)) { echo ''. @@ -342,12 +342,12 @@ } } - if (has_capability('moodle/site:backup', $context)) { + if (has_capability('moodle/site:backup', $coursecontext)) { echo ''. ' '; } - if (has_capability('moodle/site:restore', $context)) { + if (has_capability('moodle/site:restore', $coursecontext)) { echo ''. ' '; @@ -411,8 +411,7 @@ echo ''; echo '
'; } - - + echo '
'; if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $numcourses > 1) { /// Print button to re-sort courses by name unset($options); @@ -422,7 +421,6 @@ print_single_button('category.php', $options, get_string('resortcoursesbyname'), 'get'); } - $context = get_context_instance(CONTEXT_SYSTEM, SITEID); if (has_capability('moodle/course:create', $context)) { /// Print button to create a new course unset($options); $options['category'] = $category->id; @@ -430,7 +428,6 @@ echo '
'; } - $context = get_context_instance(CONTEXT_COURSECAT, $id); if (has_capability('moodle/category:update', $context)) { /// Print form to rename the category $strrename= get_string('rename'); echo '
';