// only one selected user, set a flag to select them if that option is turned on.
$select = false;
if (empty($groupedusers)) {
- $groupedusers = array(get_string('nomatchingusers', '', $search) => array());
+ if (!empty($search)) {
+ $groupedusers = array(get_string('nomatchingusers', '', $search) => array());
+ } else {
+ $groupedusers = array(get_string('none') => array());
+ }
} else if ($this->autoselectunique && count($groupedusers) == 1 &&
count(reset($groupedusers)) == 1) {
$select = true;
// Initialise the selector.
$output .= print_js_call('new user_selector', array($this->name, $hash, $this->extrafields,
$search, get_string('previouslyselectedusers', '', '%%SEARCHTERM%%'),
- get_string('nomatchingusers', '', '%%SEARCHTERM%%')), true);
+ get_string('nomatchingusers', '', '%%SEARCHTERM%%'), get_string('none')), true);
return $output;
}
* @param Array extrafields extra fields we are displaying for each user in addition to fullname.
* @param String label used for the optgroup of users who are selected but who do not match the current search.
*/
-function user_selector(name, hash, extrafields, lastsearch, strprevselected, strnomatchingusers) {
+function user_selector(name, hash, extrafields, lastsearch, strprevselected, strnomatchingusers, strnone) {
this.name = name;
this.extrafields = extrafields;
this.strprevselected = strprevselected;
this.strnomatchingusers = strnomatchingusers;
+ this.strnone = strnone;
this.searchurl = moodle_cfg.wwwroot + '/user/selector/search.php?selectorid=' +
hash + '&sesskey=' + moodle_cfg.sesskey + '&search='
*/
user_selector.prototype.strnomatchingusers = '';
+/**
+ * Name of the no matching users group when empty.
+ *
+ * @property strnone
+ * @type String
+ */
+user_selector.prototype.strnone = '';
+
// Fields that configure the control's behaviour ===============================
/**
}
if (nogroups) {
- this.output_group(this.insert_search_into_str(this.strnomatchingusers, this.lastsearch), {}, false)
+ if (this.lastsearch != '') {
+ this.output_group(this.insert_search_into_str(this.strnomatchingusers, this.lastsearch), {}, false)
+ } else {
+ this.output_group(this.strnone, {}, false)
+ }
}
// If there was only one option matching the search results, select it.