2009-11-04 08:11:02 +00:00
|
|
|
<?php
|
2010-05-13 02:02:05 +00:00
|
|
|
if (!defined('MOODLE_INTERNAL')) {
|
|
|
|
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
|
|
|
}
|
|
|
|
|
2007-10-09 17:22:10 +00:00
|
|
|
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
|
|
|
|
class editcategory_form extends moodleform {
|
|
|
|
|
|
|
|
// form definition
|
|
|
|
function definition() {
|
|
|
|
global $CFG;
|
|
|
|
$mform =& $this->_form;
|
2009-11-04 06:14:06 +00:00
|
|
|
$category = $this->_customdata['category'];
|
|
|
|
$editoroptions = $this->_customdata['editoroptions'];
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
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.
2008-12-04 08:53:10 +00:00
|
|
|
|
2007-10-09 17:22:10 +00:00
|
|
|
// get list of categories to use as parents, with site as the first one
|
2007-10-10 04:53:32 +00:00
|
|
|
$options = array(get_string('top'));
|
2007-10-10 06:21:37 +00:00
|
|
|
$parents = array();
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
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.
2008-12-04 08:53:10 +00:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2007-10-09 17:22:10 +00:00
|
|
|
$mform->addElement('select', 'parent', get_string('parentcategory'), $options);
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
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.
2008-12-04 08:53:10 +00:00
|
|
|
$mform->addElement('text', 'name', get_string('categoryname'), array('size'=>'30'));
|
|
|
|
$mform->addRule('name', get_string('required'), 'required', null);
|
2009-11-04 06:14:06 +00:00
|
|
|
$mform->addElement('editor', 'description_editor', get_string('description'), null, $editoroptions);
|
|
|
|
$mform->setType('description_editor', PARAM_RAW);
|
2007-10-10 04:05:46 +00:00
|
|
|
if (!empty($CFG->allowcategorythemes)) {
|
2010-03-18 06:02:41 +00:00
|
|
|
$themes = array(''=>get_string('forceno'));
|
|
|
|
$allthemes = get_list_of_themes();
|
|
|
|
foreach ($allthemes as $key=>$theme) {
|
|
|
|
$themes[$key] = $theme->name;
|
|
|
|
}
|
2007-10-09 17:22:10 +00:00
|
|
|
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
|
|
|
|
}
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
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.
2008-12-04 08:53:10 +00:00
|
|
|
|
|
|
|
$mform->addElement('hidden', 'id', 0);
|
2007-10-09 17:22:10 +00:00
|
|
|
$mform->setType('id', PARAM_INT);
|
course categories: Fix many bugs with category editing and permissions. Clean up code.
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.
2008-12-04 08:53:10 +00:00
|
|
|
$mform->setDefault('id', $category->id);
|
|
|
|
|
|
|
|
$this->add_action_buttons(true, $strsubmit);
|
2007-10-09 17:22:10 +00:00
|
|
|
}
|
2009-11-04 08:11:02 +00:00
|
|
|
}
|
|
|
|
|