MDL-30717 add missing time created info in create_user_record()
[moodle.git] / webservice / pluginfile.php
blob186e36e709f70403b88a8a34173c7cf5facf4dfc
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * A script to serve files from web service client
21 * @package core
22 * @subpackage file
23 * @copyright 2011 Dongsheng Cai <dongsheng@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 define('AJAX_SCRIPT', true);
28 define('NO_MOODLE_COOKIES', true);
29 require_once(dirname(dirname(__FILE__)) . '/config.php');
30 require_once($CFG->libdir . '/filelib.php');
31 require_once($CFG->dirroot . '/webservice/lib.php');
33 //authenticate the user
34 $token = required_param('token', PARAM_ALPHANUM);
35 $webservicelib = new webservice();
36 $authenticationinfo = $webservicelib->authenticate_user($token);
38 //check the service allows file download
39 $enabledfiledownload = (int) ($authenticationinfo['service']->downloadfiles);
40 if (empty($enabledfiledownload)) {
41 throw new webservice_access_exception(get_string('enabledirectdownload', 'webservice'));
44 //finally we can serve the file :)
45 $relativepath = get_file_argument();
46 file_pluginfile($relativepath, 0);