Get all users involved in conversation.
public getRecipients ( integer $ConversationID, integer $Limit = 20 ) : Gdn_DataSet | ||
$ConversationID | integer | Unique ID of conversation. |
$Limit | integer | The number of recipients to grab. |
return | Gdn_DataSet | SQL results. |
/** * * * @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'); }
/** * Are we allowed to add more recipients? * * If we pass $CountRecipients then $ConversationID isn't needed (set to zero). * * @param int $ConversationID Unique ID of the conversation. * @param int $CountRecipients Optionally skip needing to query the count by passing it. * @return bool Whether user may add more recipients to conversation. */ public function addUserAllowed($ConversationID = 0, $CountRecipients = 0) { // Determine whether recipients can be added $CanAddRecipients = true; $MaxCount = c('Conversations.MaxRecipients'); // Avoid a query if we already know we can add. MaxRecipients being unset means unlimited. if ($MaxCount && !checkPermission('Garden.Moderation.Manage')) { if (!$CountRecipients) { // Count current recipients $ConversationModel = new ConversationModel(); $CountRecipients = $ConversationModel->getRecipients($ConversationID); } // Add 1 because sender counts as a recipient. $CanAddRecipients = count($CountRecipients) < $MaxCount + 1; } return $CanAddRecipients; }