Example #1
0
 public function onBeforeRender()
 {
     parent::onBeforeRender();
     $limit = self::SECTION_ITEMS_LIMIT;
     $this->addComponent('itemsCmp', new NOTIFICATIONS_MCMP_ConsoleItems($limit));
     $this->assign('loadMore', $this->service->findNotificationCount(OW::getUser()->getId()) > $limit);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('notifications')->getStaticUrl() . 'mobile.js');
     $params = array('limit' => $limit);
     $script = 'var notificationsConsole = new OWM_NotificationsConsole(' . json_encode($params) . ');';
     OW::getDocument()->addOnloadScript($script);
 }
 public function isNotificationPermited(OW_Event $event)
 {
     $params = $event->getParams();
     if (!isset($params['userId'], $params['action'])) {
         return;
     }
     $userId = (int) $params['userId'];
     $action = $params['action'];
     $event->setData($this->service->isNotificationPermited($userId, $action));
     return $event->getData();
 }
Example #3
0
 public function sendList(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     $userIdList = $params['userIdList'];
     $notifications = $this->service->findNotificationListForSend($userIdList);
     $notificationIds = array();
     foreach ($notifications as $notification) {
         $event->add(array('pluginKey' => $notification->pluginKey, 'entityType' => $notification->entityType, 'entityId' => $notification->entityId, 'userId' => $notification->userId, 'action' => $notification->action, 'time' => $notification->timeStamp, 'viewed' => (bool) $notification->viewed, 'data' => $notification->getData()));
         $notificationIds[] = $notification->id;
     }
     $this->service->markNotificationsSentByIds($notificationIds);
 }
Example #4
0
 /**
  * Returns class instance
  *
  * @return NOTIFICATIONS_BOL_Service
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #5
0
 public function countNewItems(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     if ($params['page'] == self::CONSOLE_PAGE_KEY) {
         $service = NOTIFICATIONS_BOL_Service::getInstance();
         $event->add(array(self::CONSOLE_SECTION_KEY => $service->findNotificationCount(OW::getUser()->getId(), false)));
     }
 }
Example #6
0
 public function run()
 {
     $users = $this->service->findUserIdListForSend(100);
     if (empty($users)) {
         return;
     }
     $listEvent = new BASE_CLASS_EventCollector('notifications.send_list', array('userIdList' => $users));
     OW::getEventManager()->trigger($listEvent);
     $notifications = array();
     foreach ($listEvent->getData() as $notification) {
         $itemEvent = new OW_Event('notifications.on_item_send', $notification, $notification['data']);
         OW::getEventManager()->trigger($itemEvent);
         $notification['data'] = $itemEvent->getData();
         $notifications[$notification['userId']][] = $notification;
     }
     foreach ($notifications as $userId => $notificationList) {
         $this->service->sendPermittedNotifications($userId, $notificationList);
     }
 }
Example #7
0
 /**
  * Constructor.
  */
 public function __construct($timestamp)
 {
     parent::__construct();
     $service = NOTIFICATIONS_BOL_Service::getInstance();
     $userId = OW::getUser()->getId();
     $notifications = $service->findNewNotificationList($userId, $timestamp);
     $items = NOTIFICATIONS_MCMP_ConsoleItems::prepareData($notifications);
     $this->assign('items', $items);
     // Mark as viewed
     $service->markNotificationsViewedByUserId($userId);
     $tpl = OW::getPluginManager()->getPlugin('notifications')->getMobileCmpViewDir() . 'console_items.html';
     $this->setTemplate($tpl);
 }
 /**
  * Constructor.
  */
 public function __construct($limit, $exclude = null)
 {
     parent::__construct();
     $service = NOTIFICATIONS_BOL_Service::getInstance();
     $userId = OW::getUser()->getId();
     $notifications = $service->findNotificationList($userId, time(), $exclude, $limit);
     $items = self::prepareData($notifications);
     $this->assign('items', $items);
     $notificationIdList = array();
     foreach ($items as $id => $item) {
         $notificationIdList[] = $id;
     }
     // Mark as viewed
     $service->markNotificationsViewedByUserId($userId);
     $exclude = is_array($exclude) ? array_merge($exclude, $notificationIdList) : $notificationIdList;
     $loadMore = (bool) $service->findNotificationCount($userId, null, $exclude);
     if (!$loadMore) {
         $script = "OWM.trigger('mobile.console_hide_notifications_load_more', {});";
         OW::getDocument()->addOnloadScript($script);
     }
 }
Example #9
0
 private function winkBack($params)
 {
     if (empty($params['userId']) || empty($params['partnerId']) || empty($params['messageId']) || ($wink = $this->service->findWinkByUserIdAndPartnerId($params['userId'], $params['partnerId'])) === NULL) {
         return array('result' => FALSE, 'msg' => OW::getLanguage()->text('winks', 'wink_back_error'));
     }
     if ($this->service->setWinkback($wink->getId(), TRUE)) {
         if (OW::getPluginManager()->isPluginActive('notifications')) {
             $rule = NOTIFICATIONS_BOL_Service::getInstance()->findRuleList($wink->userId, array('wink_email_notification'));
             if (!isset($rule['wink_email_notification']) || (int) $rule['wink_email_notification']->checked) {
                 $this->sendWinkEmailNotification($wink->partnerId, $wink->userId, self::EMAIL_BACK);
             }
         }
     }
     $event = new OW_Event('winks.onWinkBack', array('userId' => $wink->getUserId(), 'partnerId' => $wink->getPartnerId(), 'conversationId' => $wink->getConversationId(), 'content' => array('entityType' => 'wink', 'eventName' => 'renderWinkBack', 'params' => array('winkId' => $wink->id, 'messageId' => $params['messageId']))));
     OW::getEventManager()->trigger($event);
 }
 public function pluginUninstall(OW_Event $e)
 {
     $params = $e->getParams();
     $pluginKey = $params['pluginKey'];
     $this->service->deleteNotificationByPluginKey($pluginKey);
 }
 public function process($data, $actions, $dtoList)
 {
     $userId = OW::getUser()->getId();
     $result = 0;
     $service = NOTIFICATIONS_BOL_Service::getInstance();
     if (!empty($data['schedule'])) {
         $result += (int) $service->setSchedule($userId, $data['schedule']);
         unset($data['schedule']);
     }
     foreach ($actions as $action) {
         /* @var $dto NOTIFICATIONS_BOL_Rule */
         if (empty($dtoList[$action])) {
             $dto = new NOTIFICATIONS_BOL_Rule();
             $dto->userId = $userId;
             $dto->action = $action;
         } else {
             $dto = $dtoList[$action];
         }
         $checked = (int) (!empty($data[$action]));
         if (!empty($dto->id) && $dto->checked == $checked) {
             continue;
         }
         $dto->checked = $checked;
         $result++;
         $service->saveRule($dto);
     }
     return $result;
 }