Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   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.
  13  //
  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/>.
  16  
  17  /**
  18   * This file contains the hooks for the Shibboleth authentication module.
  19   *
  20   * @package auth_shibboleth
  21   * @copyright 2018 Fabrice Ménard
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die;
  26  
  27  /**
  28   * Serves the logo file settings.
  29   *
  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
  38   */
  39  function auth_shibboleth_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) {
  40      if ($context->contextlevel != CONTEXT_SYSTEM) {
  41          return false;
  42      }
  43  
  44      if ($filearea !== 'logo' ) {
  45          return false;
  46      }
  47  
  48      $itemid = 0;
  49  
  50      $filename = array_pop($args);
  51      if (!$args) {
  52          $filepath = '/';
  53      } else {
  54          $filepath = '/'.implode('/', $args).'/';
  55      }
  56  
  57      $fs = get_file_storage();
  58      $file = $fs->get_file($context->id, 'auth_shibboleth', $filearea, $itemid, $filepath, $filename);
  59      if (!$file) {
  60          return false;
  61      }
  62  
  63      send_stored_file($file, null, 0, $forcedownload, $options);
  64  }