[TASK] Store last access of modules linked in the System Information menu
[Packages/TYPO3.CMS.git] / typo3 / sysext / belog / Classes / Controller / SystemInformationController.php
index 03f21f4..bb10785 100644 (file)
@@ -14,7 +14,10 @@ namespace TYPO3\CMS\Belog\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
+use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Belog\Domain\Model\Constraint;
 use TYPO3\CMS\Belog\Domain\Model\Constraint;
+use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
 
 /**
  * Count newest exceptions for the system information menu
 
 /**
  * Count newest exceptions for the system information menu
@@ -24,8 +27,7 @@ class SystemInformationController extends AbstractController {
        /**
         * Modifies the SystemInformation array
         *
        /**
         * Modifies the SystemInformation array
         *
-        * @param array $systemMessages Array of system messages
-        * @return
+        * @return NULL|array
         */
        public function appendMessage() {
                $constraint = $this->getConstraintFromBeUserData();
         */
        public function appendMessage() {
                $constraint = $this->getConstraintFromBeUserData();
@@ -33,16 +35,26 @@ class SystemInformationController extends AbstractController {
                        $constraint = $this->objectManager->get(Constraint::class);
                }
 
                        $constraint = $this->objectManager->get(Constraint::class);
                }
 
+               $timestamp = $constraint->getStartTimestamp();
+               $backendUser = $this->getBackendUserAuthentication();
+               if (isset($backendUser->uc['systeminformation'])) {
+                       $systemInformationUc = json_decode($backendUser->uc['systeminformation'], TRUE);
+                       if (isset($systemInformationUc['system_BelogLog']['lastAccess'])) {
+                               $timestamp = $systemInformationUc['system_BelogLog']['lastAccess'];
+                       }
+               }
+
                $this->setStartAndEndTimeFromTimeSelector($constraint);
                // we can't use the extbase repository here as the required TypoScript may not be parsed yet
                $this->setStartAndEndTimeFromTimeSelector($constraint);
                // we can't use the extbase repository here as the required TypoScript may not be parsed yet
-               $count = $this->getDatabaseConnection()->exec_SELECTcountRows('error', 'sys_log', 'tstamp >= ' . $constraint->getStartTimestamp() . ' AND tstamp <= ' . $constraint->getEndTimestamp() . ' AND error IN(-1,1,2,3)');
+               $count = $this->getDatabaseConnection()->exec_SELECTcountRows('error', 'sys_log', 'tstamp >= ' . $timestamp . ' AND error IN(-1,1,2)');
 
                if ($count > 0) {
                        return array(
                                array(
 
                if ($count > 0) {
                        return array(
                                array(
+                                       'module' => 'system_BelogLog',
                                        'count' => $count,
                                        'count' => $count,
-                                       'status' => \TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus::STATUS_ERROR,
-                                       'text' => sprintf(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog'), $count)
+                                       'status' => InformationStatus::STATUS_ERROR,
+                                       'text' => sprintf(LocalizationUtility::translate('systemmessage.errorsInPeriod', 'belog'), $count, BackendUtility::getModuleUrl('system_BelogLog'))
                                )
                        );
                }
                                )
                        );
                }
@@ -55,13 +67,20 @@ class SystemInformationController extends AbstractController {
         * @return \TYPO3\CMS\Belog\Domain\Model\Constraint|NULL
         */
        protected function getConstraintFromBeUserData() {
         * @return \TYPO3\CMS\Belog\Domain\Model\Constraint|NULL
         */
        protected function getConstraintFromBeUserData() {
-               $serializedConstraint = $GLOBALS['BE_USER']->getModuleData(ToolsController::class);
+               $serializedConstraint = $this->getBackendUserAuthentication()->getModuleData(ToolsController::class);
                if (!is_string($serializedConstraint) || empty($serializedConstraint)) {
                        return NULL;
                }
                return @unserialize($serializedConstraint);
        }
 
                if (!is_string($serializedConstraint) || empty($serializedConstraint)) {
                        return NULL;
                }
                return @unserialize($serializedConstraint);
        }
 
+       /**
+        * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
+        */
+       protected function getBackendUserAuthentication() {
+               return $GLOBALS['BE_USER'];
+       }
+
        /**
         * @return \TYPO3\CMS\Core\Database\DatabaseConnection
         */
        /**
         * @return \TYPO3\CMS\Core\Database\DatabaseConnection
         */