Ejemplo n.º 1
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $limit = MBOL_ConsoleService::SECTION_ITEMS_LIMIT;
     $this->addComponent('itemsCmp', new BASE_MCMP_ConsoleInvitations($limit));
     $this->assign('loadMore', $this->service->findInvitationCount(OW::getUser()->getId()) > $limit);
     $params = array('cmdUrl' => OW::getRouter()->urlFor('BASE_MCTRL_Invitations', 'command'));
     $script = 'var invitationsConsole = new OWM_InvitationsConsole(' . json_encode($params) . ');';
     OW::getDocument()->addOnloadScript($script);
 }
Ejemplo n.º 2
0
 /**
  * Returns class instance
  *
  * @return BOL_InvitationService
  */
 public static function getInstance()
 {
     if (!isset(self::$classInstance)) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Ejemplo n.º 3
0
 public function countNewInvitations(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     if ($params['page'] == self::CONSOLE_NOTIFICATIONS_PAGE_KEY) {
         $service = BOL_InvitationService::getInstance();
         $event->add(array(self::CONSOLE_INVITATIONS_SECTION_KEY => $service->findInvitationCount(OW::getUser()->getId(), false)));
     }
 }
Ejemplo n.º 4
0
 /**
  * Constructor.
  */
 public function __construct($timestamp)
 {
     parent::__construct();
     $service = BOL_InvitationService::getInstance();
     $userId = OW::getUser()->getId();
     $invitations = $service->findNewInvitationList($userId, $timestamp);
     $items = BASE_MCMP_ConsoleInvitations::prepareData($invitations);
     $this->assign('items', $items);
     // Mark as viewed
     $service->markViewedByUserId($userId);
     $tpl = OW::getPluginManager()->getPlugin('base')->getMobileCmpViewDir() . 'console_invitations.html';
     $this->setTemplate($tpl);
 }
Ejemplo n.º 5
0
 /**
  * Constructor.
  */
 public function __construct($limit, $exclude = null)
 {
     parent::__construct();
     $service = BOL_InvitationService::getInstance();
     $userId = OW::getUser()->getId();
     $invitations = $service->findInvitationList($userId, time(), $exclude, $limit);
     $items = $this->prepareData($invitations);
     $this->assign('items', $items);
     $invitationIdList = array();
     foreach ($items as $id => $item) {
         $invitationIdList[] = $id;
     }
     // Mark as viewed
     $service->markViewedByUserId($userId);
     $exclude = is_array($exclude) ? array_merge($exclude, $invitationIdList) : $invitationIdList;
     $loadMore = (bool) $service->findInvitationCount($userId, null, $exclude);
     if (!$loadMore) {
         $script = "OWM.trigger('mobile.console_hide_invitations_load_more', {});";
         OW::getDocument()->addOnloadScript($script);
     }
 }
Ejemplo n.º 6
0
 public function onCommand(OW_Event $event)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return;
     }
     $params = $event->getParams();
     if (!in_array($params['command'], array('events.accept', 'events.ignore'))) {
         return;
     }
     $eventId = $params['data'];
     $eventDto = EVENT_BOL_EventService::getInstance()->findEvent($eventId);
     $userId = OW::getUser()->getId();
     $eventService = EVENT_BOL_EventService::getInstance();
     if (empty($eventDto)) {
         BOL_InvitationService::getInstance()->deleteInvitation(EVENT_CLASS_InvitationHandler::INVITATION_JOIN, $eventId, $userId);
         return;
     }
     $lang = OW::getLanguage();
     $result = array('result' => false);
     if ($params['command'] == 'events.accept') {
         $exit = false;
         $attendedStatus = 1;
         if ($eventService->canUserView($eventId, $userId)) {
             $eventDto = $eventService->findEvent($eventId);
             if ($eventDto->getEndTimeStamp() < time()) {
                 $eventService->deleteUserEventInvites((int) $eventId, $userId);
                 $result['msg'] = $lang->text('event', 'user_status_updated');
                 $event->setData($result);
                 return;
             }
             $eventUser = $eventService->findEventUser($eventId, $userId);
             if ($eventUser !== null && (int) $eventUser->getStatus() === (int) $attendedStatus) {
                 $result['msg'] = $lang->text('event', 'user_status_not_changed_error');
                 $exit = true;
             }
             if ($eventDto->getUserId() == OW::getUser()->getId() && (int) $attendedStatus == EVENT_BOL_EventService::USER_STATUS_NO) {
                 $result['msg'] = $lang->text('event', 'user_status_author_cant_leave_error');
                 $exit = true;
             }
             if (!$exit) {
                 $eventUserDto = EVENT_BOL_EventService::getInstance()->addEventUser($userId, $eventId, $attendedStatus);
                 if (!empty($eventUserDto)) {
                     $e = new OW_Event(EVENT_BOL_EventService::EVENT_ON_CHANGE_USER_STATUS, array('eventId' => $eventDto->id, 'userId' => $eventUserDto->userId));
                     OW::getEventManager()->trigger($e);
                     $result = array('result' => true, 'msg' => $lang->text('event', 'user_status_updated'));
                     BOL_InvitationService::getInstance()->deleteInvitation(EVENT_CLASS_InvitationHandler::INVITATION_JOIN, $eventId, $userId);
                 } else {
                     $result['msg'] = $lang->text('event', 'user_status_update_error');
                 }
             }
         } else {
             $result['msg'] = $lang->text('event', 'user_status_update_error');
         }
     } else {
         if ($params['command'] == 'events.ignore') {
             $eventService->deleteUserEventInvites((int) $eventId, $userId);
             $result = array('result' => true, 'msg' => $lang->text('event', 'user_status_updated'));
             BOL_InvitationService::getInstance()->deleteInvitation(EVENT_CLASS_InvitationHandler::INVITATION_JOIN, $eventId, $userId);
         }
     }
     $event->setData($result);
 }
Ejemplo n.º 7
0
 /**
  * Deletes event.
  *
  * @param integer $eventId
  */
 public function deleteEvent($eventId)
 {
     $eventDto = $this->eventDao->findById((int) $eventId);
     if ($eventDto === null) {
         return;
     }
     $e = new OW_Event(self::EVENT_ON_DELETE_EVENT, array('eventId' => (int) $eventId));
     OW::getEventManager()->trigger($e);
     if (!empty($eventDto->image)) {
         $storage = OW::getStorage();
         $storage->removeFile($this->generateImagePath($eventDto->image));
         $storage->removeFile($this->generateImagePath($eventDto->image, false));
     }
     $this->eventUserDao->deleteByEventId($eventDto->getId());
     $this->eventDao->deleteById($eventDto->getId());
     $this->eventInviteDao->deleteByEventId($eventDto->getId());
     BOL_InvitationService::getInstance()->deleteInvitationByEntity('event', $eventId);
     BOL_InvitationService::getInstance()->deleteInvitationByEntity('event-invitation', $eventId);
 }
Ejemplo n.º 8
0
 public function clearEventInvitations($eventId)
 {
     BOL_InvitationService::getInstance()->deleteInvitationByEntity('event', (int) $eventId);
     BOL_InvitationService::getInstance()->deleteInvitationByEntity('event-invitation', (int) $eventId);
     BOL_InvitationService::getInstance()->deleteInvitationByEntity(EVENT_CLASS_InvitationHandler::INVITATION_JOIN, (int) $eventId);
     $this->eventInviteDao->deleteByEventId($eventId);
 }
Ejemplo n.º 9
0
 public function pluginUninstall(OW_Event $e)
 {
     $params = $e->getParams();
     $pluginKey = $params['pluginKey'];
     $this->service->deleteInvitationByPluginKey($pluginKey);
 }
Ejemplo n.º 10
0
 public function onCommand(OW_Event $event)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return 'auth faild';
     }
     $params = $event->getParams();
     if (!in_array($params['command'], array('events.accept', 'events.ignore'))) {
         return 'wrong command';
     }
     $eventId = $params['data'];
     $eventDto = EVENT_BOL_EventService::getInstance()->findEvent($eventId);
     $userId = OW::getUser()->getId();
     $jsResponse = UTIL_JsGenerator::newInstance();
     $eventService = EVENT_BOL_EventService::getInstance();
     if (empty($eventDto)) {
         BOL_InvitationService::getInstance()->deleteInvitation(self::INVITATION_JOIN, $eventId, $userId);
         return 'empty Event Id';
     }
     if ($params['command'] == 'events.accept') {
         $feedback = array('messageType' => 'error');
         $exit = false;
         $attendedStatus = 1;
         if ($eventService->canUserView($eventId, $userId)) {
             $eventDto = $eventService->findEvent($eventId);
             if ($eventDto->getEndTimeStamp() < time()) {
                 $eventService->deleteUserEventInvites((int) $eventId, $userId);
                 $jsResponse->callFunction(array('OW', 'error'), array(OW::getLanguage()->text('event', 'user_status_updated')));
                 $event->setData($jsResponse);
                 return;
             }
             $eventUser = $eventService->findEventUser($eventId, $userId);
             if ($eventUser !== null && (int) $eventUser->getStatus() === (int) $attendedStatus) {
                 $jsResponse->callFunction(array('OW', 'error'), array(OW::getLanguage()->text('event', 'user_status_not_changed_error')));
                 $exit = true;
             }
             if ($eventDto->getUserId() == OW::getUser()->getId() && (int) $attendedStatus == EVENT_BOL_EventService::USER_STATUS_NO) {
                 $jsResponse->callFunction(array('OW', 'error'), array(OW::getLanguage()->text('event', 'user_status_author_cant_leave_error')));
                 $exit = true;
             }
             if (!$exit) {
                 $eventUserDto = EVENT_BOL_EventService::getInstance()->addEventUser($userId, $eventId, $attendedStatus);
                 if (!empty($eventUserDto)) {
                     $e = new OW_Event(EVENT_BOL_EventService::EVENT_ON_CHANGE_USER_STATUS, array('eventId' => $eventDto->id, 'userId' => $eventUserDto->userId));
                     OW::getEventManager()->trigger($e);
                     $jsResponse->callFunction(array('OW', 'info'), array(OW::getLanguage()->text('event', 'user_status_updated')));
                     BOL_InvitationService::getInstance()->deleteInvitation(self::INVITATION_JOIN, $eventId, $userId);
                 } else {
                     $jsResponse->callFunction(array('OW', 'error'), array(OW::getLanguage()->text('event', 'user_status_update_error')));
                 }
             }
         } else {
             $jsResponse->callFunction(array('OW', 'error'), array(OW::getLanguage()->text('event', 'user_status_update_error')));
         }
     } else {
         if ($params['command'] == 'events.ignore') {
             $eventService->deleteUserEventInvites((int) $eventId, $userId);
             $jsResponse->callFunction(array('OW', 'info'), array(OW::getLanguage()->text('event', 'user_status_updated')));
             BOL_InvitationService::getInstance()->deleteInvitation(self::INVITATION_JOIN, $eventId, $userId);
         }
     }
     $event->setData($jsResponse);
 }