Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * unilabel type carousel.
19
 *
20
 * @package     unilabeltype_carousel
21
 * @author      Andreas Grabs <info@grabs-edv.de>
22
 * @copyright   2018 onwards Grabs EDV {@link https://www.grabs-edv.de}
23
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @param mixed $course
25
 * @param mixed $cm
26
 * @param mixed $context
27
 * @param mixed $filearea
28
 * @param mixed $args
29
 * @param mixed $forcedownload
30
 */
31
 
32
/**
33
 * Send files provided by this plugin.
34
 *
35
 * @param  \stdClass $course
36
 * @param  \stdClass $cm
37
 * @param  \context  $context
38
 * @param  string    $filearea
39
 * @param  array     $args
40
 * @param  bool      $forcedownload
41
 * @return bool
42
 */
43
function unilabeltype_carousel_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
44
    if ($context->contextlevel != CONTEXT_MODULE) {
45
        return false;
46
    }
47
 
48
    require_course_login($course, true, $cm);
49
    if (!has_capability('mod/unilabel:view', $context)) {
50
        return false;
51
    }
52
 
53
    switch ($filearea) {
54
        case 'caption':
55
        case 'image':
56
        case 'image_mobile':
57
            break;
58
        default:
59
            return false;
60
    }
61
 
62
    $relativepath = implode('/', $args);
63
    $fullpath     = '/' . $context->id . '/unilabeltype_carousel/' . $filearea . '/' . $relativepath;
64
 
65
    $fs = get_file_storage();
66
    if ($file = $fs->get_file_by_hash(sha1($fullpath))) {
67
        if (!$file->is_directory()) {
68
            send_stored_file($file, 0, 0, true); // Download MUST be forced - security!
69
        }
70
    }
71
 
72
    return false;
73
}