TYPO3  7.6
SystemInformationController.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Belog\Controller;
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 
21 
26 {
32  public function appendMessage()
33  {
34  $constraint = $this->getConstraintFromBeUserData();
35  if ($constraint === null) {
36  $constraint = $this->objectManager->get(Constraint::class);
37  }
38 
39  $timestamp = $constraint->getStartTimestamp();
40  $backendUser = $this->getBackendUserAuthentication();
41  if (isset($backendUser->uc['systeminformation'])) {
42  $systemInformationUc = json_decode($backendUser->uc['systeminformation'], true);
43  if (isset($systemInformationUc['system_BelogLog']['lastAccess'])) {
44  $timestamp = $systemInformationUc['system_BelogLog']['lastAccess'];
45  }
46  }
47 
48  $this->setStartAndEndTimeFromTimeSelector($constraint);
49  // we can't use the extbase repository here as the required TypoScript may not be parsed yet
50  $count = $this->getDatabaseConnection()->exec_SELECTcountRows('error', 'sys_log', 'tstamp >= ' . $timestamp . ' AND error IN(-1,1,2)');
51 
52  if ($count > 0) {
53  return array(
54  array(
55  'module' => 'system_BelogLog',
56  'count' => $count,
58  'text' => sprintf(LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog'), $count, BackendUtility::getModuleUrl('system_BelogLog'))
59  )
60  );
61  }
62  return null;
63  }
64 
70  protected function getConstraintFromBeUserData()
71  {
72  $serializedConstraint = $this->getBackendUserAuthentication()->getModuleData(ToolsController::class);
73  if (!is_string($serializedConstraint) || empty($serializedConstraint)) {
74  return null;
75  }
76  return @unserialize($serializedConstraint);
77  }
78 
82  protected function getBackendUserAuthentication()
83  {
84  return $GLOBALS['BE_USER'];
85  }
86 
90  protected function getDatabaseConnection()
91  {
92  return $GLOBALS['TYPO3_DB'];
93  }
94 }