category editing MDL-21671 fixed deprecated function call, check capability when parent category changed

This commit is contained in:
Dongsheng Cai 2010-12-20 17:11:42 +08:00 committed by Eloy Lafuente (stronk7)
parent 450498bff1
commit b72ca9f81a
2 changed files with 4 additions and 2 deletions

View File

@ -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);
}

View File

@ -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 {