/**
  * @test
  */
 public function logInUserWithNullSetsStatusToNotLoggedIn()
 {
     $user = new Tx_Oelib_Model_FrontEndUser();
     $this->subject->logInUser($user);
     $this->subject->logInUser(NULL);
     self::assertFalse($this->subject->isLoggedIn());
 }
 /**
  * Checks whether the logged-in user (if any) in the current environment has access to a CSV export.
  *
  * @return bool whether the logged-in user (if any) in the current environment has access to a CSV export.
  *
  * @throws BadMethodCallException
  */
 public function hasAccess()
 {
     if ($this->getEvent() === NULL) {
         throw new BadMethodCallException('Please set an event first.', 1389096647);
     }
     if (!Tx_Oelib_FrontEndLoginManager::getInstance()->isLoggedIn()) {
         return FALSE;
     }
     $configuration = Tx_Oelib_ConfigurationRegistry::get('plugin.tx_seminars_pi1');
     if (!$configuration->getAsBoolean('allowCsvExportOfRegistrationsInMyVipEventsView')) {
         return FALSE;
     }
     $user = Tx_Oelib_FrontEndLoginManager::getInstance()->getLoggedInUser('tx_seminars_Mapper_FrontEndUser');
     $vipsGroupUid = $configuration->getAsInteger('defaultEventVipsFeGroupID');
     return $this->getEvent()->isUserVip($user->getUid(), $vipsGroupUid);
 }
 /**
  * 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();
 }
Example #4
0
 /**
  * Initializes the list view (normal list, my events or my VIP events) and
  * creates a seminar bag or a registration bag (for the "my events" view),
  * but does not create any actual HTML output.
  *
  * @param string $whatToDisplay
  *        the flavor of list view: either an empty string (for the default
  *        list view), the value from "what_to_display", or "other_dates"
  *
  * @return tx_seminars_Bag_Abstract a seminar bag or a registration bag
  *                                  containing the seminars or registrations
  *                                  for the list view
  */
 public function initListView($whatToDisplay = '')
 {
     if (strstr($this->cObj->currentRecord, 'tt_content')) {
         $this->conf['pidList'] = $this->getConfValueString('pages');
         $this->conf['recursive'] = $this->getConfValueInteger('recursive');
     }
     $this->hideColumnsForAllViewsFromTypoScriptSetup();
     $this->hideRegisterColumnIfNecessary($whatToDisplay);
     $this->hideColumnsForAllViewsExceptMyEvents($whatToDisplay);
     $this->hideCsvExportOfRegistrationsColumnIfNecessary($whatToDisplay);
     $this->hideListRegistrationsColumnIfNecessary($whatToDisplay);
     $this->hideEditColumnIfNecessary($whatToDisplay);
     $this->hideFilesColumnIfUserCannotAccessFiles();
     $this->hideStatusColumnIfNotUsed($whatToDisplay);
     if (!isset($this->piVars['pointer'])) {
         $this->piVars['pointer'] = 0;
     }
     $this->internal['descFlag'] = $this->getListViewConfValueBoolean('descFlag');
     $this->internal['orderBy'] = $this->getListViewConfValueString('orderBy');
     if (class_exists('t3lib_utility_Math')) {
         // number of results to show in a listing
         $this->internal['results_at_a_time'] = t3lib_utility_Math::forceIntegerInRange($this->getListViewConfValueInteger('results_at_a_time'), 0, 1000, 20);
         // maximum number of 'pages' in the browse-box: 'Page 1', 'Page 2', etc.
         $this->internal['maxPages'] = t3lib_utility_Math::forceIntegerInRange($this->getListViewConfValueInteger('maxPages'), 0, 1000, 2);
     } else {
         // number of results to show in a listing
         $this->internal['results_at_a_time'] = t3lib_div::intInRange($this->getListViewConfValueInteger('results_at_a_time'), 0, 1000, 20);
         // maximum number of 'pages' in the browse-box: 'Page 1', 'Page 2', etc.
         $this->internal['maxPages'] = t3lib_div::intInRange($this->getListViewConfValueInteger('maxPages'), 0, 1000, 2);
     }
     if ($whatToDisplay === 'my_events') {
         $builder = $this->createRegistrationBagBuilder();
     } else {
         $builder = $this->createSeminarBagBuilder();
     }
     if ($whatToDisplay !== 'my_events') {
         $this->limitForAdditionalParameters($builder);
     }
     if (!in_array($whatToDisplay, array('my_entered_events', 'my_events', 'topic_list'), TRUE)) {
         $builder->limitToDateAndSingleRecords();
         $this->limitToTimeFrameSetting($builder);
     }
     $user = Tx_Oelib_FrontEndLoginManager::getInstance()->getLoggedInUser('tx_seminars_Mapper_FrontEndUser');
     switch ($whatToDisplay) {
         case 'topic_list':
             $builder->limitToTopicRecords();
             $this->hideColumnsForTheTopicListView();
             break;
         case 'my_events':
             $builder->limitToAttendee($user);
             break;
         case 'my_vip_events':
             $groupForDefaultVips = $this->getConfValueInteger('defaultEventVipsFeGroupID', 's_template_special');
             $isDefaultVip = $groupForDefaultVips != 0 && $user->hasGroupMembership($groupForDefaultVips);
             if (!$isDefaultVip) {
                 // The current user is not listed as a default VIP for all
                 // events. Change the query to show only events where the
                 // current user is manually added as a VIP.
                 $builder->limitToEventManager($this->getLoggedInFrontEndUserUid());
             }
             break;
         case 'my_entered_events':
             $builder->limitToOwner($user !== NULL ? $user->getUid() : 0);
             $builder->showHiddenRecords();
             break;
         case 'events_next_day':
             $builder->limitToEventsNextDay($this->seminar);
             break;
         case 'other_dates':
             $builder->limitToOtherDatesForTopic($this->seminar);
             break;
         default:
     }
     if ($whatToDisplay === 'other_dates' || $whatToDisplay === 'seminar_list') {
         $hideBookedOutEvents = $this->getConfValueBoolean('showOnlyEventsWithVacancies', 's_listView');
         if ($hideBookedOutEvents) {
             $builder->limitToEventsWithVacancies();
         }
     }
     $pointer = (int) $this->piVars['pointer'];
     if (class_exists('t3lib_utility_Math')) {
         $resultsAtATime = t3lib_utility_Math::forceIntegerInRange($this->internal['results_at_a_time'], 1, 1000);
     } else {
         $resultsAtATime = t3lib_div::intInRange($this->internal['results_at_a_time'], 1, 1000);
     }
     $builder->setLimit($pointer * $resultsAtATime . ',' . $resultsAtATime);
     $seminarOrRegistrationBag = $builder->build();
     $this->internal['res_count'] = $seminarOrRegistrationBag->countWithoutLimit();
     $this->previousDate = '';
     $this->previousCategory = '';
     return $seminarOrRegistrationBag;
 }
 /**
  * @test
  */
 public function hasAccessForVipFrontEndUserAndVipAccessReturnsTrue()
 {
     $this->seminarsPluginConfiguration->setAsBoolean('allowCsvExportOfRegistrationsInMyVipEventsView', TRUE);
     $user = $this->getMock('tx_seminars_Model_FrontEndUser');
     $userUid = 42;
     $user->expects(self::any())->method('getUid')->will(self::returnValue($userUid));
     /** @var $user tx_seminars_Model_FrontEndUser */
     Tx_Oelib_FrontEndLoginManager::getInstance()->logInUser($user);
     $event = $this->getMock('tx_seminars_seminar', array(), array(), '', FALSE);
     $event->expects(self::any())->method('isUserVip')->with($userUid, $this->vipsGroupUid)->will(self::returnValue(TRUE));
     /** @var $event tx_seminars_seminar */
     $this->subject->setEvent($event);
     self::assertTrue($this->subject->hasAccess());
 }
Example #6
0
 /**
  * Purges the current instance so that getInstance will create a new
  * instance.
  *
  * @return void
  */
 public static function purgeInstance()
 {
     self::$instance = NULL;
 }
Example #7
0
 /**
  * Checks whether the currently logged-in FE user (if any) belongs to the
  * FE group that is allowed to enter and edit event records in the FE.
  * This group can be set using plugin.tx_seminars.eventEditorFeGroupID.
  *
  * It also is checked whether that event record exists and the logged-in
  * FE user is the owner or is editing a new record.
  *
  * @return string locallang key of an error message, will be an empty string if access was granted
  */
 private function checkAccess()
 {
     if (!Tx_Oelib_FrontEndLoginManager::getInstance()->isLoggedIn()) {
         return 'message_notLoggedIn';
     }
     $objectUid = $this->getObjectUid();
     if ($objectUid > 0 && !tx_seminars_OldModel_Abstract::recordExists($objectUid, 'tx_seminars_seminars', TRUE)) {
         return 'message_wrongSeminarNumber';
     }
     $user = self::getLoggedInUser();
     if ($objectUid > 0) {
         /** @var tx_seminars_seminar $seminar */
         $seminar = t3lib_div::makeInstance('tx_seminars_seminar', $this->getObjectUid(), FALSE, TRUE);
         $isUserVip = $seminar->isUserVip($user->getUid(), $this->getConfValueInteger('defaultEventVipsFeGroupID'));
         $isUserOwner = $seminar->isOwnerFeUser();
         $mayManagersEditTheirEvents = $this->getConfValueBoolean('mayManagersEditTheirEvents', 's_listView');
         $hasAccess = $isUserOwner || $mayManagersEditTheirEvents && $isUserVip;
     } else {
         $eventEditorGroupUid = $this->getConfValueInteger('eventEditorFeGroupID', 's_fe_editing');
         $hasAccess = $eventEditorGroupUid !== 0 && $user->hasGroupMembership($eventEditorGroupUid);
     }
     return $hasAccess ? '' : 'message_noAccessToEventEditor';
 }
Example #8
0
 /**
  * @test
  */
 public function logoutFrontEndUserAfterLoginSwitchesLoginManagerToNotLoggedIn()
 {
     $this->subject->createFrontEndPage();
     $this->subject->createFakeFrontEnd();
     $feUserId = $this->subject->createFrontEndUser();
     $this->subject->loginFrontEndUser($feUserId);
     $this->subject->logoutFrontEndUser();
     self::assertFalse(Tx_Oelib_FrontEndLoginManager::getInstance()->isLoggedIn());
 }
 /**
  * Checks whether the logged-in FE user is the owner of this event.
  *
  * @return bool TRUE if a FE user is logged in and the user is
  *                 the owner of this event, FALSE otherwise
  */
 public function isOwnerFeUser()
 {
     $loginManager = Tx_Oelib_FrontEndLoginManager::getInstance();
     if (!$loginManager->isLoggedIn()) {
         return FALSE;
     }
     return $this->getRecordPropertyInteger('owner_feuser') === $loginManager->getLoggedInUser('tx_seminars_Mapper_FrontEndUser')->getUid();
 }
Example #10
0
 /**
  * Checks whether a FE user is logged in.
  *
  * @throws BadMethodCallException if no front end has been created
  *
  * @return bool TRUE if a FE user is logged in, FALSE otherwise
  *
  * @throws BadMethodCallException
  */
 public function isLoggedIn()
 {
     if (!$this->hasFakeFrontEnd()) {
         throw new BadMethodCallException('Please create a front end before calling isLoggedIn.', 1331490846);
     }
     return Tx_Oelib_FrontEndLoginManager::getInstance()->isLoggedIn();
 }
 /**
  * Returns the UID of the logged-in front-end user (or 0 if no user is logged in).
  *
  * @return int
  */
 protected function getLoggedInFrontEndUserUid()
 {
     $loginManager = Tx_Oelib_FrontEndLoginManager::getInstance();
     return $loginManager->isLoggedIn() ? $loginManager->getLoggedInUser('tx_seminars_Mapper_FrontEndUser')->getUid() : 0;
 }