Permalink
Browse files

MDL-35381 added consistent sorting to the new selector (MDL-34657)

  • Loading branch information...
1 parent 9f7b195 commit e24d97f944a60b8ce98eba093859b3126983c6e8 @stronk7 stronk7 committed Nov 5, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 admin/roles/lib.php
View
@@ -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) {
@@ -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;
}
@@ -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;
}

0 comments on commit e24d97f

Please sign in to comment.