mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
8ed5dd63ee
Bugs: MDL-17479, MDL-16426, MDL-16063, MDL-16013, MDL-15658, MDL-15556, MDL-15161, MDL-14925, MDL-13742, MDL-11557. * Simplify category editing permissions to just moodle/category:manage and moodle/category:seehiddencategories. * Enforce those correctly. (Note MDL 17502 is still outstanding.) * Don't screw up category sort order when you just edit name or description. * Niceties like where redirects go when you cancel or submit forms. * Make sure a global course creator can see the site admin block. * Don't allow a category to be made the child of one of its children! * General code cleanup to bring key files more in line with best pracitice. Apologies for the fact it is one big patch, rather than a series of smaller patches. However, categoryedit.php, category.php and index.php where in pretty bad shape and needed significant cleaning up. categoryedit.php, in particular, was almost completely rewritten. Merged from MOODLE_19_STABLE.
45 lines
1.8 KiB
PHP
45 lines
1.8 KiB
PHP
<?php
|
|
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
|
|
class editcategory_form extends moodleform {
|
|
|
|
// form definition
|
|
function definition() {
|
|
global $CFG;
|
|
$mform =& $this->_form;
|
|
$category = $this->_customdata;
|
|
|
|
// get list of categories to use as parents, with site as the first one
|
|
$options = array(get_string('top'));
|
|
$parents = array();
|
|
if ($category->id) {
|
|
// Editing an existing category.
|
|
make_categories_list($options, $parents, 'moodle/category:manage', $category->id);
|
|
$strsubmit = get_string('savechanges');
|
|
} else {
|
|
// Making a new category
|
|
make_categories_list($options, $parents, 'moodle/category:manage');
|
|
$strsubmit = get_string('createcategory');
|
|
}
|
|
|
|
$mform->addElement('select', 'parent', get_string('parentcategory'), $options);
|
|
$mform->addElement('text', 'name', get_string('categoryname'), array('size'=>'30'));
|
|
$mform->addRule('name', get_string('required'), 'required', null);
|
|
$mform->addElement('htmleditor', 'description', get_string('description'));
|
|
$mform->setType('description', PARAM_RAW);
|
|
if (!empty($CFG->allowcategorythemes)) {
|
|
$themes=array();
|
|
$themes[''] = get_string('forceno');
|
|
$themes += get_list_of_themes();
|
|
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
|
|
}
|
|
$mform->setHelpButton('description', array('writing', 'richtext2'), false, 'editorhelpbutton');
|
|
|
|
$mform->addElement('hidden', 'id', 0);
|
|
$mform->setType('id', PARAM_INT);
|
|
$mform->setDefault('id', $category->id);
|
|
|
|
$this->add_action_buttons(true, $strsubmit);
|
|
}
|
|
}
|
|
?>
|