From d216096ede8bad94254a32435f828c915d632fb2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 1 Apr 2001 10:52:01 +0000 Subject: - simplified some of the node stuff: stories can no longer be scheduled -> this functionality will be made generic for all nodes --- modules/book.module | 8 +------- modules/book/book.module | 8 +------- modules/story.module | 45 ++++++++++++++++++--------------------------- modules/story/story.module | 45 ++++++++++++++++++--------------------------- 4 files changed, 38 insertions(+), 68 deletions(-) (limited to 'modules') diff --git a/modules/book.module b/modules/book.module index 6a094870a..04b0eb280 100644 --- a/modules/book.module +++ b/modules/book.module @@ -87,7 +87,7 @@ function book_toc($parent = 0, $offset = "", $toc = array()) { } function book_form($edit = array()) { - global $allowed_html, $PHP_SELF, $REQUEST_URI, $status, $theme, $user; + global $allowed_html, $PHP_SELF, $REQUEST_URI, $user; $output .= "
\n"; @@ -124,16 +124,10 @@ function book_form($edit = array()) { } if (user_access($user, "book")) { - $status = array_intersect($status, array(0, 2, 3)); - $output .= "". t("Weight") .":
\n"; for ($count = 0; $count < 25; $count++) $options3 .= ""; $output .= "
\n"; $output .= "". t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top.") ."

\n"; - - $output .= "". t("Status") .":
\n"; - foreach ($status as $value=>$key) $options4 .= ""; - $output .= "

\n"; } if (!$edit) { diff --git a/modules/book/book.module b/modules/book/book.module index 6a094870a..04b0eb280 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -87,7 +87,7 @@ function book_toc($parent = 0, $offset = "", $toc = array()) { } function book_form($edit = array()) { - global $allowed_html, $PHP_SELF, $REQUEST_URI, $status, $theme, $user; + global $allowed_html, $PHP_SELF, $REQUEST_URI, $user; $output .= "\n"; @@ -124,16 +124,10 @@ function book_form($edit = array()) { } if (user_access($user, "book")) { - $status = array_intersect($status, array(0, 2, 3)); - $output .= "". t("Weight") .":
\n"; for ($count = 0; $count < 25; $count++) $options3 .= ""; $output .= "
\n"; $output .= "". t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top.") ."

\n"; - - $output .= "". t("Status") .":
\n"; - foreach ($status as $value=>$key) $options4 .= ""; - $output .= "

\n"; } if (!$edit) { diff --git a/modules/story.module b/modules/story.module index 81f46be78..a2912b645 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.

@@ -111,37 +101,39 @@ function story_form($edit = array()) { $output .= "\n"; - $output .= "". t("Your name") .":
\n"; - $output .= "\n"; - $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."

"; + // nid: + $node = node_get_object("nid", $edit[nid]); + if ($node) $output .= "\n"; + + // author: + $output .= node_form_author($edit); - $output .= "". t("Subject") .":
\n"; - $output .= "

\n"; + // date: + if ($node) $output .= node_form_date($edit, array($node->timestamp, time())); + // subject: + $output .= node_form_title($edit); + + // section: $output .= "". t("Section") .":
\n"; foreach ($sections = section_get() as $value) $options .= " \n"; $output .= "

\n"; + // abstract: $output .= "". t("Abstract") .":
\n"; $output .= "
\n"; $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; + // body: $output .= "". t("Body") .":
\n"; $output .= "
\n"; $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"; + // status: + if (user_access($user, "story")) $output .= node_form_status($edit, array(dumped, queued, posted)); - $output .= "\n"; - $output .= "\n"; - } + // error checking: $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'")); if (!$edit) { @@ -174,7 +166,6 @@ 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]))); } diff --git a/modules/story/story.module b/modules/story/story.module index 81f46be78..a2912b645 100644 --- a/modules/story/story.module +++ b/modules/story/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.

@@ -111,37 +101,39 @@ function story_form($edit = array()) { $output .= "\n"; - $output .= "". t("Your name") .":
\n"; - $output .= "\n"; - $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."

"; + // nid: + $node = node_get_object("nid", $edit[nid]); + if ($node) $output .= "\n"; + + // author: + $output .= node_form_author($edit); - $output .= "". t("Subject") .":
\n"; - $output .= "

\n"; + // date: + if ($node) $output .= node_form_date($edit, array($node->timestamp, time())); + // subject: + $output .= node_form_title($edit); + + // section: $output .= "". t("Section") .":
\n"; foreach ($sections = section_get() as $value) $options .= " \n"; $output .= "

\n"; + // abstract: $output .= "". t("Abstract") .":
\n"; $output .= "
\n"; $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; + // body: $output .= "". t("Body") .":
\n"; $output .= "
\n"; $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"; + // status: + if (user_access($user, "story")) $output .= node_form_status($edit, array(dumped, queued, posted)); - $output .= "\n"; - $output .= "\n"; - } + // error checking: $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'")); if (!$edit) { @@ -174,7 +166,6 @@ 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]))); } -- cgit v1.2.3