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/story.module | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'modules/story.module') diff --git a/modules/story.module b/modules/story.module index e71f74bba..4a199951b 100644 --- a/modules/story.module +++ b/modules/story.module @@ -16,14 +16,21 @@ function story_cron() { } function story_find($keys) { + global $user; $find = array(); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.status = 2 AND (s.subject LIKE '%". check_input($keys) ."%' OR s.abstract LIKE '%". check_input($keys) ."%' OR s.article LIKE '%". check_input($keys) ."%') ORDER BY s.timestamp DESC LIMIT 20"); while ($story = db_fetch_object($result)) { - array_push($find, array("subject" => check_output($story->subject), "link" => "story.php?id=$story->id", "user" => $story->userid, "date" => $story->timestamp)); + array_push($find, array("subject" => check_output($story->subject), "link" => (user_permission($user) ? "admin.php?mod=story&op=edit&id=$story->id" : "story.php?id=$story->id"), "user" => $story->userid, "date" => $story->timestamp)); } return $find; } +function story_search() { + global $keys, $mod; + search_form($keys); + search_data($keys, $mod); +} + function story_help() { ?>

Scheduled stories: stories that are scheduled to be automatically published at a given date and time. Useful when you have to leave the site alone for a while or when you want to regulate the flow of new content.

@@ -187,28 +194,28 @@ function story_display() { $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 1 ORDER BY timestamp DESC"); $output .= " queued stories\n"; while ($story = db_fetch_object($result)) { - $output .= " id\">". check_output($story->subject) ."". format_username($story->userid, 1) ."votes: $story->votes, score: $story->scoreid\">edit\n"; + $output .= " id\">". check_output($story->subject) ."". format_username($story->userid) ."votes: $story->votes, score: $story->scoreid\">edit\n"; } // Scheduled stories: $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 3 ORDER BY timestamp"); $output .= " scheduled stories\n"; while ($story = db_fetch_object($result)) { - $output .= " id\">". check_output($story->subject) ."". format_username($story->userid, 1) ."". date("D, m/d/Y H:i", $story->timestamp) ." - ". format_interval($story->timestamp - time()) ." leftid\">edit\n"; + $output .= " id\">". check_output($story->subject) ."". format_username($story->userid) ."". date("D, m/d/Y H:i", $story->timestamp) ." - ". format_interval($story->timestamp - time()) ." leftid\">edit\n"; } // Dumped stories: $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 0 ORDER BY timestamp DESC LIMIT 5"); $output .= " dumped stories\n"; while ($story = db_fetch_object($result)) { - $output .= " id\">". check_output($story->subject) ."". format_username($story->userid, 1) ."$story->sectionid\">edit\n"; + $output .= " id\">". check_output($story->subject) ."". format_username($story->userid) ."$story->sectionid\">edit\n"; } // Posted stories: $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 2 ORDER BY timestamp DESC LIMIT 15"); $output .= " posted stories\n"; while ($story = db_fetch_object($result)) { - $output .= " id\">". check_output($story->subject) ."". format_username($story->userid, 1) ."$story->sectionid\">edit\n"; + $output .= " id\">". check_output($story->subject) ."". format_username($story->userid) ."$story->sectionid\">edit\n"; } $output .= "\n"; @@ -219,7 +226,7 @@ function story_display() { function story_admin() { global $op, $id, $edit; - print "add new story | overview | help
\n"; + print "add new story | overview | search story | help
\n"; switch ($op) { case "add": @@ -231,6 +238,9 @@ function story_admin() { case "help": story_help(); break; + case "search": + story_search(); + break; case "Add story": story_add_save($edit); story_display(); -- cgit v1.2.3