Esempio n. 1
0
 /**
  * User's events list controller
  * 
  * @param array $params 
  */
 public function eventUserLists($params)
 {
     if (empty($params['eventId']) || empty($params['list'])) {
         throw new Redirect404Exception();
     }
     $event = $this->eventService->findEvent((int) $params['eventId']);
     if ($event === null) {
         throw new Redirect404Exception();
     }
     $listArray = array_flip($this->eventService->getUserListsArray());
     if (!array_key_exists($params['list'], $listArray)) {
         throw new Redirect404Exception();
     }
     if (!OW::getUser()->isAuthorized('event', 'view_event') && $event->getUserId() != OW::getUser()->getId() && !OW::getUser()->isAuthorized('event')) {
         $this->assign('authErrorText', OW::getLanguage()->text('event', 'event_view_permission_error_message'));
         return;
     }
     // guest gan't view private events
     if ((int) $event->getWhoCanView() === EVENT_BOL_EventService::CAN_VIEW_INVITATION_ONLY && !OW::getUser()->isAuthenticated()) {
         $this->redirect(OW::getRouter()->urlForRoute('event.private_event', array('eventId' => $event->getId())));
     }
     $eventInvite = $this->eventService->findEventInvite($event->getId(), OW::getUser()->getId());
     $eventUser = $this->eventService->findEventUser($event->getId(), OW::getUser()->getId());
     // check if user can view event
     if ((int) $event->getWhoCanView() === EVENT_BOL_EventService::CAN_VIEW_INVITATION_ONLY && $eventUser === null && $eventInvite === null && !OW::getUser()->isAuthorized('event')) {
         $this->redirect(OW::getRouter()->urlForRoute('event.private_event', array('eventId' => $event->getId())));
     }
     $language = OW::getLanguage();
     $configs = $this->eventService->getConfigs();
     $page = empty($_GET['page']) || (int) $_GET['page'] < 0 ? 1 : (int) $_GET['page'];
     $status = $listArray[$params['list']];
     $eventUsers = $this->eventService->findEventUsers($event->getId(), $status, $page);
     $eventUsersCount = $this->eventService->findEventUsersCount($event->getId(), $status);
     $userIdList = array();
     /* @var $eventUser EVENT_BOL_EventUser */
     foreach ($eventUsers as $eventUser) {
         $userIdList[] = $eventUser->getUserId();
     }
     $userDtoList = BOL_UserService::getInstance()->findUserListByIdList($userIdList);
     $this->addComponent('users', new EVENT_CMP_EventUsersList($userDtoList, $eventUsersCount, $configs[EVENT_BOL_EventService::CONF_EVENT_USERS_COUNT_ON_PAGE], true));
     $this->setPageHeading($language->text('event', 'user_list_page_heading_' . $status, array('eventTitle' => $event->getTitle())));
     $this->setPageTitle($language->text('event', 'user_list_page_heading_' . $status, array('eventTitle' => $event->getTitle())));
     OW::getDocument()->setDescription($language->text('event', 'user_list_page_desc_' . $status, array('eventTitle' => $event->getTitle())));
     OW::getNavigation()->activateMenuItem(OW_Navigation::MAIN, 'event', 'main_menu_item');
     $this->assign("eventId", $event->id);
 }