function smarty_block_mtifauthornotlikethiscomment($args, $content, &$ctx, &$repeat)
{
    $comment = $ctx->stash('comment');
    if (!$comment) {
        return $ctx->_hdlr_if($args, $content, $ctx, $repeat, FALSE);
    }
    $comment_id = $comment->id;
    $app = $ctx->stash('bootstrapper');
    $author = $app->user();
    if (!$author) {
        return $ctx->_hdlr_if($args, $content, $ctx, $repeat, FALSE);
    }
    $author_id = $author->id;
    $like = $ctx->stash('likeauthorcomment:' . $comment_id . ':' . $author_id);
    if ($like) {
        if ($like->not_like) {
            return $ctx->_hdlr_if($args, $content, $ctx, $repeat, TRUE);
        } else {
            return $ctx->_hdlr_if($args, $content, $ctx, $repeat, FALSE);
        }
    }
    require_once 'class.mt_likecomment.php';
    $_like = new LikeComment();
    $where = "likecomment_comment_id={$comment_id} AND likecomment_author_id={$author_id}";
    $like = $_like->Find($where, FALSE, FALSE, array('limit' => 1));
    if (is_array($like)) {
        $like = $like[0];
        $ctx->stash('likeauthorcomment:' . $comment_id . ':' . $author_id, $like);
    }
    if ($like->not_like) {
        return $ctx->_hdlr_if($args, $content, $ctx, $repeat, TRUE);
    }
    return $ctx->_hdlr_if($args, $content, $ctx, $repeat, FALSE);
}
function smarty_function_mtcommentnotlikecount($args, &$ctx)
{
    $comment = $ctx->stash('comment');
    if (!$comment) {
        return 0;
        //or return $ctx->error();
    }
    $comment_id = $comment->id;
    $likes = $ctx->stash('likecomment:' . $comment_id);
    if ($likes) {
        return $likes['not_like'];
    }
    require_once 'class.mt_likecomment.php';
    $_like = new LikeComment();
    $where = "likecomment_comment_id={$comment_id} AND likecomment_like=1";
    $like = $_like->Find($where, FALSE, FALSE, array());
    $where = "likecomment_comment_id={$comment_id} AND likecomment_not_like=1";
    $not_like = $_like->Find($where, FALSE, FALSE, array());
    $total = count($like) + count($not_like);
    $likes = array('like' => count($like), 'not_like' => count($not_like), 'total' => $total);
    $ctx->stash('likecomment:' . $comment_id, $likes);
    return $likes['not_like'];
}
Example #3
0
 /**
  * Decrementa un like en el Comment
  * @param Like $like
  * @throws PDOException si ocurre algun error en la BD
  */
 public function removeLikeComment(LikeComment $like)
 {
     $stmt = $this->db->prepare("DELETE FROM likescomments WHERE authorLike=? and likeComment=?");
     $stmt->execute(array($like->getAuthor(), $like->getComment()->getId()));
 }