Merge branch 'MDL-35776_22' of git://github.com/timhunt/moodle into MOODLE_22_STABLE
This commit is contained in:
+6
-2
@@ -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:
|
||||
|
||||
@@ -53,9 +53,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) {
|
||||
@@ -79,6 +79,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':
|
||||
@@ -135,4 +139,4 @@ switch ($action) {
|
||||
throw new enrol_ajax_exception('unknowajaxaction');
|
||||
}
|
||||
|
||||
echo json_encode($outcome);
|
||||
echo json_encode($outcome);
|
||||
|
||||
@@ -221,8 +221,9 @@ M.core_user.init_user_selector = function (Y, name, hash, extrafields, lastsearc
|
||||
|
||||
// Output each optgroup.
|
||||
var count = 0;
|
||||
for (var groupname in data.results) {
|
||||
this.output_group(groupname, data.results[groupname], selectedusers, true);
|
||||
for (var key in data.results) {
|
||||
var groupdata = data.results[key];
|
||||
this.output_group(groupdata.name, groupdata.users, selectedusers, true);
|
||||
count++;
|
||||
}
|
||||
if (!count) {
|
||||
@@ -248,13 +249,14 @@ M.core_user.init_user_selector = function (Y, name, hash, extrafields, lastsearc
|
||||
output_group : function(groupname, users, selectedusers, processsingle) {
|
||||
var optgroup = Y.Node.create('<optgroup></optgroup>');
|
||||
var count = 0;
|
||||
for (var userid in users) {
|
||||
var user = users[userid];
|
||||
var option = Y.Node.create('<option value="'+userid+'">'+user.name+'</option>');
|
||||
for (var key in users) {
|
||||
var user = users[key];
|
||||
var option = Y.Node.create('<option value="'+user.id+'">'+user.name+'</option>');
|
||||
if (user.disabled) {
|
||||
option.set('disabled', true);
|
||||
} else if (selectedusers===true || selectedusers[userid]) {
|
||||
} else if (selectedusers===true || selectedusers[user.id]) {
|
||||
option.set('selected', true);
|
||||
delete selectedusers[user.id];
|
||||
} else {
|
||||
option.set('selected', false);
|
||||
}
|
||||
|
||||
@@ -78,17 +78,20 @@ 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);
|
||||
if (!empty($user->disabled)) {
|
||||
$output->disabled = true;
|
||||
}
|
||||
$group[$user->id] = $output;
|
||||
$groupdata['users'][] = $output;
|
||||
}
|
||||
$json[] = $groupdata;
|
||||
}
|
||||
|
||||
echo json_encode(array('results' => $users));
|
||||
echo json_encode(array('results' => $json));
|
||||
|
||||
Reference in New Issue
Block a user