mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
fixed several warnings in get_course()
This commit is contained in:
parent
8743f4f3ec
commit
09575480bb
@ -265,7 +265,7 @@
|
||||
}
|
||||
|
||||
/// Find any orphan courses that don't yet have a valid category and set to default
|
||||
if ($courses = get_courses(NULL,NULL,'c.id, c.category, c.sortorder')) {
|
||||
if ($courses = get_courses(NULL,NULL,'c.id, c.category, c.sortorder, c.visible')) {
|
||||
foreach ($courses as $course) {
|
||||
if ($course->category and !isset($categories[$course->category])) {
|
||||
set_field("course", "category", $default, "id", $course->id);
|
||||
|
@ -483,30 +483,38 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
|
||||
|
||||
global $USER, $CFG;
|
||||
|
||||
$categoryselect = "";
|
||||
if ($categoryid != "all" && is_numeric($categoryid)) {
|
||||
$categoryselect = "WHERE c.category = '$categoryid'";
|
||||
} else {
|
||||
$categoryselect = "";
|
||||
}
|
||||
|
||||
// pull out all course matching the cat
|
||||
$courses = get_records_sql("SELECT $fields
|
||||
FROM {$CFG->prefix}course c
|
||||
$categoryselect
|
||||
ORDER BY $sort");
|
||||
}
|
||||
|
||||
if (empty($sort)) {
|
||||
$sortstatement = "";
|
||||
} else {
|
||||
$sortstatement = "ORDER BY $sort";
|
||||
}
|
||||
|
||||
$visiblecourses = array();
|
||||
|
||||
// loop throught them
|
||||
foreach ($courses as $course) {
|
||||
if ($course->visible <= 0) {
|
||||
// for hidden courses, require visibility check
|
||||
if (has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
// pull out all course matching the cat
|
||||
if ($courses = get_records_sql("SELECT $fields
|
||||
FROM {$CFG->prefix}course c
|
||||
$categoryselect
|
||||
$sortstatement")) {
|
||||
|
||||
// loop throught them
|
||||
foreach ($courses as $course) {
|
||||
|
||||
if ($course->visible <= 0) {
|
||||
// for hidden courses, require visibility check
|
||||
if (has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$visiblecourses [] = $course;
|
||||
}
|
||||
} else {
|
||||
$visiblecourses [] = $course;
|
||||
}
|
||||
} else {
|
||||
$visiblecourses [] = $course;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $visiblecourses;
|
||||
|
||||
@ -1540,4 +1548,4 @@ function category_parent_visible($parent = 0) {
|
||||
}
|
||||
|
||||
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
|
||||
?>
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user