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.
This commit is contained in:
patrickslee
2006-02-07 01:13:27 +00:00
parent bfb55c1870
commit 8e227aa767
2 changed files with 8 additions and 5 deletions
+7 -4
View File
@@ -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 {
+1 -1
View File
@@ -156,7 +156,7 @@
print_my_moodle();
} else {
print_heading_block(get_string('availablecourses'));
print_courses(0, '100%');
print_courses(0, '100%', true);
}
break;