mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
Merge branch 'MDL-33680-m' of git://github.com/andrewnicols/moodle
This commit is contained in:
commit
bab8a6724f
@ -57,7 +57,6 @@ require_login($course, false, $cm);
|
||||
$PAGE->set_context($context);
|
||||
|
||||
echo $OUTPUT->header(); // send headers
|
||||
@header('Content-type: text/html; charset=utf-8');
|
||||
|
||||
// If uploaded file is larger than post_max_size (php.ini) setting, $_POST content will be empty.
|
||||
if (empty($_POST) && !empty($action)) {
|
||||
|
@ -70,7 +70,7 @@ abstract class user_selector_base {
|
||||
protected static $jsmodule = array(
|
||||
'name' => 'user_selector',
|
||||
'fullpath' => '/user/selector/module.js',
|
||||
'requires' => array('node', 'event-custom', 'datasource', 'json'),
|
||||
'requires' => array('node', 'event-custom', 'datasource', 'json', 'moodle-core-notification'),
|
||||
'strings' => array(
|
||||
array('previouslyselectedusers', 'moodle', '%%SEARCHTERM%%'),
|
||||
array('nomatchingusers', 'moodle', '%%SEARCHTERM%%'),
|
||||
|
@ -151,8 +151,7 @@ M.core_user.init_user_selector = function (Y, name, hash, extrafields, lastsearc
|
||||
method: 'POST',
|
||||
data: 'selectorid='+hash+'&sesskey='+M.cfg.sesskey+'&search='+value + '&userselector_searchanywhere=' + this.get_option('searchanywhere'),
|
||||
on: {
|
||||
success:this.handle_response,
|
||||
failure:this.handle_failure
|
||||
complete: this.handle_response
|
||||
},
|
||||
context:this
|
||||
});
|
||||
@ -175,26 +174,15 @@ M.core_user.init_user_selector = function (Y, name, hash, extrafields, lastsearc
|
||||
}
|
||||
this.listbox.setStyle('background','');
|
||||
var data = Y.JSON.parse(response.responseText);
|
||||
if (data.error) {
|
||||
this.searchfield.addClass('error');
|
||||
return new M.core.ajaxException(data);
|
||||
}
|
||||
this.output_options(data);
|
||||
} catch (e) {
|
||||
this.handle_failure(requestid);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Handles what happens when the ajax request fails.
|
||||
*/
|
||||
handle_failure : function(requestid) {
|
||||
delete this.iotransactions[requestid];
|
||||
if (!Y.Object.isEmpty(this.iotransactions)) {
|
||||
// More searches pending. Wait until they are all done.
|
||||
return;
|
||||
}
|
||||
this.listbox.setStyle('background','');
|
||||
this.searchfield.addClass('error');
|
||||
|
||||
// If we are in developer debug mode, output a link to help debug the failure.
|
||||
if (M.cfg.developerdebug) {
|
||||
this.searchfield.insert(Y.Node.create('<a href="'+M.cfg.wwwroot +'/user/selector/search.php?selectorid='+hash+'&sesskey='+M.cfg.sesskey+'&search='+this.get_search_text()+'&debug=1">Ajax call failed. Click here to try the search call directly.</a>'));
|
||||
this.listbox.setStyle('background','');
|
||||
this.searchfield.addClass('error');
|
||||
return new M.core.exception(e);
|
||||
}
|
||||
},
|
||||
/**
|
||||
@ -379,4 +367,4 @@ M.core_user.init_user_selector_options_tracker = function(Y) {
|
||||
user_selector_options_tracker.init();
|
||||
// Return it just incase it is ever wanted
|
||||
return user_selector_options_tracker;
|
||||
};
|
||||
};
|
||||
|
@ -23,29 +23,19 @@
|
||||
* @package user
|
||||
*/
|
||||
|
||||
define('AJAX_SCRIPT', true);
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/user/selector/lib.php');
|
||||
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_url('/user/selector/search.php');
|
||||
|
||||
// In developer debug mode, when there is a debug=1 in the URL send as plain text
|
||||
// for easier debugging.
|
||||
if (debugging('', DEBUG_DEVELOPER) && optional_param('debug', false, PARAM_BOOL)) {
|
||||
header('Content-type: text/plain; charset=UTF-8');
|
||||
$debugmode = true;
|
||||
} else {
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
$debugmode = false;
|
||||
}
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Check access.
|
||||
if (!isloggedin()) {;
|
||||
print_error('mustbeloggedin');
|
||||
}
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
require_login();
|
||||
require_sesskey();
|
||||
|
||||
// Get the search parameter.
|
||||
$search = required_param('search', PARAM_RAW);
|
||||
@ -59,13 +49,6 @@ if (!isset($USER->userselectors[$selectorhash])) {
|
||||
// Get the options.
|
||||
$options = $USER->userselectors[$selectorhash];
|
||||
|
||||
if ($debugmode) {
|
||||
echo 'Search string: ', $search, "\n";
|
||||
echo 'Options: ';
|
||||
print_r($options);
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
// Create the appropriate userselector.
|
||||
$classname = $options['class'];
|
||||
unset($options['class']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user