mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-35776 user ajax: fix sort order in chrome.
It seems that Chrome orders fields of objects in order of array key. Therefore we must stop using user.id in the PHP arrays, and instead ensure that we use sequential numbers. This commit fixes the user selector.
This commit is contained in:
parent
d91750bc5a
commit
c62488c22f
2 changed files with 16 additions and 12 deletions
|
@ -78,9 +78,11 @@ if (isset($options['file'])) {
|
|||
$userselector = new $classname($name, $options);
|
||||
|
||||
// Do the search and output the results.
|
||||
$users = $userselector->find_users($search);
|
||||
foreach ($users as &$group) {
|
||||
foreach ($group as $user) {
|
||||
$results = $userselector->find_users($search);
|
||||
$json = array();
|
||||
foreach ($results as $groupname => $users) {
|
||||
$groupdata = array('name' => $groupname, 'users' => array());
|
||||
foreach ($users as $user) {
|
||||
$output = new stdClass;
|
||||
$output->id = $user->id;
|
||||
$output->name = $userselector->output_user($user);
|
||||
|
@ -90,8 +92,9 @@ foreach ($users as &$group) {
|
|||
if (!empty($user->infobelow)) {
|
||||
$output->infobelow = $user->infobelow;
|
||||
}
|
||||
$group[$user->id] = $output;
|
||||
$groupdata['users'][] = $output;
|
||||
}
|
||||
$json[] = $groupdata;
|
||||
}
|
||||
|
||||
echo json_encode(array('results' => $users));
|
||||
echo json_encode(array('results' => $json));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue