Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | 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
declare(strict_types=1);
18
 
19
namespace core_course\reportbuilder\local\formatters;
20
 
21
use core_user\output\status_field;
22
use lang_string;
23
 
24
/**
25
 * Formatters for the course enrolment entity
26
 *
27
 * @package     core_course
28
 * @copyright   2022 David Matamoros <davidmc@moodle.com>
29
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 */
31
class enrolment {
32
 
33
    /**
34
     * @deprecated since Moodle 4.3 - please do not use this function any more (to remove in MDL-78118)
35
     */
1441 ariadna 36
    #[\core\attribute\deprecated(null, reason: 'It is no longer used', since: '4.3', mdl: 'MDL-76900', final: true)]
37
    public static function enrolment_name(): void {
38
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
1 efrain 39
    }
40
 
41
    /**
42
     * Returns list of enrolment statuses
43
     *
44
     * @return lang_string[]
45
     */
46
    public static function enrolment_values(): array {
47
        return [
48
            status_field::STATUS_ACTIVE => new lang_string('participationactive', 'enrol'),
49
            status_field::STATUS_SUSPENDED => new lang_string('participationsuspended', 'enrol'),
50
            status_field::STATUS_NOT_CURRENT => new lang_string('participationnotcurrent', 'enrol'),
51
        ];
52
    }
53
 
54
    /**
55
     * Return enrolment status for user
56
     *
57
     * @param string|null $value
58
     * @return string|null
59
     */
60
    public static function enrolment_status(?string $value): ?string {
61
        if ($value === null) {
62
            return null;
63
        }
64
 
65
        $statusvalues = self::enrolment_values();
66
 
67
        $value = (int) $value;
68
        if (!array_key_exists($value, $statusvalues)) {
69
            return null;
70
        }
71
 
72
        return (string) $statusvalues[$value];
73
    }
74
}