\n";
$theme->box(t("Reply"), $output);
}
function comment_preview($pid, $id, $subject, $comment) {
global $allowed_html, $REQUEST_URI, $theme, $user;
// Preview comment:
comment_view(new Comment($user->userid, $subject, $comment, time(), $user->url, $user->fake_email, 0, 0, 0, 0), t("reply to this comment"));
// Build reply form:
$output .= "\n";
$theme->box(t("Reply"), $output);
}
function comment_post($pid, $id, $subject, $comment) {
global $theme, $user;
throttle("post comment", variable_get(max_comment_rate, 60));
// Check for duplicate comments:
$duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$pid' AND lid = '$id' AND subject = '$subject' AND comment = '$comment'"), 0);
if ($duplicate != 0) {
watchdog("warning", "comment: duplicate '$subject'");
}
else {
// Validate subject:
$subject = ($subject) ? $subject : substr($comment, 0, 29);
// Add watchdog entry:
watchdog("special", "comment: added '$subject'");
// Add comment to database:
db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('$id', '$pid', '$user->id', '$subject', '$comment', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->userid ? 1 : 0) ."')");
}
}
function comment_score($comment) {
$value = ($comment->votes) ? ($comment->score / $comment->votes) : (($comment->score) ? $comment->score : 0);
return ((strpos($value, ".")) ? substr($value ."00", 0, 4) : $value .".00");
}
function comment_num_replies($id, $count = 0) {
$result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$id'");
return ($result) ? db_result($result, 0) : 0;
}
function comment_num_filtered($lid, $pid) {
global $user;
$threshold = ($user->id) ? $user->threshold : "0";
$pid = ($pid) ? $pid : 0;
$result = db_query("SELECT COUNT(cid) FROM comments WHERE lid = '$lid' AND pid = '$pid' AND ((votes = 0 AND score < $threshold) OR (score / votes < $threshold))");
return ($result) ? db_result($result, 0) : 0;
}
function comment_moderation($comment) {
global $comment_votes, $op, $user;
if ($op == "reply") {
// preview comment:
$output .= " ";
}
else if ($user->id && $user->userid != $comment->userid && !user_get($user, "history", "c$comment->cid")) {
// comment hasn't been moderated yet:
foreach ($comment_votes as $key=>$value) $options .= " \n";
$output .= "\n";
}
else {
// comment has already been moderated:
$output .= "
". t("score") .":
". check_output($comment->score) ."
". t("votes") .":
". check_output($comment->votes) ."
\n";
}
return $output;
}
function comment_controls($threshold = 1, $mode = 3, $order = 1) {
global $REQUEST_URI, $user;
$output .= "\n";
return $output;
}
function comment_threshold($threshold) {
for ($i = -1; $i < 6; $i++) $options .= " ";
return "\n";
}
function comment_mode($mode) {
global $cmodes;
foreach ($cmodes as $key=>$value) $options .= " \n";
return "\n";
}
function comment_order($order) {
global $corder;
foreach ($corder as $key=>$value) $options .= " \n";
return "\n";
}
function comment_query($lid, $order, $pid = -1) {
$query .= "SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.lid = '$lid'";
if ($pid >= 0) $query .= " AND pid = '$pid'";
if ($order == 1) $query .= " ORDER BY c.timestamp DESC";
else if ($order == 2) $query .= " ORDER BY c.timestamp";
else if ($order == 3) $query .= " ORDER BY c.score DESC";
else if ($order == 4) $query .= " ORDER BY c.score";
return db_query($query);
}
function comment_visible($comment, $threshold = 0) {
if ($comment->votes == 0 && $comment->score >= $threshold) return 1;
else if ($comment->votes > 0 && $comment->score / $comment->votes >= $threshold) return 1;
else return 0;
}
function comment_uri($args = 0) {
global $mod;
if ($args) return ($mod) ? "module.php?mod=$mod;$args" : "node.php?$args";
else return ($mod) ? "module.php?mod=$mod" : "node.php";
}
function comment_link($comment, $return = 1) {
global $theme;
if ($return) return "lid#$comment->cid") ."\">type\">". t("return") ." | lid&pid=$comment->cid") ."\">type\">". t("reply to this comment") ."";
else return "lid&pid=$comment->cid") ."\">type\">". t("reply to this comment") ."";
}
function comment_view($comment, $folded = 0) {
global $theme;
// calculate comment's score:
$comment->score = comment_score($comment);
// display comment:
if ($folded) $theme->comment($comment, $folded);
else print "lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ." by ". format_username($comment->userid) ." ($comment->score)
";
}
function comment_thread_min($cid, $threshold) {
global $user;
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid");
print "
";
}
function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) {
global $user;
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid");
print "