Merge branch 'MDL-59169-master' of https://github.com/nwp90/moodle
[moodle.git] / auth / shibboleth / lib.php
blobf8ac757398457937d30d0bd0b9d3952b1c2c63cf
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/>.
17 /**
18 * This file contains the hooks for the Shibboleth authentication module.
20 * @package auth_shibboleth
21 * @copyright 2018 Fabrice Ménard
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die;
27 /**
28 * Serves the logo file settings.
30 * @param stdClass $course course object
31 * @param stdClass $cm course module object
32 * @param stdClass $context context object
33 * @param string $filearea file area
34 * @param array $args extra arguments
35 * @param bool $forcedownload whether or not force download
36 * @param array $options additional options affecting the file serving
37 * @return bool false if file not found, does not return if found - justsend the file
39 function auth_shibboleth_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
40 if ($context->contextlevel != CONTEXT_SYSTEM) {
41 return false;
44 if ($filearea !== 'logo' ) {
45 return false;
48 $itemid = 0;
50 $filename = array_pop($args);
51 if (!$args) {
52 $filepath = '/';
53 } else {
54 $filepath = '/'.implode('/', $args).'/';
57 $fs = get_file_storage();
58 $file = $fs->get_file($context->id, 'auth_shibboleth', $filearea, $itemid, $filepath, $filename);
59 if (!$file) {
60 return false;
63 send_stored_file($file, null, 0, $forcedownload, $options);