MDL-73726 reportbuilder: restrict schedule formats to enabled types.

This commit is contained in:
Paul Holden 2022-02-01 12:00:32 +00:00
parent 473ac1285e
commit 72286f9296
2 changed files with 8 additions and 6 deletions

View File

@ -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);
}

View File

@ -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;
}
})
);