$PAGE->set_url('course/index.php');
$PAGE->set_context($systemcontext);
- if (update_category_button()) {
+ if (can_edit_in_category()) {
if ($categoryedit !== -1) {
$USER->editing = $categoryedit;
}
}
/// Everything else is editing on mode.
require_once($CFG->libdir.'/adminlib.php');
- admin_externalpage_setup('coursemgmt', update_category_button());
+ admin_externalpage_setup('coursemgmt');
/// Delete a category.
if (!empty($delete) and confirm_sesskey()) {
}
}
+/**
+ * Does the user have permission to edit things in this category?
+ *
+ * @param integer $categoryid The id of the category we are showing, or 0 for system context.
+ * @return boolean has_any_capability(array(...), ...); in the appropriate context.
+ */
+function can_edit_in_category($categoryid = 0) {
+ $context = get_category_or_system_context($categoryid);
+ return has_any_capability(array('moodle/category:manage', 'moodle/course:create'), $context);
+}
+
/**
* Prints the turn editing on/off button on course/index.php or course/category.php.
*
global $CFG, $PAGE;
// Check permissions.
- $context = get_category_or_system_context($categoryid);
- if (!has_any_capability(array('moodle/category:manage', 'moodle/course:create'), $context)) {
+ if (!can_edit_in_category($categoryid)) {
return '';
}