From b9952f537d5f1a102e145b0529c78bc31a1509af Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 16 Apr 2001 11:38:12 +0000 Subject: Large commit, read it carefully, and make the required changes to your theme: - corrected some missing translations in story.module. Oops! - grealty simplified the "moderation threshold mechanism"(tm) so that module writers don't have to worry about this. As a result story.module and book.module became a bit smaller and easier to grasp. - greatly simplified new "category" and "topic" code which is soon going to replace the "section" code. Needs more work though so hang on thight. - includes/section.inc and modules/section.module are replaced by includes/structure.module and modules/structure.module. - beautified example.theme a bit without adding HTML complexity: it is a good example but still useful as a theme - made theme example use "categories" and "topics" --> TAKE A LOOK AT IT AND UPDATE YOUR THEME - made theme marvin use "categories" and "topics" --> TAKE A LOOK AT IT AND UPDATE YOUR THEME - added 2 new "story listings" to administrator interface of story.module to verify story integrity. - optimized comment table a bit (work in progress) --- modules/story/story.module | 80 +++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 48 deletions(-) (limited to 'modules/story/story.module') diff --git a/modules/story/story.module b/modules/story/story.module index 19448fcac..4667494fe 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -8,32 +8,21 @@ $module = array("help" => "story_help", "admin" => "story_admin", "block" => "story_block"); -include_once "includes/section.inc"; +include_once "includes/structure.inc"; class Story { - function Story($story, $category = 0, $topic = 0) { + function Story($story) { + global $user; $this->userid = $story[userid] ? $story[userid] : $user->userid; $this->title = $story[title]; $this->abstract = $story[abstract]; $this->body = $story[body]; $this->timestamp = $story[timestamp] ? $story[timestamp] : time(); - $this->category = ($category ? $category : node_get_category($story[nid])); - $this->topic = ($topic ? $topic : node_get_topic($story[nid])); + $this->cid = $story[cid]; + $this->tid = $story[tid]; } } -function story_post_threshold($node, $default) { - return section_post_threshold($node->section, $default); -} - -function story_dump_threshold($node, $default) { - return section_dump_threshold($node->section, $default); -} - -function story_timout_threshold($node, $default) { - return section_timout_threshold($node->section, $default); -} - function story_status() { return array(dumped, queued, posted); } @@ -61,7 +50,7 @@ function story_type() { } function story_view($node, $page = 1) { - global $id, $cid, $op, $moderate, $pid, $subject, $comment, $theme, $mode, $order, $threshold; + global $id, $cid, $op, $moderate, $pid, $subject, $comment, $theme, $mode, $order, $threshold, $PHP_SELF; if ($page == 1) { switch($op) { @@ -109,55 +98,51 @@ function story_view($node, $page = 1) { } } else { - $theme->story($node, "[ nid&pid=0\">". t("reply to this story") ." ]"); + $theme->story($node, ($PHP_SELF == "/node.php" ? "[ nid&pid=0\">". t("reply to this story") ." ]" : 0)); } } -function story_form($story = array()) { +function story_form($edit = array()) { global $allowed_html, $REQUEST_URI, $user; $output .= "
\n"; $output .= "". t("Your name") .":
\n"; - $output .= "\n"; - $output .= format_username(($story[userid] ? $story[userid] : $user->userid)) ."

"; + $output .= "\n"; + $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."

"; $output .= "". t("Subject") .":
\n"; - $output .= "

\n"; + $output .= "

\n"; - $output .= structure_form("story"); + $output .= structure_form("story", $edit); $output .= "". t("Abstract") .":
\n"; - $output .= "
\n"; + $output .= "
\n"; $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; $output .= "". t("Body") .":
\n"; - $output .= "
\n"; + $output .= "
\n"; $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; if (user_access($user, "story")) { - $output .= "\n"; - $output .= "\n"; + $output .= "\n"; + $output .= "\n"; } $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'")); - if (!$story) { + if (!$edit) { $output .= "\n"; } - else if (!$story[title]) { + else if (!$edit[title]) { $output .= "". t("Warning: you did not supply a subject.") ."

\n"; $output .= "\n"; } - else if (!$story[section]) { - $output .= "". t("Warning: you did not supply a section.") ."

\n"; - $output .= "\n"; - } - else if (!$story[abstract]) { + else if (!$edit[abstract]) { $output .= "". t("Warning: you did not supply an abstract.") ."

\n"; $output .= "\n"; } - else if (!$story[nid] && $duplicate) { + else if (!$edit[nid] && $duplicate) { $output .= "". t("Warning: there is already a story with that subject.") ."

\n"; $output .= "\n"; } @@ -170,9 +155,8 @@ function story_form($story = array()) { return $output; } -function story_save($story, $category, $topic) { - node_save(array_diff(array_merge($story, array(nid => $story[nid], type => "story")), array(userid => $story[userid]))); - structure_save($category, $topic); +function story_save($edit) { + node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "story")), array(userid => $edit[userid]))); } function story_block() { @@ -207,7 +191,7 @@ function story_block() { function story_query($type = "") { global $status; - $queries = array(array("recent stories", "WHERE n.type = 'story' ORDER BY n.timestamp DESC"), array("posted stories", "WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued stories", "WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped stories", "WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC")); + $queries = array(array("recent stories", "WHERE n.type = 'story' ORDER BY n.timestamp DESC"), array("posted stories", "WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued stories", "WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped stories", "WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"), array("stories without category (integrity)", "WHERE n.cid = '0' ORDER BY n.timestamp DESC"), array("stories without topic (integrity)", "WHERE n.tid = '0' ORDER BY n.timestamp DESC")); return ($queries[$type] ? $queries[$type] : $queries); } @@ -216,7 +200,7 @@ function story_overview($query = array()) { } function story_admin() { - global $id, $story, $category, $topic, $mod, $keys, $op, $theme, $type, $user; + global $id, $edit, $mod, $keys, $op, $theme, $type, $user; print "add new story | story listing | search story | overview | help


\n"; @@ -244,11 +228,11 @@ function story_admin() { print search_data($keys, $mod); break; case t("Preview"): - story_view(new Story($story, $category, $topic),0); - print story_form($story); + story_view(new Story($edit),0); + print story_form($edit); break; case t("Submit"): - story_save($story, $category, $topic); + story_save($edit); // fall through: default: print story_overview(story_query($type)); @@ -257,19 +241,19 @@ function story_admin() { function story_user() { - global $story, $category, $topic, $op, $theme, $user; + global $edit, $op, $theme, $user; switch($op) { case t("Preview"): - story_view(new Story($story, $category, $topic), 0); - $theme->box("Submit", story_form($story)); + story_view(new Story($edit), 0); + $theme->box(t("Submit"), story_form($edit)); break; case t("Submit"): - story_save($story, $category, $topic); + story_save($edit); $theme->box(t("Submit"), t("Thank you for your submission.")); break; default: - $theme->box("Submit", story_form()); + $theme->box(t("Submit"), story_form()); } } -- cgit v1.2.3