From 8e227aa7670ed02f51cbb3719e893a83aa75d340 Mon Sep 17 00:00:00 2001 From: patrickslee Date: Tue, 7 Feb 2006 01:13:27 +0000 Subject: [PATCH] Added a parameter to print_courses() to hide site course This parameter is used in index.php because if the moodle site have more than one category the site course will be displayed in the course list in the front page. This problem appeared after the "front page format" feature is introduced. As the old front page will show a category tree with courses if there are more than one category in the system when "list of courses" is chosen as the front page. --- course/lib.php | 11 +++++++---- index.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/course/lib.php b/course/lib.php index fdf8ba96c27..d7558ab8f22 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1373,7 +1373,7 @@ function print_category_info($category, $depth) { } -function print_courses($category, $width="100%") { +function print_courses($category, $width="100%", $hidesitecourse = false) { /// Category is 0 (for all courses) or an object global $CFG; @@ -1382,18 +1382,21 @@ function print_courses($category, $width="100%") { $categories = get_categories(0); // Parent = 0 ie top-level categories only if (count($categories) == 1) { $category = array_shift($categories); - $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency'); + $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.category,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency'); } else { - $courses = get_courses('all', 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency'); + $courses = get_courses('all', 'c.sortorder ASC', 'c.id,c.category,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency'); } unset($categories); } else { $categories = get_categories($category->id); // sub categories - $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency'); + $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.category,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency'); } if ($courses) { foreach ($courses as $course) { + if ($hidesitecourse && !$course->category) { + continue; + } print_course($course, $width); } } else { diff --git a/index.php b/index.php index 47d286a53a4..014bf5b45a6 100644 --- a/index.php +++ b/index.php @@ -156,7 +156,7 @@ print_my_moodle(); } else { print_heading_block(get_string('availablecourses')); - print_courses(0, '100%'); + print_courses(0, '100%', true); } break;