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


PHP CommentModel::Delete方法代码示例

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


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

示例1: 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', GetValue('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);
             } else {
                 if ($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:edward-tsai,项目名称:vanilla4china,代码行数:50,代码来源:class.moderationcontroller.php

示例2: DiscussionController_VoteComment_Create

 /**
  * Increment/decrement comment scores
  */
 public function DiscussionController_VoteComment_Create($Sender)
 {
     //		if (!C('Plugins.Voting.Enabled'))
     //			return;
     $CommentID = GetValue(0, $Sender->RequestArgs, 0);
     $VoteType = GetValue(1, $Sender->RequestArgs);
     $TransientKey = GetValue(2, $Sender->RequestArgs);
     $Session = Gdn::Session();
     $FinalVote = 0;
     $Total = 0;
     if ($Session->IsValid() && $Session->ValidateTransientKey($TransientKey) && $CommentID > 0) {
         $CommentModel = new CommentModel();
         $OldUserVote = $CommentModel->GetUserScore($CommentID, $Session->UserID);
         $NewUserVote = $VoteType == 'voteup' ? 1 : -1;
         $FinalVote = intval($OldUserVote) + intval($NewUserVote);
         // Allow admins to vote unlimited.
         $AllowVote = $Session->CheckPermission('Garden.Moderation.Manage');
         // Only allow users to vote up or down by 1.
         if (!$AllowVote) {
             $AllowVote = $FinalVote > -2 && $FinalVote < 2;
         }
         if ($AllowVote) {
             $Total = $CommentModel->SetUserScore($CommentID, $Session->UserID, $FinalVote);
         }
         // Move the comment into or out of moderation.
         if (class_exists('LogModel')) {
             $Moderate = FALSE;
             if ($Total <= C('Plugins.Voting.ModThreshold1', -10)) {
                 $LogOptions = array('GroupBy' => array('RecordID'));
                 // Get the comment row.
                 $Data = $CommentModel->GetID($CommentID, DATASET_TYPE_ARRAY);
                 if ($Data) {
                     // Get the users that voted the comment down.
                     $OtherUserIDs = $CommentModel->SQL->Select('UserID')->From('UserComment')->Where('CommentID', $CommentID)->Where('Score <', 0)->Get()->ResultArray();
                     $OtherUserIDs = array_column($OtherUserIDs, 'UserID');
                     $LogOptions['OtherUserIDs'] = $OtherUserIDs;
                     // Add the comment to moderation.
                     if ($Total > C('Plugins.Voting.ModThreshold2', -20)) {
                         LogModel::Insert('Moderate', 'Comment', $Data, $LogOptions);
                     }
                 }
                 $Moderate = TRUE;
             }
             if ($Total <= C('Plugins.Voting.ModThreshold2', -20)) {
                 // Remove the comment.
                 $CommentModel->Delete($CommentID, array('Log' => 'Moderate'));
                 $Sender->InformMessage(sprintf(T('The %s has been removed for moderation.'), T('comment')));
             } elseif ($Moderate) {
                 $Sender->InformMessage(sprintf(T('The %s has been flagged for moderation.'), T('comment')));
             }
         }
     }
     $Sender->DeliveryType(DELIVERY_TYPE_BOOL);
     $Sender->SetJson('TotalScore', $Total);
     $Sender->SetJson('FinalVote', $FinalVote);
     $Sender->Render();
 }
开发者ID:vanilla,项目名称:addons,代码行数:60,代码来源:class.voting.plugin.php


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