From 1f79863053350f1a7d6cb654ac615123bc3b5133 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 25 Mar 2001 10:57:01 +0000 Subject: - large commit of everything else that has been queued in my backlog: it's not 100% stable yet --- CHANGELOG | 11 ++++ account.php | 48 ++++++++------- includes/hostname.conf | 4 +- includes/node.inc | 54 ++++++++++------- includes/search.inc | 2 +- includes/theme.inc | 9 ++- index.php | 2 +- modules/account.module | 14 ++--- modules/affiliate-site.module | 2 +- modules/book.module | 133 ++++++++++++++++++++++++++++-------------- modules/book/book.module | 133 ++++++++++++++++++++++++++++-------------- modules/drupal-site.module | 2 +- modules/moderation.module | 32 +++++----- modules/story.module | 60 ++++++++++--------- modules/story/story.module | 60 ++++++++++--------- node.php | 26 +++++---- submit.php | 125 +++++++-------------------------------- themes/example/example.theme | 2 +- 18 files changed, 381 insertions(+), 338 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 07dabe42a..fe0f4328b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,14 @@ +drupal x.xx, xx/xx/xxxx +----------------------- +- major overhaul of the underlying design: + * everything is based on nodes + * introduced links / drupal tags +- refactored submission / moderation queue +- added a "wiki module" +- various updates: + * added preview functionality when submitting new content (such as a story) from the administration pages. + * made the administration section only show those links a user has access to. + drupal 2.00, 15/03/2001 ----------------------- - rewrote the comment/discussion code: diff --git a/account.php b/account.php index ebfdaea78..791987ae7 100644 --- a/account.php +++ b/account.php @@ -68,35 +68,35 @@ function account_user_edit() { $output .= "". t("Username") .":
\n"; $output .= "$user->userid

\n"; - $output .= "". t("Required, unique, and can not be changed.") ."

\n"; + $output .= "". t("Required, unique, and can not be changed.") ."

\n"; $output .= "". t("Real name") .":
\n"; $output .= "name\">
\n"; - $output .= "". t("Optional") .".

\n"; + $output .= "". t("Optional") .".

\n"; $output .= "". t("Real e-mail address") .":
\n"; $output .= "$user->real_email

\n"; - $output .= "". t("Required, unique, can not be changed.") ." ". t("Your real e-mail address is never displayed publicly: only needed in case you lose your password.") ."

\n"; + $output .= "". t("Required, unique, can not be changed.") ." ". t("Your real e-mail address is never displayed publicly: only needed in case you lose your password.") ."

\n"; $output .= "". t("Fake e-mail address") .":
\n"; $output .= "fake_email\">
\n"; - $output .= "". t("Optional") .". ". t("Displayed publicly so you may spam proof your real e-mail address if you want.") ."

\n"; + $output .= "". t("Optional") .". ". t("Displayed publicly so you may spam proof your real e-mail address if you want.") ."

\n"; $output .= "". t("Homepage") .":
\n"; $output .= "url\">
\n"; - $output .= "". t("Optional") .". ". t("Make sure you enter fully qualified URLs only. That is, remember to include \"http://\".") ."

\n"; + $output .= "". t("Optional") .". ". t("Make sure you enter fully qualified URLs only. That is, remember to include \"http://\".") ."

\n"; $output .= "". t("Bio") .": (". t("maximal 255 characters") .")
\n"; $output .= "
\n"; - $output .= "". t("Optional") .". ". t("This biographical information is publicly displayed on your user page.") ."
". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; + $output .= "". t("Optional") .". ". t("This biographical information is publicly displayed on your user page.") ."
". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; $output .= "". t("Signature") .": (". t("maximal 255 characters") .")
\n"; $output .= "
\n"; - $output .= "". t("Optional") .". ". t("This information will be publicly displayed at the end of your comments.") ."
". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; + $output .= "". t("Optional") .". ". t("This information will be publicly displayed at the end of your comments.") ."
". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; $output .= "". t("Password") .":
\n"; $output .= "
\n"; - $output .= "". t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password.") ."

\n"; + $output .= "". t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password.") ."

\n"; $output .= "
\n"; $output .= "\n"; @@ -131,25 +131,23 @@ function account_site_edit() { $output .= "". t("Theme") .":
\n"; foreach ($themes as $key=>$value) $options1 .= " \n"; $output .= "
\n"; - $output .= "". t("Selecting a different theme will change the look and feel of the site.") ."

\n"; + $output .= "". t("Selecting a different theme will change the look and feel of the site.") ."

\n"; $output .= "". t("Timezone") .":
\n"; $date = time() - date("Z"); for ($zone = -43200; $zone <= 46800; $zone += 3600) $options2 .= " \n"; $output .= "
\n"; - $output .= "". t("Select what time you currently have and your timezone settings will be set appropriate.") ."

\n"; + $output .= "". t("Select what time you currently have and your timezone settings will be set appropriate.") ."

\n"; - if ($languages) { - $output .= "". t("Language" ) .":
\n"; - foreach ($languages as $key=>$value) $options3 .= " \n"; - $output .= "
\n"; - $output .= "". t("Selecting a different language will change the language the site.") ."

\n"; - } + $output .= "". t("Language" ) .":
\n"; + foreach ($languages as $key=>$value) $options3 .= " \n"; + $output .= "
\n"; + $output .= "". t("Selecting a different language will change the language the site.") ."

\n"; $output .= "". t("Maximum number of items to display") .":
\n"; for ($nodes = 10; $nodes <= 30; $nodes += 5) $options4 .= "\n"; $output .= "
\n"; - $output .= "". t("The maximum number of nodes that will be displayed on the main page.") ."

\n"; + $output .= "". t("The maximum number of nodes that will be displayed on the main page.") ."

\n"; foreach ($cmodes as $key=>$value) $options5 .= "\n"; $output .= "". t("Comment display mode") .":
\n"; @@ -162,7 +160,7 @@ function account_site_edit() { for ($i = -1; $i < 6; $i++) $options7 .= " "; $output .= "". t("Comment filter") .":
\n"; $output .= "
\n"; - $output .= "". t("Comments that scored less than this threshold setting will be ignored. Anonymous comments start at 0, comments of people logged on start at 1 and moderators can add and subtract points.") ."

\n"; + $output .= "". t("Comments that scored less than this threshold setting will be ignored. Anonymous comments start at 0, comments of people logged on start at 1 and moderators can add and subtract points.") ."

\n"; $output .= "
\n"; $output .= "\n"; @@ -197,7 +195,7 @@ function account_content_edit() { $entry = db_fetch_object(db_query("SELECT * FROM layout WHERE block = '$block->name' AND user = '$user->id'")); $output .= "name]\"". ($entry->user ? " CHECKED" : "") ."> ". t($block->name) ."
\n"; } - $output .= "

". t("Enable the blocks you would like to see displayed in the side bars.") ."

\n"; + $output .= "

". t("Enable the blocks you would like to see displayed in the side bars.") ."

\n"; $output .= "\n"; $output .= "\n"; @@ -224,7 +222,7 @@ function account_content_save($edit) { } function account_user($uname) { - global $user, $theme; + global $user, $status, $theme; function module($name, $module, $username) { global $theme; @@ -256,7 +254,7 @@ function account_user($uname) { $block1 .= "\n"; /* - $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.timestamp, n.title AS node FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN nodes ON n.id = c.lid WHERE u.userid = '$uname' AND n.status = 2 AND s.timestamp > ". (time() - 1209600) ." ORDER BY cid DESC LIMIT 10"); + $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.timestamp, n.title AS node FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN nodes ON n.id = c.lid WHERE u.userid = '$uname' AND n.status = '$status[posted]' AND s.timestamp > ". (time() - 1209600) ." ORDER BY cid DESC LIMIT 10"); while ($comment = db_fetch_object($result)) { $block2 .= "\n"; $block2 .= " \n"; @@ -427,9 +425,9 @@ function account_track_comments() { } function account_track_nodes() { - global $theme, $user; + global $status, $theme, $user; - $result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM nodes n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '2' AND n.author = '$user->id' GROUP BY n.nid DESC"); + $result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM nodes n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '$status[posted]' AND n.author = '$user->id' GROUP BY n.nid DESC"); while ($node = db_fetch_object($result)) { $output .= "
". t("Comment") .":lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."
\n"; @@ -446,11 +444,11 @@ function account_track_nodes() { } function account_track_site() { - global $theme, $user, $site_name; + global $status, $theme, $user, $site_name; $period = 259200; // 3 days - $sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN nodes n ON c.lid = n.nid WHERE n.status = 2 AND ". time() ." - n.timestamp < $period GROUP BY c.lid ORDER BY n.timestamp DESC LIMIT 10"); + $sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN nodes n ON c.lid = n.nid WHERE n.status = '$status[posted]' AND ". time() ." - n.timestamp < $period GROUP BY c.lid ORDER BY n.timestamp DESC LIMIT 10"); while ($node = db_fetch_object($sresult)) { $output .= "
  • ". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." 'nid\">". check_output($node->title) ."':
  • "; diff --git a/includes/hostname.conf b/includes/hostname.conf index 57d5f574c..764c1f52b 100644 --- a/includes/hostname.conf +++ b/includes/hostname.conf @@ -58,8 +58,8 @@ $themes = array("UnConeD" => array( # # Submission moderation votes: # The keys of this associative array are displayed in each submission's selection box whereas the corresponding values represent the mathematical calculation to be performed to update a comment's value. -# Warning: changing $submission_votes will affect the integrity of all pending stories in the open submission queue. Do not change this setting unless there are no pending stories in the submission queue or unless you know what you are doing. -$submission_votes = array("neutral (+0)" => "+ 0", +# Warning: changing $moderation_votes will affect the integrity of all pending stories in the open submission queue. Do not change this setting unless there are no pending stories in the submission queue or unless you know what you are doing. +$moderation_votes = array("neutral (+0)" => "+ 0", "post it (+1)" => "+ 1", "dump it (-1)" => "- 1"); diff --git a/includes/node.inc b/includes/node.inc index 824c83ec2..b682b4e4c 100644 --- a/includes/node.inc +++ b/includes/node.inc @@ -1,5 +1,7 @@ 0, expired => 1, queued => 2, posted => 3, scheduled => 4); + function _node_get($field, $value) { $result = db_query("SELECT lid, type FROM nodes WHERE $field = '$value'"); if ($node = db_fetch_object($result)) { @@ -32,9 +34,9 @@ function node_del_array($field, $value) { } function node_save($node) { - global $user; + global $user, $status; - $rows = array(nid, lid, type, title, score, votes, author, status, timestamp); + $rows = array(nid, pid, lid, log, type, title, score, votes, author, status, timestamp); // insert or update node: if ($node[nid]) { @@ -55,10 +57,12 @@ function node_save($node) { db_query("UPDATE nodes SET $u1 WHERE nid = '$node[nid]'"); db_query("UPDATE $node[type] SET $u2 WHERE node = '$node[nid]'"); + + watchdog("message", "modified node '$node[title]'"); } else { // setup default values: - $node = array_merge(array(type => "?", title => "?", score => 0, votes => 0, author => $user->id, status => 1, timestamp => time()), $node); + $node = array_merge(array(title => "?", author => $user->id, type => "?", pid => 0, log => "node created", status => $status[queued], score => 0, votes => 0, timestamp => time()), $node); // prepare queries: $f1 = array(); @@ -82,28 +86,36 @@ function node_save($node) { $f2 = implode(", ", $f2); $v2 = implode(", ", $v2); -// if (!_node_get("title = $node[title] AND timestamp < ". time() ." - 60")) { - db_query("INSERT INTO nodes ($f1) VALUES ($v1)"); - if ($nid = db_insert_id()) { - $lid = db_query("INSERT INTO $node[type] ($f2, node) VALUES ($v2, $nid)"); - if ($lid = db_insert_id()) { - db_query("UPDATE nodes SET lid = '$lid' WHERE nid = '$nid'"); - } - else { - db_query("DELETE FROM nodes WHERE nid = '$nid'"); - } + db_query("INSERT INTO nodes ($f1) VALUES ($v1)"); + if ($nid = db_insert_id()) { + $lid = db_query("INSERT INTO $node[type] ($f2, node) VALUES ($v2, $nid)"); + if ($lid = db_insert_id()) { + db_query("UPDATE nodes SET lid = '$lid' WHERE nid = '$nid'"); + } + else { + db_query("DELETE FROM nodes WHERE nid = '$nid'"); } -// } + } + + watchdog("message", "added node '$node[title]'"); + } + + if (($node[pid]) && ($node[status] == $status[posted])) { + db_query("UPDATE nodes SET status = '$status[expired]' WHERE nid = '$node[pid]'"); } } -function node_view($node, $page = 0) { +function node_view($node, $page) { if ($node->type) { $function = $node->type ."_view"; - $function($node); + return $function($node, $page); } - else { - print "not found"; +} + +function node_form($node) { + if ($node[type]) { + $function = $node[type] ."_form"; + return $function($node); } } @@ -122,7 +134,7 @@ function node_info($node) { nid" => t("view node"), "/node.php?op=update&id=$node->nid" => t("suggest update"), "/node.php?op=history&id=$node->nid" => t("view history"), "/node.php?op=referer&id=$node->nid" => t("view referers")); + $choices = array("/node.php?id=$node->nid" => t("view node"), "/submit.php?mod=$node->type&op=update&id=$node->nid" => t("suggest update"), "/node.php?op=history&id=$node->nid" => t("view history")); $output .= "\n"; foreach ($choices as $key => $value) $options .= "\n"; @@ -133,8 +145,8 @@ function node_info($node) { } function node_visible($node) { - global $user; - return ($node->status == 2) || ($node->status == 1 && $user->id) || user_access($user, "node"); + global $user, $status; + return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->id) || user_access($user, "node"); } function node_post_threshold($node, $threshold = 5) { diff --git a/includes/search.inc b/includes/search.inc index 78ec7ed8e..47eefecd9 100644 --- a/includes/search.inc +++ b/includes/search.inc @@ -14,7 +14,7 @@ function search_data($keys, $type) { $result = module_execute($type, "find", $keys); foreach ($result as $entry) { $output .= "

    \n"; - $output .= " $entry[subject]
    "; + $output .= " $entry[title]
    "; $output .= " $site_url$entry[link]". ($entry[user] ? " - ". format_username($entry[user]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") .""; $output .= "

    \n"; } diff --git a/includes/theme.inc b/includes/theme.inc index f7fe640dc..6182f8936 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -75,13 +75,13 @@ function theme_account($theme) { function theme_blocks($region, $theme) { - global $id, $PHP_SELF, $user; + global $id, $PHP_SELF, $status, $user; switch (strrchr($PHP_SELF, "/")) { case "/node.php": if ($region != "left") { if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM nodes WHERE nid = '$id'")); - if ($node->status == 1) theme_moderation_results($theme, $node); + if ($node->status == $status[queued]) theme_moderation_results($theme, $node); // else theme_new_headlines($theme); } break; @@ -113,6 +113,10 @@ function theme_moderation_results($theme, $node) { } } +/* +// +// depricated -> new block strategy +// function theme_new_headlines($theme, $num = 10) { $result = db_query("SELECT nid, title FROM nodes WHERE status = 2 AND type = 'story' ORDER BY nid DESC LIMIT $num"); while ($node = db_fetch_object($result)) $content .= "
  • nid\">". check_output($node->title) ."
  • \n"; @@ -132,5 +136,6 @@ function theme_old_headlines($theme, $num = 10) { } $theme->box(t("Older headlines"), $content); } +*/ ?> diff --git a/index.php b/index.php index 885fee9f7..bb928266f 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ $number = ($user->nodes) ? $user->nodes : 10; $date = ($date > 0) ? $date : time(); // Perform query: -$result = db_query("SELECT n.*, s.*, u.userid, COUNT(c.lid) AS comments FROM nodes n LEFT JOIN story s ON n.nid = s.node LEFT JOIN comments c ON n.nid = c.lid LEFT JOIN users u ON n.author = u.id WHERE n.status = 2 AND n.type = 'story' ". ($section ? "AND s.section = '$section' " : "") ."AND n.timestamp <= $date GROUP BY n.nid ORDER BY n.timestamp DESC LIMIT $number"); +$result = db_query("SELECT n.*, s.*, u.userid, COUNT(c.lid) AS comments FROM nodes n LEFT JOIN story s ON n.nid = s.node 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(); diff --git a/modules/account.module b/modules/account.module index 9823e1585..980080796 100644 --- a/modules/account.module +++ b/modules/account.module @@ -58,18 +58,18 @@ function account_blocks($id) { return $output; } -function account_stories($id) { - $result = db_query("SELECT * FROM stories WHERE author = $id ORDER BY timestamp DESC"); - while ($story = db_fetch_object($result)) { - $output .= "
  • id\">$story->subject
  • \n"; +function account_nodes($id) { + $result = db_query("SELECT * FROM nodes WHERE author = $id ORDER BY timestamp DESC"); + while ($node = db_fetch_object($result)) { + $output .= "
  • nid\">$node->title ($node->type)
  • \n"; } return $output; } function account_comments($id) { - $result = db_query("SELECT * FROM comments WHERE link = 'story' AND author = '$id' ORDER BY timestamp DESC"); + $result = db_query("SELECT * FROM comments WHERE author = '$id' ORDER BY timestamp DESC"); while ($comment = db_fetch_object($result)) { - $output .= "
  • lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">$comment->subject
  • \n"; + $output .= "
  • lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">$comment->subject
  • \n"; } return $output; } @@ -153,7 +153,7 @@ function account_view($name) { $output .= " \n"; $output .= " \n"; $output .= " \n"; - $output .= " \n"; + $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
    Theme:". check_output($account->theme) ."
    Timezone:". check_output($account->timezone / 3600) ."
    Selected blocks:". check_output(account_blocks($account->id)) ."
    Submitted stories:". check_output(account_stories($account->id)) ."
    Submitted nodes:". check_output(account_nodes($account->id)) ."
    Submitted comments:". check_output(account_comments($account->id)) ."
    userid\">
    \n"; diff --git a/modules/affiliate-site.module b/modules/affiliate-site.module index 3f88c01ba..1f004d11c 100644 --- a/modules/affiliate-site.module +++ b/modules/affiliate-site.module @@ -15,7 +15,7 @@ function affiliate_block() { $result = db_query("SELECT * FROM affiliates ORDER BY name"); - $content .= "