TYPO3 CMS  TYPO3_8-7
SystemInformationController.php
Go to the documentation of this file.
1 <?php
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 
25 
30 {
36  public function appendMessage(SystemInformationToolbarItem $systemInformationToolbarItem)
37  {
38  $constraint = $this->getConstraintFromBeUserData();
39  if ($constraint === null) {
40  $constraint = $this->objectManager->get(Constraint::class);
41  }
42 
43  $timestamp = $constraint->getStartTimestamp();
44  $backendUser = $this->getBackendUserAuthentication();
45  if (isset($backendUser->uc['systeminformation'])) {
46  $systemInformationUc = json_decode($backendUser->uc['systeminformation'], true);
47  if (isset($systemInformationUc['system_BelogLog']['lastAccess'])) {
48  $timestamp = $systemInformationUc['system_BelogLog']['lastAccess'];
49  }
50  }
51 
52  $this->setStartAndEndTimeFromTimeSelector($constraint);
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('tstamp', $queryBuilder->createNamedParameter($timestamp, \PDO::PARAM_INT)),
59  $queryBuilder->expr()->in(
60  'error',
61  $queryBuilder->createNamedParameter([-1, 1, 2], Connection::PARAM_INT_ARRAY)
62  )
63  )
64  ->execute()
65  ->fetchColumn(0);
66 
67  if ($count > 0) {
68  $systemInformationToolbarItem->addSystemMessage(
69  sprintf(LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog'), $count, BackendUtility::getModuleUrl('system_BelogLog')),
71  $count,
72  'system_BelogLog'
73  );
74  }
75  }
76 
82  protected function getConstraintFromBeUserData()
83  {
84  $serializedConstraint = $this->getBackendUserAuthentication()->getModuleData(ToolsController::class);
85  if (!is_string($serializedConstraint) || empty($serializedConstraint)) {
86  return null;
87  }
88  return @unserialize($serializedConstraint);
89  }
90 
94  protected function getBackendUserAuthentication()
95  {
96  return $GLOBALS['BE_USER'];
97  }
98 }
static translate($key, $extensionName=null, $arguments=null)
static makeInstance($className,... $constructorArguments)
appendMessage(SystemInformationToolbarItem $systemInformationToolbarItem)
setStartAndEndTimeFromTimeSelector(\TYPO3\CMS\Belog\Domain\Model\Constraint $constraint)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']