Get meta data of a single conversation.
public getID ( integer $ConversationID, string $datasetType = false, array $options = [] ) : array | stdClass | ||
$ConversationID | integer | Unique ID of conversation. |
$datasetType | string | The format of the resulting conversation. |
$options | array | Options to modify the get. Currently supports `viewingUserID`. |
return | array | stdClass | Returns a conversation. |
/** * * * @param $ConversationID * @param null $LastMessageID * @throws Exception */ public function getNew($ConversationID, $LastMessageID = null) { $this->RecipientData = $this->ConversationModel->getRecipients($ConversationID); $this->setData('Recipients', $this->RecipientData); // Check permissions on the recipients. $InConversation = false; foreach ($this->RecipientData->result() as $Recipient) { if ($Recipient->UserID == Gdn::session()->UserID) { $InConversation = true; break; } } if (!$InConversation) { // Conversation moderation must be enabled and they must have permission if (!c('Conversations.Moderation.Allow', false)) { throw permissionException(); } $this->permission('Conversations.Moderation.Manage'); } $this->Conversation = $this->ConversationModel->getID($ConversationID); $this->setData('Conversation', $this->Conversation); // Bad conversation? Redirect if ($this->Conversation === false) { throw notFoundException('Conversation'); } $Where = array(); if ($LastMessageID) { if (strpos($LastMessageID, '_') !== false) { $LastMessageID = array_pop(explode('_', $LastMessageID)); } $Where['MessageID >='] = $LastMessageID; } // Fetch message data $this->setData('MessageData', $this->ConversationMessageModel->get($ConversationID, Gdn::session()->UserID, 0, 50, $Where), true); $this->render('Messages'); }