--- category_original.php,v 1.119.2.8 2009-02-13 10:18:05.000000000 +0100
+++ category.php 2009-02-13 10:17:03.000000000 +0100
@@ -18,6 +18,8 @@
$rename = optional_param('rename', '', PARAM_TEXT);
$resort = optional_param('resort', 0, PARAM_BOOL);
$categorytheme= optional_param('categorytheme', false, PARAM_SAFEDIR);
+
+ $resortcat = optional_param('resortcat', 0, PARAM_BOOL);
if ($CFG->forcelogin) {
require_login();
@@ -92,6 +94,24 @@
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) ){
@@ -284,6 +304,17 @@
echo "";
echo "
";
}
+ /// Print button to re-sort categories by name
+ $numsubcategories = count($subcategories);
+ if (has_capability('moodle/category:update', $context) and $subcategorieswereshown and $numsubcategories>1) {
+ echo '