From 7a45d84a9f9458387bf4f57ac5a520f31c1604ab Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 14 Dec 2000 14:13:37 +0000 Subject: - added a whole bunch of NEW modules --- modules/story/story.module | 127 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 modules/story/story.module (limited to 'modules/story/story.module') diff --git a/modules/story/story.module b/modules/story/story.module new file mode 100644 index 000000000..172cdfdcb --- /dev/null +++ b/modules/story/story.module @@ -0,0 +1,127 @@ + "story_admin"); + +function story_edit($id) { + global $categories; + + $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id"); + $story = db_fetch_object($result); + + $output .= "
\n"; + + $output .= "

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

\n"; + + $output .= "

\n"; + $output .= " Subject:
\n"; + $output .= " subject)) ."\">
\n"; + $output .= "

\n"; + + $output .= "

Category:
\n"; + $output .= " \n"; + $output .= "

\n"; + + $output .= "

\n"; + $output .= "Abstract:
\n"; + $output .= "
\n"; + $output .= "

\n"; + + $output .= "

\n"; + $output .= "Editor's note/updates:
\n"; + $output .= "
\n"; + $output .= "

\n"; + + $output .= "

\n"; + $output .= " Extended story:
\n"; + $output .= "
\n"; + $output .= "

\n"; + + $output .= "

Status:
\n"; + $output .= " \n"; + $output .= "

\n"; + + $output .= "

\n"; + $output .= " \n"; + $output .= "

\n"; + $output .= "
\n"; + + print $output; +} + +function story_save($id, $subject, $abstract, $updates, $article, $category, $status) { + db_query("UPDATE stories SET subject = '". check_input($subject) ."', abstract = '". check_input($abstract) ."', updates = '". check_input($updates) ."', article = '". check_input($article) ."', category = '". check_input($category) ."', status = '$status' WHERE id = $id"); + watchdog("message", "modified story `$subject'."); +} + +function story_display($order = "date") { + ### Initialize variables: + $status = array("deleted", "pending", "public"); + $fields = array("author" => "author", "category" => "category", "date" => "timestamp DESC", "status" => "status DESC"); + + ### Perform SQL query: + $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author ORDER BY s.$fields[$order]"); + + ### Display stories: + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + + while ($story = db_fetch_object($result)) { + $output .= " \n"; + } + + $output .= "
\n"; + $output .= "
\n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
\n"; + $output .= "
subjectauthorcategorystatusoperations
id\">". check_output($story->subject) ."". format_username($story->userid, 1) ."$story->category". $status[$story->status] ."id\">edit
\n"; + + print $output; +} + +function story_admin() { + global $op, $id, $subject, $abstract, $updates, $article, $category, $status, $order; + switch ($op) { + case "edit": + story_edit($id); + break; + case "Save story": + story_save($id, $subject, $abstract, $updates, $article, $category, $status); + story_edit($id); + break; + case "Update": + story_display($order); + break; + default: + story_display(); + } +} + +?> \ No newline at end of file -- cgit v1.2.3