2001-03-10 11:07:52 +00:00
<?php
2000-12-14 14:13:37 +00:00
2001-02-07 22:01:57 +00:00
function comment_find($keys) {
2001-02-10 11:59:06 +00:00
global $user;
2001-02-07 22:01:57 +00:00
$find = array();
2001-03-07 21:29:40 +00:00
$result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
2001-02-07 22:01:57 +00:00
while ($comment = db_fetch_object($result)) {
2001-03-25 16:56:37 +00:00
array_push($find, array("title" => check_output($comment->subject), "link" => (user_access($user, "comment") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->userid, "date" => $comment->timestamp));
2001-02-07 22:01:57 +00:00
}
return $find;
}
2000-12-14 14:13:37 +00:00
function comment_edit($id) {
2001-05-02 20:52:19 +00:00
global $REQUEST_URI;
2001-03-07 21:29:40 +00:00
$result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'");
2000-12-14 14:13:37 +00:00
$comment = db_fetch_object($result);
2001-04-30 17:13:08 +00:00
$form .= form_item(t("Author"), format_username($comment->userid));
$form .= form_textfield(t("Subject"), "subject", $comment->subject, 50, 128);
$form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10);
2001-05-03 18:48:42 +00:00
$form .= form_submit(t("Submit"));
2000-12-14 14:13:37 +00:00
2001-05-02 20:52:19 +00:00
return form($REQUEST_URI, $form);
2000-12-14 14:13:37 +00:00
}
2001-04-30 17:13:08 +00:00
function comment_save($id, $edit) {
db_query("UPDATE comments SET subject = '". check_input($edit[subject]) ."', comment = '". check_input($edit[comment]) ."' WHERE cid = '$id'");
watchdog("message", "comment: modified '$edit[subject]'");
2000-12-14 14:13:37 +00:00
}
2001-05-02 20:52:19 +00:00
function comment_overview() {
2001-04-30 17:13:08 +00:00
$result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY timestamp DESC LIMIT 50");
2001-01-26 13:38:46 +00:00
2000-12-29 11:00:56 +00:00
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
2001-04-30 17:13:08 +00:00
$output .= " <TR><TH>subject</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
2000-12-14 14:13:37 +00:00
while ($comment = db_fetch_object($result)) {
2001-04-30 17:13:08 +00:00
$output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n";
2000-12-14 14:13:37 +00:00
}
$output .= "</TABLE>\n";
2001-01-26 13:38:46 +00:00
2001-04-30 17:13:08 +00:00
return $output;
2000-12-14 14:13:37 +00:00
}
function comment_admin() {
2001-04-30 17:13:08 +00:00
global $op, $id, $edit, $mod, $keys, $order;
2000-12-14 14:13:37 +00:00
2001-02-10 11:59:06 +00:00
print "<SMALL><A HREF=\"admin.php?mod=comment\">overview</A> | <A HREF=\"admin.php?mod=comment&op=search\">search comment</A></SMALL><HR>\n";
2000-12-14 14:13:37 +00:00
switch ($op) {
case "edit":
2001-04-30 17:13:08 +00:00
print comment_edit($id);
2000-12-14 14:13:37 +00:00
break;
2001-02-10 11:59:06 +00:00
case "search":
2001-04-04 21:09:24 +00:00
print search_form($keys);
print search_data($keys, $mod);
2001-02-10 11:59:06 +00:00
break;
2001-05-03 18:48:42 +00:00
case t("Submit"):
2001-04-30 17:13:08 +00:00
print status(comment_save(check_input($id), $edit));
2001-05-02 20:52:19 +00:00
print comment_overview();
2000-12-14 14:13:37 +00:00
break;
default:
2001-05-02 20:52:19 +00:00
print comment_overview();
2000-12-14 14:13:37 +00:00
}
}
?>