예제 #1
0
 /**
  * Returns class instance
  *
  * @return MAILBOX_BOL_ConversationDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
예제 #2
0
 public function checkUserSendMessageInterval($userId)
 {
     $send_message_interval = (int) OW::getConfig()->getValue('mailbox', 'send_message_interval');
     $conversation = $this->conversationDao->findUserLastConversation($userId);
     if ($conversation != null) {
         if (time() - $conversation->createStamp < $send_message_interval) {
             return false;
         }
     }
     return true;
 }
예제 #3
0
 public function onConversationSearch(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     $kw = $params["kw"];
     $userId = $params["userId"];
     $recipients = $params["recipients"];
     $conversationIds = array();
     if ($params["preload"]) {
         if ($kw === null) {
             $conversations = MAILBOX_BOL_ConversationService::getInstance()->getConversationListByUserId(OW::getUser()->getId(), 0, 200);
         } else {
             $conversationIds = $this->conversationDao->findConversationByKeyword($kw, 16);
             $conversations = MAILBOX_BOL_ConversationService::getInstance()->getConversationItemByConversationIdList($conversationIds);
         }
     }
     $data = $this->buildConversationData($conversations, OW::getLanguage()->text('mailbox', 'selector_group_other'), array($userId));
     foreach ($data as $item) {
         $event->add($item);
     }
 }
예제 #4
0
 public function getConversationListForConsoleNotificationMailer($userIdList)
 {
     return $this->conversationDao->getNewConversationListForConsoleNotificationMailer($userIdList);
 }
예제 #5
0
 public function findUnreadConversations($userId, $messageIgnoreList, $timeStamp = null)
 {
     if (empty($timeStamp)) {
         $timeStamp = time();
     }
     $ignore = "";
     if (!empty($messageIgnoreList)) {
         $ignore = " AND `m`.id NOT IN (" . $this->dbo->mergeInClause($messageIgnoreList) . ") ";
     }
     $sql = "SELECT `conv`.id FROM `{$this->getTableName()}` as `m`\r\n        INNER JOIN `" . MAILBOX_BOL_ConversationDao::getInstance()->getTableName() . "` as `conv` ON (`conv`.`id` = `m`.`conversationId`)\r\n        WHERE ( ( ( `conv`.`initiatorId` = :userId AND `conv`.`deleted` != " . MAILBOX_BOL_ConversationDao::DELETED_INITIATOR . " )\r\n        OR ( `conv`.`interlocutorId` = :userId AND `conv`.`deleted` != " . MAILBOX_BOL_ConversationDao::DELETED_INTERLOCUTOR . " ) )\r\n        AND `m`.`recipientId` = :userId AND `m`.`recipientRead` = 0 {$ignore} ) OR ( `m`.`senderId` = :userId AND `m`.`timeStamp` > :timeStamp )\r\n        GROUP BY `conv`.`id`";
     return $this->dbo->queryForColumnList($sql, array('userId' => $userId, 'timeStamp' => $timeStamp));
 }
예제 #6
0
 public function onPing(OW_Event $event)
 {
     $eventParams = $event->getParams();
     $params = $eventParams['params'];
     if ($eventParams['command'] == 'mailbox_api_ping') {
         return $this->onApiPing($event);
     }
     if ($eventParams['command'] != 'mailbox_ping') {
         return;
     }
     if (empty($_SESSION['lastRequestTimestamp'])) {
         $_SESSION['lastRequestTimestamp'] = (int) $params['lastRequestTimestamp'];
     }
     if ((int) $params['lastRequestTimestamp'] - (int) $_SESSION['lastRequestTimestamp'] < 3) {
         $event->setData(array('error' => "Too much requests"));
     }
     $_SESSION['lastRequestTimestamp'] = (int) $params['lastRequestTimestamp'];
     if (!OW::getUser()->isAuthenticated()) {
         $event->setData(array('error' => "You have to sign in"));
     }
     if (!OW::getRequest()->isAjax()) {
         $event->setData(array('error' => "Ajax request required"));
     }
     $userId = OW::getUser()->getId();
     /** SET **/
     if (!empty($params['readMessageList'])) {
         $this->service->markMessageIdListRead($params['readMessageList']);
         $this->service->resetUserLastData($userId);
     }
     if (!empty($params['viewedConversationList'])) {
         $this->service->setConversationViewedInConsole($params['viewedConversationList'], OW::getUser()->getId());
         $this->service->resetUserLastData($userId);
     }
     $ajaxActionResponse = array();
     if (!empty($params['ajaxActionData'])) {
         $this->service->resetUserLastData($userId);
         foreach ($params['ajaxActionData'] as $action) {
             switch ($action['name']) {
                 case 'postMessage':
                     $ajaxActionResponse[$action['uniqueId']] = $this->ajaxService->postMessage($action['data']);
                     if (!empty($ajaxActionResponse[$action['uniqueId']]['message'])) {
                         $params['lastMessageTimestamp'] = $ajaxActionResponse[$action['uniqueId']]['message']['timeStamp'];
                     }
                     break;
                 case 'getLog':
                     $ajaxActionResponse[$action['uniqueId']] = $this->ajaxService->getLog($action['data']);
                     break;
                 case 'markConversationUnRead':
                     $ajaxActionResponse[$action['uniqueId']] = $this->ajaxService->markConversationUnRead($action['data']);
                     break;
                 case 'markConversationRead':
                     $this->ajaxService->markConversationRead($action['data']);
                     break;
                 case 'loadMoreConversations':
                     if (isset($action['data']['searching']) && $action['data']['searching'] == 1) {
                         $conversationIds = MAILBOX_BOL_ConversationDao::getInstance()->findConversationByKeyword($action['data']['kw'], 8, $action['data']['from']);
                         $ajaxActionResponse[$action['uniqueId']] = MAILBOX_BOL_ConversationService::getInstance()->getConversationItemByConversationIdList($conversationIds);
                     } else {
                         $ajaxActionResponse[$action['uniqueId']] = $this->service->getConversationListByUserId(OW::getUser()->getId(), $action['data']['from'], 10);
                     }
                     break;
                 case 'bulkActions':
                     $ajaxActionResponse[$action['uniqueId']] = $this->ajaxService->bulkActions($action['data']);
                     break;
             }
         }
     }
     /** **/
     /** GET **/
     $response = $this->service->getLastData($params);
     if (!empty($ajaxActionResponse)) {
         $response['ajaxActionResponse'] = $ajaxActionResponse;
     }
     $markedUnreadConversationList = $this->service->getMarkedUnreadConversationList(OW::getUser()->getId());
     if (count($markedUnreadConversationList) > 0) {
         $response['markedUnreadConversationList'] = $markedUnreadConversationList;
     }
     /** **/
     $event->setData($response);
 }