Prevent 'Warning: Invalid argument supplied for foreach() in ...' for get_courses_page function when there are no courses in the required category.
This commit is contained in:
+6
-4
@@ -576,11 +576,13 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
|
||||
}
|
||||
|
||||
// pull out all course matching the cat
|
||||
$courses = get_records_sql("SELECT $fields
|
||||
$visiblecourses = array();
|
||||
if (!($courses = get_records_sql("SELECT $fields
|
||||
FROM {$CFG->prefix}course c
|
||||
$categoryselect
|
||||
ORDER BY $sort");
|
||||
$visiblecourses = array();
|
||||
ORDER BY $sort"))) {
|
||||
return $visiblecourses;
|
||||
}
|
||||
$totalcount = 0;
|
||||
|
||||
if (!$limitnum) {
|
||||
@@ -1515,4 +1517,4 @@ function category_parent_visible($parent = 0) {
|
||||
}
|
||||
|
||||
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user