From 450498bff1410e97a14aa326ebbc0f9e201b226c Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Mon, 20 Dec 2010 11:03:31 +0800 Subject: [PATCH] MDL-21671, site level categroy manage capability when edit category, credits to Vadim Dvorovenko --- course/editcategory_form.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/course/editcategory_form.php b/course/editcategory_form.php index 3f86854c85e..b8f191788f3 100644 --- a/course/editcategory_form.php +++ b/course/editcategory_form.php @@ -14,11 +14,17 @@ class editcategory_form extends moodleform { $editoroptions = $this->_customdata['editoroptions']; // get list of categories to use as parents, with site as the first one - $options = array(get_string('top')); + $options = array(); + if (has_capability('moodle/category:manage', get_system_context()) || $category->parent == 0) { + $options[0] = get_string('top'); + } $parents = array(); if ($category->id) { // Editing an existing category. make_categories_list($options, $parents, 'moodle/category:manage', $category->id); + if (empty($options[$category->parent])) { + $options[$category->parent] = get_field('course_categories', 'name', 'id', $category->parent); + } $strsubmit = get_string('savechanges'); } else { // Making a new category