diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-02-10 11:59:06 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-02-10 11:59:06 +0000 |
commit | d6ce51e4ce39c143732f69de9a5590428d6e3c6c (patch) | |
tree | b6f29b8ce560ed4fa57a66d925fe9c8dc8230bba /modules/comment/comment.module | |
parent | b26c49d3d8706278bc6adeadaff9544c74f0e025 (diff) | |
download | brdo-d6ce51e4ce39c143732f69de9a5590428d6e3c6c.tar.gz brdo-d6ce51e4ce39c143732f69de9a5590428d6e3c6c.tar.bz2 |
- added a "search framework" which allows for easy searching
(to be continued)
- tidyied up some existing code
Diffstat (limited to 'modules/comment/comment.module')
-rw-r--r-- | modules/comment/comment.module | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index bd6594dbc..f97728e7a 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -4,14 +4,21 @@ $module = array("find" => "comment_find", "admin" => "comment_admin"); function comment_find($keys) { + global $user; $find = array(); $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%". check_input($keys) ."%' OR c.comment LIKE '%". check_input($keys) ."%' ORDER BY c.timestamp DESC LIMIT 20"); while ($comment = db_fetch_object($result)) { - array_push($find, array("subject" => check_output($comment->subject), "link" => "story.php?id=$comment->lid&cid=$comment->cid", "user" => $story->userid, "date" => $comment->timestamp)); + array_push($find, array("subject" => check_output($comment->subject), "link" => (user_permission($user) ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "story.php?id=$comment->lid&cid=$comment->cid"), "user" => $story->userid, "date" => $comment->timestamp)); } return $find; } +function comment_search() { + global $keys, $mod; + search_form($keys); + search_data($keys, $mod); +} + function comment_edit($id) { $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = $id"); @@ -21,7 +28,7 @@ function comment_edit($id) { $output .= "<P>\n"; $output .= " <B>Author:</B><BR>\n"; - $output .= " ". format_username($comment->userid, 1) ."\n"; + $output .= " ". format_username($comment->userid) ."\n"; $output .= "</P>\n"; $output .= "<P>\n"; @@ -76,7 +83,7 @@ function comment_display($order = "date") { $output .= " </TR>\n"; while ($comment = db_fetch_object($result)) { - $output .= " <TR><TD>". ($comment->link == "story" ? "<A HREF=\"story.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>" : check_output($comment->subject)) ."</TD><TD>". format_username($comment->userid, 1) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit</A></TD></TR>\n"; + $output .= " <TR><TD>". ($comment->link == "story" ? "<A HREF=\"story.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>" : check_output($comment->subject)) ."</TD><TD>". format_username($comment->userid) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit</A></TD></TR>\n"; } $output .= "</TABLE>\n"; @@ -87,10 +94,15 @@ function comment_display($order = "date") { function comment_admin() { global $op, $id, $subject, $comment, $order; + print "<SMALL><A HREF=\"admin.php?mod=comment\">overview</A> | <A HREF=\"admin.php?mod=comment&op=search\">search comment</A></SMALL><HR>\n"; + switch ($op) { case "edit": comment_edit($id); break; + case "search": + comment_search(); + break; case "Save comment": comment_save($id, $subject, $comment); comment_edit($id); |