Skip to content
Snippets Groups Projects
Commit edbaad16 authored by Michael Oehlhof's avatar Michael Oehlhof Committed by Anja Leichsenring
Browse files

[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: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarAlexander Stehlik <alexander.stehlik@gmail.com>
Tested-by: default avatarAlexander Stehlik <alexander.stehlik@gmail.com>
Reviewed-by: default avatarManuel Glauser <mail@manuelglauser.ch>
Tested-by: default avatarManuel Glauser <mail@manuelglauser.ch>
Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Tested-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent 6fcdf1b8
No related merge requests found
.. 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
......@@ -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
*/
......
......@@ -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']));
}
/**
......
......@@ -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>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment