MDL-57564 enrol: Change the default sort in enrol_get_my_courses()

The new default value (null) now respects the navsortmycoursessort
behaviour and should be consistently used whenever we are displaying the
courses in the UI.
This commit is contained in:
Daniel Thee Roperto 2017-11-22 16:13:03 +11:00 committed by David Mudrák
parent 5f54a8760f
commit ee2187273f

View File

@ -554,15 +554,23 @@ function enrol_add_course_navigation(navigation_node $coursenode, $course) {
* password).
*
* @param string|array $fields
* @param string $sort
* @param string|null $sort
* @param int $limit max number of courses
* @param array $courseids the list of course ids to filter by
* @param bool $allaccessible Include courses user is not enrolled in, but can access
* @return array
*/
function enrol_get_my_courses($fields = null, $sort = 'visible DESC,sortorder ASC',
function enrol_get_my_courses($fields = null, $sort = null,
$limit = 0, $courseids = [], $allaccessible = false) {
global $DB, $USER, $CFG;
global $CFG, $DB, $USER;
if (is_null($sort)) {
if (empty($CFG->navsortmycoursessort)) {
$sort = 'visible DESC, sortorder ASC';
} else {
$sort = 'visible DESC, '.$CFG->navsortmycoursessort.' ASC';
}
}
// Guest account does not have any enrolled courses.
if (!$allaccessible && (isguestuser() or !isloggedin())) {