Skip to content

Commit fb6a0f2

Browse files
New feature: Add possibility to restrict allowed download formats.
1 parent d2e826b commit fb6a0f2

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

classes/output/table.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,10 @@ public function __construct(wunderbyte_table $table, string $encodedtable = '')
613613
*/
614614
private function return_dataformat_selector() {
615615
$formats = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
616+
$allowed = $this->wbtable->alloweddownloadformats ?? [];
616617
$printoptions = [];
617618
foreach ($formats as $format) {
618-
if ($format->is_enabled()) {
619+
if ($format->is_enabled() && (empty($allowed) || in_array($format->name, $allowed, true))) {
619620
$printoptions[] = [
620621
'value' => $format->name,
621622
'label' => get_string('dataformat', $format->component),

classes/wunderbyte_table.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ class wunderbyte_table extends table_sql {
141141
*/
142142
public $showdownloadbutton = false;
143143

144+
/**
145+
* Restrict the download formats shown in the selector.
146+
* An empty array means all enabled formats are shown.
147+
* Example: ['pdf'] to show only the PDF format.
148+
*
149+
* @var array
150+
*/
151+
public $alloweddownloadformats = [];
152+
144153
/**
145154
*
146155
* @var bool Show button to add individual custom filters.

0 commit comments

Comments
 (0)