From edbaad16482eb3451e47a05ac051594d0f9efbea Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Wed, 30 Nov 2016 14:59:57 +0100 Subject: [PATCH] [FEATURE] Add option to "system status updates" report to send all tests Resolves: #52286 Releases: master Change-Id: I875a6e7f70007c125408ec6c62c4fba1b2616233 Reviewed-on: https://review.typo3.org/50811 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Alexander Stehlik <alexander.stehlik@gmail.com> Tested-by: Alexander Stehlik <alexander.stehlik@gmail.com> Reviewed-by: Manuel Glauser <mail@manuelglauser.ch> Tested-by: Manuel Glauser <mail@manuelglauser.ch> Reviewed-by: Daniel Goerz <ervaude@gmail.com> Tested-by: Daniel Goerz <ervaude@gmail.com> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> --- ...mStatusUpdatesReport-jobToSendAllTests.rst | 25 ++++++++++++++++ .../Classes/Task/SystemStatusUpdateTask.php | 29 +++++++++++++++++-- ...StatusUpdateTaskNotificationEmailField.php | 16 +++++++++- .../Private/Language/locallang_reports.xlf | 8 ++++- 4 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Feature-52286-AddOptionToSystemStatusUpdatesReport-jobToSendAllTests.rst diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-52286-AddOptionToSystemStatusUpdatesReport-jobToSendAllTests.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-52286-AddOptionToSystemStatusUpdatesReport-jobToSendAllTests.rst new file mode 100644 index 000000000000..11f76c525c86 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-52286-AddOptionToSystemStatusUpdatesReport-jobToSendAllTests.rst @@ -0,0 +1,25 @@ +.. include:: ../../Includes.txt + +==================================================================================== +Feature: #52286 - Add option to "system status updates" report-job to send all tests +==================================================================================== + +See :issue:`52286` + +Description +=========== + +Sometimes it could be useful to get every test in the "System Status Updates (reports)" - also via mail. + +A checkbox was added to the job-configuration for the decision to get a mail if the +system has WARNING or ERROR events, or just get everything. +If the checkbox is not set (default) it works like before, including WARNING and ERROR events only. + + +Impact +====== + +If the checkbox `Notification for all type of status, not only warning and error` is checked, +then the `System Status Update (reports)` contains all type of notifications. + +.. index:: Backend \ No newline at end of file diff --git a/typo3/sysext/reports/Classes/Task/SystemStatusUpdateTask.php b/typo3/sysext/reports/Classes/Task/SystemStatusUpdateTask.php index 12054c0e1260..8cb9513a50ff 100644 --- a/typo3/sysext/reports/Classes/Task/SystemStatusUpdateTask.php +++ b/typo3/sysext/reports/Classes/Task/SystemStatusUpdateTask.php @@ -35,6 +35,13 @@ class SystemStatusUpdateTask extends AbstractTask */ protected $notificationEmail = null; + /** + * Checkbox for to send all types of notification, not only problems + * + * @var bool + */ + protected $notificationAll = false; + /** * Executes the System Status Update task, determining the highest severity of * status reports and saving that to the registry to be displayed at login @@ -51,7 +58,7 @@ class SystemStatusUpdateTask extends AbstractTask $systemStatus = $statusReport->getDetailedSystemStatus(); $highestSeverity = $statusReport->getHighestSeverity($systemStatus); $registry->set('tx_reports', 'status.highestSeverity', $highestSeverity); - if ($highestSeverity > Status::OK) { + if (($highestSeverity > Status::OK) || $this->getNotificationAll()) { $this->sendNotificationEmail($systemStatus); } return true; @@ -90,7 +97,7 @@ class SystemStatusUpdateTask extends AbstractTask foreach ($systemStatus as $statusProvider) { /** @var Status $status */ foreach ($statusProvider as $status) { - if ($status->getSeverity() > Status::OK) { + if ($this->getNotificationAll() || ($status->getSeverity() > Status::OK)) { $systemIssues[] = (string)$status . CRLF . $status->getMessage() . CRLF . CRLF; } } @@ -101,7 +108,7 @@ class SystemStatusUpdateTask extends AbstractTask $sendEmailsTo[] = $notificationEmail; } $subject = sprintf($this->getLanguageService()->getLL('status_updateTask_email_subject'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']); - $message = sprintf($this->getLanguageService()->getLL('status_problemNotification'), '', ''); + $message = $this->getNotificationAll() ? $this->getLanguageService()->getLL('status_allNotification') : $this->getLanguageService()->getLL('status_problemNotification'); $message .= CRLF . CRLF; $message .= $this->getLanguageService()->getLL('status_updateTask_email_site') . ': ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; $message .= CRLF . CRLF; @@ -118,6 +125,22 @@ class SystemStatusUpdateTask extends AbstractTask $mail->send(); } + /** + * @return bool + */ + public function getNotificationAll(): bool + { + return $this->notificationAll; + } + + /** + * @param bool $notificationAll + */ + public function setNotificationAll(bool $notificationAll) + { + $this->notificationAll = $notificationAll; + } + /** * @return LanguageService */ diff --git a/typo3/sysext/reports/Classes/Task/SystemStatusUpdateTaskNotificationEmailField.php b/typo3/sysext/reports/Classes/Task/SystemStatusUpdateTaskNotificationEmailField.php index 82c1c66f426d..d7aebd639358 100644 --- a/typo3/sysext/reports/Classes/Task/SystemStatusUpdateTaskNotificationEmailField.php +++ b/typo3/sysext/reports/Classes/Task/SystemStatusUpdateTaskNotificationEmailField.php @@ -31,7 +31,7 @@ class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldPro * * @var array */ - protected $fields = ['notificationEmail']; + protected $fields = ['notificationEmail', 'notificationAll']; /** * Field prefix. @@ -52,6 +52,7 @@ class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldPro { if ($schedulerModule->CMD == 'edit') { $taskInfo[$this->fieldPrefix . 'NotificationEmail'] = $task->getNotificationEmail(); + $taskInfo[$this->fieldPrefix . 'NotificationAll'] = $task->getNotificationAll(); } // build html for additional email field $fieldName = $this->getFullFieldName('notificationEmail'); @@ -66,6 +67,18 @@ class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldPro 'cshLabel' => $fieldId ]; + // build html for additional mail all checkbox field + $fieldName = $this->getFullFieldName('notificationAll'); + $fieldId = 'task_' . $fieldName; + $fieldHtml = '<input type="checkbox" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="1"' . ($taskInfo[$fieldName] ? ' checked="checked"' : '') . '>'; + + $additionalFields[$fieldId] = [ + 'code' => $fieldHtml, + 'label' => 'LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationAll', + 'cshKey' => '', + 'cshLabel' => $fieldId + ]; + return $additionalFields; } @@ -106,6 +119,7 @@ class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldPro throw new \InvalidArgumentException('Expected a task of type ' . SystemStatusUpdateTask::class . ', but got ' . get_class($task), 1295012802); } $task->setNotificationEmail($submittedData[$this->fieldPrefix . 'NotificationEmail']); + $task->setNotificationAll(!empty($submittedData[$this->fieldPrefix . 'NotificationAll'])); } /** diff --git a/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf b/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf index a1fc98495a19..8e677e49928b 100644 --- a/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf +++ b/typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf @@ -55,7 +55,10 @@ <source>Update Incomplete</source> </trans-unit> <trans-unit id="status_problemNotification"> - <source>One or more problems were detected with your TYPO3 installation. Please check the %sstatus report%s for more information.</source> + <source>One or more problems were detected with your TYPO3 installation. Please check the status report for more information.</source> + </trans-unit> + <trans-unit id="status_allNotification"> + <source>This report contains all System Status Notifications from your TYPO3 installation. Please check the status report for more information.</source> </trans-unit> <trans-unit id="status_typo3"> <source>TYPO3 System</source> @@ -282,6 +285,9 @@ You can increase the size to 8MB (default on unix) by adding to the httpd.conf: <trans-unit id="status_updateTaskField_notificationEmails_invalid"> <source>Empty or invalid notification email addresses.</source> </trans-unit> + <trans-unit id="status_updateTaskField_notificationAll"> + <source>Always send notification mail (not only on errors or warnings)</source> + </trans-unit> <trans-unit id="status_updateTask_email_subject"> <source>System Status Notification for site %s</source> </trans-unit> -- GitLab