コード例 #1
1
ファイル: functions.inc.php プロジェクト: khanhnnvn/OKMS
function list_comments_without_right($pid, $c = null)
{
    //Return list of comments by post ID without normal rights
    $output = '';
    $default = DEFAULT_AVATAR;
    $post = post_load($pid);
    $comments = comments_load_by_pid($pid);
    usort($comments, 'sort_comment_date_ascend');
    $count = $c == null ? count($comments) : $c;
    $output .= '<div class="comments" id="comments_pid_' . $pid . '" style="display: none">';
    for ($i = 0; $i < $count; $i++) {
        if (isset($comments[$i])) {
            $user = user_load($comments[$i]['User_ID']);
            $comid = $comments[$i]['Comment_ID'];
            $comment_vote = comment_vote_load($comid, $_SESSION['uid']);
            $email = $user['User_Mail'];
            $size = 30;
            $grav_url = $comments[$i]['Comment_Hide_Name'] == 0 && user_existed($comments[$i]['User_ID']) ? "http://0.gravatar.com/avatar/" . md5(strtolower(trim($email))) . "?d=" . $default . "&s=" . $size : $default;
            $output .= '<div class="comment">';
            $output .= '<a class="author" href="?p=user/' . $user['User_Username'] . '"><img src="' . $grav_url . '" width="30px"/></a>';
            $output .= '<div class="comment_right_detail">';
            $output .= '<div class="name' . ($user['Role_ID'] == 3 ? ' lecturer' : '') . '">' . ($comments[$i]['Comment_Hide_Name'] == 0 && user_existed($comments[$i]['User_ID']) ? isset($user['User_Fullname']) ? $user['User_Fullname'] : $user['User_Username'] : '******') . '</div>';
            $output .= '<div class="date">' . ago($comments[$i]['Comment_Created']) . ($comments[$i]['Comment_Edited'] != 0 ? ' - edited: ' . ago($comments[$i]['Comment_Edited']) : '') . '</div>';
            $output .= '<p>' . $comments[$i]['Comment_Body'] . '</p>';
            $output .= '<a title="Like this comment" class="button disabled like" id="comment_like_comid_' . $comid . '">' . count_comment_likes($comid) . ' Like' . (count_comment_likes($comid) == 0 || count_comment_likes($comid) == 1 ? '' : 's') . '</a>';
            $output .= '<a title="Dislike this comment" class="button disabled dislike" id="comment_dislike_comid_' . $comid . '">' . count_comment_dislikes($comid) . ' Dislike' . (count_comment_dislikes($comid) == 0 || count_comment_dislikes($comid) == 1 ? '' : 's') . '</a>';
            $output .= '</div>';
            $output .= '</div>';
        }
    }
    $output .= '</div>';
    return $output;
}
コード例 #2
0
<?php

//Update dislike comment button
require_once '../includes/functions.inc.php';
require_once '../includes/admin.inc.php';
if (isset($_POST['comid']) && isset($_SESSION['uid'])) {
    $comid = $_POST['comid'];
    $uid = $_SESSION['uid'];
    $comment_vote = comment_vote_load($comid, $uid);
    print '<script type="text/javascript">
			$("#comment_dislike_comid_' . $comid . '").html("' . count_comment_dislikes($comid) . ' Dislike' . (count_comment_dislikes($comid) == 0 || count_comment_dislikes($comid) == 1 ? '' : 's') . '").' . ($comment_vote['CommentVote_Dislike'] == 0 ? 'remove' : 'add') . 'Class("clicked");
			</script>';
}