/**
  * @see	\wbb\data\DatabaseObjectList::__construct()
  */
 public function __construct()
 {
     parent::__construct();
     // get object types
     $conversationObjectType = ConversationModificationLogHandler::getInstance()->getObjectType('com.woltlab.wcf.conversation.conversation');
     $this->conversationObjectTypeID = $conversationObjectType->objectTypeID;
 }
 /**
  * Removes a participant from a conversation.
  */
 public function removeParticipant()
 {
     $this->conversation->removeParticipant($this->parameters['userID']);
     $this->conversation->updateParticipantSummary();
     ConversationModificationLogHandler::getInstance()->removeParticipant($this->conversation->getDecoratedObject(), $this->parameters['userID']);
     // reset storage
     UserStorageHandler::getInstance()->reset(array($this->parameters['userID']), 'unreadConversationCount');
     return array('userID' => $this->parameters['userID']);
 }
示例#3
0
 /**
  * delete conversation
  *
  * @param  Object  $oMbqEtPc
  * @param  Integer  $mode
  */
 public function deleteConversation($oMbqEtPc = null, $mode = null)
 {
     $oConversation = $oMbqEtPc->mbqBind['oViewableConversation']->getDecoratedObject();
     $conversationEditor = new ConversationEditor($oConversation);
     if ($mode == 1) {
         $hideConversation = Conversation::STATE_HIDDEN;
     } elseif ($mode == 2) {
         $hideConversation = Conversation::STATE_LEFT;
     } else {
         MbqError::alert('', 'Need valid mode.', '', MBQ_ERR_APP);
     }
     $objectIDs = array($oMbqEtPc->convId->oriValue);
     //ref wcf\data\conversation\ConversationAction::hideConversation()
     $sql = "UPDATE\twcf" . WCF_N . "_conversation_to_user\r\n\t\t\tSET\thideConversation = ?\r\n\t\t\tWHERE\tconversationID = ?\r\n\t\t\t\tAND participantID = ?";
     $statement = WCF::getDB()->prepareStatement($sql);
     WCF::getDB()->beginTransaction();
     foreach ($objectIDs as $conversationID) {
         $statement->execute(array($hideConversation, $conversationID, WCF::getUser()->userID));
     }
     WCF::getDB()->commitTransaction();
     // reset user's conversation counters if user leaves conversation
     // permanently
     if ($hideConversation == Conversation::STATE_LEFT) {
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'conversationCount');
         UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'unreadConversationCount');
     }
     // add modification log entry
     if ($hideConversation == Conversation::STATE_LEFT) {
         ConversationModificationLogHandler::getInstance()->leave($conversationEditor->getDecoratedObject());
     }
     // unmark items
     ClipboardHandler::getInstance()->unmark($objectIDs, ClipboardHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.conversation.conversation'));
     if ($hideConversation == Conversation::STATE_LEFT) {
         // update participant summary
         ConversationEditor::updateParticipantSummaries($objectIDs);
         // delete conversation if all users have left it
         $conditionBuilder = new PreparedStatementConditionBuilder();
         $conditionBuilder->add('conversation.conversationID IN (?)', array($objectIDs));
         $conditionBuilder->add('conversation_to_user.conversationID IS NULL');
         $conversationIDs = array();
         $sql = "SELECT\t\tDISTINCT conversation.conversationID\r\n\t\t\t\tFROM\t\twcf" . WCF_N . "_conversation conversation\r\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_conversation_to_user conversation_to_user\r\n\t\t\t\tON\t\t(conversation_to_user.conversationID = conversation.conversationID AND conversation_to_user.hideConversation <> " . Conversation::STATE_LEFT . ")\r\n\t\t\t\t" . $conditionBuilder;
         $statement = WCF::getDB()->prepareStatement($sql);
         $statement->execute($conditionBuilder->getParameters());
         while ($row = $statement->fetchArray()) {
             $conversationIDs[] = $row['conversationID'];
         }
         if (!empty($conversationIDs)) {
             $action = new ConversationAction($conversationIDs, 'delete');
             $action->executeAction();
         }
     }
 }