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

apsolu / local_apsolu / 19636371037

24 Nov 2025 01:40PM UTC coverage: 10.658% (-0.04%) from 10.699%
19636371037

push

github

jboulen
feat(db): ajoute un script permettant de modifier le schéma de base de données sans avoir à changer le numéro de version du module

669 of 6277 relevant lines covered (10.66%)

0.15 hits per line

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

0.0
/classes/core/customfields.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
// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod
18

19
namespace local_apsolu\core;
20

21
use coding_exception;
22

23
/**
24
 * Fonctions pour le module apsolu.
25
 *
26
 * @package    local_apsolu
27
 * @copyright  2018 Université Rennes 2 <dsi-contact@univ-rennes2.fr>
28
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 */
30
class customfields {
31
    /**
32
     * Retourne la liste des champs personnalisés APSOLU indéxés par nom abrégé.
33
     *
34
     * @return array
35
     */
36
    public static function getCustomFields() {
37
        global $DB;
×
38

39
        $fields = [];
×
40

41
        $sql = "SELECT * FROM {user_info_field} WHERE shortname LIKE 'apsolu%'";
×
42
        foreach ($DB->get_records_sql($sql) as $field) {
×
43
            $fields[$field->shortname] = $field;
×
44
        }
45

46
        return $fields;
×
47
    }
48

49
    /**
50
     * Retourne la liste des champs additionnels.
51
     *
52
     * @param string $context Contexte d'utilisation des champs additionnels. Peut être display ou export.
53
     *
54
     * @return array
55
     */
56
    public static function get_extra_fields(string $context): array {
57
        // Valide le contexte d'utilisation.
58
        if (in_array($context, ['display', 'export'], $strict = true) === false) {
×
59
            throw new coding_exception('Unexpected value for $context argument in ' . __METHOD__);
×
60
        }
61

62
        $extrafields = [];
×
63

64
        $fields = json_decode(get_config('local_apsolu', sprintf('%s_fields', $context)));
×
65
        if (is_array($fields) === false) {
×
66
            $fields = [];
×
67
        }
68

69
        $customfields = false;
×
70
        foreach ($fields as $field) {
×
71
            if (str_starts_with($field, 'extra_') === false) {
×
72
                $extrafields[$field] = get_string($field);
×
73
                continue;
×
74
            }
75

76
            if ($customfields === false) {
×
77
                $customfields = [];
×
78
                foreach (profile_get_custom_fields() as $customfield) {
×
79
                    $customfields['extra_' . $customfield->shortname] = $customfield;
×
80
                }
81
            }
82

83
            if (isset($customfields[$field]) === false) {
×
84
                continue;
×
85
            }
86

87
            $customfield = $customfields[$field];
×
88
            $extrafields[$customfield->shortname] = $customfield->name;
×
89
        }
90

91
        return $extrafields;
×
92
    }
93

94
    /**
95
     * Retourne la liste des champs additionnels à exporter.
96
     *
97
     * @return array
98
     */
99
    #[\core\attribute\deprecated('local_apsolu\core\customfields::get_extra_fields("export")')]
100
    public static function get_extra_fields_for_export(): array {
101
        \core\deprecation::emit_deprecation(__METHOD__);
×
102

103
        return self::get_extra_fields('export');
×
104
    }
105
}
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