[FEATURE] Add option to "system status updates" report to send all tests 11/50811/7
authorMichael Oehlhof <typo3@oehlhof.de>
Wed, 30 Nov 2016 13:59:57 +0000 (14:59 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 4 Dec 2016 13:27:54 +0000 (14:27 +0100)
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>
typo3/sysext/core/Documentation/Changelog/master/Feature-52286-AddOptionToSystemStatusUpdatesReport-jobToSendAllTests.rst [new file with mode: 0644]
typo3/sysext/reports/Classes/Task/SystemStatusUpdateTask.php
typo3/sysext/reports/Classes/Task/SystemStatusUpdateTaskNotificationEmailField.php
typo3/sysext/reports/Resources/Private/Language/locallang_reports.xlf

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 (file)
index 0000000..11f76c5
--- /dev/null
@@ -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
index 12054c0..8cb9513 100644 (file)
@@ -36,6 +36,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
      * if necessary.
@@ -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;
@@ -119,6 +126,22 @@ class SystemStatusUpdateTask extends AbstractTask
     }
 
     /**
+     * @return bool
+     */
+    public function getNotificationAll(): bool
+    {
+        return $this->notificationAll;
+    }
+
+    /**
+     * @param bool $notificationAll
+     */
+    public function setNotificationAll(bool $notificationAll)
+    {
+        $this->notificationAll = $notificationAll;
+    }
+
+    /**
      * @return LanguageService
      */
     protected function getLanguageService()
index 82c1c66..d7aebd6 100644 (file)
@@ -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']));
     }
 
     /**
index a1fc984..8e677e4 100644 (file)
                                <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>