Airship\Cabin\Bridge\Blueprint\Blog::hideComment PHP Метод

hideComment() публичный Метод

Make a comment invisible on blog posts.
public hideComment ( integer $commentId ) : boolean
$commentId integer
Результат boolean
    public function hideComment(int $commentId) : bool
    {
        $this->db->beginTransaction();
        $this->db->update('hull_blog_comments', ['approved' => false], ['commentid' => $commentId]);
        $latestVersion = $this->db->cell('SELECT MAX(versionid) FROM hull_blog_comment_versions WHERE comment = ?', $commentId);
        $this->db->update('hull_blog_comment_versions', ['approved' => false], ['versionid' => $latestVersion]);
        return $this->db->commit();
    }

Usage Example

Пример #1
0
 /**
  * View a comment
  *
  * @param string $commentId
  * @route blog/comments/view/{id}
  */
 public function viewComment(string $commentId = '')
 {
     $commentId = (int) $commentId;
     $post = $this->post(new CommentFilter());
     if (!empty($post)) {
         switch ($post['comment_btn']) {
             case 'publish':
                 if ($this->can('publish')) {
                     $this->blog->publishComment($commentId);
                 }
                 break;
             case 'hide':
                 if ($this->can('publish')) {
                     $this->blog->hideComment($commentId);
                 }
                 break;
             case 'delete':
                 if ($this->can('delete')) {
                     if ($this->blog->deleteComment($commentId)) {
                         \Airship\redirect($this->airship_cabin_prefix . '/blog/comments');
                     }
                 }
                 break;
         }
     }
     $this->lens('blog/comments_view', ['active_link' => 'bridge-link-blog-comments', 'comment' => $this->blog->getCommentById((int) $commentId)]);
 }