/** * get private conversation objs * * $mbqOpt['case'] = 'all' means get my all data. * $mbqOpt['case'] = 'byConvIds' means get data by conversation ids.$var is the ids. * $mbqOpt['case'] = 'byObjsStdPc' means get data by objsStdPc.$var is the objsStdPc. * @return Mixed */ public function getObjsMbqEtPc($var, $mbqOpt) { if ($mbqOpt['case'] == 'all') { if ($mbqOpt['oMbqDataPage']) { $oMbqDataPage = $mbqOpt['oMbqDataPage']; //ref wcf\page\ConversationListPage,wcf\data\conversation\UserConversationList $oUserConversationList = new UserConversationList(WCF::getUser()->userID, '', 0); $oUserConversationList->sqlOffset = $oMbqDataPage->startNum; $oUserConversationList->sqlLimit = $oMbqDataPage->numPerPage; $oUserConversationList->sqlOrderBy = 'conversation.lastPostTime DESC'; $oUserConversationList->readObjects(); $oMbqDataPage->totalNum = $oUserConversationList->countObjects(); /* common begin */ $mbqOpt['case'] = 'byObjsViewableConversation'; $mbqOpt['oMbqDataPage'] = $oMbqDataPage; return $this->getObjsMbqEtPc($oUserConversationList->getObjects(), $mbqOpt); /* common end */ } } elseif ($mbqOpt['case'] == 'byConvIds') { $oUserConversationList = new UserConversationList(WCF::getUser()->userID, '', 0); $oUserConversationList->setObjectIDs($var); $oUserConversationList->readObjects(); $objects = $oUserConversationList->getObjects(); /* common begin */ $mbqOpt['case'] = 'byObjsViewableConversation'; return $this->getObjsMbqEtPc($objects, $mbqOpt); /* common end */ } elseif ($mbqOpt['case'] == 'byObjsViewableConversation') { $objsViewableConversation = $var; /* common begin */ $objsMbqEtPc = array(); foreach ($objsViewableConversation as $oViewableConversation) { $objsMbqEtPc[] = $this->initOMbqEtPc($oViewableConversation, array('case' => 'oViewableConversation')); } /* load objsRecipientMbqEtUser property */ $oMbqRdEtUser = MbqMain::$oClk->newObj('MbqRdEtUser'); foreach ($objsMbqEtPc as &$oMbqEtPc) { $userIdsRecipient = $oMbqEtPc->mbqBind['oViewableConversation']->getDecoratedObject()->getParticipantIDs(); $objsRecipientMbqEtUser = $oMbqRdEtUser->getObjsMbqEtUser($userIdsRecipient, array('case' => 'byUserIds')); $oMbqEtPc->objsRecipientMbqEtUser = $objsRecipientMbqEtUser; //$oMbqEtPc->participantCount->setOriValue(count($oMbqEtPc->objsRecipientMbqEtUser)); } if ($mbqOpt['oMbqDataPage']) { $oMbqDataPage = $mbqOpt['oMbqDataPage']; $oMbqDataPage->datas = $objsMbqEtPc; return $oMbqDataPage; } else { return $objsMbqEtPc; } /* common end */ } MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_UNKNOWN_CASE); }
/** * Returns a mixed conversation list with up to 5 unread conversations. * * @return array<mixed> */ public function getMixedConversationList() { $unreadConversationList = new UserConversationList(WCF::getUser()->userID); $unreadConversationList->getConditionBuilder()->add('conversation_to_user.lastVisitTime < conversation.lastPostTime'); $unreadConversationList->sqlLimit = 5; $unreadConversationList->sqlOrderBy = 'conversation.lastPostTime DESC'; $unreadConversationList->readObjects(); $conversations = array(); $count = 0; foreach ($unreadConversationList as $conversation) { $conversations[] = $conversation; $count++; } if ($count < 5) { $conversationList = new UserConversationList(WCF::getUser()->userID); $conversationList->getConditionBuilder()->add('conversation_to_user.lastVisitTime >= conversation.lastPostTime'); $conversationList->sqlLimit = 5 - $count; $conversationList->sqlOrderBy = 'conversation.lastPostTime DESC'; $conversationList->readObjects(); foreach ($conversationList as $conversation) { $conversations[] = $conversation; } } WCF::getTPL()->assign(array('conversations' => $conversations)); $totalCount = ConversationHandler::getInstance()->getUnreadConversationCount(); if ($count < 5 && $count < $totalCount) { UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadConversationCount'); } return array('template' => WCF::getTPL()->fetch('conversationListUserPanel'), 'totalCount' => $totalCount); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); if ($this->filter != '') { // add breadcrumbs WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.conversation.conversations'), LinkHandler::getInstance()->getLink('ConversationList'))); } // read stats if (!$this->labelID) { switch ($this->filter) { case '': $this->conversationCount = $this->items; break; case 'draft': $this->draftCount = $this->items; break; case 'hidden': $this->hiddenCount = $this->items; break; case 'outbox': $this->outboxCount = $this->items; break; } } if ($this->filter != '' || $this->labelID) { $conversationList = new UserConversationList(WCF::getUser()->userID, ''); $this->conversationCount = $conversationList->countObjects(); } if ($this->filter != 'draft' || $this->labelID) { $conversationList = new UserConversationList(WCF::getUser()->userID, 'draft'); $this->draftCount = $conversationList->countObjects(); } if ($this->filter != 'hidden' || $this->labelID) { $conversationList = new UserConversationList(WCF::getUser()->userID, 'hidden'); $this->hiddenCount = $conversationList->countObjects(); } if ($this->filter != 'outbox' || $this->labelID) { $conversationList = new UserConversationList(WCF::getUser()->userID, 'outbox'); $this->outboxCount = $conversationList->countObjects(); } }
/** * get conversation by conv id * * @param Integer $convId * @return Mixed */ protected function getConversationByConvId($convId) { $oUserConversationList = new UserConversationList(WCF::getUser()->userID, '', 0); $oUserConversationList->setObjectIDs(array($convId)); $oUserConversationList->readObjects(); $objsViewableConversation = $oUserConversationList->getObjects(); if ($objsViewableConversation && ($oViewableConversation = array_shift($objsViewableConversation)) && ($oConversation = $oViewableConversation->getDecoratedObject()) && $oConversation->conversationID) { return $oConversation; } else { return false; } }