‪TYPO3CMS  9.5
SystemInformationController.php
Go to the documentation of this file.
1 <?php
2 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 
25 
31 {
36 
37  public function ‪__construct(array ‪$backendUserConfiguration = null)
38  {
39  $this->backendUserConfiguration = ‪$backendUserConfiguration ?? ‪$GLOBALS['BE_USER']->uc;
40  }
41 
47  public function ‪appendMessage(‪SystemInformationToolbarItem $systemInformationToolbarItem)
48  {
49  // we can't use the extbase repository here as the required TypoScript may not be parsed yet
50  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_log');
51  $count = $queryBuilder->count('error')
52  ->from('sys_log')
53  ->where(
54  $queryBuilder->expr()->gte(
55  'tstamp',
56  $queryBuilder->createNamedParameter($this->fetchLastAccessTimestamp(), \PDO::PARAM_INT)
57  ),
58  $queryBuilder->expr()->in(
59  'error',
60  $queryBuilder->createNamedParameter([-1, 1, 2], Connection::PARAM_INT_ARRAY)
61  )
62  )
63  ->execute()
64  ->fetchColumn(0);
65 
66  if ($count > 0) {
67  $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
68  $systemInformationToolbarItem->‪addSystemMessage(
69  sprintf(
70  ‪LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog'),
71  $count,
72  (string)$uriBuilder->buildUriFromRoute(
73  'system_BelogLog',
74  ['tx_belog_system_beloglog' => ['constraint' => ['action' => -1]]]
75  )
76  ),
78  $count,
79  'system_BelogLog',
80  http_build_query(['tx_belog_system_beloglog' => ['constraint' => ['action' => -1]]])
81  );
82  }
83  }
84 
85  protected function ‪fetchLastAccessTimestamp(): int
86  {
87  if (!isset($this->backendUserConfiguration['systeminformation'])) {
88  return 0;
89  }
90  $systemInformationUc = json_decode($this->backendUserConfiguration['systeminformation'], true);
91  if (!isset($systemInformationUc['system_BelogLog']['lastAccess'])) {
92  return 0;
93  }
94 
95  return (int)$systemInformationUc['system_BelogLog']['lastAccess'];
96  }
97 }
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:29
‪TYPO3\CMS\Belog\Controller\SystemInformationController\$backendUserConfiguration
‪array $backendUserConfiguration
Definition: SystemInformationController.php:34
‪TYPO3\CMS\Belog\Controller
Definition: BackendLogController.php:2
‪TYPO3\CMS\Belog\Controller\SystemInformationController
Definition: SystemInformationController.php:31
‪TYPO3\CMS\Belog\Controller\SystemInformationController\fetchLastAccessTimestamp
‪fetchLastAccessTimestamp()
Definition: SystemInformationController.php:84
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate($key, $extensionName=null, $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:63
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:35
‪TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem
Definition: SystemInformationToolbarItem.php:37
‪TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus\STATUS_ERROR
‪const STATUS_ERROR
Definition: InformationStatus.php:49
‪TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus
Definition: InformationStatus.php:23
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:31
‪TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem\addSystemMessage
‪addSystemMessage($text, $status=InformationStatus::STATUS_OK, $count=0, $module='', $params='')
Definition: SystemInformationToolbarItem.php:91
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Belog\Controller\SystemInformationController\__construct
‪__construct(array $backendUserConfiguration=null)
Definition: SystemInformationController.php:36
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Belog\Controller\SystemInformationController\appendMessage
‪appendMessage(SystemInformationToolbarItem $systemInformationToolbarItem)
Definition: SystemInformationController.php:46