From 805107cd2202ddee66c4743e43804a3069508f29 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 2 Apr 2001 15:54:37 +0000 Subject: Commiting my work of last Sunday: - removed ban.inc and ban.module and integrated it in account.module under the name "access control" --> the ban code was not really up to standard so this has now been dealt with. This refactoring and reintegration cuts down the code size with 100 lines too. :-) (The ban.module code was really old and it showed.) - added node.module and made the other modules reuse some of this code --> cut down the code size of modules by at least 100 lines and adds stability. - added a status() function to admin.php to display a conform status message where appropriate. See admin.php for usage. - removed $theme->control() and made comments.inc handle this itself wrapped in a $theme->box(). No need to clutter the themes with such complexity --> updated all themes already. :-) - some small visual changes to some administration pages to be more consistent across different modules. --- modules/story.module | 69 +++++----------------------------------------------- 1 file changed, 6 insertions(+), 63 deletions(-) (limited to 'modules/story.module') diff --git a/modules/story.module b/modules/story.module index 81f46be78..82254440b 100644 --- a/modules/story.module +++ b/modules/story.module @@ -1,7 +1,6 @@ "story_cron", - "help" => "story_help", +$module = array("help" => "story_help", "find" => "story_find", "user" => "story_user", "queue" => "story_queue", @@ -20,14 +19,6 @@ class Story { } } -function story_cron() { - global $status; - $result = db_query("SELECT * FROM node WHERE status = '$status[scheduled]' AND timestamp <= ". time() .""); - while ($story = db_fetch_object($result)) { - db_query("UPDATE node SET status = '$status[queued]', timestamp = '". time() ."' WHERE nid = '$story->nid' AND type = 'story'"); - } -} - function story_find($keys) { global $status, $user; $find = array(); @@ -46,7 +37,6 @@ function story_search() { 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.

Queued stories: user-contributed stories are automatically whisked away to a submission queue for moderators (i.e. registered user) to frown at. Moderators vote whether or not a story should be posted to the front page for discussion.

Posted stories: published stories accessible to all visitors.

Dumped stories: rejected stories that are no longer available to visitors.

@@ -107,7 +97,7 @@ function story_view($node, $page = 1) { } function story_form($edit = array()) { - global $allowed_html, $REQUEST_URI, $status, $theme, $user; + global $allowed_html, $REQUEST_URI, $user; $output .= "
\n"; @@ -131,13 +121,6 @@ function story_form($edit = array()) { $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; if (user_access($user, "story")) { - $output .= "". t("Status") .":
\n"; - $output .= " scheduled for
\n"; - $output .= " dumped
\n"; - $output .= " queued
\n"; - $output .= " posted
\n"; - $output .= "The textfield for scheduled stories expects a string containing an English date format of when you want to have your story automatically published. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ...

\n"; - $output .= "\n"; $output .= "\n"; } @@ -173,15 +156,9 @@ function story_form($edit = array()) { } function story_save($edit) { - global $status; - $edit[timestamp] = ($edit[status] == $status[scheduled] && strtotime($edit[timestamp]) > time()) ? strtotime($edit[timestamp]) : ($node[timestamp] ? $node[timestamp] : time()); node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "story")), array(userid => $edit[userid]))); } -function story_delete($id) { - return ($node = node_del("nid", $id) ? "story has been deleted" : "failed to delete story: change status to 'dumped' first"); -} - function story_block() { /* // @@ -213,41 +190,7 @@ function story_block() { } function story_overview() { - global $status; - - $output .= "\n"; - - // Queued stories: - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY timestamp DESC"); - $output .= " \n"; - while ($node = db_fetch_object($result)) { - $output .= " \n"; - } - - // Scheduled stories: - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[scheduled]' ORDER BY timestamp DESC"); - $output .= " \n"; - while ($node = db_fetch_object($result)) { - $output .= " \n"; - } - - // Dumped stories: - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY timestamp DESC LIMIT 5"); - $output .= " \n"; - while ($node = db_fetch_object($result)) { - $output .= " \n"; - } - - // Posted stories: - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY timestamp DESC LIMIT 15"); - $output .= " \n"; - while ($node = db_fetch_object($result)) { - $output .= " \n"; - } - - $output .= "
queued stories
nid\">". check_output($node->title) ."". format_username($node->userid) ."votes: $node->votes, score: $node->scorenid\">viewnid\">editnid\">delete
scheduled stories
nid\">". check_output($node->title) ."". format_username($node->userid) ."". format_date($node->timestamp, "small") ."
(". format_interval($node->timestamp - time()) ." left)
nid\">viewnid\">editnid\">delete
dumped stories
nid\">". check_output($node->title) ."". format_username($node->userid) ."". format_date($node->timestamp, "small") ."nid\">viewnid\">editnid\">delete
posted stories
nid\">". check_output($node->title) ."". format_username($node->userid) ."". format_date($node->timestamp, "small") ."nid\">viewnid\">editnid\">delete
\n"; - - print $output; + return node_overview("type = 'story'"); } function story_admin() { @@ -261,7 +204,7 @@ function story_admin() { break; case "delete": print story_delete($id); - story_overview(); + print story_overview(); break; case "edit": print story_form(node_get_array("nid", check_input($id))); @@ -278,10 +221,10 @@ function story_admin() { break; case t("Submit"): story_save($edit); - story_overview(); + print story_overview(); break; default: - story_overview(); + print story_overview(); } } -- cgit v1.2.3