mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-33680 JavaScript: Use the correct Content-Type for AJAX scripts
The repository_ajax.php script was returning a text/plain Content-Type and user/selector/search.php was setting the content-type when this should be handled by with the definition of AJAX_SCRIPT.
This commit is contained in:
parent
7112729206
commit
28037331fb
@ -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)) {
|
||||
|
@ -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