• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apsolu / local_apsolu / 18468445848

13 Oct 2025 02:06PM UTC coverage: 9.418% (+0.2%) from 9.224%
18468445848

push

github

jboulen
refactor(core): applique des corrections pour le nouveau coding style de Moodle

69 of 875 new or added lines in 51 files covered. (7.89%)

47 existing lines in 11 files now uncovered.

557 of 5914 relevant lines covered (9.42%)

0.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib.php
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
 * Enregistre un nouveau type d'élément de formulaire.
19
 *
20
 * @package    local_apsolu
21
 * @copyright  2021 Université Rennes 2 <dsi-contact@univ-rennes2.fr>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24

25
// phpcs:ignore MoodleQuickForm::registerElementType('time', __DIR__.'/classes/time_form_element.php', 'local_apsolu_time_form_element');
26

27
/**
28
 * Fonction spéciale gérée par Moodle, permettant d'étendre un menu dans un cours.
29
 *
30
 * @see https://docs.moodle.org/dev/Local_plugins#Adding_an_element_to_the_settings_menu
31
 *
32
 * @param navigation_node $navigation The navigation node to extend
33
 * @param stdClass $course The course to object for the tool
34
 * @param context $context The context of the course
35
 *
36
 * @return void|null return null if we don't want to display the node.
37
 */
38
function local_apsolu_extend_navigation_course($navigation, $course, $context) {
39
    global $PAGE;
40

41
    // Only add this settings item on non-site course pages.
42
    if (!$PAGE->course || $PAGE->course->id == SITEID) {
×
43
        return null;
×
44
    }
45

46
    $url = new moodle_url('/course/view.php');
×
47
    if ($PAGE->url->compare($url, URL_MATCH_BASE) === true) {
×
48
        // Surcharge la page d'accueil d'un cours.
49
        return local_apsolu_override_course_page($course);
×
50
    }
51
}
52

53
/**
54
 * Fonction spéciale permettant de surcharger la page d'accueil d'un cours avec du javascript.
55
 *
56
 * @param stdClass $course The course to object for the tool
57
 *
58
 * @return void
59
 */
60
function local_apsolu_override_course_page($course) {
61
    global $PAGE;
62

63
    if (has_capability('moodle/course:update', context_course::instance($course->id, MUST_EXIST)) === true) {
×
64
        // Affiche les boutons de prise de présences et de gestion des étudiants en haut de la page.
65
        $PAGE->requires->js_call_amd('local_apsolu/attendance', 'setupcourse');
×
66
    }
67
}
68

69
/**
70
 * Gère les contrôles d'accès pour la diffusion des fichiers du module local_apsolu.
71
 *
72
 * @param stdClass $course        Course object.
73
 * @param stdClass $cm            Course module object.
74
 * @param stdClass $context       Context object.
75
 * @param string   $filearea      File area.
76
 * @param array    $args          Extra arguments.
77
 * @param bool     $forcedownload Whether or not force download.
78
 * @param array    $options       Additional options affecting the file serving.
79
 *
80
 * @return void|bool Retourne False en cas d'erreur.
81
 */
82
function local_apsolu_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []) {
83
    global $USER;
84

85
    if ($context->contextlevel != CONTEXT_COURSE) {
×
NEW
86
        debugging('Wrong contextlevel: ' . $context->contextlevel, DEBUG_DEVELOPER);
×
87
        return false;
×
88
    }
89

90
    if (in_array($filearea, ['information', 'medicalcertificate', 'parentalauthorization'], $strict = true) === false) {
×
NEW
91
        debugging('Wrong filearea: ' . $filearea, DEBUG_DEVELOPER);
×
92
        return false;
×
93
    }
94

95
    $itemid = (int)array_shift($args);
×
96

97
    $fs = get_file_storage();
×
98

99
    $filename = array_pop($args);
×
100
    if (empty($args) === true) {
×
101
        $filepath = '/';
×
102
    } else {
NEW
103
        $filepath = '/' . implode('/', $args) . '/';
×
104
    }
105

106
    $file = $fs->get_file($context->id, 'local_apsolu', $filearea, $itemid, $filepath, $filename);
×
107
    if ($file === false) {
×
108
        debugging(get_string('filenotfound', 'error'), DEBUG_DEVELOPER);
×
109
        return false;
×
110
    }
111

112
    switch ($filearea) {
113
        case 'information':
×
114
            // Fichier public, visible sans droit particulier.
115
            break;
×
116
        case 'medicalcertificate':
×
117
        case 'parentalauthorization':
×
118
            // Fichier visible uniquement par le propriétaire du fichier ou un gestionnaire.
119
            if (
NEW
120
                $file->get_userid() !== $USER->id &&
×
NEW
121
                has_capability('local/apsolu:viewallmedicalcertificates', context_system::instance()) === false
×
122
            ) {
UNCOV
123
                return false;
×
124
            }
125
    }
126

127
    // Finally send the file.
128
    send_stored_file($file, 0, 0, true, $options); // Download MUST be forced - security!
×
129
}
130

131
/**
132
 * Return a list of all the user preferences used by local_apsolu.
133
 *
134
 * @return array
135
 */
136
function local_apsolu_user_preferences() {
137
    $preferences = [];
×
138
    $preferences['apsolu_maskable_config'] = [
×
139
        'type' => PARAM_RAW,
×
140
        'null' => NULL_NOT_ALLOWED,
×
141
        'default' => '{}',
×
142
    ];
×
143

144
    return $preferences;
×
145
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc