Ejemplo n.º 1
0
 /**
  * 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);
 }
 /**
  * @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();
     }
 }