From 681d95c495c8191a87c7a60b1bc316cc8a2195ac Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Fri, 23 Sep 2005 04:33:47 +0000 Subject: [PATCH] Backported Martin's sortorder fix from HEAD. Apparently this is a better fix than the one from a few days ago --- course/category.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/course/category.php b/course/category.php index 8f58ca5e00c..de2f1a497f6 100644 --- a/course/category.php +++ b/course/category.php @@ -138,9 +138,14 @@ } else { // figure out a sortorder that we can use in the destination category $sortorder = get_field_sql('SELECT MIN(sortorder)-1 AS min - FROM ' . $CFG->prefix . 'course WHERE sortorder > 2 AND category=' . $destcategory->id); - if ($sortorder < 10) { - $sortorder = 1000; + FROM ' . $CFG->prefix . 'course AND category=' . $destcategory->id); + if ($sortorder === false) { + // the category is empty + // rather than let the db default to 0 + // set it to > 100 and avoid extra work in fix_coursesortorder() + $sortorder = 200; + } else if ($sortorder < 10) { + fix_course_sortorder($categoryid); } $newcourse = new stdClass;