Skip to content

Commit

Permalink
MDL-35381 added consistent sorting to the new selector (MDL-34657)
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Nov 5, 2012
1 parent 9f7b195 commit e24d97f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions admin/roles/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,10 +1146,11 @@ public function find_users($search) {
WHERE $wherecondition";
}

$order = " ORDER BY lastname ASC, firstname ASC";

$params['contextid'] = $this->accesscontext->id;

list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
$order = ' ORDER BY ' . $sort;

$result = array();

if ($search) {
Expand All @@ -1168,7 +1169,7 @@ public function find_users($search) {
$result[implode(' - ', array_keys($toomany))] = array();

} else {
$enrolledusers = $DB->get_records_sql($fields . $sql1 . $order, $params);
$enrolledusers = $DB->get_records_sql($fields . $sql1 . $order, array_merge($params, $sortparams));
if ($enrolledusers) {
$result[$groupname1] = $enrolledusers;
}
Expand All @@ -1184,7 +1185,7 @@ public function find_users($search) {
$toomany = $this->too_many_results($search, $otheruserscount);
$result[implode(' - ', array_keys($toomany))] = array();
} else {
$otherusers = $DB->get_records_sql($fields . $sql2 . $order, $params);
$otherusers = $DB->get_records_sql($fields . $sql2 . $order, array_merge($params, $sortparams));
if ($otherusers) {
$result[$groupname2] = $otherusers;
}
Expand Down

0 comments on commit e24d97f

Please sign in to comment.