Merge branch 'MDL-35628' of https://github.com/mr-russ/moodle
authorDan Poltawski <dan@moodle.com>
Tue, 14 Jun 2016 16:25:56 +0000 (17:25 +0100)
committerDan Poltawski <dan@moodle.com>
Thu, 16 Jun 2016 08:04:12 +0000 (09:04 +0100)
1  2 
lib/editor/atto/autosave-ajax.php
theme/index.php

  
  define('AJAX_SCRIPT', true);
  
- require_once(dirname(__FILE__) . '/../../../config.php');
+ require_once(__DIR__ . '/../../../config.php');
  require_once($CFG->libdir . '/filestorage/file_storage.php');
  
 -$contextid = required_param('contextid', PARAM_INT);
 -$elementid = required_param('elementid', PARAM_ALPHANUMEXT);
 -$pagehash = required_param('pagehash', PARAM_ALPHANUMEXT);
 -$pageinstance = required_param('pageinstance', PARAM_ALPHANUMEXT);
 +// Clean up actions.
 +$actions = array_map(function($actionparams) {
 +    $action = isset($actionparams['action']) ? $actionparams['action'] : null;
 +    $params = [];
 +    $keys = [
 +        'action' => PARAM_ALPHA,
 +        'contextid' => PARAM_INT,
 +        'elementid' => PARAM_ALPHANUMEXT,
 +        'pagehash' => PARAM_ALPHANUMEXT,
 +        'pageinstance' => PARAM_ALPHANUMEXT
 +    ];
 +
 +    if ($action == 'save') {
 +        $keys['drafttext'] = PARAM_RAW;
 +    } else if ($action == 'resume') {
 +        $keys['draftid'] = PARAM_INT;
 +    }
 +
 +    foreach ($keys as $key => $type) {
 +        // Replicate required_param().
 +        if (!isset($actionparams[$key])) {
 +            print_error('missingparam', '', '', $key);
 +        }
 +        $params[$key] = clean_param($actionparams[$key], $type);
 +    }
 +
 +    return $params;
 +}, isset($_REQUEST['actions']) ? $_REQUEST['actions'] : []);
 +
  $now = time();
  // This is the oldest time any autosave text will be recovered from.
  // This is so that there is a good chance the draft files will still exist (there are many variables so
diff --cc theme/index.php
Simple merge