From d6ce51e4ce39c143732f69de9a5590428d6e3c6c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 10 Feb 2001 11:59:06 +0000 Subject: - added a "search framework" which allows for easy searching (to be continued) - tidyied up some existing code --- modules/comment/comment.module | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'modules/comment') 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 .= "

\n"; $output .= " Author:
\n"; - $output .= " ". format_username($comment->userid, 1) ."\n"; + $output .= " ". format_username($comment->userid) ."\n"; $output .= "

\n"; $output .= "

\n"; @@ -76,7 +83,7 @@ function comment_display($order = "date") { $output .= " \n"; while ($comment = db_fetch_object($result)) { - $output .= " ". ($comment->link == "story" ? "lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."" : check_output($comment->subject)) ."". format_username($comment->userid, 1) ."cid\">edit\n"; + $output .= " ". ($comment->link == "story" ? "lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."" : check_output($comment->subject)) ."". format_username($comment->userid) ."cid\">edit\n"; } $output .= "\n"; @@ -87,10 +94,15 @@ function comment_display($order = "date") { function comment_admin() { global $op, $id, $subject, $comment, $order; + print "overview | search comment


\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); -- cgit v1.2.3