MDL-72094 report_log: Modify the styling of the selector form elements
[moodle.git] / webservice / draftfile.php
blobb8fbea8c6d28735720469f88f30868152cf28bcf
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Entry point for web service via tokens access to draftfile.php.
21 * @package core
22 * @copyright 2020 Juan Leyva <juan@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 /**
27 * AJAX_SCRIPT - exception will be converted into JSON.
29 define('AJAX_SCRIPT', true);
31 /**
32 * NO_MOODLE_COOKIES - we don't want any cookie.
34 define('NO_MOODLE_COOKIES', true);
36 require_once(__DIR__ . '/../config.php');
37 require_once($CFG->dirroot . '/webservice/lib.php');
39 // Allow CORS requests.
40 header('Access-Control-Allow-Origin: *');
42 // Authenticate the user.
43 $token = required_param('token', PARAM_ALPHANUM);
45 $webservicelib = new webservice();
46 $authenticationinfo = $webservicelib->authenticate_user($token);
48 // Check the service allows file download.
49 if (empty($authenticationinfo['service']->downloadfiles)) {
50 throw new webservice_access_exception('Web service file downloading must be enabled in external service settings.');
53 require_once($CFG->dirroot . '/draftfile.php');