• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CommentModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: modify

 /**
  * modify comment
  */
 public function modify()
 {
     if ($this->isPost()) {
         $uid = $this->user['uid'];
         if (empty($uid)) {
             Message::showError('please login');
         }
         $comment_id = trim($_POST['id']);
         if (!is_numeric($comment_id)) {
             Message::showError('comment id necessay');
         }
         $content = trim($_POST['content']);
         if (empty($content)) {
             Message::showError('content is empty');
         }
         if (!is_numeric($_POST['star'])) {
             Message::showError('star is not number');
         }
         $star = trim($_POST['star']);
         $commentModel = new CommentModel();
         $result = $commentModel->modify($uid, $comment_id, $star, $content);
         if (!empty($result)) {
             Message::showSucc('modify comment success');
         } else {
             Message::showError('modify comment failed');
         }
     }
     $this->display('comment.html');
 }
开发者ID:guojianing,项目名称:dagger2,代码行数:32,代码来源:CommentController.php


示例2: sus_opp

 private function sus_opp()
 {
     $comment = new CommentModel();
     $comment->cid = $_GET['cid'];
     //支持
     if ($_GET['action'] == 'sustain') {
         $comment->sustain() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $comment->cid) : Tool::alertBack('对不起,请重试');
     }
     //反对
     if ($_GET['action'] == 'oppose') {
         $comment->oppose() ? Tool::alertLocation('谢谢您的评价', 'feedback.php?cid=' . $comment->cid) : Tool::alertBack('对不起,请重试');
     }
 }
开发者ID:hachi-zzq,项目名称:guest-cms,代码行数:13,代码来源:DetailAction.class.php


示例3: indexAction

 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: POST');
     $valid = true;
     $errors = [];
     if (CommentModel::exists($this->pdo, htmlentities($_POST['id']))) {
         $id = htmlentities($_POST['id']);
     } else {
         return json_encode($errors['id'] = '<span class="errors">Cet article n\'existe pas</span>');
     }
     $content = trim(htmlentities($_POST['content']));
     $timestamp = time();
     if (!isset($content) || empty($content)) {
         $errors['content'] = '<span class="errors">Non saisi</span>';
         $valid = false;
     } elseif (strlen($content) > 200) {
         $errors['content'] = '<span class="errors">200 caractères max</span>';
         $valid = false;
     }
     $errors['valid'] = $valid;
     if ($valid) {
         CommentModel::edit($this->pdo, $id, $content, $timestamp);
     }
     echo json_encode($errors);
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:27,代码来源:ChangeCommentController.php


示例4: indexAction

 public function indexAction()
 {
     $articles = ArticlesModel::getList($this->pdo);
     $commentaires = CommentModel::getList($this->pdo);
     include "../view/home.php";
     return;
 }
开发者ID:Sladeck,项目名称:Blog,代码行数:7,代码来源:IndexController.php


示例5: edit

 public function edit()
 {
     $this->assign('userInfo', $this->userInfo);
     $id = request('id');
     if (isset($_POST['id'])) {
         $content = request('content');
         $reply = request('reply');
         if (mb_strlen($content, 'utf8') > 200) {
             $this->error('留言的长度不能超过200字符');
         }
         if (mb_strlen($reply, 'utf8') > 200) {
             $this->error('回复的长度不能超过200字符');
         }
         $data['content'] = $content;
         $data['reply'] = $reply;
         $data['replytime'] = time();
         $data['status'] = 'replied';
         if (CommentModel::update($id, $data)) {
             $this->success(request('reffer'));
         } else {
             $this->error();
         }
     } else {
         $comment = CommentModel::get($id);
         $this->assign('comment', $comment);
         $this->assign('reffer', $this->reffer());
         $this->display();
     }
 }
开发者ID:BGCX261,项目名称:zhflash-svn-to-git,代码行数:29,代码来源:comment.php


示例6: indexAction

 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: GET');
     echo json_encode(CommentModel::showAllComments($this->pdo));
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:7,代码来源:LoadAllCommentsController.php


示例7: index

 public function index()
 {
     //header('content-type:text/html;charset=utf-8');
     $userId = $_SESSION['qq']['userId'];
     $collect = new CollectModel();
     //查询收藏
     $user_collect = $collect->getCollectByuserId($userId);
     $article = new ArticleModel();
     $arr = array();
     foreach ($user_collect as $v) {
         //根据收藏的文章id查询文章
         $a = $article->getArticleById($v['articleId']);
         //取出admin的昵称
         $a['adminName'] = $this->getAdmin($a['adminId']);
         $arr[] = $a;
     }
     $comment = new CommentModel();
     $commentAlbum = $comment->getCommentByAlbum($userId);
     $album = new AlbumModel();
     $articles = array();
     $albums = array();
     foreach ($commentAlbum as $v) {
         if ($v['albumId'] != null) {
             $c = $album->getAlbumById($v['albumId']);
             $c['adminName'] = $this->getAdmin($v['adminId']);
             $albums[] = $c;
         }
     }
     $commentArticle = $comment->getCommentByArticle($userId);
     foreach ($commentArticle as $v) {
         if ($v['articleId'] != null) {
             $a = $article->getArticleById($v['articleId']);
             $a['adminName'] = $this->getAdmin($v['adminId']);
             $articles[] = $a;
         }
     }
     var_dump($albums);
     $this->assign('user', $_SESSION['qq']['userName']);
     //评论过的相册
     $this->assign('albums', $albums);
     //评论过的文章
     $this->assign('articles', $articles);
     //收藏
     $this->assign('user_collect', $arr);
     $this->display();
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:46,代码来源:UserCtrl.class.php


示例8: 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


示例9: AddReplyButton

    protected function AddReplyButton($Sender)
    {
        if (!Gdn::Session()->UserID) {
            return;
        }
        if (isset($Sender->EventArguments['Comment'])) {
            $Model = new CommentModel();
            $Data = $Model->GetID($Sender->EventArguments['Comment']->CommentID);
        } else {
            $Model = new DiscussionModel();
            $Data = $Model->GetID($Sender->Data['Discussion']->DiscussionID);
        }
        $ReplyURL = "#" . "{$Data->InsertName}";
        $ReplyText = T('Reply');
        echo <<<QUOTE
      <span class="CommentReply"><a href="{$ReplyURL}">{$ReplyText}</a></span>
QUOTE;
    }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:18,代码来源:class.reply.plugin.php


示例10: comment

 public function comment()
 {
     if (!empty($_POST)) {
         $_POST['userId'] = $_SESSION['qq']['userId'];
         $arr = $_POST;
         $comment = new CommentModel();
         $row = $comment->addComment($_POST);
         if ($row) {
             $user = new UserModel();
             $arr['addTime'] = data('Y-m-d H:i:s');
             $user = $user->getUser($_POST['userId']);
             $arr['face'] = $user['face'];
             $arr['userName'] = $user['userName'];
             echo json_encode($arr);
         } else {
             exit('发表失败');
         }
     }
 }
开发者ID:Jnnock,项目名称:myyyk,代码行数:19,代码来源:ArticleCtrl.class.php


示例11: indexAction

 public function indexAction()
 {
     if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
         header('Location: /');
         exit;
     } else {
         $id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
     }
     if (CommentModel::exists($this->pdo, $id)) {
         if ($_SESSION['auth']['username'] === CommentModel::getAuthor($this->pdo, $id)) {
             include '../app/views/editcomment.php';
             return;
         }
     } else {
         header('Location: /404');
         exit;
     }
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:18,代码来源:EditCommentController.php


示例12: indexAction

 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: POST');
     $comments = CommentModel::showComments($this->pdo, htmlentities($_POST['id']));
     if (isset($_SESSION['auth'])) {
         $needed = $_SESSION['auth']['username'];
     } else {
         $needed = '';
     }
     for ($i = 0; $i < count($comments); $i++) {
         if ($comments[$i]['author'] == $needed) {
             $comments[$i]['author'] = 'Moi';
         }
     }
     echo json_encode($comments);
 }
开发者ID:Alegzandr,项目名称:alexandre.farrenq.dev2018-my_blog,代码行数:18,代码来源:LoadCommentsController.php


示例13: 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


示例14: commentModel_afterSaveComment_handler

 /**
  * Give point(s) to the current user if the right conditions are met.
  *
  * @param CommentModel $sender Sending controller instance.
  * @param array $args Event arguments.
  */
 public function commentModel_afterSaveComment_handler($sender, $args)
 {
     if (!c('QnA.Points.Enabled', false) || !$args['Insert']) {
         return;
     }
     $discussionModel = new DiscussionModel();
     $discussion = $discussionModel->getID($args['CommentData']['DiscussionID'], DATASET_TYPE_ARRAY);
     $isCommentAnAnswer = $discussion['Type'] === 'Question';
     $isQuestionResolved = $discussion['QnA'] === 'Accepted';
     $isCurrentUserOriginalPoster = $discussion['InsertUserID'] == GDN::session()->UserID;
     if (!$isCommentAnAnswer || $isQuestionResolved || $isCurrentUserOriginalPoster) {
         return;
     }
     $userAnswersToQuestion = $sender->getWhere(array('DiscussionID' => $args['CommentData']['DiscussionID'], 'InsertUserId' => GDN::session()->UserID));
     // Award point(s) only for the first answer to the question
     if ($userAnswersToQuestion->count() > 1) {
         return;
     }
     UserModel::givePoints(GDN::session()->UserID, c('QnA.Points.Answer', 1), 'QnA');
 }
开发者ID:vanilla,项目名称:addons,代码行数:26,代码来源:class.qna.plugin.php


示例15: getDetails

 private function getDetails()
 {
     if (isset($_GET['id'])) {
         parent::__construct($this->_tpl, new ContentModel());
         $this->_model->id = $_GET['id'];
         if (!$this->_model->getOneContent()) {
             Tool::alertBack('警告:不存在此文档!');
         }
         $_content = $this->_model->getOneContent();
         $_comment = new CommentModel();
         $_comment->cid = $this->_model->id;
         $_tarArr = explode(',', $_content->tag);
         if (is_array($_tarArr)) {
             foreach ($_tarArr as $_value) {
                 $_content->tag = str_replace($_value, '<a href="search.php?type=3&inputkeyword=' . $_value . '">' . $_value . '</a>', $_content->tag);
             }
         }
         $this->_tpl->assign('id', $_content->id);
         $this->_tpl->assign('titlec', $_content->title);
         $this->_tpl->assign('date', $_content->date);
         $this->_tpl->assign('source', $_content->source);
         $this->_tpl->assign('author', $_content->author);
         $this->_tpl->assign('info', $_content->info);
         $this->_tpl->assign('tag', $_content->tag);
         $this->_tpl->assign('content', Tool::unHtml($_content->content));
         $this->getNav($_content->nav);
         if (IS_CAHCE) {
             $this->_tpl->assign('count', '<script type="text/javascript">getContentCount();</script>');
         } else {
             $this->_tpl->assign('count', $_content->count);
         }
         $this->_tpl->assign('comment', $_comment->getCommentTotal());
         $_object = $_comment->getNewThreeComment();
         if ($_object) {
             foreach ($_object as $_value) {
                 switch ($_value->manner) {
                     case -1:
                         $_value->manner = '反对';
                         break;
                     case 0:
                         $_value->manner = '中立';
                         break;
                     case 1:
                         $_value->manner = '支持';
                         break;
                 }
                 if (empty($_value->face)) {
                     $_value->face = '00.gif';
                 }
                 if (!empty($_value->oppose)) {
                     $_value->oppose = '-' . $_value->oppose;
                 }
             }
         }
         $this->_tpl->assign('NewThreeComment', $_object);
         $this->_model->nav = $_content->nav;
         $_object = $this->_model->getMonthNavRec();
         $this->setObject($_object);
         $this->_tpl->assign('MonthNavRec', $_object);
         $_object = $this->_model->getMonthNavHot();
         $this->setObject($_object);
         $this->_tpl->assign('MonthNavHot', $_object);
         $_object = $this->_model->getMonthNavPic();
         $this->setObject($_object);
         $this->_tpl->assign('MonthNavPic', $_object);
     } else {
         Tool::alertBack('警告:非法操作!');
     }
 }
开发者ID:denson7,项目名称:phpstudy,代码行数:69,代码来源:DetailsAction.class.php


示例16: Gdn_Statistics_Tick_Handler

 public function Gdn_Statistics_Tick_Handler($Sender, $Args)
 {
     $Path = GetValue('Path', $Args);
     if (preg_match('`discussion\\/(\\d+)`i', $Path, $Matches)) {
         $DiscussionID = $Matches[1];
     } elseif (preg_match('`discussion\\/comment\\/(\\d+)`i', $Path, $Matches)) {
         $CommentID = $Matches[1];
         $CommentModel = new CommentModel();
         $Comment = $CommentModel->GetID($CommentID);
         $DiscussionID = GetValue('DiscussionID', $Comment);
     }
     if (isset($DiscussionID)) {
         $DiscussionModel = new DiscussionModel();
         $Discussion = $DiscussionModel->GetID($DiscussionID);
         $DiscussionModel->AddView($DiscussionID, GetValue('CountViews', $Discussion));
     }
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:17,代码来源:class.hooks.php


示例17: gdn_statistics_tick_handler

 /**
  * Discussion view counter.
  *
  * @param $Sender
  * @param $Args
  */
 public function gdn_statistics_tick_handler($Sender, $Args)
 {
     $Path = Gdn::request()->post('Path');
     $Args = Gdn::request()->post('Args');
     parse_str($Args, $Args);
     $ResolvedPath = trim(Gdn::request()->post('ResolvedPath'), '/');
     $ResolvedArgs = Gdn::request()->post('ResolvedArgs');
     $DiscussionID = null;
     $DiscussionModel = new DiscussionModel();
     // Comment permalink
     if ($ResolvedPath == 'vanilla/discussion/comment') {
         $CommentID = val('CommentID', $ResolvedArgs);
         $CommentModel = new CommentModel();
         $Comment = $CommentModel->getID($CommentID);
         $DiscussionID = val('DiscussionID', $Comment);
     } elseif ($ResolvedPath == 'vanilla/discussion/index') {
         $DiscussionID = val('DiscussionID', $ResolvedArgs, null);
     } elseif ($ResolvedPath == 'vanilla/discussion/embed') {
         $ForeignID = val('vanilla_identifier', $Args);
         if ($ForeignID) {
             // This will be hit a lot so let's try caching it...
             $Key = "DiscussionID.ForeignID.page.{$ForeignID}";
             $DiscussionID = Gdn::cache()->get($Key);
             if (!$DiscussionID) {
                 $Discussion = $DiscussionModel->getForeignID($ForeignID, 'page');
                 $DiscussionID = val('DiscussionID', $Discussion);
                 Gdn::cache()->store($Key, $DiscussionID, array(Gdn_Cache::FEATURE_EXPIRY, 1800));
             }
         }
     }
     if ($DiscussionID) {
         $DiscussionModel->addView($DiscussionID);
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:40,代码来源:class.hooks.php


示例18: ModerationController_MergeDiscussions_Create

 /**
  * Add a method to the ModerationController to handle merging discussions.
  * @param Gdn_Controller $Sender
  */
 public function ModerationController_MergeDiscussions_Create($Sender)
 {
     $Session = Gdn::Session();
     $Sender->Form = new Gdn_Form();
     $Sender->Title(T('Merge Discussions'));
     $DiscussionModel = new DiscussionModel();
     $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
     if (!is_array($CheckedDiscussions)) {
         $CheckedDiscussions = array();
     }
     $DiscussionIDs = $CheckedDiscussions;
     $Sender->SetData('DiscussionIDs', $DiscussionIDs);
     $CountCheckedDiscussions = count($DiscussionIDs);
     $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
     $Sender->SetData('Discussions', $Discussions);
     // Perform the merge
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
             if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                 $MergeDiscussion = $Discussion;
                 break;
             }
         }
         $RedirectLink = $Sender->Form->GetFormValue('RedirectLink');
         if ($MergeDiscussion) {
             $ErrorCount = 0;
             // Verify that the user has permission to perform the merge.
             $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
             if ($Category && !$Category['PermsDiscussionsEdit']) {
                 throw PermissionException('Vanilla.Discussions.Edit');
             }
             $DiscussionModel->DefineSchema();
             $MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
             // Assign the comments to the new discussion record
             $DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $MergeDiscussionID)->WhereIn('DiscussionID', $DiscussionIDs)->Put();
             $CommentModel = new CommentModel();
             foreach ($Discussions as $Discussion) {
                 if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                     continue;
                 }
                 // Create a comment out of the discussion.
                 $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
                 $Comment['DiscussionID'] = $MergeDiscussionID;
                 $CommentModel->Validation->Results(TRUE);
                 $CommentID = $CommentModel->Save($Comment);
                 if ($CommentID) {
                     // Move any attachments (FileUpload plugin awareness)
                     if (class_exists('MediaModel')) {
                         $MediaModel = new MediaModel();
                         $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                     }
                     if ($RedirectLink) {
                         // The discussion needs to be changed to a moved link.
                         $RedirectDiscussion = array('Name' => SliceString(sprintf(T('Merged: %s'), $Discussion['Name']), $MaxNameLength), 'Type' => 'redirect', 'Body' => FormatString(T('This discussion has been <a href="{url,html}">merged</a>.'), array('url' => DiscussionUrl($MergeDiscussion))), 'Format' => 'Html');
                         $DiscussionModel->SetField($Discussion['DiscussionID'], $RedirectDiscussion);
                         $CommentModel->UpdateCommentCount($Discussion['DiscussionID']);
                         $CommentModel->RemovePageCache($Discussion['DiscussionID']);
                     } else {
                         // Delete discussion that was merged.
                         $DiscussionModel->Delete($Discussion['DiscussionID']);
                     }
                 } else {
                     $Sender->InformMessage($CommentModel->Validation->ResultsText());
                     $ErrorCount++;
                 }
             }
             // Update counts on all affected discussions.
             $CommentModel->UpdateCommentCount($MergeDiscussionID);
             $CommentModel->RemovePageCache($MergeDiscussionID);
             // Clear selections
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($Sender);
             if ($ErrorCount == 0) {
                 $Sender->JsonTarget('', '', 'Refresh');
             }
         }
     }
     $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:87,代码来源:class.splitmerge.plugin.php


示例19: Gdn_Statistics_Tick_Handler

 public function Gdn_Statistics_Tick_Handler($Sender, $Args)
 {
     $Path = Gdn::Request()->Post('Path');
     $Args = Gdn::Request()->Post('Args');
     parse_str($Args, $Args);
     $ResolvedPath = trim(Gdn::Request()->Post('ResolvedPath'), '/');
     $ResolvedArgs = @json_decode(Gdn::Request()->Post('ResolvedArgs'));
     $DiscussionID = NULL;
     $DiscussionModel = new DiscussionModel();
     //      Gdn::Controller()->SetData('Path', $Path);
     //      Gdn::Controller()->SetData('Args', $Args);
     //      Gdn::Controller()->SetData('ResolvedPath', $ResolvedPath);
     //      Gdn::Controller()->SetData('ResolvedArgs', $ResolvedArgs);
     // Comment permalink
     if ($ResolvedPath == 'vanilla/discussion/comment') {
         $CommentID = GetValue('CommentID', $ResolvedArgs);
         $CommentModel = new CommentModel();
         $Comment = $CommentModel->GetID($CommentID);
         $DiscussionID = GetValue('DiscussionID', $Comment);
     } elseif ($ResolvedPath == 'vanilla/discussion/index') {
         $DiscussionID = GetValue('DiscussionID', $ResolvedArgs, NULL);
     } elseif ($ResolvedPath == 'vanilla/discussion/embed') {
         $ForeignID = GetValue('vanilla_identifier', $Args);
         if ($ForeignID) {
             // This will be hit a lot so let's try caching it...
             $Key = "DiscussionID.ForeignID.page.{$ForeignID}";
             $DiscussionID = Gdn::Cache()->Get($Key);
             if (!$DiscussionID) {
                 $Discussion = $DiscussionModel->GetForeignID($ForeignID, 'page');
                 $DiscussionID = GetValue('DiscussionID', $Discussion);
                 Gdn::Cache()->Store($Key, $DiscussionID, array(Gdn_Cache::FEATURE_EXPIRY, 1800));
             }
         }
     }
     if ($DiscussionID) {
         $DiscussionModel->AddView($DiscussionID);
     }
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:38,代码来源:class.hooks.php


示例20: ModerationController_MergeDiscussions_Create

 /**
  * Add a method to the ModerationController to handle merging discussions.
  * @param Gdn_Controller $Sender
  */
 public function ModerationController_MergeDiscussions_Create($Sender)
 {
     $Session = Gdn::Session();
     $Sender->Form = new Gdn_Form();
     $Sender->Title(T('Merge Discussions'));
     $DiscussionModel = new DiscussionModel();
     $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
     if (!is_array($CheckedDiscussions)) {
         $CheckedDiscussions = array();
     }
     $DiscussionIDs = $CheckedDiscussions;
     $Sender->SetData('DiscussionIDs', $DiscussionIDs);
     $CountCheckedDiscussions = count($DiscussionIDs);
     $Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     $Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
     $Sender->SetData('Discussions', $Discussions);
     // Perform the merge
     if ($Sender->Form->AuthenticatedPostBack()) {
         // Create a new discussion record
         $MergeDiscussion = FALSE;
         $MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
         foreach ($Discussions as $Discussion) {
             if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                 $MergeDiscussion = $Discussion;
                 break;
             }
         }
         if ($MergeDiscussion) {
             $ErrorCount = 0;
             // Verify that the user has permission to perform the merge.
             $Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
             if ($Category && !$Category['PermsDiscussionsEdit']) {
                 throw PermissionException('Vanilla.Discussions.Edit');
             }
             // Assign the comments to the new discussion record
             $DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $MergeDiscussionID)->WhereIn('DiscussionID', $DiscussionIDs)->Put();
             $CommentModel = new CommentModel();
             foreach ($Discussions as $Discussion) {
                 if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
                     continue;
                 }
                 // Create a comment out of the discussion.
                 $Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
                 $Comment['DiscussionID'] = $MergeDiscussionID;
                 $CommentModel->Validation->Results(TRUE);
                 $CommentID = $CommentModel->Save($Comment);
                 if ($CommentID) {
                     // Move any attachments (FileUpload plugin awareness)
                     if (class_exists('MediaModel')) {
                         $MediaModel = new MediaModel();
                         $MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
                     }
                     // Delete discussion that was merged
                     $DiscussionModel->Delete($Discussion['DiscussionID']);
                 } else {
                     $Sender->InformMessage($CommentModel->Validation->ResultsText());
                     $ErrorCount++;
                 }
             }
             // Update counts on all affected discussions.
             $CommentModel->UpdateCommentCount($MergeDiscussionID);
             $CommentModel->RemovePageCache($MergeDiscussionID);
             // Clear selections
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($Sender);
             if ($ErrorCount == 0) {
                 $Sender->RedirectUrl = Url("/discussion/{$MergeDiscussionID}/" . Gdn_Format::Url($MergeDiscussion['Name']));
             }
         }
     }
     $Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
 }
开发者ID:bishopb,项目名称:vanilla,代码行数:76,代码来源:class.splitmerge.plugin.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Comments类代码示例发布时间:2022-05-23
下一篇:
PHP CommentForm类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap