/**
  * 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);
 }
 /**
  * @test
  */
 public function setLoggedInUserForUserGivenAndAlreadyStoredLoggedInUserOverridesTheOldUserWithTheNewOne()
 {
     /** @var tx_oelib_Model_BackEndUser $oldBackEndUser */
     $oldBackEndUser = Tx_Oelib_MapperRegistry::get('tx_oelib_Mapper_BackEndUser')->getNewGhost();
     $this->subject->setLoggedInUser($oldBackEndUser);
     /** @var tx_oelib_Model_BackEndUser $newBackEndUser */
     $newBackEndUser = Tx_Oelib_MapperRegistry::get('tx_oelib_Mapper_BackEndUser')->getNewGhost();
     $this->subject->setLoggedInUser($newBackEndUser);
     self::assertSame($newBackEndUser, $this->subject->getLoggedInUser());
 }
 /**
  * Cleans up oelib after running a test.
  *
  * @return void
  */
 public function cleanUp()
 {
     Tx_Oelib_ConfigurationProxy::purgeInstances();
     Tx_Oelib_BackEndLoginManager::purgeInstance();
     Tx_Oelib_ConfigurationRegistry::purgeInstance();
     Tx_Oelib_FrontEndLoginManager::purgeInstance();
     tx_oelib_Geocoding_Google::purgeInstance();
     tx_oelib_headerProxyFactory::purgeInstance();
     Tx_Oelib_MapperRegistry::purgeInstance();
     Tx_Oelib_PageFinder::purgeInstance();
     Tx_Oelib_Session::purgeInstances();
     Tx_Oelib_TemplateHelper::purgeCachedConfigurations();
     Tx_Oelib_TranslatorRegistry::purgeInstance();
     /** @var Tx_Oelib_MailerFactory $mailerFactory */
     $mailerFactory = t3lib_div::makeInstance('Tx_Oelib_MailerFactory');
     $mailerFactory->cleanUp();
 }
Beispiel #5
0
 /**
  * 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());
 }
 protected function tearDown()
 {
     Tx_Oelib_BackEndLoginManager::purgeInstance();
     $this->testingFramework->cleanUp();
     $GLOBALS['BE_USER'] = $this->backEndUserBackup;
 }
Beispiel #8
0
 /**
  * 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;
 }
Beispiel #9
0
 /**
  * Purges the current instance so that getInstance will create a new
  * instance.
  *
  * @return void
  */
 public static function purgeInstance()
 {
     self::$instance = NULL;
 }