‪TYPO3CMS  10.4
SystemInformationController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
27 
34 {
39 
40  public function ‪__construct(array ‪$backendUserConfiguration = null)
41  {
42  $this->backendUserConfiguration = ‪$backendUserConfiguration ?? ‪$GLOBALS['BE_USER']->uc;
43  }
44 
51  {
52  $systemInformationToolbarItem = $event->‪getToolbarItem();
53  // we can't use the extbase repository here as the required TypoScript may not be parsed yet
54  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_log');
55  $count = $queryBuilder->count('error')
56  ->from('sys_log')
57  ->where(
58  $queryBuilder->expr()->gte(
59  'tstamp',
60  $queryBuilder->createNamedParameter($this->fetchLastAccessTimestamp(), \PDO::PARAM_INT)
61  ),
62  $queryBuilder->expr()->in(
63  'error',
64  $queryBuilder->createNamedParameter([-1, 1, 2], Connection::PARAM_INT_ARRAY)
65  )
66  )
67  ->execute()
68  ->fetchColumn(0);
69 
70  if ($count > 0) {
71  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
72  $systemInformationToolbarItem->addSystemMessage(
73  sprintf(
74  ‪LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog') ?? '',
75  $count,
76  (string)$uriBuilder->buildUriFromRoute(
77  'system_BelogLog',
78  ['tx_belog_system_beloglog' => ['constraint' => ['action' => -1]]]
79  )
80  ),
82  $count,
83  'system_BelogLog',
84  http_build_query(['tx_belog_system_beloglog' => ['constraint' => ['action' => -1]]])
85  );
86  }
87  }
88 
89  private function ‪fetchLastAccessTimestamp(): int
90  {
91  if (!isset($this->backendUserConfiguration['systeminformation'])) {
92  return 0;
93  }
94  $systemInformationUc = json_decode($this->backendUserConfiguration['systeminformation'], true);
95  if (!isset($systemInformationUc['system_BelogLog']['lastAccess'])) {
96  return 0;
97  }
98 
99  return (int)$systemInformationUc['system_BelogLog']['lastAccess'];
100  }
101 }
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:33
‪TYPO3\CMS\Belog\Controller\SystemInformationController\$backendUserConfiguration
‪array $backendUserConfiguration
Definition: SystemInformationController.php:37
‪TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent
Definition: SystemInformationToolbarCollectorEvent.php:27
‪TYPO3\CMS\Belog\Controller
Definition: BackendLogController.php:16
‪TYPO3\CMS\Belog\Controller\SystemInformationController
Definition: SystemInformationController.php:34
‪TYPO3\CMS\Belog\Controller\SystemInformationController\fetchLastAccessTimestamp
‪fetchLastAccessTimestamp()
Definition: SystemInformationController.php:88
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate(string $key, ?string $extensionName=null, array $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:67
‪TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus\STATUS_ERROR
‪const STATUS_ERROR
Definition: InformationStatus.php:50
‪TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus
Definition: InformationStatus.php:24
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:36
‪TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent\getToolbarItem
‪getToolbarItem()
Definition: SystemInformationToolbarCollectorEvent.php:37
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Belog\Controller\SystemInformationController\appendMessage
‪appendMessage(SystemInformationToolbarCollectorEvent $event)
Definition: SystemInformationController.php:49
‪TYPO3\CMS\Belog\Controller\SystemInformationController\__construct
‪__construct(array $backendUserConfiguration=null)
Definition: SystemInformationController.php:39
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46