mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-73726 reportbuilder: restrict schedule formats to enabled types.
This commit is contained in:
parent
473ac1285e
commit
72286f9296
2 changed files with 8 additions and 6 deletions
|
@ -339,10 +339,10 @@ class schedule {
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public static function get_format_options(): array {
|
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 array_map(static function(string $pluginname): string {
|
||||||
return $dataformat->displayname;
|
return get_string('dataformat', 'dataformat_' . $pluginname);
|
||||||
}, $dataformats);
|
}, $dataformats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ use core_reportbuilder\local\entities\user;
|
||||||
use core_reportbuilder\local\filters\date;
|
use core_reportbuilder\local\filters\date;
|
||||||
use core_reportbuilder\local\filters\text;
|
use core_reportbuilder\local\filters\text;
|
||||||
use core_reportbuilder\local\helpers\format;
|
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\report;
|
||||||
use core_reportbuilder\local\models\schedule;
|
use core_reportbuilder\local\models\schedule;
|
||||||
use core_reportbuilder\local\report\action;
|
use core_reportbuilder\local\report\action;
|
||||||
|
@ -198,8 +197,11 @@ class report_schedules extends system_report {
|
||||||
->add_fields("{$tablealias}.format")
|
->add_fields("{$tablealias}.format")
|
||||||
->set_is_sortable(true)
|
->set_is_sortable(true)
|
||||||
->add_callback(static function(string $format): string {
|
->add_callback(static function(string $format): string {
|
||||||
$formats = helper::get_format_options();
|
if (get_string_manager()->string_exists('dataformat', 'dataformat_' . $format)) {
|
||||||
return $formats[$format] ?? '';
|
return get_string('dataformat', 'dataformat_' . $format);
|
||||||
|
} else {
|
||||||
|
return $format;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue