diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-11-01 11:00:51 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-11-01 11:00:51 +0000 |
commit | 336b713a5f1807d9f144fb2dc375bbc8479ffa5d (patch) | |
tree | 8a80bd1ee4ea3b7f6a851f47d2f021edf738f10a /modules/story.module | |
parent | aafedfb367b2b2ec18b1bc30beb309cc3fae0858 (diff) | |
download | brdo-336b713a5f1807d9f144fb2dc375bbc8479ffa5d.tar.gz brdo-336b713a5f1807d9f144fb2dc375bbc8479ffa5d.tar.bz2 |
- A large batch of updates, amongst them a rewritten node system. More
information available on the mailing list.
Diffstat (limited to 'modules/story.module')
-rw-r--r-- | modules/story.module | 104 |
1 files changed, 17 insertions, 87 deletions
diff --git a/modules/story.module b/modules/story.module index 3753bbc9c..91bb9ef81 100644 --- a/modules/story.module +++ b/modules/story.module @@ -1,27 +1,6 @@ <?php // $Id$ -class Story { - function Story($story) { - $this = new Node($story); - $this->abstract = $story[abstract]; - $this->body = $story[body]; - } -} - -function story_status() { - return array(dumped, queued, posted); -} - -function story_search($keys) { - global $PHP_SELF, $status; - $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20"); - while ($story = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($story->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp); - } - return $find; -} - function story_help() { ?> <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> @@ -30,78 +9,29 @@ function story_help() { <?php } -function story_summary($node) { - return $node->abstract; -} - -function story_view($node, $main = 0) { - global $theme; - $node->body = ((!$main) && ($node->body)) ? "$node->abstract<HR>$node->body" : $node->abstract; - $theme->node($node, $main); -} - -function story_form($edit = array()) { - global $user; - - if ($edit[title]) { - story_view(new Story(node_preview($edit))); - } +function story_form($node) { - $form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous")))); - $form .= form_hidden("name", $edit[name]); - $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); - $form .= node_attributes_edit("story", $edit); - $form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); - $form .= form_textarea(t("Body"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); + $output = form_textarea(t("Body"), "body", $node->body, 60, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); - if ($edit[nid] > 0) { - $form .= form_hidden("nid", $edit[nid]); - } - - if (!$edit) { - $form .= form_submit(t("Preview")); - } - else if ($edit && !$edit[title]) { - $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n"; - $form .= form_submit(t("Preview")); - } - else if ($edit && !$edit[abstract]) { - $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n"; - $form .= form_submit(t("Preview")); - } - else { - $form .= form_submit(t("Preview")); - $form .= form_submit(t("Submit")); - } - - return form($form); + return $output; } -function story_save($edit) { - global $status, $user; - - if (!$edit[nid]) { - node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), uid => $user->uid, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0)); +function story_save($node) { + if ($node->nid) { + if (user_access("administer nodes")) { + return array(); + } + else { + return 0; + } } - else if (user_access("administer nodes")) { - node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story")); + else { + /* + ** By default, stories get promoted to the front page and they are + ** subject to moderation. + */ + return array("promote" => 1, "moderate" => 1); } } -function story_user() { - global $edit, $op, $theme; - - switch($op) { - case t("Preview"): - $theme->box(t("Submit"), story_form($edit)); - break; - case t("Submit"): - story_save($edit); - $theme->box(t("Submit"), t("Thank you for your submission.")); - break; - default: - $theme->box(t("Submit"), story_form()); - } -} -
?> |