Example #1
0
 /**
  * Class constructor
  */
 private function __construct()
 {
     $this->conversationDao = MAILBOX_BOL_ConversationDao::getInstance();
     $this->lastMessageDao = MAILBOX_BOL_LastMessageDao::getInstance();
     $this->messageDao = MAILBOX_BOL_MessageDao::getInstance();
     $this->attachmentDao = MAILBOX_BOL_AttachmentDao::getInstance();
 }
Example #2
0
 public function getInboxConversationList($userId, $first, $count)
 {
     $sql = " SELECT `conv`.*, `last_m`.*, `mess`.* FROM `" . $this->getTableName() . "` AS `conv`\n\n\t\t\t\t INNER JOIN `" . MAILBOX_BOL_LastMessageDao::getInstance()->getTableName() . "` AS `last_m`\n\t\t\t\t\t ON ( `last_m`.`conversationId` = `conv`.`id` )\n\n\t\t\t\t INNER JOIN `" . MAILBOX_BOL_MessageDao::getInstance()->getTableName() . "` AS `mess`\n\t\t\t\t \tON ( `conv`.`id` = `mess`.conversationId )\n\n\t\t\t\t WHERE ( `conv`.`initiatorId` = :user AND `conv`.`deleted` != " . self::DELETED_INITIATOR . " AND `mess`.`id` = `last_m`.`interlocutorMessageId` )\n\t\t\t\t\t \tOR ( `conv`.`interlocutorId` = :user AND `conv`.`deleted` != " . self::DELETED_INTERLOCUTOR . " AND `mess`.`id` = `last_m`.`initiatorMessageId` )\n\n\t\t\t\t ORDER BY `mess`.`timeStamp` DESC\n\n\t\t\t\t LIMIT :first, :count ";
     return $this->dbo->queryForList($sql, array('user' => $userId, 'first' => $first, 'count' => $count));
 }
Example #3
0
 /**
  *
  * @param array $userId
  * @return array
  */
 public function getNewConversationListForConsoleNotificationMailer($userIdList)
 {
     if (empty($userIdList)) {
         return array();
     }
     $userList = $this->dbo->mergeInClause($userIdList);
     $sql = " SELECT mess.*, `conv`.* FROM `" . $this->getTableName() . "` AS `conv`\n\n\t\t\t\t INNER JOIN `" . MAILBOX_BOL_LastMessageDao::getInstance()->getTableName() . "` AS `last_m`\n\t\t\t\t\t ON (`last_m`.`conversationId` = `conv`.`id`)\n\n            \t INNER JOIN `" . MAILBOX_BOL_MessageDao::getInstance()->getTableName() . "` AS `mess`\n\t\t\t\t \tON ( `last_m`.`initiatorMessageId` = `mess`.id AND ( `last_m`.`initiatorMessageId` > `last_m`.interlocutorMessageId )\n                    OR `last_m`.`interlocutorMessageId` = `mess`.id AND ( `last_m`.`initiatorMessageId` < `last_m`.interlocutorMessageId ) )\n\n\t\t\t     WHERE  `conv`.`notificationSent` = 0 AND ( ( `conv`.`initiatorId` IN ( {$userList} ) AND `last_m`.`interlocutorMessageId` > 0 AND `conv`.`deleted` != " . self::DELETED_INITIATOR . " AND NOT `conv`.`read` & " . self::READ_INITIATOR . "  AND NOT `conv`.`viewed` &  " . self::VIEW_INITIATOR . " )\n\t\t\t\t\t \tOR ( `conv`.`interlocutorId` IN ( {$userList} ) AND `conv`.`deleted` != " . self::DELETED_INTERLOCUTOR . "  AND  NOT `conv`.`read` & " . self::READ_INTERLOCUTOR . " AND NOT `conv`.`viewed` &  " . self::VIEW_INTERLOCUTOR . " ) ) \n        ";
     $conversationList = $this->dbo->queryForList($sql);
     $resultList = array();
     foreach ($conversationList as $conversation) {
         $userId = $conversation['recipientId'];
         $resultList[$userId][] = $conversation;
     }
     return $resultList;
 }