--- category_original.php,v 1.119.2.12 2008-12-12 00:03:22.000000000 +0100
+++ category.php 2009-02-13 11:26:39.000000000 +0100
@@ -16,6 +16,8 @@
$movedown = optional_param('movedown', 0, PARAM_INT);
$moveto = optional_param('moveto', 0, PARAM_INT);
$resort = optional_param('resort', 0, PARAM_BOOL);
+
+ $resortcat = optional_param('resortcat', 0, PARAM_BOOL);
if ($CFG->forcelogin) {
require_login();
@@ -69,6 +71,22 @@
fix_course_sortorder($category->id);
}
}
+ /// Resort the sub-categories in the category if requested
+ if ($resortcat and confirm_sesskey()) {
+ if ($categories = get_categories($category->id,'name')) {
+ // move it off the range
+ $count = get_record_sql('SELECT MAX(sortorder) AS max, 1
+ FROM ' . $CFG->prefix . 'course_categories WHERE parent=' . $category->id);
+ $count = $count->max + 100;
+ begin_sql();
+ foreach ($categories as $cat) {
+ set_field('course_categories', 'sortorder', $count, 'id', $cat->id);
+ $count++;
+ }
+ commit_sql();
+ }
+ }
+
}
if(!empty($CFG->allowcategorythemes) && isset($category->theme)) {
@@ -234,6 +252,17 @@
echo '';
echo '
';
}
+ /// Print button to re-sort categories by name
+ $numsubcategories = count($subcategories);
+ if (has_capability('moodle/category:manage', $context) and $subcategorieswereshown and $numsubcategories>1) {
+ echo '