Skip to content
Permalink
Browse files

Merge branch 'MDL-29774-master-by-sam-wilson' of git://github.com/jun…

…pataleta/moodle
  • Loading branch information...
stronk7 committed Oct 18, 2016
2 parents 876fc28 + 813c059 commit 3fdbba0e276c04eff891db7711e83c51077fd153
Showing with 35 additions and 7 deletions.
  1. +17 −4 user/selector/lib.php
  2. +8 −0 user/selector/module.js
  3. +10 −3 user/selector/search.php
@@ -799,12 +799,26 @@ public function get_js_module() {
*
* Used by /group/clientlib.js
*
* @global moodle_database $DB
* @global moodle_page $PAGE
* @param int $courseid
*/
public function print_user_summaries($courseid) {
global $DB, $PAGE;
global $PAGE;
$usersummaries = $this->get_user_summaries($courseid);
$PAGE->requires->data_for_js('userSummaries', $usersummaries);
}
/**
* Construct HTML lists of group-memberships of the current set of users.
*
* Used in user/selector/search.php to repopulate the userSummaries JS global
* that is created in self::print_user_summaries() above.
*
* @param int $courseid The course
* @return string[] Array of HTML lists of groups.
*/
public function get_user_summaries($courseid) {
global $DB;
$usersummaries = array();
@@ -838,8 +852,7 @@ public function print_user_summaries($courseid) {
$usersummaries[] = $usergrouplist;
}
}
$PAGE->requires->data_for_js('userSummaries', $usersummaries);
return $usersummaries;
}
/**
@@ -179,6 +179,14 @@ M.core_user.init_user_selector = function (Y, name, hash, extrafields, lastsearc
return new M.core.ajaxException(data);
}
this.output_options(data);

// If updated userSummaries are present, overwrite the global variable
// that's output by group_non_members_selector::print_user_summaries() in user/selector/lib.php
if (typeof data.userSummaries !== "undefined") {
/* global userSummaries:true */
/* exported userSummaries */
userSummaries = data.userSummaries;
}
} catch (e) {
this.listbox.setStyle('background','');
this.searchfield.addClass('error');
@@ -61,7 +61,7 @@
// Do the search and output the results.
$results = $userselector->find_users($search);
$json = array();
$jsonresults = array();
foreach ($results as $groupname => $users) {
$groupdata = array('name' => $groupname, 'users' => array());
foreach ($users as $user) {
@@ -76,7 +76,14 @@
}
$groupdata['users'][] = $output;
}
$json[] = $groupdata;
$jsonresults[] = $groupdata;
}
echo json_encode(array('results' => $json));
$json = array('results' => $jsonresults);
// Also add users' group membership summaries, if possible.
if (is_callable(array($userselector, 'get_user_summaries')) && isset($options['courseid'])) {
$json['userSummaries'] = $userselector->get_user_summaries($options['courseid']);
}
echo json_encode($json);

0 comments on commit 3fdbba0

Please sign in to comment.
You can’t perform that action at this time.