2 // This file is part of Moodle - http://moodle.org/
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.
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 * Authentication Plugin: CAS Authentication.
20 * Authentication using CAS (Central Authentication Server).
23 * @copyright 2018 Fabrice Ménard <menard.fabrice@gmail.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') ||
die;
30 * Serves the logo file settings.
32 * @param stdClass $course course object
33 * @param stdClass $cm course module object
34 * @param stdClass $context context object
35 * @param string $filearea file area
36 * @param array $args extra arguments
37 * @param bool $forcedownload whether or not force download
38 * @param array $options additional options affecting the file serving
39 * @return bool false|void
41 function auth_cas_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []) {
42 if ($context->contextlevel
!= CONTEXT_SYSTEM
) {
46 if ($filearea !== 'logo' ) {
50 // Extract the filename / filepath from the $args array.
51 $filename = array_pop($args);
55 $filepath = '/' . implode('/', $args) . '/';
58 // Retrieve the file from the Files API.
60 $fs = get_file_storage();
61 $file = $fs->get_file($context->id
, 'auth_cas', $filearea, $itemid, $filepath, $filename);
63 return false; // The file does not exist.
66 send_stored_file($file, null, 0, $forcedownload, $options);