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 local_downloadcenter for 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
 * Download center plugin
19
 *
20
 * @package       local_downloadcenter
21
 * @author        Simeon Naydenov (moniNaydenov@gmail.com)
22
 * @copyright     2020 Academic Moodle Cooperation {@link http://www.academic-moodle-cooperation.org}
23
 * @license       http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
/**
29
 *
30
 * @param settings_navigation $settingsnav
31
 * @param context $context
32
 * @return null
33
 */
34
function local_downloadcenter_extend_settings_navigation(settings_navigation $settingsnav, context $context) {
35
    return; // Not used anymore!
36
}
37
 
38
/**
39
 * @param navigation_node $parentnode Node where the new link is inserted
40
 * @param stdClass $course current course
41
 * @param context_course $context current course context
42
 * @throws coding_exception
43
 * @throws moodle_exception
44
 */
45
function local_downloadcenter_extend_navigation_course(navigation_node $parentnode, stdClass $course, context_course $context) {
46
    if (!has_capability('local/downloadcenter:view', $context)) {
47
        return;
48
    }
49
 
50
    // Find appropriate key where our link should come. Probably won't work, but at least try.
51
    $keys = [
52
        'questionbank' => navigation_node::TYPE_CONTAINER,
53
        'unenrolself' => navigation_node::TYPE_SETTING,
54
        'fitlermanagement' => navigation_node::TYPE_SETTING,
55
    ];
56
    $beforekey = null;
57
    foreach ($keys as $key => $type) {
58
        if ($foundnode = $parentnode->find($key, $type)) {
59
            $beforekey = $key;
60
            break;
61
        }
62
    }
63
 
64
    $url = new moodle_url('/local/downloadcenter/index.php', array('courseid' => $course->id));
65
    $title = get_string('navigationlink', 'local_downloadcenter');
66
    $pix = new pix_icon('icon', $title, 'local_downloadcenter');
67
    $childnode = navigation_node::create(
68
        $title,
69
        $url,
70
        navigation_node::TYPE_SETTING,
71
        'downloadcenter',
72
        'downloadcenter',
73
        $pix
74
    );
75
 
76
    $node = $parentnode->add_node($childnode, $beforekey);
77
    $node->nodetype = navigation_node::TYPE_SETTING;
78
    $node->collapse = true;
79
    $node->add_class('downloadcenterlink');
80
}
81
/**
82
 * @param global_navigation $nav
83
 * @throws coding_exception
84
 * @throws moodle_exception
85
 */
86
function local_downloadcenter_extend_navigation(global_navigation $nav) {
87
    return; // Not used anymore!
88
}
89
 
90
/**
91
 * @return array
92
 */
93
function local_downloadcenter_get_fontawesome_icon_map() {
94
    return [
95
        'local_downloadcenter:icon' => 'fa-arrow-circle-o-down',
96
    ];
97
}