TYPO3 CMS  TYPO3_6-2
SystemStatusUpdateTask.php
Go to the documentation of this file.
1 <?php
3 
22 
29  protected $notificationEmail = NULL;
30 
38  public function execute() {
42  $statusReport = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Report\\Status\\Status');
43  $systemStatus = $statusReport->getSystemStatus();
44  $highestSeverity = $statusReport->getHighestSeverity($systemStatus);
45  $registry->set('tx_reports', 'status.highestSeverity', $highestSeverity);
46  if ($highestSeverity > \TYPO3\CMS\Reports\Status::OK) {
47  $this->sendNotificationEmail($systemStatus);
48  }
49  return TRUE;
50  }
51 
57  public function getNotificationEmail() {
59  }
60 
68  $this->notificationEmail = $notificationEmail;
69  }
70 
77  protected function sendNotificationEmail(array $systemStatus) {
78  $systemIssues = array();
79  foreach ($systemStatus as $statusProvider) {
80  foreach ($statusProvider as $status) {
81  if ($status->getSeverity() > \TYPO3\CMS\Reports\Status::OK) {
82  $systemIssues[] = (string) $status;
83  }
84  }
85  }
86  $notificationEmails = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $this->notificationEmail, TRUE);
87  $sendEmailsTo = array();
88  foreach ($notificationEmails as $notificationEmail) {
89  $sendEmailsTo[] = $notificationEmail;
90  }
91  $subject = sprintf($GLOBALS['LANG']->getLL('status_updateTask_email_subject'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
92  $message = sprintf($GLOBALS['LANG']->getLL('status_problemNotification'), '', '');
93  $message .= CRLF . CRLF;
94  $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_site') . ': ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
95  $message .= CRLF . CRLF;
96  $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_issues') . ': ' . CRLF;
97  $message .= implode(CRLF, $systemIssues);
98  $message .= CRLF . CRLF;
101  $mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
102  $mail->setFrom($from);
103  $mail->setTo($sendEmailsTo);
104  $mail->setSubject($subject);
105  $mail->setBody($message);
106  $mail->send();
107  }
108 
109 }
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
$registry
Definition: ext_tables.php:46
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]