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.
This commit is contained in:
tjhunt
2008-12-04 08:53:10 +00:00
parent 4faace3781
commit 8ed5dd63ee
18 changed files with 501 additions and 721 deletions
+2 -7
View File
@@ -57,16 +57,11 @@ class course_edit_form extends moodleform {
//--------------------------------------------------------------------------------
$mform->addElement('header','general', get_string('general', 'form'));
//must have create course capability in both categories in order to move course
// Must have create course capability in both categories in order to move course
if (has_capability('moodle/course:create', $categorycontext)) {
$displaylist = array();
$parentlist = array();
make_categories_list($displaylist, $parentlist);
foreach ($displaylist as $key=>$val) {
if (!has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $key))) {
unset($displaylist[$key]);
}
}
make_categories_list($displaylist, $parentlist, 'moodle/course:create');
$mform->addElement('select', 'category', get_string('category'), $displaylist);
} else {
$mform->addElement('hidden', 'category', null);