Skip to content

Commit

Permalink
MDL-57564 enrol: Change the default sort in enrol_get_my_courses()
Browse files Browse the repository at this point in the history
The new default value (null) now respects the navsortmycoursessort
behaviour and should be consistently used whenever we are displaying the
courses in the UI.
  • Loading branch information
roperto authored and mudrd8mz committed Dec 5, 2017
1 parent 5f54a87 commit ee21872
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/enrollib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down

0 comments on commit ee21872

Please sign in to comment.