Merge branch 'MDL-87000' of https://github.com/paulholden/moodle
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
issueNumber: MDL-87000
|
||||
notes:
|
||||
core_reportbuilder:
|
||||
- message: |
|
||||
The following enrolment entity formatter methods have been deprecated:
|
||||
|
||||
* `enrolment_status()`
|
||||
* `enrolment_values()`
|
||||
type: deprecated
|
||||
@@ -18,19 +18,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace core_course\reportbuilder\local\entities;
|
||||
|
||||
use context_course;
|
||||
use core_course\reportbuilder\local\formatters\enrolment as enrolment_formatter;
|
||||
use core\lang_string;
|
||||
use core_reportbuilder\local\entities\base;
|
||||
use core_reportbuilder\local\filters\date;
|
||||
use core_reportbuilder\local\filters\select;
|
||||
use core_reportbuilder\local\helpers\database;
|
||||
use core_reportbuilder\local\filters\{date, select};
|
||||
use core_reportbuilder\local\helpers\format;
|
||||
use core_reportbuilder\local\report\column;
|
||||
use core_reportbuilder\local\report\filter;
|
||||
use core_reportbuilder\local\report\{column, filter};
|
||||
use core_user\output\status_field;
|
||||
use enrol_plugin;
|
||||
use lang_string;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Course enrolment entity implementation
|
||||
@@ -40,7 +33,6 @@ use stdClass;
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class enrolment extends base {
|
||||
|
||||
/**
|
||||
* Database tables that this entity uses
|
||||
*
|
||||
@@ -117,10 +109,21 @@ class enrolment extends base {
|
||||
$this->get_entity_name()
|
||||
))
|
||||
->add_joins($this->get_joins())
|
||||
->set_type(column::TYPE_TEXT)
|
||||
->add_field($this->get_status_field_sql(), 'status')
|
||||
->set_is_sortable(true)
|
||||
->add_callback([enrolment_formatter::class, 'enrolment_status']);
|
||||
->add_callback(static function (?string $status): string {
|
||||
if ($status === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$statuses = [
|
||||
status_field::STATUS_ACTIVE => new lang_string('participationactive', 'core_enrol'),
|
||||
status_field::STATUS_SUSPENDED => new lang_string('participationsuspended', 'core_enrol'),
|
||||
status_field::STATUS_NOT_CURRENT => new lang_string('participationnotcurrent', 'core_enrol'),
|
||||
];
|
||||
|
||||
return (string) ($statuses[(int) $status] ?? $status);
|
||||
});
|
||||
|
||||
return $columns;
|
||||
}
|
||||
@@ -221,7 +224,11 @@ class enrolment extends base {
|
||||
$this->get_status_field_sql()
|
||||
))
|
||||
->add_joins($this->get_joins())
|
||||
->set_options(enrolment_formatter::enrolment_values());
|
||||
->set_options([
|
||||
status_field::STATUS_ACTIVE => new lang_string('participationactive', 'core_enrol'),
|
||||
status_field::STATUS_SUSPENDED => new lang_string('participationsuspended', 'core_enrol'),
|
||||
status_field::STATUS_NOT_CURRENT => new lang_string('participationnotcurrent', 'core_enrol'),
|
||||
]);
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace core_course\reportbuilder\local\formatters;
|
||||
|
||||
use core\lang_string;
|
||||
use core_user\output\status_field;
|
||||
use lang_string;
|
||||
|
||||
/**
|
||||
* Formatters for the course enrolment entity
|
||||
@@ -27,9 +27,10 @@ use lang_string;
|
||||
* @package core_course
|
||||
* @copyright 2022 David Matamoros <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*
|
||||
* @deprecated since Moodle 5.2
|
||||
*/
|
||||
class enrolment {
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 4.3 - please do not use this function any more (to remove in MDL-78118)
|
||||
*/
|
||||
@@ -42,8 +43,13 @@ class enrolment {
|
||||
* Returns list of enrolment statuses
|
||||
*
|
||||
* @return lang_string[]
|
||||
*
|
||||
* @deprecated since Moodle 5.2 - please do not use this function any more
|
||||
*/
|
||||
#[\core\attribute\deprecated(reason: 'It is no longer used', since: '5.2', mdl: 'MDL-87000')]
|
||||
public static function enrolment_values(): array {
|
||||
\core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
|
||||
|
||||
return [
|
||||
status_field::STATUS_ACTIVE => new lang_string('participationactive', 'enrol'),
|
||||
status_field::STATUS_SUSPENDED => new lang_string('participationsuspended', 'enrol'),
|
||||
@@ -56,8 +62,13 @@ class enrolment {
|
||||
*
|
||||
* @param string|null $value
|
||||
* @return string|null
|
||||
*
|
||||
* @deprecated since Moodle 5.2 - please do not use this function any more
|
||||
*/
|
||||
#[\core\attribute\deprecated(reason: 'It is no longer used', since: '5.2', mdl: 'MDL-87000')]
|
||||
public static function enrolment_status(?string $value): ?string {
|
||||
\core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
|
||||
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user