Commit b72ca9f8 authored by Dongsheng Cai's avatar Dongsheng Cai Committed by Eloy Lafuente
Browse files

category editing MDL-21671 fixed deprecated function call, check capability...

category editing MDL-21671 fixed deprecated function call, check capability when parent category changed
parent 450498bf
......@@ -77,6 +77,8 @@ if ($mform->is_cancelled()) {
// Update an existing category.
$newcategory->id = $category->id;
if ($newcategory->parent != $category->parent) {
// check category manage capability if parent changed
require_capability('moodle/category:manage', get_category_or_system_context((int)$newcategory->parent));
$parent_cat = $DB->get_record('course_categories', array('id' => $newcategory->parent));
move_category($newcategory, $parent_cat);
}
......
......@@ -8,7 +8,7 @@ class editcategory_form extends moodleform {
// form definition
function definition() {
global $CFG;
global $CFG, $DB;
$mform =& $this->_form;
$category = $this->_customdata['category'];
$editoroptions = $this->_customdata['editoroptions'];
......@@ -23,7 +23,7 @@ class editcategory_form extends moodleform {
// 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);
$options[$category->parent] = $DB->get_field('course_categories', 'name', array('id'=>$category->parent));
}
$strsubmit = get_string('savechanges');
} else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment