check_output($comment->subject), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp); } return $find; } function comment_perm() { return array("access comments", "post comments", "administer comments"); } function comment_link($type, $node = 0, $main = 0) { if ($type == "admin" and user_access("administer comments")) { $links[] = "comments"; } if ($type == "node" && $node->comment) { if ($main) { /* ** Main page: display the number of comments that have been posted. */ if (user_access("access comments")) { $links[] = "nid#comment\">". format_plural(node_get_comments($node->nid), "comment", "comments") .""; } } else { /* ** Node page: add a "post comment" link if the user is allowed to ** post comments. */ if (user_access("post comments")) { $links[] = "nid&op=comment#comment\">". t("add new comment") .""; } } } return $links ? $links : array(); } function comment_node_link($node) { /* ** Edit comments: */ $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE lid = '$node->nid' ORDER BY c.timestamp"); $output .= "

". t("Edit comments") ."

"; $output .= ""; $output .= " "; while ($comment = db_fetch_object($result)) { $output .= ""; } $output .= "
titleauthoroperations
nid&cid=$comment->cid#$comment->cid\">$comment->subject". format_name($comment) ."nid&cid=$comment->cid#$comment->cid\">". t("view comment") ."cid\">". t("edit comment") ."cid\">". t("delete comment") ."
"; return $output; } function comment_edit($id) { $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$id'"); $comment = db_fetch_object($result); $form .= form_item(t("Author"), format_name($comment)); $form .= form_textfield(t("Subject"), "subject", $comment->subject, 70, 128); $form .= form_textarea(t("Comment"), "comment", $comment->comment, 70, 15); $form .= form_submit(t("Submit")); return form($form); } function comment_save($id, $edit) { db_query("UPDATE comments SET subject = '". check_input(filter($edit[subject])) ."', comment = '". check_input(filter($edit[comment])) ."' WHERE cid = '$id'"); watchdog("special", "comment: modified '$edit[subject]'"); } function comment_overview() { $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN users u ON u.uid = c.uid ORDER BY timestamp DESC LIMIT 50"); $output .= "\n"; $output .= " \n"; while ($comment = db_fetch_object($result)) { $output .= " \n"; } $output .= "
subjectauthordateoperations
lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."". format_name($comment) ."". format_date($comment->timestamp, "small") ."cid\">edit commentcid\">delete comment
\n"; return $output; } function comment_delete($id) { db_query("DELETE FROM comments WHERE cid = '$id'"); db_query("DELETE FROM moderate WHERE cid = '$id'"); watchdog("special", "comment: deleted '$id'"); } function comment_admin() { global $op, $id, $edit, $mod, $keys, $order; if (user_access("administer comments")) { print "overview | search comment
\n"; switch ($op) { case "edit": print comment_edit($id); break; case "search": print search_type("comment", "admin.php?mod=comment&op=search"); break; case "delete": print comment_delete(check_query($id)); print comment_overview(); break; case t("Submit"): print status(comment_save(check_query($id), $edit)); print comment_overview(); break; default: print comment_overview(); } } else { print message_access(); } } ?>