diff --git a/account.php b/account.php index 7c51ea019b1..3146e7f9563 100644 --- a/account.php +++ b/account.php @@ -282,7 +282,6 @@ function account_user($uname) { // Display account information: $theme->header(); if ($block1) $theme->box(strtr(t("%a's user information"), array("%a" => $uname)), $block1); -// if ($block2) $theme->box(strtr(t("%a has posted %b recently"), array("%a" => $uname, "%b" => format_plural($comments, "comment", "comments"))), $block2); module_iterate("module", $uname); $theme->footer(); } diff --git a/includes/node.inc b/includes/node.inc index 3bb47832b63..75786cb7f3a 100644 --- a/includes/node.inc +++ b/includes/node.inc @@ -6,7 +6,7 @@ $rstatus = array(0 => dumped, 1 => expired, 2 => queued, 3 => posted); function _node_get($field, $value) { $result = db_query("SELECT lid, type FROM node WHERE $field = '$value'"); if ($node = db_fetch_object($result)) { - return db_query("SELECT n.*, l.*, u.userid FROM node n LEFT JOIN $node->type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id WHERE n.$field = '$value' ORDER BY n.timestamp DESC"); + return db_query("SELECT n.*, l.*, c.name AS category, t.name AS topic, u.userid FROM node n LEFT JOIN $node->type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid LEFT JOIN topic t ON n.tid = t.tid WHERE n.$field = '$value' ORDER BY n.timestamp DESC"); } } @@ -31,10 +31,15 @@ function node_del($field, $value) { } } +function node_get_comments($nid) { + $comment = db_fetch_object(db_query("SELECT COUNT(c.lid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.lid WHERE n.nid = '$nid' GROUP BY n.nid", 1)); + return $comment->number ? $comment->number : 0; +} + function node_save($node) { global $user, $status; - $rows = array(nid, pid, lid, log, type, title, score, votes, author, status, timestamp); + $rows = array(nid, pid, lid, cid, tid, log, type, title, score, votes, author, status, timestamp); if ($node[nid] > 0) { $n = node_get_object("nid", $node[nid]); @@ -69,7 +74,7 @@ function node_save($node) { throttle("post node", variable_get(max_node_rate, 900)); // setup default values: - $node = array_merge(array(title => "?", author => $user->id, type => "?", pid => 0, log => "node created", status => $status[queued], score => 0, votes => 0, timestamp => time()), $node); + $node = array_merge(array(title => "?", author => $user->id, type => "?", pid => 0, cid => 0, tid => 0, log => "node created", status => $status[queued], score => 0, votes => 0, timestamp => time()), $node); // prepare queries: $f1 = array(); @@ -129,7 +134,7 @@ function node_invoke($node, $name, $arg = 0) { if ($function) return ($arg ? $function($node) : $function($node, $arg)); } -function node_view($node, $page) { +function node_view($node, $page = 0) { return node_invoke($node, "view", $page); } diff --git a/includes/section.inc b/includes/section.inc deleted file mode 100644 index ad25b179c35..00000000000 --- a/includes/section.inc +++ /dev/null @@ -1,25 +0,0 @@ -name); - return $array; -} - -function section_post_threshold($section, $default) { - $section = db_fetch_object(db_query("SELECT post AS threshold FROM sections WHERE name = '". check_input($section) ."'")); - return $section->threshold ? $section->threshold : $default; -} - -function section_dump_threshold($section, $default) { - $section = db_fetch_object(db_query("SELECT dump AS threshold FROM sections WHERE name = '". check_input($section) ."'")); - return $section->threshold ? $section->threshold : $default; -} - -function section_timout_threshold($section, $default) { - $section = db_fetch_object(db_query("SELECT timout AS threshold FROM sections WHERE name = '". check_input($section) ."'")); - return $section->threshold ? $section->threshold : $default; -} - -?> \ No newline at end of file diff --git a/includes/structure.inc b/includes/structure.inc index 838d0e35170..4326e092e5a 100644 --- a/includes/structure.inc +++ b/includes/structure.inc @@ -25,19 +25,30 @@ function category_save($edit) { // delete category $cid: function category_del($cid) { db_query("DELETE FROM category WHERE cid = '". check_input($cid) ."'"); - db_query("DELETE FROM node_category WHERE cid = '". check_input($cid) ."'"); + db_query("UPDATE node SET cid = 0 WHERE cid = '". check_input($cid) ."'"); } -function category_node($nid, $cid) { - db_query("INSERT INTO node_category (nid, cid) VALUES ('". check_input($nid) ."', '". check_input($cid) ."')", 1); +function category_post_threshold($cid, $default) { + $category = db_fetch_object(db_query("SELECT post AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); + return $category->threshold ? $category->threshold : $default; +} + +function category_dump_threshold($cid, $default) { + $category = db_fetch_object(db_query("SELECT dump AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); + return $category->threshold ? $category->threshold : $default; +} + +function category_expire_threshold($cid, $default) { + $category = db_fetch_object(db_query("SELECT expire AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); + return $category->threshold ? $category->threshold : $default; } function category_form_select($type, $edit = array(), $size = 1) { $result = db_query("SELECT * FROM category WHERE type = '$type'"); while ($category = db_fetch_object($result)) { - $options .= ""; + $options .= ""; } - return "\n"; + return "\n"; } // ----- topic ----- @@ -75,20 +86,15 @@ function topic_tree($parent = 0, $name = "", $tree = array()) { // delete topic $tid: function topic_del($tid) { db_query("DELETE FROM topic WHERE tid = '". check_input($tid) ."'"); - db_query("DELETE FROM node_topic WHERE tid = '". check_input($tid) ."'"); -} - -// add node $nid to topic $tid: -function topic_node($nid, $tid) { - db_query("INSERT INTO node_topic (nid, tid) VALUES ('". check_input($nid) ."', '". check_input($tid) ."')", 1); + db_query("UPDATE node SET tid = 0 WHERE tid = '". check_input($tid) ."'"); } // renders a HTML form to select one or more topics: function topic_form_select($edit = array(), $size = 1) { foreach (topic_tree() as $tid=>$name) { - $options .= ""; + $options .= ""; } - return "\n"; + return "\n"; } // ----- structure ----- diff --git a/includes/theme.inc b/includes/theme.inc index d09ccf2cec3..51f42850c62 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -97,7 +97,7 @@ function theme_blocks($region, $theme) { } function theme_morelink($theme, $node) { - return ($node->body) ? "[ nid\">link\">". t("read more") ." | ". sizeof(explode(" ", $node->body)) ." ". t("words") ." | nid\">link\">". format_plural($node->comments, "comment", "comments") ." ]" : "[ nid\">link\">". format_plural($node->comments, "comment", "comments") ." ]"; + return ($node->body) ? "[ nid\">link\">". t("read more") ." | ". sizeof(explode(" ", $node->body)) ." ". t("words") ." | nid\">link\">". format_plural(node_get_comments($node->nid), "comment", "comments") ." ]" : "[ nid\">link\">". format_plural(node_get_comments($node->nid), "comment", "comments") ." ]"; } function theme_moderation_results($theme, $node) { diff --git a/includes/variable.inc b/includes/variable.inc index 20beb5efd19..083f7d49243 100644 --- a/includes/variable.inc +++ b/includes/variable.inc @@ -7,33 +7,15 @@ function variable_init($conf = array()) { } function handler_post_threshold($node, $default) { - if ($node->type) { - $function = $node->type ."_post_threshold"; - return $function($node, $default); - } - else { - return $default; - } + return ($threshold = category_post_threshold($node->cid) ? $threshold : $default); } function handler_dump_threshold($node, $default) { - if ($node->type) { - $function = $node->type ."_dump_threshold"; - return $function($node, $default); - } - else { - return $default; - } + return ($threshold = category_dump_threshold($node->cid) ? $threshold : $default); } -function handler_timout_threshold($node, $default) { - if ($node->type) { - $function = $node->type ."_timout_threshold"; - return $function($node, $default); - } - else { - return $default; - } +function handler_expire_threshold($node, $default) { + return ($threshold = category_expire_threshold($node->cid) ? $threshold : $default); } function variable_get($name, $default, $object = 0) { @@ -44,8 +26,8 @@ function variable_get($name, $default, $object = 0) { return handler_post_threshold($object, $default); case "dump_threshold": return handler_dump_threshold($object, $default); - case "timout_threshold": - return handler_timout_threshold($object, $default); + case "expire_threshold": + return handler_expire_threshold($object, $default); default: return ($conf[$name] ? $conf[$name] : $default); } diff --git a/index.php b/index.php index d86ebe81f07..1235481109c 100644 --- a/index.php +++ b/index.php @@ -4,16 +4,12 @@ include_once "includes/common.inc"; if (variable_get(dev_timing, 0)) timer_start(); -// Initialize/pre-process variables: -$number = ($user->nodes) ? $user->nodes : 10; -$date = ($date > 0) ? $date : time(); +$result = db_query("SELECT nid FROM node WHERE type = 'story' AND status = '$status[posted]' AND timestamp <= ". ($date > 0 ? $date : time()) ." ". ($category ? "AND cid = '$category'" : "") ." ". ($topic ? "AND tid = '$topic'" : "") ." ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : 10)); -// Perform query: -$result = db_query("SELECT n.*, s.*, u.userid, COUNT(c.lid) AS comments FROM node n LEFT JOIN story s ON n.nid = s.nid LEFT JOIN comments c ON n.nid = c.lid LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[posted]' AND n.type = 'story' ". ($section ? "AND s.section = '$section' " : "") ."AND n.timestamp <= $date GROUP BY n.nid ORDER BY n.timestamp DESC LIMIT $number"); - -// Display nodes: $theme->header(); -while ($story = db_fetch_object($result)) $theme->story($story); +while ($node = db_fetch_object($result)) { + node_view(node_get_object("nid", $node->nid)); +} $theme->footer(); if (variable_get(dev_timing, 0)) timer_print(); diff --git a/modules/book.module b/modules/book.module index 6c4ce6a8a94..1924072eccf 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 6c4ce6a8a94..1924072eccf 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 ac193c166fa..75a6df1b8ee 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 9b42e46d1cb..00000000000 --- a/modules/section.module +++ /dev/null @@ -1,137 +0,0 @@ - "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() { - ?> -

When submitting new stories, every story is assigned a section or category. Sections can be maintained from the administration pages.

-

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.

- name) ."\">$_section->name (". check_output($_section->stories, 0) .")\n"; - } - - $block[0][subject] = "Sections"; - $block[0][content] = $content; - $block[0][info] = "Section list"; - - return $block; -} - -function section_add() { - global $_section; - - $output .= "
\n"; - $output .= "

\n"; - $output .= " Section name:
\n"; - $output .= " \n"; - $output .= "

\n"; - $output .= "

\n"; - $output .= " Post threshold:
\n"; - $output .= " \n"; - $output .= "

\n"; - $output .= "

\n"; - $output .= " Dump threshold:
\n"; - $output .= " \n"; - $output .= "

\n"; - $output .= "

\n"; - $output .= " Timout threshold:
\n"; - $output .= " \n"; - $output .= "

\n"; - $output .= " \n"; - $output .= "
\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 .= "
\n"; - $output .= "\n"; - $output .= " \n"; - while ($_section = db_fetch_object($result)) { - foreach ($status as $key=>$value) $options0 .= "\n"; - foreach ($post as $value) $options1 .= "\n"; - foreach ($dump as $value) $options2 .= "\n"; - foreach ($timout as $value) $options3 .= "\n"; - $output .= " \n"; - unset($options0); unset($options1); unset($options2); unset($options3); - } - $output .= "
section namestatuspost thresholddump thresholdexpiration thresholdoperations
". check_output($_section->name) ."name) ."\">delete
\n"; - $output .= "\n"; - $output .= "
\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 "add new section | overview | help
\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 19448fcac89..4667494fe22 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, "[ 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()); } } diff --git a/modules/story/story.module b/modules/story/story.module index 19448fcac89..4667494fe22 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()); } } diff --git a/modules/structure.module b/modules/structure.module index 7404e6b8a8f..db4e13ea2b4 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 .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($category = db_fetch_object($result)) { - $output .= " \n"; + $output .= " \n"; } $output .= "
nametypecommentssubmissionsthresholdsoperations
nametypecommentssubmissionsoperations
". check_output($category->name) ."". check_output($category->type) ."". check_output($cstatus[$category->comment]) ."". check_output($mstatus[$category->submission]) ."post: $category->post, dump: $category->dump, expire: $category->expirecid\">edit category
". check_output($category->name) ."". check_output($category->type) ."". check_output($cstatus[$category->comment]) ."". check_output($mstatus[$category->submission]) ."". ($category->submission ? "
post: $category->post, dump: $category->dump, expire: $category->expire" : "") ."
cid\">edit category
\n"; return $output; @@ -88,7 +88,7 @@ function topic_form($edit = array()) { $output .= "\n"; $output .= "Name:
\n"; - $output .= "

\n"; + $output .= "
\n"; $output .= "A unique name for this topic like 'science', 'internet', 'culture', etc.

\n"; $output .= "Parent:
\n"; @@ -112,9 +112,9 @@ function topic_overview() { $tree = topic_tree(); $output .= "\n"; - $output .= " \n"; + $output .= " \n"; foreach ($tree as $id=>$name) { - $output .= " \n"; + $output .= " \n"; } $output .= "
nameoperations
nameread accesswrite accessoperations
". check_output($name) ."edit topic
". check_output($name) ."allalledit topic
\n"; return $output; @@ -133,7 +133,7 @@ function structure_overview() { function structure_admin() { global $id, $op, $type, $edit; - print "add new category | add new topic | categories | topics | overview


\n"; + print "add new category | add new topic | overview
\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: diff --git a/themes/example/example.theme b/themes/example/example.theme index dbdad530dd0..9d5cbd250b0 100644 --- a/themes/example/example.theme +++ b/themes/example/example.theme @@ -19,7 +19,7 @@ <? echo variable_get(site_name, "drupal"); ?> - +
"; + echo " "; + echo "
@@ -50,10 +50,10 @@ function story($story, $reply = 0) { ?> - +
@@ -65,13 +65,11 @@ ?> - @@ -112,41 +110,41 @@ echo "cid\">\n"; // Create comment header: - echo "
- title); ?> + title); ?>
- + section) ."\">". check_output($story->section) .""; + echo "cid\">". check_output($story->category) ." / tid\">". check_output($story->topic) .""; ?> -
"; - echo " "; - echo " "; - echo " "; + echo "
"; - echo t("Subject") .":"; - echo " "; - echo " ". check_output($comment->subject); - echo "
"; + echo " "; + echo " "; + echo " "; // Moderation: - echo " "; - echo " "; + echo " "; + echo " "; // Author and date: - echo " "; - echo " "; - echo " "; - echo " "; + echo " "; + echo " "; + echo " "; + echo " "; // Body of comment: - echo " "; - echo " "; + echo " "; - echo " "; - echo "
"; + echo t("Subject") .":"; + echo " "; + echo " ". check_output($comment->subject); + echo " "; - echo comment_moderation($comment); - echo "
"; + echo comment_moderation($comment); + echo "
"; - echo t("Author") .":"; - echo " "; - echo format_username($comment->userid) ." on ". format_date($comment->timestamp); - echo "
"; + echo t("Author") .":"; + echo " "; + echo format_username($comment->userid) ." on ". format_date($comment->timestamp); + echo "
"; - echo check_output($comment->comment, 1); + echo "
"; + echo check_output($comment->comment, 1); // Print navigation / control links: - echo "

$link

"; - echo "
"; + echo "

$link

"; + echo "
"; } // close comment function function box($subject, $content, $options = "") { @@ -156,7 +154,7 @@ diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme index 00a415640cb..3f19502f1b5 100644 --- a/themes/marvin/marvin.theme +++ b/themes/marvin/marvin.theme @@ -51,7 +51,7 @@ print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; diff --git a/themes/yaroon/jeroen2.theme b/themes/yaroon/jeroen2.theme index 27b7b05415f..236bbbd6690 100644 --- a/themes/yaroon/jeroen2.theme +++ b/themes/yaroon/jeroen2.theme @@ -168,7 +168,7 @@ @@ -209,7 +209,7 @@
-

+

\"\"
\n"; - print " ". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?>department) print "
from the $story->department dept."; ?>
section) ."\">". check_output($story->section) ."\n"; + print " ". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?>department) print "
from the $story->department dept."; ?>
cid\">". check_output($story->category) ." / tid\">". check_output($story->topic) ."\n"; print "
 
 subject); ?> - format_username($comment->userid), "%b" => format_date($comment->timestamp), "small")); ?> + format_username($comment->userid), "%b" => format_date($comment->timestamp), "small")); ?>
- + diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql index 5a94039e7eb..f5e3f08177c 100644 --- a/updates/2.00-to-x.xx.sql +++ b/updates/2.00-to-x.xx.sql @@ -1,6 +1,8 @@ # 14/04/2001: ALTER TABLE node ADD cid int(10) unsigned DEFAULT '0' NOT NULL; ALTER TABLE node ADD tid int(10) unsigned DEFAULT '0' NOT NULL; +ALTER TABLE story DROP section; +ALTER TABLE comments ADD KEY(lid); CREATE TABLE category ( cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,