mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
category editing MDL-21671 fixed deprecated function call, check capability when parent category changed
This commit is contained in:
parent
450498bff1
commit
b72ca9f81a
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user