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 enrol UI.
This commit is contained in:
Tim Hunt 2012-10-03 18:46:07 +01:00
parent c62488c22f
commit 13bd955e65
2 changed files with 12 additions and 4 deletions

View File

@ -54,9 +54,9 @@ echo $OUTPUT->header(); // send headers
$manager = new course_enrolment_manager($PAGE, $course);
$outcome = new stdClass;
$outcome = new stdClass();
$outcome->success = true;
$outcome->response = new stdClass;
$outcome->response = new stdClass();
$outcome->error = '';
switch ($action) {
@ -99,6 +99,10 @@ switch ($action) {
$user->fullname = fullname($user);
unset($user->id);
}
// Chrome will display users in the order of the array keys, so we need
// to ensure that the results ordered array keys. Fortunately, the JavaScript
// does not care what the array keys are. It uses user.id where necessary.
$outcome->response['users'] = array_values($outcome->response['users']);
$outcome->success = true;
break;
default:

View File

@ -51,9 +51,9 @@ echo $OUTPUT->header(); // Send headers.
$manager = new course_enrolment_manager($PAGE, $course);
$outcome = new stdClass;
$outcome = new stdClass();
$outcome->success = true;
$outcome->response = new stdClass;
$outcome->response = new stdClass();
$outcome->error = '';
switch ($action) {
@ -77,6 +77,10 @@ switch ($action) {
}
$user->extrafields = implode(', ', $fieldvalues);
}
// Chrome will display users in the order of the array keys, so we need
// to ensure that the results ordered array keys. Fortunately, the JavaScript
// does not care what the array keys are. It uses user.id where necessary.
$outcome->response['users'] = array_values($outcome->response['users']);
$outcome->success = true;
break;
case 'enrol':