diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-04-16 11:38:12 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-04-16 11:38:12 +0000 |
commit | b9952f537d5f1a102e145b0529c78bc31a1509af (patch) | |
tree | 51f6a0ab5c46bd4643c5b2ac0579a4a411e45977 /modules | |
parent | 49a7dccb64a239097d44e235b525708c6a39d29e (diff) | |
download | brdo-b9952f537d5f1a102e145b0529c78bc31a1509af.tar.gz brdo-b9952f537d5f1a102e145b0529c78bc31a1509af.tar.bz2 |
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)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/book.module | 12 | ||||
-rw-r--r-- | modules/book/book.module | 12 | ||||
-rw-r--r-- | modules/moderation.module | 2 | ||||
-rw-r--r-- | modules/section.module | 137 | ||||
-rw-r--r-- | modules/story.module | 80 | ||||
-rw-r--r-- | modules/story/story.module | 80 | ||||
-rw-r--r-- | modules/structure.module | 26 |
7 files changed, 78 insertions, 271 deletions
diff --git a/modules/book.module b/modules/book.module index 6c4ce6a8a..1924072ec 100644 --- a/modules/book.module +++ b/modules/book.module @@ -19,18 +19,6 @@ class Book { } } -function book_post_threshold($node, $default) { - return $default; -} - -function book_dump_threshold($node, $default) { - return $default; -} - -function book_timout_threshold($node, $default) { - return $default; -} - function book_status() { return array(dumped, expired, queued, posted); } diff --git a/modules/book/book.module b/modules/book/book.module index 6c4ce6a8a..1924072ec 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -19,18 +19,6 @@ class Book { } } -function book_post_threshold($node, $default) { - return $default; -} - -function book_dump_threshold($node, $default) { - return $default; -} - -function book_timout_threshold($node, $default) { - return $default; -} - function book_status() { return array(dumped, expired, queued, posted); } diff --git a/modules/moderation.module b/modules/moderation.module index ac193c166..75a6df1b8 100644 --- a/modules/moderation.module +++ b/modules/moderation.module @@ -47,7 +47,7 @@ function moderation_vote($id, $vote) { node_save(array(nid => $id, status => $status[dumped])); watchdog("message", "node: dumped '$node->title' - moderation"); } - else if (variable_get("timout_threshold", 8, $node) <= $node->votes) { + else if (variable_get("expire_threshold", 8, $node) <= $node->votes) { node_save(array(nid => $id, status => $status[expired])); watchdog("message", "node: expired '$node->title' - moderation"); } diff --git a/modules/section.module b/modules/section.module deleted file mode 100644 index 9b42e46d1..000000000 --- a/modules/section.module +++ /dev/null @@ -1,137 +0,0 @@ -<?php - -$module = array("help" => "section_help", - "block" => "section_block", - "admin" => "section_admin"); - -// global variables: -$_section = array("status" => array(2 => "enabled: always", 1 => "enabled: custom", 0 => "disabled"), - "timout" => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100), - "post" => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100), - "dump" => array(-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -20, -25, -30)); - -function section_help() { - ?> - <P>When submitting new stories, every story is assigned a section or category. Sections can be maintained from the administration pages.</P> - <P>For moderation purpose, you can specify a post, dump and expiration thresholds for each available section according to type and urgency level of a section. This is useful considering the fact that some sections do not really "expire" and stay interesting and active as time passes by, whereas news-related stories are only considered "hot" over a short period of time.</P> - <?php -} - -function section_block() { - $result = db_query("SELECT se.name, COUNT(st.nid) AS stories FROM sections se LEFT JOIN story st ON se.name = st.section GROUP BY se.name"); - while ($_section = db_fetch_object($result)) { - $content .= "<LI><A HREF=\"?section=". urlencode($_section->name) ."\">$_section->name</A> (". check_output($_section->stories, 0) .")</LI>\n"; - } - - $block[0][subject] = "Sections"; - $block[0][content] = $content; - $block[0][info] = "Section list"; - - return $block; -} - -function section_add() { - global $_section; - - $output .= " <FORM ACTION=\"admin.php?mod=section\" METHOD=\"post\">\n"; - $output .= " <P>\n"; - $output .= " <B>Section name:</B><BR>\n"; - $output .= " <INPUT TYPE=\"text\" NAME=\"edit[name]\" SIZE=\"50\">\n"; - $output .= " </P>\n"; - $output .= " <P>\n"; - $output .= " <B>Post threshold:</B><BR>\n"; - $output .= " <SELECT NAME=\"edit[post]\">\n"; - foreach ($_section[post] as $value) $output .= "<OPTION VALUE=\"$value\">". format_plural($value, "point", "points") ."</OPTION>\n"; - $output .= " </SELECT>\n"; - $output .= " </P>\n"; - $output .= " <P>\n"; - $output .= " <B>Dump threshold:</B><BR>\n"; - $output .= " <SELECT NAME=\"edit[dump]\">\n"; - foreach ($_section[dump] as $value) $output .= "<OPTION VALUE=\"$value\">". format_plural($value, "point", "points") ."</OPTION>\n"; - $output .= " </SELECT>\n"; - $output .= " </P>\n"; - $output .= " <P>\n"; - $output .= " <B>Timout threshold:</B><BR>\n"; - $output .= " <SELECT NAME=\"edit[timout]\">\n"; - foreach ($_section[timout] as $value) $output .= "<OPTION VALUE=\"$value\">". format_plural($value, "vote", "votes") ."</OPTION>\n"; - $output .= " </SELECT>\n"; - $output .= " </P>\n"; - $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Add section\">\n"; - $output .= " </FORM>\n"; - - print $output; -} - -function section_add_save($edit) { - db_query("INSERT INTO sections (name, post, dump, timout) VALUES ('". check_input($edit[name]) ."', '". check_input($edit[post]) ."', '". check_input($edit[dump]) ."', '". check_input($edit[timout]) ."')"); -} - -function section_delete($name) { - db_query("DELETE FROM sections WHERE name = '$name'"); -} - -function section_display() { - global $_section; - - $status = $_section[status]; - $timout = $_section[timout]; - $post = $_section[post]; - $dump = $_section[dump]; - - // Perform query: - $result = db_query("SELECT * FROM sections ORDER BY name"); - - // Generate output: - $output .= "<FORM ACTION=\"admin.php?mod=section\" METHOD=\"post\">\n"; - $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>section name</TH><TH>status</TH><TH>post threshold</TH><TH>dump threshold</TH><TH>expiration threshold<TH>operations</TH></TR>\n"; - while ($_section = db_fetch_object($result)) { - foreach ($status as $key=>$value) $options0 .= "<OPTION VALUE=\"$key\"". (($_section->status == $key) ? " SELECTED" : "") .">$value</OPTION>\n"; - foreach ($post as $value) $options1 .= "<OPTION VALUE=\"$value\"". (($_section->post == $value) ? " SELECTED" : "") .">". format_plural($value, "point", "points") ."</OPTION>\n"; - foreach ($dump as $value) $options2 .= "<OPTION VALUE=\"$value\"". (($_section->dump == $value) ? " SELECTED" : "") .">". format_plural($value, "point", "points") ."</OPTION>\n"; - foreach ($timout as $value) $options3 .= "<OPTION VALUE=\"$value\"". (($_section->timout == $value) ? " SELECTED" : "") .">". format_plural($value, "vote", "votes") ."</OPTION>\n"; - $output .= " <TR><TD>". check_output($_section->name) ."</TD><TD><SELECT NAME=\"edit[$_section->name][status]\">$options0</SELECT></TD><TD><SELECT NAME=\"edit[$_section->name][post]\">$options1</SELECT></TD><TD><SELECT NAME=\"edit[$_section->name][dump]\">$options2</SELECT></TD><TD><SELECT NAME=\"edit[$_section->name][timout]\">$options3</SELECT></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=section&op=delete&name=". urlencode($_section->name) ."\">delete</A></TD></TR>\n"; - unset($options0); unset($options1); unset($options2); unset($options3); - } - $output .= "</TABLE>\n"; - $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save sections\">\n"; - $output .= "</FORM>\n"; - - print $output; -} - -function section_display_save($edit) { - foreach ($edit as $key=>$value) { - db_query("UPDATE sections SET status = '". check_input($value[status]) ."', post = '". check_input($value[post]) ."', dump = '". check_input($value[dump]) ."', timout = '". check_input($value[timout]) ."' WHERE name = '". check_input($key) ."'"); - } -} - -function section_admin() { - global $op, $edit, $name; - - print "<SMALL><A HREF=\"admin.php?mod=section&op=add\">add new section</A> | <A HREF=\"admin.php?mod=section\">overview</A> | <A HREF=\"admin.php?mod=section&op=help\">help</A></SMALL><HR>\n"; - - switch($op) { - case "add": - section_add(); - break; - case "help": - section_help(); - break; - case "delete": - section_delete(check_input($name)); - section_display(); - break; - case "Add section": - section_add_save($edit); - section_display(); - break; - case "Save sections": - section_display_save($edit); - // fall through - default: - section_display(); - } -} - -?> diff --git a/modules/story.module b/modules/story.module index 19448fcac..4667494fe 100644 --- a/modules/story.module +++ b/modules/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, "[ <A HREF=\"node.php?op=reply&id=$node->nid&pid=0\">". t("reply to this story") ."</A> ]"); + $theme->story($node, ($PHP_SELF == "/node.php" ? "[ <A HREF=\"node.php?op=reply&id=$node->nid&pid=0\">". t("reply to this story") ."</A> ]" : 0)); } } -function story_form($story = array()) { +function story_form($edit = array()) { global $allowed_html, $REQUEST_URI, $user; $output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n"; $output .= "<B>". t("Your name") .":</B><BR>\n"; - $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[userid]\" VALUE=\"$story[userid]\">\n"; - $output .= format_username(($story[userid] ? $story[userid] : $user->userid)) ."<P>"; + $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[userid]\" VALUE=\"$edit[userid]\">\n"; + $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."<P>"; $output .= "<B>". t("Subject") .":</B><BR>\n"; - $output .= "<INPUT TYPE=\"text\" NAME=\"story[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($story[title]) ."\"><P>\n"; + $output .= "<INPUT TYPE=\"text\" NAME=\"edit[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n"; - $output .= structure_form("story"); + $output .= structure_form("story", $edit); $output .= "<B>". t("Abstract") .":</B><BR>\n"; - $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"story[abstract]\">". check_textarea($story[abstract]) ."</TEXTAREA><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"; $output .= "<B>". t("Body") .":</B><BR>\n"; - $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"story[body]\">". check_textarea($story[body]) ."</TEXTAREA><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 .= "<INPUT TYPE=\"hidden\" NAME=\"story[timestamp]\" VALUE=\"$story[timestamp]\">\n"; - $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[nid]\" VALUE=\"$story[nid]\">\n"; + $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[timestamp]\" VALUE=\"$edit[timestamp]\">\n"; + $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n"; } $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'")); - if (!$story) { + if (!$edit) { $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n"; } - else if (!$story[title]) { + else if (!$edit[title]) { $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n"; } - else if (!$story[section]) { - $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a section.") ."</FONT><P>\n"; - $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n"; - } - else if (!$story[abstract]) { + else if (!$edit[abstract]) { $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n"; } - else if (!$story[nid] && $duplicate) { + else if (!$edit[nid] && $duplicate) { $output .= "<FONT COLOR=\"red\">". t("Warning: there is already a story with that subject.") ."</FONT><P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\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 "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story&op=listing\">story listing</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\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()); } } 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, "[ <A HREF=\"node.php?op=reply&id=$node->nid&pid=0\">". t("reply to this story") ."</A> ]"); + $theme->story($node, ($PHP_SELF == "/node.php" ? "[ <A HREF=\"node.php?op=reply&id=$node->nid&pid=0\">". t("reply to this story") ."</A> ]" : 0)); } } -function story_form($story = array()) { +function story_form($edit = array()) { global $allowed_html, $REQUEST_URI, $user; $output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n"; $output .= "<B>". t("Your name") .":</B><BR>\n"; - $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[userid]\" VALUE=\"$story[userid]\">\n"; - $output .= format_username(($story[userid] ? $story[userid] : $user->userid)) ."<P>"; + $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[userid]\" VALUE=\"$edit[userid]\">\n"; + $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."<P>"; $output .= "<B>". t("Subject") .":</B><BR>\n"; - $output .= "<INPUT TYPE=\"text\" NAME=\"story[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($story[title]) ."\"><P>\n"; + $output .= "<INPUT TYPE=\"text\" NAME=\"edit[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n"; - $output .= structure_form("story"); + $output .= structure_form("story", $edit); $output .= "<B>". t("Abstract") .":</B><BR>\n"; - $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"story[abstract]\">". check_textarea($story[abstract]) ."</TEXTAREA><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"; $output .= "<B>". t("Body") .":</B><BR>\n"; - $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"story[body]\">". check_textarea($story[body]) ."</TEXTAREA><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 .= "<INPUT TYPE=\"hidden\" NAME=\"story[timestamp]\" VALUE=\"$story[timestamp]\">\n"; - $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[nid]\" VALUE=\"$story[nid]\">\n"; + $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[timestamp]\" VALUE=\"$edit[timestamp]\">\n"; + $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n"; } $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'")); - if (!$story) { + if (!$edit) { $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n"; } - else if (!$story[title]) { + else if (!$edit[title]) { $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n"; } - else if (!$story[section]) { - $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a section.") ."</FONT><P>\n"; - $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n"; - } - else if (!$story[abstract]) { + else if (!$edit[abstract]) { $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n"; } - else if (!$story[nid] && $duplicate) { + else if (!$edit[nid] && $duplicate) { $output .= "<FONT COLOR=\"red\">". t("Warning: there is already a story with that subject.") ."</FONT><P>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\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 "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story&op=listing\">story listing</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\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()); } } diff --git a/modules/structure.module b/modules/structure.module index 7404e6b8a..db4e13ea2 100644 --- a/modules/structure.module +++ b/modules/structure.module @@ -3,7 +3,7 @@ $module = array("admin" => "structure_admin"); $cstatus = array("disabled", "enabled: incl. anonymous", "enabled: excl. anonymous"); -$mstatus = array("post new submissions", "queue new submissions"); +$mstatus = array("post new submissions", "moderate new submissions"); include "includes/structure.inc"; @@ -73,9 +73,9 @@ function category_overview() { $result = db_query("SELECT * FROM category ORDER BY name"); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>name</TH><TH>type</TH><TH>comments</TH><TH>submissions</TH><TH>thresholds</TH><TH>operations</TH></TR>\n"; + $output .= " <TR><TH>name</TH><TH>type</TH><TH>comments</TH><TH>submissions</TH><TH>operations</TH></TR>\n"; while ($category = db_fetch_object($result)) { - $output .= " <TR><TD>". check_output($category->name) ."</TD><TD>". check_output($category->type) ."</TD><TD>". check_output($cstatus[$category->comment]) ."</TD><TD>". check_output($mstatus[$category->submission]) ."</TD><TD>post: $category->post, dump: $category->dump, expire: $category->expire</TD><TD><A HREF=\"admin.php?mod=structure&type=category&op=edit&id=$category->cid\">edit category</A></TD></TR>\n"; + $output .= " <TR><TD>". check_output($category->name) ."</TD><TD>". check_output($category->type) ."</TD><TD>". check_output($cstatus[$category->comment]) ."</TD><TD>". check_output($mstatus[$category->submission]) ."". ($category->submission ? "<BR><SMALL>post: $category->post, dump: $category->dump, expire: $category->expire</SMALL>" : "") ."</TD><TD><A HREF=\"admin.php?mod=structure&type=category&op=edit&id=$category->cid\">edit category</A></TD></TR>\n"; } $output .= "</TABLE>\n"; return $output; @@ -88,7 +88,7 @@ function topic_form($edit = array()) { $output .= "<FORM ACTION=\"admin.php?mod=structure&type=topic\" METHOD=\"post\">\n"; $output .= "<B>Name:</B><BR>\n"; - $output .= "<INPUT NAME=\"edit[name]\" SIZE=\"55\" VALUE=\"". check_textfield($edit[name]) ."\"><P>\n"; + $output .= "<INPUT NAME=\"edit[name]\" SIZE=\"55\" VALUE=\"". check_textfield($edit[name]) ."\"><BR>\n"; $output .= "<SMALL><I>A unique name for this topic like 'science', 'internet', 'culture', etc.</I></SMALL><P>\n"; $output .= "<B>Parent:</B><BR>\n"; @@ -112,9 +112,9 @@ function topic_overview() { $tree = topic_tree(); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>name</TH><TH>operations</TH></TR>\n"; + $output .= " <TR><TH>name</TH><TH>read access</TH><TH>write access</TH><TH>operations</TH></TR>\n"; foreach ($tree as $id=>$name) { - $output .= " <TR><TD>". check_output($name) ."</TD><TD><A HREF=\"admin.php?mod=structure&type=topic&op=edit&id=$id\">edit topic</A></TD></TR>\n"; + $output .= " <TR><TD>". check_output($name) ."</TD><TD ALIGN=\"center\">all</TD><TD ALIGN=\"center\">all</TD><TD><A HREF=\"admin.php?mod=structure&type=topic&op=edit&id=$id\">edit topic</A></TD></TR>\n"; } $output .= "</TABLE>\n"; return $output; @@ -133,7 +133,7 @@ function structure_overview() { function structure_admin() { global $id, $op, $type, $edit; - print "<SMALL><A HREF=\"admin.php?mod=structure&type=category&op=add\">add new category</A> | <A HREF=\"admin.php?mod=structure&type=topic&op=add\">add new topic</A> | <A HREF=\"admin.php?mod=structure&type=category\">categories</A> | <A HREF=\"admin.php?mod=structure&type=topic\">topics</A> | <A HREF=\"admin.php?mod=structure\">overview</A></SMALL><HR>\n"; + print "<SMALL><A HREF=\"admin.php?mod=structure&type=category&op=add\">add new category</A> | <A HREF=\"admin.php?mod=structure&type=topic&op=add\">add new topic</A> | <A HREF=\"admin.php?mod=structure\">overview</A></SMALL><HR>\n"; switch ($type) { case "category": @@ -149,14 +149,14 @@ function structure_admin() { break; case "Delete category": print status(category_del($edit[cid])); - print category_overview(); + print structure_overview(); break; case "Save category": print status(category_save($edit)); - print category_overview(); + print structure_overview(); break; default: - print category_overview(); + print structure_overview(); } break; case "topic": @@ -172,14 +172,14 @@ function structure_admin() { break; case "Delete topic": print status(topic_del($edit[tid])); - print topic_overview(); + print structure_overview(); break; case "Save topic": print status(topic_save($edit)); - print topic_overview(); + print structure_overview(); break; default: - print topic_overview(); + print structure_overview(); } break; default: |