/** * Checks whether the currently logged-in BE-User is allowed to access the given table and page. * * @param string $tableName * the name of the table to check the read access for, must not be empty * * @param int $pageUid the page to check the access for, must be >= 0 * * @return bool TRUE if the user has access to the given table and page, * FALSE otherwise, will also return FALSE if no BE user is logged in */ protected function canAccessTableAndPage($tableName, $pageUid) { if (!Tx_Oelib_BackEndLoginManager::getInstance()->isLoggedIn()) { return FALSE; } return $this->hasReadAccessToTable($tableName) && $this->hasReadAccessToPage($pageUid); }
/** * Checks whether the logged-in user (if any) in the current environment has access to a CSV export. * * If a page UID has been set, this method also checks that the user has read access to that page. * * @return bool whether the logged-in user (if any) in the current environment has access to a CSV export. */ public function hasAccess() { if (!Tx_Oelib_BackEndLoginManager::getInstance()->isLoggedIn()) { return FALSE; } $hasAccessToPage = $this->getPageUid() !== 0 ? $this->hasReadAccessToPage($this->getPageUid()) : TRUE; return $hasAccessToPage && $this->hasReadAccessToTable(self::TABLE_NAME_EVENTS) && $this->hasReadAccessToTable(self::TABLE_NAME_REGISTRATIONS); }
/** * Reads a record from the database by UID (from this mapper's table). Also * hidden records will be retrieved. * * @throws tx_oelib_Exception_NotFound if there is no record in the DB * with the UID $uid * * @param int $uid * the UID of the record to retrieve, must be > 0 * * @return array the record from the database, will not be empty */ protected function retrieveRecordByUid($uid) { $authentication = $this->getBackEndUserAuthentication(); if (Tx_Oelib_BackEndLoginManager::getInstance()->isLoggedIn() && (int) $authentication->user['uid'] === $uid) { $data = $authentication->user; } else { $data = parent::retrieveRecordByUid($uid); } return $data; }
/** * @test */ public function initializeBackEndWithBackEndUserLanguageGermanSetsLanguageGerman() { $backEndUser = new Tx_Oelib_Model_BackEndUser(); $backEndUser->setDefaultLanguage('de'); Tx_Oelib_BackEndLoginManager::getInstance()->setLoggedInUser($backEndUser); self::assertSame('de', Tx_Oelib_TranslatorRegistry::get('oelib')->getLanguageKey()); }
/** * @test */ public function getInstanceAfterPurgeInstanceReturnsNewInstance() { Tx_Oelib_BackEndLoginManager::purgeInstance(); self::assertNotSame($this->subject, Tx_Oelib_BackEndLoginManager::getInstance()); }
/** * Initializes the TranslatorRegistry for the back end. * * @return void */ private function initializeBackEnd() { $backEndUser = Tx_Oelib_BackEndLoginManager::getInstance()->getLoggedInUser('tx_oelib_Mapper_BackEndUser'); $this->languageKey = $backEndUser->getLanguage(); $this->renderCharset = $this->getLanguageService()->charSet; $this->charsetConversion = $this->getLanguageService()->csConvObj; }