summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-04-01 10:52:01 +0000
committerDries Buytaert <dries@buytaert.net>2001-04-01 10:52:01 +0000
commitd216096ede8bad94254a32435f828c915d632fb2 (patch)
tree824487e806469e3fdca8171c55ea181d329e3705
parentce5a005d9e9fd47dfb27aec89ed00aaa95c3ce3a (diff)
downloadbrdo-d216096ede8bad94254a32435f828c915d632fb2.tar.gz
brdo-d216096ede8bad94254a32435f828c915d632fb2.tar.bz2
- simplified some of the node stuff:
stories can no longer be scheduled -> this functionality will be made generic for all nodes
-rw-r--r--includes/node.inc2
-rw-r--r--modules/book.module8
-rw-r--r--modules/book/book.module8
-rw-r--r--modules/story.module45
-rw-r--r--modules/story/story.module45
5 files changed, 39 insertions, 69 deletions
diff --git a/includes/node.inc b/includes/node.inc
index 468b8f2e1..8afed3ecc 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -1,6 +1,6 @@
<?php
-$status = array(dumped => 0, expired => 1, queued => 2, posted => 3, scheduled => 4);
+$status = array(dumped => 0, expired => 1, queued => 2, posted => 3);
function _node_get($field, $value) {
$result = db_query("SELECT lid, type FROM node WHERE $field = '$value'");
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 .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
@@ -124,16 +124,10 @@ function book_form($edit = array()) {
}
if (user_access($user, "book")) {
- $status = array_intersect($status, array(0, 2, 3));
-
$output .= "<B>". t("Weight") .":</B><BR>\n";
for ($count = 0; $count < 25; $count++) $options3 .= "<OPTION VALUE=\"$count\"". ($edit[weight] == $count ? " SELECTED" : "") .">$count</OPTION>";
$output .= "<SELECT NAME=\"edit[weight]\">$options3</SELECT><BR>\n";
$output .= "<SMALL><I>". t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top.") ."</I></SMALL><P>\n";
-
- $output .= "<B>". t("Status") .":</B><BR>\n";
- foreach ($status as $value=>$key) $options4 .= "<OPTION VALUE=\"$key\"". ($edit[status] == $key ? " SELECTED" : "") .">$value</OPTION>";
- $output .= "<SELECT NAME=\"edit[status]\">$options4</SELECT><P>\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 .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
@@ -124,16 +124,10 @@ function book_form($edit = array()) {
}
if (user_access($user, "book")) {
- $status = array_intersect($status, array(0, 2, 3));
-
$output .= "<B>". t("Weight") .":</B><BR>\n";
for ($count = 0; $count < 25; $count++) $options3 .= "<OPTION VALUE=\"$count\"". ($edit[weight] == $count ? " SELECTED" : "") .">$count</OPTION>";
$output .= "<SELECT NAME=\"edit[weight]\">$options3</SELECT><BR>\n";
$output .= "<SMALL><I>". t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top.") ."</I></SMALL><P>\n";
-
- $output .= "<B>". t("Status") .":</B><BR>\n";
- foreach ($status as $value=>$key) $options4 .= "<OPTION VALUE=\"$key\"". ($edit[status] == $key ? " SELECTED" : "") .">$value</OPTION>";
- $output .= "<SELECT NAME=\"edit[status]\">$options4</SELECT><P>\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 @@
<?php
-$module = array("cron" => "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() {
?>
- <P>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.</P>
<P>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.</P>
<P>Posted stories: published stories accessible to all visitors.</P>
<P>Dumped stories: rejected stories that are no longer available to visitors.</P>
@@ -111,37 +101,39 @@ function story_form($edit = array()) {
$output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
- $output .= "<B>". t("Your name") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[userid]\" VALUE=\"$edit[userid]\">\n";
- $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."<P>";
+ // nid:
+ $node = node_get_object("nid", $edit[nid]);
+ if ($node) $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
+
+ // author:
+ $output .= node_form_author($edit);
- $output .= "<B>". t("Subject") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"text\" NAME=\"edit[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n";
+ // date:
+ if ($node) $output .= node_form_date($edit, array($node->timestamp, time()));
+ // subject:
+ $output .= node_form_title($edit);
+
+ // section:
$output .= "<B>". t("Section") .":</B><BR>\n";
foreach ($sections = section_get() as $value) $options .= " <OPTION VALUE=\"". check_select($value) ."\"". ($edit[section] == $value ? " SELECTED" : "") .">". check_output($value) ."</OPTION>\n";
$output .= "<SELECT NAME=\"edit[section]\">$options</SELECT><P>\n";
+ // abstract:
$output .= "<B>". t("Abstract") .":</B><BR>\n";
$output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"edit[abstract]\">". check_textarea($edit[abstract]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
+ // body:
$output .= "<B>". t("Body") .":</B><BR>\n";
$output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"edit[body]\">". check_textarea($edit[body]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
- if (user_access($user, "story")) {
- $output .= "<B>". t("Status") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"radio\" NAME=\"edit[status]\" VALUE=\"$status[scheduled]\"". ($edit[status] == $status[scheduled] ? " CHECKED" : "") ."> scheduled for <INPUT TYPE=\"text\" NAME=\"edit[timestamp]\" SIZE=\"30\" VALUE=\"". date("j F Y G:i", ($edit[timetsamp] ? $edit[timestamp] : time())) ."\"><BR>\n";
- $output .= "<INPUT TYPE=\"radio\" NAME=\"edit[status]\" VALUE=\"$status[dumped]\"". ($edit[status] == $status[dumped] ? " CHECKED" : "") ."> dumped<BR>\n";
- $output .= "<INPUT TYPE=\"radio\" NAME=\"edit[status]\" VALUE=\"$status[queued]\"". ($edit[status] == $status[queued] ? " CHECKED" : "") ."> queued<BR>\n";
- $output .= "<INPUT TYPE=\"radio\" NAME=\"edit[status]\" VALUE=\"$status[posted]\"". ($edit[status] == $status[posted] ? " CHECKED" : "") ."> posted<BR>\n";
- $output .= "<SMALL><I>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") ."', ...</I></SMALL><P>\n";
+ // status:
+ if (user_access($user, "story")) $output .= node_form_status($edit, array(dumped, queued, posted));
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[timestamp]\" VALUE=\"$edit[timestamp]\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\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 @@
<?php
-$module = array("cron" => "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() {
?>
- <P>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.</P>
<P>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.</P>
<P>Posted stories: published stories accessible to all visitors.</P>
<P>Dumped stories: rejected stories that are no longer available to visitors.</P>
@@ -111,37 +101,39 @@ function story_form($edit = array()) {
$output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
- $output .= "<B>". t("Your name") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[userid]\" VALUE=\"$edit[userid]\">\n";
- $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."<P>";
+ // nid:
+ $node = node_get_object("nid", $edit[nid]);
+ if ($node) $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
+
+ // author:
+ $output .= node_form_author($edit);
- $output .= "<B>". t("Subject") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"text\" NAME=\"edit[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n";
+ // date:
+ if ($node) $output .= node_form_date($edit, array($node->timestamp, time()));
+ // subject:
+ $output .= node_form_title($edit);
+
+ // section:
$output .= "<B>". t("Section") .":</B><BR>\n";
foreach ($sections = section_get() as $value) $options .= " <OPTION VALUE=\"". check_select($value) ."\"". ($edit[section] == $value ? " SELECTED" : "") .">". check_output($value) ."</OPTION>\n";
$output .= "<SELECT NAME=\"edit[section]\">$options</SELECT><P>\n";
+ // abstract:
$output .= "<B>". t("Abstract") .":</B><BR>\n";
$output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"edit[abstract]\">". check_textarea($edit[abstract]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
+ // body:
$output .= "<B>". t("Body") .":</B><BR>\n";
$output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"edit[body]\">". check_textarea($edit[body]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
- if (user_access($user, "story")) {
- $output .= "<B>". t("Status") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"radio\" NAME=\"edit[status]\" VALUE=\"$status[scheduled]\"". ($edit[status] == $status[scheduled] ? " CHECKED" : "") ."> scheduled for <INPUT TYPE=\"text\" NAME=\"edit[timestamp]\" SIZE=\"30\" VALUE=\"". date("j F Y G:i", ($edit[timetsamp] ? $edit[timestamp] : time())) ."\"><BR>\n";
- $output .= "<INPUT TYPE=\"radio\" NAME=\"edit[status]\" VALUE=\"$status[dumped]\"". ($edit[status] == $status[dumped] ? " CHECKED" : "") ."> dumped<BR>\n";
- $output .= "<INPUT TYPE=\"radio\" NAME=\"edit[status]\" VALUE=\"$status[queued]\"". ($edit[status] == $status[queued] ? " CHECKED" : "") ."> queued<BR>\n";
- $output .= "<INPUT TYPE=\"radio\" NAME=\"edit[status]\" VALUE=\"$status[posted]\"". ($edit[status] == $status[posted] ? " CHECKED" : "") ."> posted<BR>\n";
- $output .= "<SMALL><I>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") ."', ...</I></SMALL><P>\n";
+ // status:
+ if (user_access($user, "story")) $output .= node_form_status($edit, array(dumped, queued, posted));
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[timestamp]\" VALUE=\"$edit[timestamp]\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\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])));
}