|
|
|
|
@ -142,12 +142,14 @@ class CourseManager |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns a list of courses. Should work with quickform syntax |
|
|
|
|
* @param integer Offset (from the 7th = '6'). Optional. |
|
|
|
|
* @param integer Number of results we want. Optional. |
|
|
|
|
* @param string The column we want to order it by. Optional, defaults to first column. |
|
|
|
|
* @param string The direction of the order (ASC or DESC). Optional, defaults to ASC. |
|
|
|
|
* @param string The visibility of the course, or all by default. |
|
|
|
|
* @param string If defined, only return results for which the course *title* begins with this string |
|
|
|
|
* @param integer $from Offset (from the 7th = '6'). Optional. |
|
|
|
|
* @param integer $howmany Number of results we want. Optional. |
|
|
|
|
* @param string $orderby The column we want to order it by. Optional, defaults to first column. |
|
|
|
|
* @param string $orderdirection The direction of the order (ASC or DESC). Optional, defaults to ASC. |
|
|
|
|
* @param string $visibility The visibility of the course, or all by default. |
|
|
|
|
* @param string $startwith If defined, only return results for which the course *title* begins with this string |
|
|
|
|
* @param string $urlId The Access URL ID, if using multiple URLs |
|
|
|
|
* @param string $alsoSearchCode An extension option to indicate that we also want to search for course codes (not *only* titles) |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public static function get_courses_list( |
|
|
|
|
@ -157,7 +159,8 @@ class CourseManager |
|
|
|
|
$orderdirection = 'ASC', |
|
|
|
|
$visibility = -1, |
|
|
|
|
$startwith = '', |
|
|
|
|
$urlId = null |
|
|
|
|
$urlId = null, |
|
|
|
|
$alsoSearchCode = false |
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
$sql = "SELECT course.* FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." course "; |
|
|
|
|
@ -168,7 +171,11 @@ class CourseManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($startwith)) { |
|
|
|
|
$sql .= "WHERE title LIKE '".Database::escape_string($startwith)."%' "; |
|
|
|
|
$sql .= "WHERE (title LIKE '".Database::escape_string($startwith)."%' "; |
|
|
|
|
if ($alsoSearchCode) { |
|
|
|
|
$sql .= "OR code LIKE '".Database::escape_string($startwith)."%' "; |
|
|
|
|
} |
|
|
|
|
$sql .= ') '; |
|
|
|
|
if ($visibility !== -1 && $visibility == strval(intval($visibility))) { |
|
|
|
|
$sql .= " AND visibility = $visibility "; |
|
|
|
|
} |
|
|
|
|
|