Permalink
Browse files

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.
  • Loading branch information...
1 parent 7112729 commit 28037331fb5300662d069885bafd17d4dde66704 @andrewnicols andrewnicols committed Mar 1, 2013
Showing with 5 additions and 23 deletions.
  1. +0 −1 repository/repository_ajax.php
  2. +5 −22 user/selector/search.php
@@ -57,7 +57,6 @@
$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 @@
// 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']);

0 comments on commit 2803733

Please sign in to comment.