Differences Between: [Versions 400 and 402] [Versions 400 and 403]
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 * Main library of plugin. 19 * 20 * @package quizaccess_seb 21 * @author Andrew Madden <andrewmadden@catalyst-au.net> 22 * @author Dmitrii Metelkin <dmitriim@catalyst-au.net> 23 * @copyright 2019 Catalyst IT 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 /** 30 * Serve the files. 31 * 32 * @param stdClass $course the course object 33 * @param stdClass $cm the course module object 34 * @param \context $context the context 35 * @param string $filearea the name of the file area 36 * @param array $args extra arguments (itemid, path) 37 * @param bool $forcedownload whether or not force download 38 * @param array $options additional options affecting the file serving 39 * @return bool false if the file not found, just send the file otherwise and do not return anything 40 */ 41 function quizaccess_seb_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()) { 42 if ($context->contextlevel != CONTEXT_MODULE) { 43 return false; 44 } 45 46 if ($filearea !== 'filemanager_sebconfigfile') { 47 return false; 48 } 49 50 require_login($course, true, $cm); 51 if (!has_capability('quizaccess/seb:manage_filemanager_sebconfigfile', $context)) { 52 return false; 53 } 54 55 $itemid = array_shift($args); 56 $filename = array_pop($args); 57 58 if (!$args) { 59 $filepath = '/'; 60 } else { 61 $filepath = '/' .implode('/', $args) . '/'; 62 } 63 64 $fs = get_file_storage(); 65 $file = $fs->get_file($context->id, 'quizaccess_seb', $filearea, $itemid, $filepath, $filename); 66 if (!$file) { 67 return false; 68 } 69 70 send_stored_file($file, 0, 0, $forcedownload, $options); 71 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body