/** * @see \wcf\system\moderation\queue\report\IModerationQueueReportHandler::canReport() */ public function canReport($objectID) { if (!$this->isValid($objectID)) { return false; } if (!Conversation::isParticipant(array($this->getMessage($objectID)->conversationID))) { return false; } return true; }
/** * @see \wcf\system\user\notification\object\type\IUserNotificationObjectType::getObjectsByIDs() */ public function getObjectsByIDs(array $objectIDs) { $objects = Conversation::getUserConversations($objectIDs, WCF::getUser()->userID); foreach ($objects as $objectID => $conversation) { $objects[$objectID] = new static::$decoratorClassName($conversation); } foreach ($objectIDs as $objectID) { // append empty objects for unknown ids if (!isset($objects[$objectID])) { // '__unknownNotificationObject' tells the notification API // that the object does not exist anymore so that the related // notification can be deleted automatically $objects[$objectID] = new static::$decoratorClassName(new static::$objectClassName(null, array('__unknownNotificationObject' => true, 'conversationID' => $objectID))); } } return $objects; }
/** * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); if (empty($_POST)) { // check for quick reply message $this->text = QuickReplyManager::getInstance()->getMessage('conversation', $this->conversation->conversationID); if (empty($this->text)) { if (MessageQuoteManager::getInstance()->getQuoteMessageID()) { $message = new ConversationMessage(MessageQuoteManager::getInstance()->getQuoteMessageID()); if (!$message->messageID) { throw new IllegalLinkException(); } if ($message->conversationID == $this->conversation->conversationID) { $message->setConversation($this->conversation); $this->text = MessageQuoteManager::getInstance()->renderQuote($message, $message->message); } } if (empty($this->text)) { // get all message ids from current conversation $sql = "SELECT\tmessageID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_conversation_message\n\t\t\t\t\t\tWHERE\tconversationID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($this->conversation->conversationID)); $messageIDs = array(); while ($row = $statement->fetchArray()) { $messageIDs[] = $row['messageID']; } $renderedQuotes = MessageQuoteManager::getInstance()->getQuotesByObjectIDs('com.woltlab.wcf.conversation.message', $messageIDs); if (!empty($renderedQuotes)) { $this->text = implode("\n", $renderedQuotes); } } } } // add breadcrumbs WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.conversation.conversations'), LinkHandler::getInstance()->getLink('ConversationList'))); WCF::getBreadcrumbs()->add($this->conversation->getBreadcrumb()); // get message list $this->messageList = new ViewableConversationMessageList(); $this->messageList->setConversation($this->conversation); $this->messageList->sqlLimit = CONVERSATION_REPLY_SHOW_MESSAGES_MAX; $this->messageList->sqlOrderBy = 'conversation_message.time DESC'; $this->messageList->getConditionBuilder()->add('conversation_message.conversationID = ?', array($this->conversation->conversationID)); $this->messageList->readObjects(); }
/** * @see \wcf\page\IPage::readData() */ public function readData() { MessageForm::readData(); if (empty($_POST)) { $this->text = $this->message->message; if ($this->isFirstMessage) { $this->participantCanInvite = $this->conversation->participantCanInvite; $this->subject = $this->conversation->subject; if ($this->conversation->isDraft && $this->conversation->draftData) { $draftData = @unserialize($this->conversation->draftData); if (!empty($draftData['participants'])) { foreach (UserProfile::getUserProfiles($draftData['participants']) as $user) { if (!empty($this->participants)) { $this->participants .= ', '; } $this->participants .= $user->username; } } if (!empty($draftData['invisibleParticipants'])) { foreach (UserProfile::getUserProfiles($draftData['invisibleParticipants']) as $user) { if (!empty($this->invisibleParticipants)) { $this->invisibleParticipants .= ', '; } $this->invisibleParticipants .= $user->username; } } } } } // add breadcrumbs WCF::getBreadcrumbs()->add(new Breadcrumb(WCF::getLanguage()->get('wcf.conversation.conversations'), LinkHandler::getInstance()->getLink('ConversationList'))); WCF::getBreadcrumbs()->add($this->conversation->getBreadcrumb()); // get message list $this->messageList = new ViewableConversationMessageList(); $this->messageList->setConversation($this->conversation); $this->messageList->sqlLimit = CONVERSATION_REPLY_SHOW_MESSAGES_MAX; $this->messageList->sqlOrderBy = 'conversation_message.time DESC'; $this->messageList->getConditionBuilder()->add('conversation_message.conversationID = ?', array($this->message->conversationID)); $this->messageList->getConditionBuilder()->add("conversation_message.messageID <> ?", array($this->message->messageID)); $this->messageList->readObjects(); }
/** * Validates parameters to remove a participant from a conversation. */ public function validateRemoveParticipant() { $this->readInteger('userID'); // validate conversation $this->conversation = $this->getSingleObject(); if (!$this->conversation->conversationID) { throw new UserInputException('objectIDs'); } // check ownership if ($this->conversation->userID != WCF::getUser()->userID) { throw new PermissionDeniedException(); } // validate participants if ($this->parameters['userID'] == WCF::getUser()->userID || !Conversation::isParticipant(array($this->conversation->conversationID)) || !Conversation::isParticipant(array($this->conversation->conversationID), $this->parameters['userID'])) { throw new PermissionDeniedException(); } }
/** * judge can delete_conversation * * @param Object $oMbqEtPc * @param Integer $mode * @return Boolean */ public function canAclDeleteConversation($oMbqEtPc, $mode) { if (MbqMain::hasLogin() && ($mode == 1 || $mode == 2)) { //ref wcf\data\conversation\ConversationAction::validateHideConversation() // validate participation if (Conversation::isParticipant(array($oMbqEtPc->convId->oriValue))) { return true; } } return false; }
/** * init one private conversation by condition * * @param Mixed $var * @param Array $mbqOpt * $mbqOpt['case'] = 'oViewableConversation' means init private conversation by oViewableConversation * @return Mixed */ public function initOMbqEtPc($var, $mbqOpt) { if ($mbqOpt['case'] == 'oViewableConversation') { $oConversation = $var->getDecoratedObject(); $oMbqEtPc = MbqMain::$oClk->newObj('MbqEtPc'); $oMbqEtPc->convId->setOriValue($oConversation->conversationID); $oMbqEtPc->convTitle->setOriValue($oConversation->subject); $oMbqEtPc->totalMessageNum->setOriValue($oConversation->replies + 1); $oMbqEtPc->participantCount->setOriValue($oConversation->participantCount + 1); $oMbqEtPc->startUserId->setOriValue($oConversation->userID); $oMbqEtPc->startConvTime->setOriValue($oConversation->time); $oMbqEtPc->lastUserId->setOriValue($oConversation->lastPosterID); $oMbqEtPc->lastConvTime->setOriValue($oConversation->lastPostTime); $oMbqEtPc->newPost->setOriValue($oConversation->isNew() ? MbqBaseFdt::getFdt('MbqFdtPc.MbqEtPc.newPost.range.yes') : MbqBaseFdt::getFdt('MbqFdtPc.MbqEtPc.newPost.range.no')); //ref wcf\data\conversation\ConversationAction::validateGetAddParticipantsForm() if (!Conversation::isParticipant(array($oConversation->conversationID)) || !$oConversation->canAddParticipants()) { $oMbqEtPc->canInvite->setOriValue(MbqBaseFdt::getFdt('MbqFdtPc.MbqEtPc.canInvite.range.no')); } else { $oMbqEtPc->canInvite->setOriValue(MbqBaseFdt::getFdt('MbqFdtPc.MbqEtPc.canInvite.range.yes')); } $oMbqEtPc->deleteMode->setOriValue(MbqBaseFdt::getFdt('MbqFdtPc.MbqEtPc.deleteMode.range.soft-and-hard-delete')); $oMbqEtPc->firstMsgId->setOriValue($oConversation->firstMessageID); $oMbqEtPc->mbqBind['oViewableConversation'] = $var; return $oMbqEtPc; } MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_UNKNOWN_CASE); }
/** * @see \wcf\data\IMessageQuoteAction::validateSaveQuote() */ public function validateSaveQuote() { $this->readString('message'); $this->readBoolean('renderQuote', true); $this->message = $this->getSingleObject(); if (!Conversation::isParticipant(array($this->message->conversationID))) { throw new PermissionDeniedException(); } }
/** * @see \wcf\system\attachment\IAttachmentObjectType::cacheObjects() */ public function cacheObjects(array $objectIDs) { $messageList = new ConversationMessageList(); $messageList->setObjectIDs($objectIDs); $messageList->readObjects(); $conversationIDs = array(); foreach ($messageList as $message) { $conversationIDs[] = $message->conversationID; } if (!empty($conversationIDs)) { $conversations = Conversation::getUserConversations($conversationIDs, WCF::getUser()->userID); foreach ($messageList as $message) { if (isset($conversations[$message->conversationID])) { $message->setConversation($conversations[$message->conversationID]); } } } foreach ($messageList->getObjects() as $objectID => $object) { $this->cachedObjects[$objectID] = $object; } }
/** * invite participant * * @param Object $oMbqEtPcInviteParticipant */ public function inviteParticipant($oMbqEtPcInviteParticipant = null) { $oConversation = $oMbqEtPcInviteParticipant->oMbqEtPc->mbqBind['oViewableConversation']->getDecoratedObject(); $conversationEditor = new ConversationEditor($oConversation); //ref wcf\data\conversation\ConversationAction::addParticipants() try { $participantIDs = Conversation::validateParticipants(implode(",", $oMbqEtPcInviteParticipant->userNames->oriValue), 'participants', $conversationEditor->getParticipantIDs(true)); } catch (UserInputException $e) { MbqError::alert('', $e->getMessage(), '', MBQ_ERR_APP); } catch (Exception $e) { MbqError::alert('', $e->getMessage(), '', MBQ_ERR_APP); } // validate limit $newCount = $conversationEditor->participants + count($participantIDs); if ($newCount > WCF::getSession()->getPermission('user.conversation.maxParticipants')) { MbqError::alert('', 'Too many participants.', '', MBQ_ERR_APP); } $count = 0; $successMessage = ''; if (!empty($participantIDs)) { // check for already added participants $data = array(); if ($conversationEditor->isDraft) { $draftData = unserialize($conversationEditor->draftData); $draftData['participants'] = array_merge($draftData['participants'], $participantIDs); $data = array('data' => array('draftData' => serialize($draftData))); } else { $data = array('participants' => $participantIDs); } $conversationAction = new ConversationAction(array($conversationEditor), 'update', $data); $conversationAction->executeAction(); $count = count($participantIDs); $successMessage = WCF::getLanguage()->getDynamicVariable('wcf.conversation.edit.addParticipants.success', array('count' => $count)); ConversationModificationLogHandler::getInstance()->addParticipants($conversationEditor->getDecoratedObject(), $participantIDs); if (!$conversationEditor->isDraft) { // update participant summary $conversationEditor->updateParticipantSummary(); } } }
/** * Validates parameters for label assignment form. */ public function validateGetLabelForm() { if (!WCF::getSession()->getPermission('user.conversation.canUseConversation')) { throw new PermissionDeniedException(); } // validate conversation id $this->parameters['conversationIDs'] = isset($this->parameters['conversationIDs']) ? ArrayUtil::toIntegerArray($this->parameters['conversationIDs']) : array(); if (empty($this->parameters['conversationIDs'])) { throw new UserInputException('conversationID'); } if (!Conversation::isParticipant($this->parameters['conversationIDs'])) { throw new PermissionDeniedException(); } // validate available labels $this->labelList = ConversationLabel::getLabelsByUser(); if (!count($this->labelList)) { throw new IllegalLinkException(); } }
/** * @see \wcf\form\IForm::validate() */ public function validate() { if (empty($this->participants) && empty($this->invisibleParticipants) && !$this->draft) { throw new UserInputException('participants'); } // check, if user is allowed to set invisible participants if (!WCF::getSession()->getPermission('user.conversation.canAddInvisibleParticipants') && !empty($this->invisibleParticipants)) { throw new UserInputException('participants', 'invisibleParticipantsNoPermission'); } // check, if user is allowed to set participantCanInvite if (!WCF::getSession()->getPermission('user.conversation.canSetCanInvite') && $this->participantCanInvite) { throw new UserInputException('participantCanInvite', 'participantCanInviteNoPermission'); } $this->participantIDs = Conversation::validateParticipants($this->participants); $this->invisibleParticipantIDs = Conversation::validateParticipants($this->invisibleParticipants, 'invisibleParticipants'); // remove duplicates $intersection = array_intersect($this->participantIDs, $this->invisibleParticipantIDs); if (!empty($intersection)) { $this->invisibleParticipantIDs = array_diff($this->invisibleParticipantIDs, $intersection); } if (empty($this->participantIDs) && empty($this->invisibleParticipantIDs) && !$this->draft) { throw new UserInputException('participants'); } // check number of participants if (count($this->participantIDs) + count($this->invisibleParticipantIDs) > WCF::getSession()->getPermission('user.conversation.maxParticipants')) { throw new UserInputException('participants', 'tooManyParticipants'); } parent::validate(); }
/** * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_REQUEST['id'])) { $this->conversationID = intval($_REQUEST['id']); } if (isset($_REQUEST['messageID'])) { $this->messageID = intval($_REQUEST['messageID']); } if ($this->messageID) { $this->message = new ConversationMessage($this->messageID); if (!$this->message->messageID) { throw new IllegalLinkException(); } $this->conversationID = $this->message->conversationID; } $this->conversation = Conversation::getUserConversation($this->conversationID, WCF::getUser()->userID); if ($this->conversation === null) { throw new IllegalLinkException(); } if (!$this->conversation->canRead()) { throw new PermissionDeniedException(); } // load labels $this->labelList = ConversationLabel::getLabelsByUser(); $this->conversation = ViewableConversation::getViewableConversation($this->conversation, $this->labelList); // posts per page if (WCF::getUser()->conversationMessagesPerPage) { $this->itemsPerPage = WCF::getUser()->conversationMessagesPerPage; } $this->canonicalURL = LinkHandler::getInstance()->getLink('Conversation', array('object' => $this->conversation), $this->pageNo ? 'pageNo=' . $this->pageNo : ''); }
/** * judge can delete_conversation * * @param Object $oMbqEtPc * @param Integer $mode * @return Boolean */ public function canAclDeleteConversation($oMbqEtPc = null, $mode = null) { if (!WCF::getSession()->getPermission('user.conversation.canUseConversation')) { return false; } if (MbqMain::hasLogin() && ($mode == 1 || $mode == 2)) { //ref wcf\data\conversation\ConversationAction::validateHideConversation() // validate participation if (Conversation::isParticipant(array($oMbqEtPc->convId->oriValue))) { return true; } } return false; }
/** * Returns the conversation of this message. * * @return \wcf\data\conversation\Conversation */ public function getConversation() { if ($this->conversation === null) { $this->conversation = Conversation::getUserConversation($this->conversationID, WCF::getUser()->userID); } return $this->conversation; }