/** * Determines the id and evaluates any preview settings * Basically this function is about determining whether a backend user is logged in, * if he has read access to the page and if he's previewing the page. * That all determines which id to show and how to initialize the id. * * @return void */ public function determineId() { // Call pre processing function for id determination if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PreProcessing'])) { foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PreProcessing'] as $functionReference) { $parameters = array('parentObject' => $this); GeneralUtility::callUserFunction($functionReference, $parameters, $this); } } // Getting ARG-v values if some $this->setIDfromArgV(); // If there is a Backend login we are going to check for any preview settings: $this->getTimeTracker()->push('beUserLogin', ''); $originalFrontendUser = null; $backendUser = $this->getBackendUser(); if ($this->beUserLogin || $this->doWorkspacePreview()) { // Backend user preview features: if ($this->beUserLogin && $backendUser->adminPanel instanceof AdminPanelView) { $this->fePreview = (bool) $backendUser->adminPanel->extGetFeAdminValue('preview'); // If admin panel preview is enabled... if ($this->fePreview) { if ($this->fe_user->user) { $originalFrontendUser = $this->fe_user->user; } $this->showHiddenPage = (bool) $backendUser->adminPanel->extGetFeAdminValue('preview', 'showHiddenPages'); $this->showHiddenRecords = (bool) $backendUser->adminPanel->extGetFeAdminValue('preview', 'showHiddenRecords'); // Simulate date $simTime = $backendUser->adminPanel->extGetFeAdminValue('preview', 'simulateDate'); if ($simTime) { $GLOBALS['SIM_EXEC_TIME'] = $simTime; $GLOBALS['SIM_ACCESS_TIME'] = $simTime - $simTime % 60; } // simulate user $simUserGroup = $backendUser->adminPanel->extGetFeAdminValue('preview', 'simulateUserGroup'); $this->simUserGroup = $simUserGroup; if ($simUserGroup) { if ($this->fe_user->user) { $this->fe_user->user[$this->fe_user->usergroup_column] = $simUserGroup; } else { $this->fe_user->user = array($this->fe_user->usergroup_column => $simUserGroup); } } if (!$simUserGroup && !$simTime && !$this->showHiddenPage && !$this->showHiddenRecords) { $this->fePreview = 0; } } } if ($this->id) { if ($this->determineIdIsHiddenPage()) { // The preview flag is set only if the current page turns out to actually be hidden! $this->fePreview = 1; $this->showHiddenPage = true; } // For Live workspace: Check root line for proper connection to tree root (done because of possible preview of page / branch versions) if (!$this->fePreview && $this->whichWorkspace() === 0) { // Initialize the page-select functions to check rootline: $temp_sys_page = GeneralUtility::makeInstance(PageRepository::class); $temp_sys_page->init($this->showHiddenPage); // If root line contained NO records and ->error_getRootLine_failPid tells us that it was because of a pid=-1 (indicating a "version" record)...: if (empty($temp_sys_page->getRootLine($this->id, $this->MP)) && $temp_sys_page->error_getRootLine_failPid == -1) { // Setting versioningPreview flag and try again: $temp_sys_page->versioningPreview = true; if (!empty($temp_sys_page->getRootLine($this->id, $this->MP))) { // Finally, we got a root line (meaning that it WAS due to versioning preview of a page somewhere) and we set the fePreview flag which in itself will allow sys_page class to display previews of versionized records. $this->fePreview = 1; } } } } // The preview flag will be set if a backend user is in an offline workspace if (($backendUser->user['workspace_preview'] || GeneralUtility::_GP('ADMCMD_view') || $this->doWorkspacePreview()) && ($this->whichWorkspace() === -1 || $this->whichWorkspace() > 0) && !GeneralUtility::_GP('ADMCMD_noBeUser')) { // Will show special preview message. $this->fePreview = 2; } // If the front-end is showing a preview, caching MUST be disabled. if ($this->fePreview) { $this->disableCache(); } } $this->getTimeTracker()->pull(); // Now, get the id, validate access etc: $this->fetch_the_id(); // Check if backend user has read access to this page. If not, recalculate the id. if ($this->beUserLogin && $this->fePreview) { if (!$backendUser->doesUserHaveAccess($this->page, 1)) { // Resetting $this->clear_preview(); $this->fe_user->user = $originalFrontendUser; // Fetching the id again, now with the preview settings reset. $this->fetch_the_id(); } } // Checks if user logins are blocked for a certain branch and if so, will unset user login and re-fetch ID. $this->loginAllowedInBranch = $this->checkIfLoginAllowedInBranch(); // Logins are not allowed: if (!$this->loginAllowedInBranch) { // Only if there is a login will we run this... if ($this->isUserOrGroupSet()) { if ($this->loginAllowedInBranch_mode == 'all') { // Clear out user and group: $this->fe_user->hideActiveLogin(); $this->gr_list = '0,-1'; } else { $this->gr_list = '0,-2'; } // Fetching the id again, now with the preview settings reset. $this->fetch_the_id(); } } // Final cleaning. // Make sure it's an integer $this->id = $this->contentPid = (int) $this->id; // Make sure it's an integer $this->type = (int) $this->type; // Call post processing function for id determination: if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'])) { $_params = array('pObj' => &$this); foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['determineId-PostProc'] as $_funcRef) { GeneralUtility::callUserFunction($_funcRef, $_params, $this); } } }