当前位置: 首页>>代码示例>>PHP>>正文


PHP CommentModel::delete方法代码示例

本文整理汇总了PHP中CommentModel::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CommentModel::delete方法的具体用法?PHP CommentModel::delete怎么用?PHP CommentModel::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommentModel的用法示例。


在下文中一共展示了CommentModel::delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteAction

 public function deleteAction()
 {
     if (!isset($_POST['comment_id'])) {
         return json_encode(["error" => "comment_id missing"]);
     }
     $comment_id = $_POST['comment_id'];
     CommentModel::delete($this->pdo, $comment_id);
     return json_encode(["message" => "Supprimé !", "comment_id" => $comment_id]);
 }
开发者ID:LattyS,项目名称:my_blog,代码行数:9,代码来源:CommentController.php

示例2: indexAction

 public function indexAction()
 {
     if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
         header('Location: /');
         exit;
     } else {
         $article_id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
     }
     if (CommentModel::exists($this->pdo, $article_id)) {
         if ($_SESSION['auth']['username'] === CommentModel::getAuthor($this->pdo, $article_id) || $_SESSION['auth']['permissions'] === 'superadmin') {
             CommentModel::delete($this->pdo, $article_id);
             header('Location: /');
             exit;
         }
     } else {
         header('Location: /404');
         exit;
     }
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:19,代码来源:DeleteCommentController.php

示例3: confirmCommentDeletes

 /**
  * Form to confirm that the administrator wants to delete the selected
  * comments (and has permission to do so).
  */
 public function confirmCommentDeletes($DiscussionID = '')
 {
     $Session = Gdn::session();
     $this->Form = new Gdn_Form();
     $DiscussionModel = new DiscussionModel();
     $Discussion = $DiscussionModel->getID($DiscussionID);
     if (!$Discussion) {
         return;
     }
     // Verify that the user has permission to perform the delete
     $PermissionCategory = CategoryModel::categories($Discussion->CategoryID);
     $this->permission('Vanilla.Comments.Delete', true, 'Category', val('PermissionCategoryID', $PermissionCategory));
     $this->title(t('Confirm'));
     $CheckedComments = Gdn::userModel()->getAttribute($Session->User->UserID, 'CheckedComments', array());
     if (!is_array($CheckedComments)) {
         $CheckedComments = array();
     }
     $CommentIDs = array();
     $DiscussionIDs = array();
     foreach ($CheckedComments as $DiscID => $Comments) {
         foreach ($Comments as $Comment) {
             if (substr($Comment, 0, 11) == 'Discussion_') {
                 $DiscussionIDs[] = str_replace('Discussion_', '', $Comment);
             } elseif ($DiscID == $DiscussionID) {
                 $CommentIDs[] = str_replace('Comment_', '', $Comment);
             }
         }
     }
     $CountCheckedComments = count($CommentIDs);
     $this->setData('CountCheckedComments', $CountCheckedComments);
     if ($this->Form->authenticatedPostBack()) {
         // Delete the selected comments
         $CommentModel = new CommentModel();
         foreach ($CommentIDs as $CommentID) {
             $CommentModel->delete($CommentID);
         }
         // Clear selections
         unset($CheckedComments[$DiscussionID]);
         Gdn::userModel()->saveAttribute($Session->UserID, 'CheckedComments', $CheckedComments);
         ModerationController::InformCheckedComments($this);
         $this->RedirectUrl = 'discussions';
     }
     $this->render();
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:48,代码来源:class.moderationcontroller.php

示例4: DeleteCommentAction

 public function DeleteCommentAction()
 {
     $request = Project::getRequest();
     $request_user_id = (int) Project::getUser()->getShowedUser()->id;
     $user = Project::getUser()->getDbUser();
     $isAdmin = $user->user_type_id == 1 ? true : false;
     $user_id = (int) Project::getUser()->getDbUser()->id;
     $item_id = $request->getKeyByNumber(0);
     $comment_id = $request->getKeyByNumber(1);
     $item_name = $request->getKeyByNumber(2);
     $comment_model = new CommentModel($item_name . '_comment', $item_name . '_id', $comment_id);
     switch ($item_name) {
         case 'article':
             $item_model = new ArticleModel();
             $item_controller = 'Article';
             $item_action = 'ArticleView';
             $item_name_id = $comment_model->article_id;
             break;
         case 'questions':
             $item_model = new QuestionModel();
             $item_controller = 'QuestionAnswer';
             $item_action = 'ViewQuestion';
             $item_name_id = $comment_model->questions_id;
             break;
         case 'photo':
             $item_model = new PhotoModel();
             $item_controller = 'Photo';
             $item_action = 'View';
             $item_name_id = $comment_model->photo_id;
             break;
         case 'bookmarks':
             $item_model = new BookmarksModel();
             $item_controller = 'Bookmarks';
             $item_action = 'BookmarksView';
             $item_name_id = $comment_model->bookmarks_id;
             break;
         case 'social':
             $item_model = new SocialModel();
             $item_controller = 'Social';
             $item_action = 'SocialView';
             $item_name_id = $comment_model->social_id;
             break;
         case 'blog':
             $item_model = new SocialModel();
             $item_controller = 'Blog';
             $item_action = 'Comments';
             $item_name_id = $comment_model->blog_id;
             break;
     }
     $item_model->load($item_id);
     if ($comment_model->id > 0 && $item_model->id > 0 && $item_name_id == $item_model->id) {
         if ($comment_model->user_id == $user_id || $item_model->user_id == $user_id || $isAdmin) {
             $comment_model->delete($comment_model->user_id, $comment_id);
             $item_model->comments--;
             $item_model->save();
         }
     }
     Project::getResponse()->redirect($request->createUrl($item_controller, $item_action, array($item_model->id)));
 }
开发者ID:amanai,项目名称:next24,代码行数:59,代码来源:BaseCommentController.php


注:本文中的CommentModel::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。