/** * Adds new participants. * * @return array */ public function addParticipants() { try { $participantIDs = Conversation::validateParticipants($this->parameters['participants'], 'participants', $this->conversation->getParticipantIDs(true)); } catch (UserInputException $e) { $errorMessage = ''; foreach ($e->getType() as $type) { if (!empty($errorMessage)) { $errorMessage .= ' '; } $errorMessage .= WCF::getLanguage()->getDynamicVariable('wcf.conversation.participants.error.' . $type['type'], array('errorData' => array('username' => $type['username']))); } return array('actionName' => 'addParticipants', 'errorMessage' => $errorMessage); } // validate limit $newCount = $this->conversation->participants + count($participantIDs); if ($newCount > WCF::getSession()->getPermission('user.conversation.maxParticipants')) { return array('actionName' => 'addParticipants', 'errorMessage' => WCF::getLanguage()->getDynamicVariable('wcf.conversation.participants.error.tooManyParticipants')); } $count = 0; $successMessage = ''; if (!empty($participantIDs)) { // check for already added participants $data = array(); if ($this->conversation->isDraft) { $draftData = unserialize($this->conversation->draftData); $draftData['participants'] = array_merge($draftData['participants'], $participantIDs); $data = array('data' => array('draftData' => serialize($draftData))); } else { $data = array('participants' => $participantIDs); } $conversationAction = new ConversationAction(array($this->conversation), 'update', $data); $conversationAction->executeAction(); $count = count($participantIDs); $successMessage = WCF::getLanguage()->getDynamicVariable('wcf.conversation.edit.addParticipants.success', array('count' => $count)); ConversationModificationLogHandler::getInstance()->addParticipants($this->conversation->getDecoratedObject(), $participantIDs); if (!$this->conversation->isDraft) { // update participant summary $this->conversation->updateParticipantSummary(); } } return array('actionName' => 'addParticipants', 'count' => $count, 'successMessage' => $successMessage); }
/** * 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(); } } }