/** * Clear the message history for a specific conversation & user. * * @since 2.0.0 * @access public * * @param int $ConversationID Unique ID of conversation to clear. */ public function clear($ConversationID = false, $TransientKey = '') { $Session = Gdn::session(); // Yes/No response $this->_DeliveryType = DELIVERY_TYPE_BOOL; $ValidID = is_numeric($ConversationID) && $ConversationID > 0; $ValidSession = $Session->UserID > 0 && $Session->validateTransientKey($TransientKey); if ($ValidID && $ValidSession) { // Clear it $this->ConversationModel->clear($ConversationID, $Session->UserID); $this->informMessage(t('The conversation has been cleared.')); $this->RedirectUrl = url('/messages/all'); } $this->render(); }
/** * Leave a conversation that a user is participating in. * * @param int $conversationID The ID of the conversation to leave. */ public function leave($conversationID) { if (!Gdn::session()->UserID) { throw new Gdn_UserException('You must be signed in.', 403); } // Make sure the user has participated in the conversation before. $row = Gdn::sql()->getWhere('UserConversation', ['ConversationID' => $conversationID, 'UserID' => Gdn::session()->UserID])->firstRow(); if (!$row) { throw notFoundException('Conversation'); } if ($this->Form->authenticatedPostBack(true)) { $this->ConversationModel->clear($conversationID, Gdn::session()->UserID); $this->RedirectUrl = url('/messages/all'); } $this->title(t('Leave Conversation')); $this->render(); }