TYPO3 CMS  TYPO3_7-6
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 
22 
27 {
33  public function appendMessage(SystemInformationToolbarItem $systemInformationToolbarItem)
34  {
35  $constraint = $this->getConstraintFromBeUserData();
36  if ($constraint === null) {
37  $constraint = $this->objectManager->get(Constraint::class);
38  }
39 
40  $timestamp = $constraint->getStartTimestamp();
41  $backendUser = $this->getBackendUserAuthentication();
42  if (isset($backendUser->uc['systeminformation'])) {
43  $systemInformationUc = json_decode($backendUser->uc['systeminformation'], true);
44  if (isset($systemInformationUc['system_BelogLog']['lastAccess'])) {
45  $timestamp = $systemInformationUc['system_BelogLog']['lastAccess'];
46  }
47  }
48 
49  $this->setStartAndEndTimeFromTimeSelector($constraint);
50  // we can't use the extbase repository here as the required TypoScript may not be parsed yet
51  $count = $this->getDatabaseConnection()->exec_SELECTcountRows('error', 'sys_log', 'tstamp >= ' . $timestamp . ' AND error IN(-1,1,2)');
52 
53  if ($count > 0) {
54  $systemInformationToolbarItem->addSystemMessage(
55  sprintf(LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog'), $count, BackendUtility::getModuleUrl('system_BelogLog')),
57  $count,
58  'system_BelogLog'
59  );
60  }
61  }
62 
68  protected function getConstraintFromBeUserData()
69  {
70  $serializedConstraint = $this->getBackendUserAuthentication()->getModuleData(ToolsController::class);
71  if (!is_string($serializedConstraint) || empty($serializedConstraint)) {
72  return null;
73  }
74  return @unserialize($serializedConstraint);
75  }
76 
80  protected function getBackendUserAuthentication()
81  {
82  return $GLOBALS['BE_USER'];
83  }
84 
88  protected function getDatabaseConnection()
89  {
90  return $GLOBALS['TYPO3_DB'];
91  }
92 }
static translate($key, $extensionName, $arguments=null)
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']