From 8857a0b4256ec5ff3bc60b35700ab48e415d8554 Mon Sep 17 00:00:00 2001 From: poltawski Date: Tue, 8 Jan 2008 12:51:07 +0000 Subject: [PATCH] MDL-10813 - Course requests not respecting course request category. Also made the course request category more robust, as breakage would incur if $CFG->defaultrequestcategory didn't exist as a category. merged from MOODLE_19_STABLE --- course/pending.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/course/pending.php b/course/pending.php index cee06ed433..2fc6f89f95 100644 --- a/course/pending.php +++ b/course/pending.php @@ -22,10 +22,13 @@ // place at beginning of category fix_course_sortorder(); - if (empty($CFG->defaultrequestedcategory)) { - $CFG->defaultrequestedcategory = 1; //yuk, but default to miscellaneous. + + if (empty($CFG->defaultrequestcategory) or !record_exists('course_categories', 'id', $CFG->defaultrequestcategory)) { + // default to first top level directory, hacky but means things don't break + $CFG->defaultrequestcategory = get_field('course_categories', 'id', 'parent', '0'); } - $course->category = $CFG->defaultrequestedcategory; + + $course->category = $CFG->defaultrequestcategory; $course->sortorder = get_field_sql("SELECT min(sortorder)-1 FROM {$CFG->prefix}course WHERE category=$course->category"); if (empty($course->sortorder)) { $course->sortorder = 1000; -- 2.39.5