diff --git a/application/controllers/ReportController.php b/application/controllers/ReportController.php index ed843387..895ef469 100644 --- a/application/controllers/ReportController.php +++ b/application/controllers/ReportController.php @@ -7,6 +7,7 @@ use Exception; use Icinga\Application\Hook; +use Icinga\Application\Modules\Module; use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport; use Icinga\Module\Reporting\Database; use Icinga\Module\Reporting\Model; @@ -279,13 +280,17 @@ protected function assembleActions(): ActionBar { $reportId = $this->report->getId(); - $download = (new CompatDropdown('Download')) - ->addLink( + $download = new CompatDropdown('Download'); + + // TODO: Check against Hook::has once we have removed the dependency on the pdfexport module + if (Module::exists('pdfexport')) { + $download->addLink( 'PDF', Url::fromPath('reporting/report/download?type=pdf', ['id' => $reportId]), null, ['target' => '_blank'] ); + } if ($this->report->providesData()) { $download->addLink( @@ -332,15 +337,17 @@ protected function assembleActions(): ActionBar ); } - $actions - ->add($download) - ->addHtml( - (new ActionLink( - $this->translate('Send'), - Url::fromPath('reporting/report/send', ['id' => $reportId]), - 'forward' - ))->openInModal() - ); + if ($download->hasLinks()) { + $actions + ->add($download) + ->addHtml( + (new ActionLink( + $this->translate('Send'), + Url::fromPath('reporting/report/send', ['id' => $reportId]), + 'forward' + ))->openInModal() + ); + } return $actions; } diff --git a/library/Reporting/Actions/SendMail.php b/library/Reporting/Actions/SendMail.php index 73138a64..72cfc59f 100644 --- a/library/Reporting/Actions/SendMail.php +++ b/library/Reporting/Actions/SendMail.php @@ -7,6 +7,7 @@ use Icinga\Application\Config; use Icinga\Application\Logger; +use Icinga\Application\Modules\Module; use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport; use Icinga\Module\Reporting\Hook\ActionHook; use Icinga\Module\Reporting\Mail; @@ -79,7 +80,12 @@ function ($pdf) use ($mail, $name, $recipients) { public function initConfigForm(Form $form, Report $report) { - $types = ['pdf' => 'PDF']; + $types = []; + + // TODO: Check against Hook::has once we have removed the dependency on the pdfexport module + if (Module::exists('pdfexport')) { + $types['pdf'] = 'PDF'; + } if ($report->providesData()) { $types['csv'] = 'CSV';