Skip to content

Commit

Permalink
MDL-73726 reportbuilder: restrict schedule formats to enabled types.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jun 6, 2022
1 parent 473ac12 commit 72286f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions reportbuilder/classes/local/helpers/schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ public static function delete_schedule(int $reportid, int $scheduleid): bool {
* @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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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;
Expand Down Expand Up @@ -198,8 +197,11 @@ protected function add_columns(): void {
->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;
}
})
);

Expand Down

0 comments on commit 72286f9

Please sign in to comment.