From 72286f9296294dc2e8d14bdcf6e489ab5e61dbdb Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 1 Feb 2022 12:00:32 +0000 Subject: [PATCH] MDL-73726 reportbuilder: restrict schedule formats to enabled types. --- reportbuilder/classes/local/helpers/schedule.php | 6 +++--- .../classes/local/systemreports/report_schedules.php | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/reportbuilder/classes/local/helpers/schedule.php b/reportbuilder/classes/local/helpers/schedule.php index 9dcfd65c853..c103f502ce1 100644 --- a/reportbuilder/classes/local/helpers/schedule.php +++ b/reportbuilder/classes/local/helpers/schedule.php @@ -339,10 +339,10 @@ class schedule { * @return string[] */ public static function get_format_options(): array { - $dataformats = core_plugin_manager::instance()->get_plugins_of_type('dataformat'); + $dataformats = dataformat::get_enabled_plugins(); - return array_map(static function(dataformat $dataformat): string { - return $dataformat->displayname; + return array_map(static function(string $pluginname): string { + return get_string('dataformat', 'dataformat_' . $pluginname); }, $dataformats); } diff --git a/reportbuilder/classes/local/systemreports/report_schedules.php b/reportbuilder/classes/local/systemreports/report_schedules.php index 071850c7f62..c42dce210cf 100644 --- a/reportbuilder/classes/local/systemreports/report_schedules.php +++ b/reportbuilder/classes/local/systemreports/report_schedules.php @@ -29,7 +29,6 @@ use core_reportbuilder\local\entities\user; use core_reportbuilder\local\filters\date; use core_reportbuilder\local\filters\text; use core_reportbuilder\local\helpers\format; -use core_reportbuilder\local\helpers\schedule as helper; use core_reportbuilder\local\models\report; use core_reportbuilder\local\models\schedule; use core_reportbuilder\local\report\action; @@ -198,8 +197,11 @@ class report_schedules extends system_report { ->add_fields("{$tablealias}.format") ->set_is_sortable(true) ->add_callback(static function(string $format): string { - $formats = helper::get_format_options(); - return $formats[$format] ?? ''; + if (get_string_manager()->string_exists('dataformat', 'dataformat_' . $format)) { + return get_string('dataformat', 'dataformat_' . $format); + } else { + return $format; + } }) );