function counterize_print_browser($before = '', $after = '', $image = false, $between = 'on')
{
    global $user_ID, $post, $comment;
    get_currentuserinfo();
    if (!$comment->comment_agent) {
        return;
    }
    if (user_can_edit_post_comments($user_ID, $post->ID)) {
        $uastring = " <a href='#' title='" . htmlspecialchars($comment->comment_agent) . "'>*</a>";
    }
    $string = counterize_browser_string($comment->comment_agent, $image, $between);
    echo $before . $string . $uastring . $after;
}
Example #2
0
/**
 * Whether user can delete a post.
 *
 * @since 1.5
 * @deprecated 2.0
 * @deprecated Use current_user_can()
 * @see current_user_can()
 *
 * @param int $user_id
 * @param int $post_id
 * @param int $blog_id Not Used
 * @return bool returns true if $user_id can delete $post_id's comments
 */
function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1)
{
    _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()');
    // right now if one can edit comments, one can delete comments
    return user_can_edit_post_comments($user_id, $post_id, $blog_id);
}
function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1)
{
    // right now if one can edit comments, one can delete comments
    return user_can_edit_post_comments($user_id, $post_id, $blog_id);
}
Example #4
0
function write_comment(&$c, $deep_id = -1, $color = true)
{
    global $max_level;
    $comments_reply = $GLOBALS['comments_reply'];
    if ($c->comment_author_email == get_the_author_email()) {
        $style = ' class="mine"';
    } else {
        if ($color == true) {
            $style = ' class="borderc1"';
            $color = !$color;
        } else {
            $style = ' class="borderc2"';
            $color = !$color;
        }
    }
    ?>
		<li id="comment-<?php 
    echo $c->comment_ID;
    ?>
" <?php 
    echo $style;
    ?>
><div class="commenthead">At <?php 
    echo mysql2date('Y.m.d H:i', $c->comment_date);
    ?>
, <a name='comment-<?php 
    echo $c->comment_ID;
    ?>
'></a><span><?php 
    echo get_comment_author_link();
    ?>
</span> said: </div>
	<div class="body">
			<?php 
    comment_text();
    ?>
		</div>
		<div class="meta">
			<?php 
    global $user_ID, $post;
    get_currentuserinfo();
    if (user_can_edit_post_comments($user_ID, $c->comment_post_ID) || $GLOBALS['cmtDepth'] < $max_level) {
        echo '[';
    }
    // delete link
    if (user_can_edit_post_comments($user_ID, $c->comment_post_ID)) {
        $deleteurl = get_bloginfo("siteurl") . '/wp-admin/comment.php?action=deletecomment&amp;p=' . $c->comment_post_ID . '&amp;c=' . $c->comment_ID;
        $deleteurl = wp_nonce_url($deleteurl, 'delete-comment_' . $c->comment_ID);
        echo "<a href='{$deleteurl}' onclick='ajaxShowPost(\"{$deleteurl}\", \"comment-{$c->comment_ID}\", \"\", \"alert(\\\"comment is deleted\\\")\", \"delete\");return false;'>delete</a>|";
        $spamurl = get_bloginfo("siteurl") . '/wp-admin/comment.php?action=deletecomment&amp;dt=spam&amp;p=' . $c->comment_post_ID . '&amp;c=' . $c->comment_ID;
        $spamurl = wp_nonce_url($spamurl, 'delete-comment_' . $c->comment_ID);
        echo "<a href='{$spamurl}' onclick='ajaxShowPost(\"{$spamurl}\", \"comment-{$c->comment_ID}\", \"\", \"alert(\\\"comment is spamed\\\")\", \"delete\");return false;'>spam</a>|";
        edit_comment_link('Edit', '', $GLOBALS['cmtDepth'] < $max_level ? '|' : '');
    }
    if ($GLOBALS['cmtDepth'] < $max_level) {
        if (get_option("comment_registration") && !$user_ID) {
            echo '<a href="' . get_option('siteurl') . '/wp-login.php?redirect_to=' . get_permalink() . '">Log in to Reply</a> ]';
        } else {
            echo '<a href="javascript:moveForm(' . $c->comment_ID . ')" title="reply">Reply</a>';
        }
    }
    if (user_can_edit_post_comments($user_ID, $post->ID) || $GLOBALS['cmtDepth'] < $max_level) {
        echo ']</div>';
    }
    if ($comments_reply[$c->comment_ID]) {
        $id = $c->comment_ID;
        if ($GLOBALS['cmtDepth'] < $max_level) {
            echo '<ul>';
        }
        $first_c = true;
        foreach ($comments_reply[$id] as $c) {
            if ($first_c) {
                $first_c = false;
                continue;
            }
            $GLOBALS['cmtDepth']++;
            if ($GLOBALS['cmtDepth'] == $max_level) {
                write_comment($c, $c->comment_ID, $color);
            } else {
                write_comment($c, $deep_id, $color);
            }
            $GLOBALS['cmtDepth']--;
        }
        if ($GLOBALS['cmtDepth'] < $max_level) {
            echo '</ul>';
        }
    }
    echo '</li>';
}
Example #5
0
         wp_notify_postauthor($comment);
     }
     if ($_SERVER['HTTP_REFERER'] != "" && false == $noredir) {
         header('Location: ' . $_SERVER['HTTP_REFERER']);
     } else {
         header('Location: ' . get_settings('siteurl') . '/wp-admin/edit.php?p=' . $p . '&c=1#comments');
     }
     break;
 case 'editedcomment':
     $comment_ID = (int) $_POST['comment_ID'];
     $comment_post_ID = (int) $_POST['comment_post_ID'];
     $newcomment_author = $_POST['newcomment_author'];
     $newcomment_author_email = $_POST['newcomment_author_email'];
     $newcomment_author_url = $_POST['newcomment_author_url'];
     $comment_status = $_POST['comment_status'];
     if (!user_can_edit_post_comments($user_ID, $comment_post_ID)) {
         die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
     }
     if (user_can_edit_post_date($user_ID, $post_ID) && !empty($_POST['edit_date'])) {
         $aa = $_POST['aa'];
         $mm = $_POST['mm'];
         $jj = $_POST['jj'];
         $hh = $_POST['hh'];
         $mn = $_POST['mn'];
         $ss = $_POST['ss'];
         $jj = $jj > 31 ? 31 : $jj;
         $hh = $hh > 23 ? $hh - 24 : $hh;
         $mn = $mn > 59 ? $mn - 60 : $mn;
         $ss = $ss > 59 ? $ss - 60 : $ss;
         $datemodif = ", comment_date = '{$aa}-{$mm}-{$jj} {$hh}:{$mn}:{$ss}'";
     } else {
function write_comment(&$c, $deep_id = -1, $color = true)
{
    global $max_level;
    $comments_reply = $GLOBALS['comments_reply'];
    if ($c->comment_author_email == '*****@*****.**' || $c->comment_author_email == '*****@*****.**' || $c->comment_author_email == '*****@*****.**') {
        $style = ' class="mine"';
    } else {
        if ($color == true) {
            $style = ' class="borderc1"';
            $color = !$color;
        } else {
            $style = ' class="borderc2"';
            $color = !$color;
        }
    }
    ?>
		<li id="comment-<?php 
    echo $c->comment_ID;
    ?>
" <?php 
    echo $style;
    ?>
><div class="commenthead">At <?php 
    echo mysql2date('Y.m.d H:i', $c->comment_date);
    ?>
, <a name='comment-<?php 
    echo $c->comment_ID;
    ?>
'></a><span><?php 
    echo get_comment_author_link();
    ?>
</span> said: </div>
	<div class="body">
			<?php 
    comment_text();
    ?>
		</div>
		<div class="meta">
			<?php 
    global $user_ID, $post;
    get_currentuserinfo();
    if (user_can_edit_post_comments($user_ID, $post->ID) || $GLOBALS['cmtDepth'] < $max_level) {
        echo '[';
    }
    //	comment_favicon();
    edit_comment_link('Edit', '', $GLOBALS['cmtDepth'] < $max_level ? '|' : '');
    if ($GLOBALS['cmtDepth'] < $max_level) {
        if (get_option("comment_registration") && !$user_ID) {
            echo '<a href="' . get_option('siteurl') . '/wp-login.php?redirect_to=' . get_permalink() . '">Log in to Reply</a> ]';
        } else {
            echo '<a href="javascript:moveForm(' . $c->comment_ID . ')" title="reply">Reply</a>';
        }
    }
    if (user_can_edit_post_comments($user_ID, $post->ID) || $GLOBALS['cmtDepth'] < $max_level) {
        echo ']</div>';
    }
    if ($comments_reply[$c->comment_ID]) {
        $id = $c->comment_ID;
        if ($GLOBALS['cmtDepth'] < $max_level) {
            echo '<ul>';
        }
        foreach ($comments_reply[$id] as $c) {
            $GLOBALS['cmtDepth']++;
            if ($GLOBALS['cmtDepth'] == $max_level) {
                write_comment($c, $c->comment_ID, $color);
            } else {
                write_comment($c, $deep_id, $color);
            }
            $GLOBALS['cmtDepth']--;
        }
        if ($GLOBALS['cmtDepth'] < $max_level) {
            echo '</ul>';
        }
    }
    echo '</li>';
}
function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
	global $user_ID, $post, $comment;

	get_currentuserinfo();

	if ( !user_can_edit_post_comments($user_ID, $post->ID) )
		return;

	$location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&amp;comment=$comment->comment_ID";
	echo $before . "<a href='$location'>$link</a>" . $after;
}
function edit_comment_link($link = 'Edit This', $before = '', $after = '')
{
    global $user_ID, $post, $comment;
    get_currentuserinfo();
    if (!user_can_edit_post_comments($user_ID, $post->ID)) {
        return;
    }
    $location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&amp;comment={$comment->comment_ID}";
    echo "{$before} <a href='{$location}'>{$link}</a> {$after}";
}