/**
*
*
* @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');
}