示例#1
0
 public function deletePost($postID)
 {
     if (!($post = $this->getModelFromCache('XenForo_Model_Post')->getPostById($postID))) {
         return false;
     }
     $this->getModelFromCache('XenForo_Model_Post')->deletePost($post['post_id'], 'hard');
     XenForo_Helper_Cookie::clearIdFromCookie($post['post_id'], 'inlinemod_posts');
     return true;
 }
示例#2
0
 protected function _deleteContent(array $content, $reason, array $viewingUser)
 {
     $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_ProfilePost', XenForo_DataWriter::ERROR_SILENT);
     if ($dw->setExistingData($content)) {
         $dw->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_DELETE_REASON, $reason);
         $dw->set('message_state', 'deleted');
         $dw->save();
     }
     XenForo_Model_Log::logModeratorAction('profile_post', $content, 'delete_soft', array('reason' => $reason), $this->_getProfilePostModel()->getProfileUserFromProfilePost($content));
     XenForo_Helper_Cookie::clearIdFromCookie($content['profile_post_id'], 'inlinemod_profilePosts');
 }
示例#3
0
 /**
  * Deletes a profile post.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionDelete()
 {
     $profilePostId = $this->_input->filterSingle('profile_post_id', XenForo_Input::UINT);
     list($profilePost, $user) = $this->getHelper('UserProfile')->assertProfilePostValidAndViewable($profilePostId);
     $hardDelete = $this->_input->filterSingle('hard_delete', XenForo_Input::UINT);
     $deleteType = $hardDelete ? 'hard' : 'soft';
     $profilePostModel = $this->_getProfilePostModel();
     if (!$profilePostModel->canDeleteProfilePost($profilePost, $user, $deleteType, $errorPhraseKey)) {
         throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey);
     }
     if ($this->isConfirmedPost()) {
         $reason = $this->_input->filterSingle('reason', XenForo_Input::STRING);
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_ProfilePost');
         $dw->setExistingData($profilePostId);
         if ($deleteType == 'hard') {
             $dw->delete();
         } else {
             $dw->setExtraData(XenForo_DataWriter_DiscussionMessage::DATA_DELETE_REASON, $reason);
             $dw->set('message_state', 'deleted');
             $dw->save();
         }
         $options = array('authorAlert' => $this->_input->filterSingle('send_author_alert', XenForo_Input::BOOLEAN), 'authorAlertReason' => $this->_input->filterSingle('author_alert_reason', XenForo_Input::STRING));
         if ($options['authorAlert'] && $profilePostModel->canSendProfilePostActionAlert($profilePost, $user)) {
             $profilePostModel->sendModeratorActionAlertForProfilePost('delete', $dw->getMergedData(), $user, $options['authorAlertReason']);
         }
         XenForo_Model_Log::logModeratorAction('profile_post', $profilePost, 'delete_' . $deleteType, array('reason' => $reason), $user);
         XenForo_Helper_Cookie::clearIdFromCookie($profilePostId, 'inlinemod_profilePosts');
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('members', $user));
     } else {
         $viewParams = array('profilePost' => $profilePost, 'user' => $user, 'canHardDelete' => $profilePostModel->canDeleteProfilePost($profilePost, $user, 'hard'), 'canSendAlert' => $profilePostModel->canSendProfilePostActionAlert($profilePost, $user));
         return $this->responseView('XenForo_ViewPublic_ProfilePost_Delete', 'profile_post_delete', $viewParams);
     }
 }
示例#4
0
 /**
  * Leave a (user's) conversation.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionLeave()
 {
     $conversationId = $this->_input->filterSingle('conversation_id', XenForo_Input::UINT);
     $conversation = $this->_getConversationOrError($conversationId);
     $deleteType = $this->_input->filterSingle('delete_type', XenForo_Input::STRING);
     if ($this->isConfirmedPost()) {
         $this->_getConversationModel()->deleteConversationForUser($conversationId, XenForo_Visitor::getUserId(), $deleteType);
         XenForo_Helper_Cookie::clearIdFromCookie($conversationId, 'inlinemod_conversations');
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('conversations'));
     } else {
         $viewParams = array('conversation' => $conversation);
         return $this->responseView('XenForo_ViewPublic_Conversation_Leave', 'conversation_leave', $viewParams);
     }
 }
示例#5
0
文件: Post.php 项目: Sywooch/forums
 /**
  * Deletes an existing post.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionDelete()
 {
     $postId = $this->_input->filterSingle('post_id', XenForo_Input::UINT);
     $ftpHelper = $this->getHelper('ForumThreadPost');
     list($post, $thread, $forum) = $ftpHelper->assertPostValidAndViewable($postId);
     $hardDelete = $this->_input->filterSingle('hard_delete', XenForo_Input::UINT);
     $deleteType = $hardDelete ? 'hard' : 'soft';
     $this->_assertCanDeletePost($post, $thread, $forum, $deleteType);
     $postModel = $this->_getPostModel();
     if ($this->isConfirmedPost()) {
         $options = array('reason' => $this->_input->filterSingle('reason', XenForo_Input::STRING), 'authorAlert' => $this->_input->filterSingle('send_author_alert', XenForo_Input::BOOLEAN), 'authorAlertReason' => $this->_input->filterSingle('author_alert_reason', XenForo_Input::STRING));
         if ($thread['discussion_state'] != 'visible' || $post['message_state'] != 'visible' || $post['user_id'] == XenForo_Visitor::getUserId()) {
             $options['authorAlert'] = false;
         }
         $dw = $postModel->deletePost($postId, $deleteType, $options, $forum);
         if ($post['post_id'] == $thread['first_post_id']) {
             XenForo_Model_Log::logModeratorAction('thread', $thread, 'delete_' . $deleteType, array('reason' => $options['reason']));
         } else {
             XenForo_Model_Log::logModeratorAction('post', $post, 'delete_' . $deleteType, array('reason' => $options['reason']), $thread);
         }
         XenForo_Helper_Cookie::clearIdFromCookie($postId, 'inlinemod_posts');
         if ($dw->discussionDeleted() || !$post['position']) {
             XenForo_Helper_Cookie::clearIdFromCookie($thread['thread_id'], 'inlinemod_threads');
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('forums', $forum));
         } else {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink('threads', $thread)));
         }
     } else {
         $viewParams = array('post' => $post, 'thread' => $thread, 'forum' => $forum, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum), 'canHardDelete' => $postModel->canDeletePost($post, $thread, $forum, 'hard'), 'redirect' => $this->getDynamicRedirect(XenForo_Link::buildPublicLink('threads', $thread)));
         return $this->responseView('XenForo_ViewPublic_Post_Delete', 'post_delete', $viewParams);
     }
 }
示例#6
0
 /**
  * Deletes an existing post.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionDelete()
 {
     $postId = $this->_input->filterSingle('post_id', XenForo_Input::UINT);
     $ftpHelper = $this->getHelper('ForumThreadPost');
     list($post, $thread, $forum) = $ftpHelper->assertPostValidAndViewable($postId);
     $hardDelete = $this->_input->filterSingle('hard_delete', XenForo_Input::UINT);
     $deleteType = $hardDelete ? 'hard' : 'soft';
     $this->_assertCanDeletePost($post, $thread, $forum, $deleteType);
     $postModel = $this->_getPostModel();
     if ($this->isConfirmedPost()) {
         $options = array('reason' => $this->_input->filterSingle('reason', XenForo_Input::STRING));
         $dw = $postModel->deletePost($postId, $deleteType, $options);
         XenForo_Helper_Cookie::clearIdFromCookie($postId, 'inlinemod_posts');
         if ($dw->discussionDeleted()) {
             XenForo_Helper_Cookie::clearIdFromCookie($thread['thread_id'], 'inlinemod_threads');
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('forums', $forum));
         } else {
             return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink('threads', $thread)));
         }
     } else {
         $viewParams = array('post' => $post, 'thread' => $thread, 'forum' => $forum, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum), 'canHardDelete' => $postModel->canDeletePost($post, $thread, $forum, 'hard'));
         return $this->responseView('XenForo_ViewPublic_Post_Delete', 'post_delete', $viewParams);
     }
 }
示例#7
0
 /**
  * Deletes an existing thread.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionDelete()
 {
     $threadId = $this->_input->filterSingle('thread_id', XenForo_Input::UINT);
     $ftpHelper = $this->getHelper('ForumThreadPost');
     list($thread, $forum) = $ftpHelper->assertThreadValidAndViewable($threadId);
     $threadModel = $this->_getThreadModel();
     $hardDelete = $this->_input->filterSingle('hard_delete', XenForo_Input::UINT);
     $deleteType = $hardDelete ? 'hard' : 'soft';
     $this->_assertCanDeleteThread($thread, $forum, $deleteType);
     if ($this->isConfirmedPost()) {
         $input = $this->_input->filter(array('reason' => XenForo_Input::STRING, 'send_starter_alert' => XenForo_Input::BOOLEAN, 'starter_alert_reason' => XenForo_Input::STRING));
         $options = array('reason' => $input['reason']);
         $threadModel->deleteThread($threadId, $deleteType, $options);
         XenForo_Model_Log::logModeratorAction('thread', $thread, 'delete_' . $deleteType, array('reason' => $options['reason']));
         if ($thread['discussion_state'] == 'visible' && $input['send_starter_alert'] && $thread['user_id'] && $thread['user_id'] != XenForo_Visitor::getUserId()) {
             $this->_getThreadModel()->sendModeratorActionAlert('delete', $thread, $input['starter_alert_reason']);
         }
         XenForo_Helper_Cookie::clearIdFromCookie($threadId, 'inlinemod_threads');
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, XenForo_Link::buildPublicLink('forums', $forum));
     } else {
         return $this->responseView('XenForo_ViewPublic_Thread_Delete', 'thread_delete', array('thread' => $thread, 'forum' => $forum, 'nodeBreadCrumbs' => $ftpHelper->getNodeBreadCrumbs($forum), 'canHardDelete' => $threadModel->canDeleteThread($thread, $forum, 'hard')));
     }
 }
示例#8
0
 protected function _deleteContent(array $content, $reason, array $viewingUser)
 {
     $this->_getPostModel()->deletePost($content['post_id'], 'soft', array('reason' => $reason));
     XenForo_Model_Log::logModeratorAction('post', $content, 'delete_soft', array('reason' => $reason), $content);
     XenForo_Helper_Cookie::clearIdFromCookie($content['post_id'], 'inlinemod_posts');
 }
示例#9
0
文件: Post.php 项目: Sywooch/forums
 public function actionDelete()
 {
     list($post, $team, $category) = $this->_getTeamHelper()->assertPostValidAndViewable();
     if (!$this->_getPostModel()->canDeletePost($post, $team, $category, $key)) {
         throw $this->getErrorOrNoPermissionResponseException($key);
     }
     if ($this->isConfirmedPost()) {
         $this->_getPostModel()->deletePost($post, $team);
         XenForo_Helper_Cookie::clearIdFromCookie($post['post_id'], 'inlinemod_teamPosts');
         return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(XenForo_Link::buildPublicLink(TEAM_ROUTE_PREFIX, $team)));
     } else {
         $viewParams = array('post' => $post, 'team' => $team, 'category' => $category, 'categoryBreadcrumbs' => $this->_getCategoryModel()->getCategoryBreadcrumb($category), 'redirect' => $this->getDynamicRedirect(XenForo_Link::buildPublicLink(TEAM_ROUTE_PREFIX, $team)));
         return $this->responseView('Nobita_Teams_ViewPublic_Post_Delete', 'Team_post_delete', $viewParams);
     }
 }