[CLEANUP] Code cleanup in ext:reports
[Packages/TYPO3.CMS.git] / typo3 / sysext / reports / Classes / Report / Status / WarningMessagePostProcessor.php
1 <?php
2 namespace TYPO3\CMS\Reports\Report\Status;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
17 use TYPO3\CMS\Core\Registry;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Lang\LanguageService;
20 use TYPO3\CMS\Reports\Status;
21
22 /**
23 * Post processes the warning messages found in about modules.
24 */
25 class WarningMessagePostProcessor
26 {
27 /**
28 * Tries to get the highest severity of the system's status first, if
29 * something is found it is assumed that the status update task is set up
30 * properly or the status report has been checked manually and we take over
31 * control over the system warning messages.
32 *
33 * @param array $warningMessages An array of messages related to already found issues.
34 * @return void
35 */
36 public function displayWarningMessages_postProcess(array &$warningMessages)
37 {
38 if (!$this->getBackendUser()->isAdmin()) {
39 return;
40 }
41 // Get highest severity
42 /** @var Registry $registry */
43 $registry = GeneralUtility::makeInstance(Registry::class);
44 $highestSeverity = $registry->get('tx_reports', 'status.highestSeverity', null);
45 if (!is_null($highestSeverity)) {
46 if ($highestSeverity > Status::OK) {
47 // Display a message that there's something wrong and that
48 // the admin should take a look at the detailed status report
49 $this->getLanguageService()->includeLLFile('EXT:reports/Resources/Private/Language/locallang_reports.xlf');
50 $reportModuleIdentifier = 'system_ReportsTxreportsm1';
51 $reportModuleParameters = array(
52 'tx_reports_system_reportstxreportsm1[extension]=tx_reports',
53 'tx_reports_system_reportstxreportsm1[report]=status',
54 'tx_reports_system_reportstxreportsm1[action]=detail',
55 'tx_reports_system_reportstxreportsm1[controller]=Report',
56 );
57 $warningMessages['tx_reports_status_notification'] = sprintf(
58 $this->getLanguageService()->getLL('status_problemNotification'),
59 '<a href="javascript:top.goToModule(' . GeneralUtility::quoteJSvalue($reportModuleIdentifier) . ', 1, ' . GeneralUtility::quoteJSvalue('&' . implode('&', $reportModuleParameters)) . ');">',
60 '</a>'
61 );
62 }
63 }
64 }
65
66 /**
67 * @return LanguageService
68 */
69 protected function getLanguageService()
70 {
71 return $GLOBALS['LANG'];
72 }
73
74 /**
75 * @return BackendUserAuthentication
76 */
77 protected function getBackendUser()
78 {
79 return $GLOBALS['BE_USER'];
80 }
81 }