Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

category editing MDL-21671 fixed deprecated function call, check capa…

…bility when parent category changed
  • Loading branch information...
commit b72ca9f81a98800db71755b64ba5292ec122e0bc 1 parent 450498b
@dcai dcai authored stronk7 committed
Showing with 4 additions and 2 deletions.
  1. +2 −0  course/editcategory.php
  2. +2 −2 course/editcategory_form.php
View
2  course/editcategory.php
@@ -77,6 +77,8 @@
// 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
4 course/editcategory_form.php
@@ -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 @@ function definition() {
// 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 {
Please sign in to comment.
Something went wrong with that request. Please try again.