From 115a622d8c97816d486c5d2e1553797d508b1fb9 Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Fri, 13 Apr 2007 05:40:11 +0000 Subject: [PATCH] merged MDL-9273 related fixes --- course/category.php | 18 ++++++++++++++++-- lib/datalib.php | 3 +-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/course/category.php b/course/category.php index 5c872b0641..ce7cdff9ab 100644 --- a/course/category.php +++ b/course/category.php @@ -135,6 +135,10 @@ if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved + // user must have category update in both cats to perform this + require_capability('moodle/category:update', $context); + require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto)); + if (! $destcategory = get_record("course_categories", "id", $data->moveto)) { error("Error finding the category"); } @@ -152,6 +156,7 @@ /// Hide or show a course if ((!empty($hide) or !empty($show)) and confirm_sesskey()) { + require_capability('moodle/course:visibility', $context); if (!empty($hide)) { $course = get_record("course", "id", $hide); $visible = 0; @@ -170,7 +175,7 @@ /// Move a course up or down if ((!empty($moveup) or !empty($movedown)) and confirm_sesskey()) { - + require_capability('moodle/category:update', $context); $movecourse = NULL; $swapcourse = NULL; @@ -400,8 +405,17 @@ if ($abletomovecourses) { echo ''; - echo '
'; + echo '
'; unset($displaylist[$category->id]); + + // loop and unset categories the user can't move into + + foreach ($displaylist as $did=>$dlist) { + if (!has_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $did))) { + unset($displaylist[$did]); + } + } + choose_from_menu ($displaylist, "moveto", "", get_string("moveselectedcoursesto"), "javascript: getElementById('movecourses').submit()"); echo ''; echo ''; diff --git a/lib/datalib.php b/lib/datalib.php index ad0ea507df..534d9472a2 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -925,10 +925,9 @@ function get_categories($parent='none', $sort='sortorder ASC') { $categories = get_records('course_categories', 'parent', $parent, $sort); } if ($categories) { /// Remove unavailable categories from the list - $creator = has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID)); foreach ($categories as $key => $category) { if (!$category->visible) { - if (!$creator) { + if (!has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $category->id))) { unset($categories[$key]); } } -- 2.39.5