Differences Between: [Versions 401 and 403] [Versions 402 and 403]
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 use stdClass; 24 25 /** 26 * Formatters for the course enrolment entity 27 * 28 * @package core_course 29 * @copyright 2022 David Matamoros <davidmc@moodle.com> 30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 31 */ 32 class enrolment { 33 34 /** 35 * Return enrolment plugin instance name 36 * 37 * @param string|null $value 38 * @param stdClass $row 39 * @return string 40 * 41 * @deprecated since Moodle 4.3 - please do not use this function any more (to remove in MDL-78118) 42 */ 43 public static function enrolment_name(?string $value, stdClass $row): string { 44 global $DB; 45 46 if (empty($value)) { 47 return ''; 48 } 49 50 $instance = $DB->get_record('enrol', ['id' => $row->id, 'enrol' => $row->enrol], '*', MUST_EXIST); 51 $plugin = enrol_get_plugin($row->enrol); 52 53 return $plugin ? $plugin->get_instance_name($instance) : '-'; 54 } 55 56 /** 57 * Returns list of enrolment statuses 58 * 59 * @return lang_string[] 60 */ 61 public static function enrolment_values(): array { 62 return [ 63 status_field::STATUS_ACTIVE => new lang_string('participationactive', 'enrol'), 64 status_field::STATUS_SUSPENDED => new lang_string('participationsuspended', 'enrol'), 65 status_field::STATUS_NOT_CURRENT => new lang_string('participationnotcurrent', 'enrol'), 66 ]; 67 } 68 69 /** 70 * Return enrolment status for user 71 * 72 * @param string|null $value 73 * @return string|null 74 */ 75 public static function enrolment_status(?string $value): ?string { 76 if ($value === null) { 77 return null; 78 } 79 80 $statusvalues = self::enrolment_values(); 81 82 $value = (int) $value; 83 if (!array_key_exists($value, $statusvalues)) { 84 return null; 85 } 86 87 return (string) $statusvalues[$value]; 88 } 89 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body