Commit 1f798630 authored by Dries's avatar Dries

- large commit of everything else that has been queued in my backlog:
  it's not 100% stable yet
parent d3075189
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 drupal 2.00, 15/03/2001
----------------------- -----------------------
- rewrote the comment/discussion code: - rewrote the comment/discussion code:
......
...@@ -68,35 +68,35 @@ function account_user_edit() { ...@@ -68,35 +68,35 @@ function account_user_edit() {
$output .= "<B>". t("Username") .":</B><BR>\n"; $output .= "<B>". t("Username") .":</B><BR>\n";
$output .= "$user->userid<P>\n"; $output .= "$user->userid<P>\n";
$output .= "<I>". t("Required, unique, and can not be changed.") ."</I><P>\n"; $output .= "<I><SMALL>". t("Required, unique, and can not be changed.") ."</SMALL></I><P>\n";
$output .= "<B>". t("Real name") .":</B><BR>\n"; $output .= "<B>". t("Real name") .":</B><BR>\n";
$output .= "<INPUT NAME=\"edit[name]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"$user->name\"><BR>\n"; $output .= "<INPUT NAME=\"edit[name]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"$user->name\"><BR>\n";
$output .= "<I>". t("Optional") .".</I><P>\n"; $output .= "<I><SMALL>". t("Optional") .".</SMALL></I><P>\n";
$output .= "<B>". t("Real e-mail address") .":</B><BR>\n"; $output .= "<B>". t("Real e-mail address") .":</B><BR>\n";
$output .= "$user->real_email<P>\n"; $output .= "$user->real_email<P>\n";
$output .= "<I>". 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.") ."</I><P>\n"; $output .= "<I><SMALL>". 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.") ."</SMALL></I><P>\n";
$output .= "<B>". t("Fake e-mail address") .":</B><BR>\n"; $output .= "<B>". t("Fake e-mail address") .":</B><BR>\n";
$output .= "<INPUT NAME=\"edit[fake_email]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"$user->fake_email\"><BR>\n"; $output .= "<INPUT NAME=\"edit[fake_email]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"$user->fake_email\"><BR>\n";
$output .= "<I>". t("Optional") .". ". t("Displayed publicly so you may spam proof your real e-mail address if you want.") ."</I><P>\n"; $output .= "<I><SMALL>". t("Optional") .". ". t("Displayed publicly so you may spam proof your real e-mail address if you want.") ."</SMALL></I><P>\n";
$output .= "<B>". t("Homepage") .":</B><BR>\n"; $output .= "<B>". t("Homepage") .":</B><BR>\n";
$output .= "<INPUT NAME=\"edit[url]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"$user->url\"><BR>\n"; $output .= "<INPUT NAME=\"edit[url]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"$user->url\"><BR>\n";
$output .= "<I>". t("Optional") .". ". t("Make sure you enter fully qualified URLs only. That is, remember to include \"http://\".") ."</I><P>\n"; $output .= "<I><SMALL>". t("Optional") .". ". t("Make sure you enter fully qualified URLs only. That is, remember to include \"http://\".") ."</SMALL></I><P>\n";
$output .= "<B>". t("Bio") .":</B> (". t("maximal 255 characters") .")<BR>\n"; $output .= "<B>". t("Bio") .":</B> (". t("maximal 255 characters") .")<BR>\n";
$output .= "<TEXTAREA NAME=\"edit[bio]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">$user->bio</TEXTAREA><BR>\n"; $output .= "<TEXTAREA NAME=\"edit[bio]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">$user->bio</TEXTAREA><BR>\n";
$output .= "<I>". t("Optional") .". ". t("This biographical information is publicly displayed on your user page.") ."<BR>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I><P>\n"; $output .= "<I><SMALL>". t("Optional") .". ". t("This biographical information is publicly displayed on your user page.") ."<BR>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</SMALL></I><P>\n";
$output .= "<B>". t("Signature") .":</B> (". t("maximal 255 characters") .")<BR>\n"; $output .= "<B>". t("Signature") .":</B> (". t("maximal 255 characters") .")<BR>\n";
$output .= "<TEXTAREA NAME=\"edit[signature]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">$user->signature</TEXTAREA><BR>\n"; $output .= "<TEXTAREA NAME=\"edit[signature]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">$user->signature</TEXTAREA><BR>\n";
$output .= "<I>". t("Optional") .". ". t("This information will be publicly displayed at the end of your comments.") ."<BR>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I><P>\n"; $output .= "<I><SMALL>". t("Optional") .". ". t("This information will be publicly displayed at the end of your comments.") ."<BR>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</SMALL></I><P>\n";
$output .= "<B>". t("Password") .":</B><BR>\n"; $output .= "<B>". t("Password") .":</B><BR>\n";
$output .= "<INPUT TYPE=\"password\" NAME=\"edit[pass1]\" SIZE=\"10\" MAXLENGTH=\"20\"> <INPUT TYPE=\"password\" NAME=\"edit[pass2]\" SIZE=\"10\" MAXLENGTH=\"20\"><BR>\n"; $output .= "<INPUT TYPE=\"password\" NAME=\"edit[pass1]\" SIZE=\"10\" MAXLENGTH=\"20\"> <INPUT TYPE=\"password\" NAME=\"edit[pass2]\" SIZE=\"10\" MAXLENGTH=\"20\"><BR>\n";
$output .= "<I>". 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.") ."</I><P>\n"; $output .= "<I><SMALL>". 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.") ."</SMALL></I><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Save user information") ."\"><BR>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Save user information") ."\"><BR>\n";
$output .= "</FORM>\n"; $output .= "</FORM>\n";
...@@ -131,25 +131,23 @@ function account_site_edit() { ...@@ -131,25 +131,23 @@ function account_site_edit() {
$output .= "<B>". t("Theme") .":</B><BR>\n"; $output .= "<B>". t("Theme") .":</B><BR>\n";
foreach ($themes as $key=>$value) $options1 .= " <OPTION VALUE=\"$key\"". (($user->theme == $key) ? " SELECTED" : "") .">$key - $value[1]</OPTION>\n"; foreach ($themes as $key=>$value) $options1 .= " <OPTION VALUE=\"$key\"". (($user->theme == $key) ? " SELECTED" : "") .">$key - $value[1]</OPTION>\n";
$output .= "<SELECT NAME=\"edit[theme]\">\n$options1</SELECT><BR>\n"; $output .= "<SELECT NAME=\"edit[theme]\">\n$options1</SELECT><BR>\n";
$output .= "<I>". t("Selecting a different theme will change the look and feel of the site.") ."</I><P>\n"; $output .= "<I><SMALL>". t("Selecting a different theme will change the look and feel of the site.") ."</SMALL></I><P>\n";
$output .= "<B>". t("Timezone") .":</B><BR>\n"; $output .= "<B>". t("Timezone") .":</B><BR>\n";
$date = time() - date("Z"); $date = time() - date("Z");
for ($zone = -43200; $zone <= 46800; $zone += 3600) $options2 .= " <OPTION VALUE=\"$zone\"". (($user->timezone == $zone) ? " SELECTED" : "") .">". date("l, F dS, Y - h:i A", $date + $zone) ." (GMT ". $zone / 3600 .")</OPTION>\n"; for ($zone = -43200; $zone <= 46800; $zone += 3600) $options2 .= " <OPTION VALUE=\"$zone\"". (($user->timezone == $zone) ? " SELECTED" : "") .">". date("l, F dS, Y - h:i A", $date + $zone) ." (GMT ". $zone / 3600 .")</OPTION>\n";
$output .= "<SELECT NAME=\"edit[timezone]\">\n$options2</SELECT><BR>\n"; $output .= "<SELECT NAME=\"edit[timezone]\">\n$options2</SELECT><BR>\n";
$output .= "<I>". t("Select what time you currently have and your timezone settings will be set appropriate.") ."</I><P>\n"; $output .= "<I><SMALL>". t("Select what time you currently have and your timezone settings will be set appropriate.") ."</SMALL></I><P>\n";
if ($languages) { $output .= "<B>". t("Language" ) .":</B><BR>\n";
$output .= "<B>". t("Language" ) .":</B><BR>\n"; foreach ($languages as $key=>$value) $options3 .= " <OPTION VALUE=\"$key\"". (($user->language == $key) ? " SELECTED" : "") .">$value - $key</OPTION>\n";
foreach ($languages as $key=>$value) $options3 .= " <OPTION VALUE=\"$key\"". (($user->language == $key) ? " SELECTED" : "") .">$value - $key</OPTION>\n"; $output .= "<SELECT NAME=\"edit[language]\">\n$options3</SELECT><BR>\n";
$output .= "<SELECT NAME=\"edit[language]\">\n$options3</SELECT><BR>\n"; $output .= "<I><SMALL>". t("Selecting a different language will change the language the site.") ."</SMALL></I><P>\n";
$output .= "<I>". t("Selecting a different language will change the language the site.") ."</I><P>\n";
}
$output .= "<B>". t("Maximum number of items to display") .":</B><BR>\n"; $output .= "<B>". t("Maximum number of items to display") .":</B><BR>\n";
for ($nodes = 10; $nodes <= 30; $nodes += 5) $options4 .= "<OPTION VALUE=\"$nodes\"". (($user->nodes == $nodes) ? " SELECTED" : "") .">$nodes</OPTION>\n"; for ($nodes = 10; $nodes <= 30; $nodes += 5) $options4 .= "<OPTION VALUE=\"$nodes\"". (($user->nodes == $nodes) ? " SELECTED" : "") .">$nodes</OPTION>\n";
$output .= "<SELECT NAME=\"edit[nodes]\">\n$options4</SELECT><BR>\n"; $output .= "<SELECT NAME=\"edit[nodes]\">\n$options4</SELECT><BR>\n";
$output .= "<I>". t("The maximum number of nodes that will be displayed on the main page.") ."</I><P>\n"; $output .= "<I><SMALL>". t("The maximum number of nodes that will be displayed on the main page.") ."</SMALL></I><P>\n";
foreach ($cmodes as $key=>$value) $options5 .= "<OPTION VALUE=\"$key\"". ($user->mode == $key ? " SELECTED" : "") .">$value</OPTION>\n"; foreach ($cmodes as $key=>$value) $options5 .= "<OPTION VALUE=\"$key\"". ($user->mode == $key ? " SELECTED" : "") .">$value</OPTION>\n";
$output .= "<B>". t("Comment display mode") .":</B><BR>\n"; $output .= "<B>". t("Comment display mode") .":</B><BR>\n";
...@@ -162,7 +160,7 @@ function account_site_edit() { ...@@ -162,7 +160,7 @@ function account_site_edit() {
for ($i = -1; $i < 6; $i++) $options7 .= " <OPTION VALUE=\"$i\"". ($user->threshold == $i ? " SELECTED" : "") .">Filter - $i</OPTION>"; for ($i = -1; $i < 6; $i++) $options7 .= " <OPTION VALUE=\"$i\"". ($user->threshold == $i ? " SELECTED" : "") .">Filter - $i</OPTION>";
$output .= "<B>". t("Comment filter") .":</B><BR>\n"; $output .= "<B>". t("Comment filter") .":</B><BR>\n";
$output .= "<SELECT NAME=\"edit[threshold]\">$options7</SELECT><BR>\n"; $output .= "<SELECT NAME=\"edit[threshold]\">$options7</SELECT><BR>\n";
$output .= "<I>". 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.") ."</I><P>\n"; $output .= "<I><SMALL>". 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.") ."</SMALL></I><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Save site settings") ."\"><BR>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Save site settings") ."\"><BR>\n";
$output .= "</FORM>\n"; $output .= "</FORM>\n";
...@@ -197,7 +195,7 @@ function account_content_edit() { ...@@ -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'")); $entry = db_fetch_object(db_query("SELECT * FROM layout WHERE block = '$block->name' AND user = '$user->id'"));
$output .= "<INPUT TYPE=\"checkbox\" NAME=\"edit[$block->name]\"". ($entry->user ? " CHECKED" : "") ."> ". t($block->name) ."<BR>\n"; $output .= "<INPUT TYPE=\"checkbox\" NAME=\"edit[$block->name]\"". ($entry->user ? " CHECKED" : "") ."> ". t($block->name) ."<BR>\n";
} }
$output .= "<P><I>". t("Enable the blocks you would like to see displayed in the side bars.") ."</I></P>\n"; $output .= "<P><I><SMALL>". t("Enable the blocks you would like to see displayed in the side bars.") ."</SMALL></I></P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Save content settings") ."\">\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Save content settings") ."\">\n";
$output .= "</FORM>\n"; $output .= "</FORM>\n";
...@@ -224,7 +222,7 @@ function account_content_save($edit) { ...@@ -224,7 +222,7 @@ function account_content_save($edit) {
} }
function account_user($uname) { function account_user($uname) {
global $user, $theme; global $user, $status, $theme;
function module($name, $module, $username) { function module($name, $module, $username) {
global $theme; global $theme;
...@@ -256,7 +254,7 @@ function module($name, $module, $username) { ...@@ -256,7 +254,7 @@ function module($name, $module, $username) {
$block1 .= "</TABLE>\n"; $block1 .= "</TABLE>\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)) { while ($comment = db_fetch_object($result)) {
$block2 .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n"; $block2 .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
$block2 .= " <TR><TD ALIGN=\"right\"><B>". t("Comment") .":</B></TD><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD></TR>\n"; $block2 .= " <TR><TD ALIGN=\"right\"><B>". t("Comment") .":</B></TD><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD></TR>\n";
...@@ -427,9 +425,9 @@ function account_track_comments() { ...@@ -427,9 +425,9 @@ function account_track_comments() {
} }
function account_track_nodes() { 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)) { while ($node = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n"; $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
...@@ -446,11 +444,11 @@ function account_track_nodes() { ...@@ -446,11 +444,11 @@ function account_track_nodes() {
} }
function account_track_site() { function account_track_site() {
global $theme, $user, $site_name; global $status, $theme, $user, $site_name;
$period = 259200; // 3 days $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)) { while ($node = db_fetch_object($sresult)) {
$output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>"; $output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>";
......
...@@ -58,8 +58,8 @@ $themes = array("UnConeD" => array( ...@@ -58,8 +58,8 @@ $themes = array("UnConeD" => array(
# #
# Submission moderation votes: # 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. # 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. # 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.
$submission_votes = array("neutral (+0)" => "+ 0", $moderation_votes = array("neutral (+0)" => "+ 0",
"post it (+1)" => "+ 1", "post it (+1)" => "+ 1",
"dump it (-1)" => "- 1"); "dump it (-1)" => "- 1");
......
<?php <?php
$status = array(dumped => 0, expired => 1, queued => 2, posted => 3, scheduled => 4);
function _node_get($field, $value) { function _node_get($field, $value) {
$result = db_query("SELECT lid, type FROM nodes WHERE $field = '$value'"); $result = db_query("SELECT lid, type FROM nodes WHERE $field = '$value'");
if ($node = db_fetch_object($result)) { if ($node = db_fetch_object($result)) {
...@@ -32,9 +34,9 @@ function node_del_array($field, $value) { ...@@ -32,9 +34,9 @@ function node_del_array($field, $value) {
} }
function node_save($node) { 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: // insert or update node:
if ($node[nid]) { if ($node[nid]) {
...@@ -55,10 +57,12 @@ function node_save($node) { ...@@ -55,10 +57,12 @@ function node_save($node) {
db_query("UPDATE nodes SET $u1 WHERE nid = '$node[nid]'"); db_query("UPDATE nodes SET $u1 WHERE nid = '$node[nid]'");
db_query("UPDATE $node[type] SET $u2 WHERE node = '$node[nid]'"); db_query("UPDATE $node[type] SET $u2 WHERE node = '$node[nid]'");
watchdog("message", "modified node '$node[title]'");
} }
else { else {
// setup default values: // 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: // prepare queries:
$f1 = array(); $f1 = array();
...@@ -82,28 +86,36 @@ function node_save($node) { ...@@ -82,28 +86,36 @@ function node_save($node) {
$f2 = implode(", ", $f2); $f2 = implode(", ", $f2);
$v2 = implode(", ", $v2); $v2 = implode(", ", $v2);
// if (!_node_get("title = $node[title] AND timestamp < ". time() ." - 60")) { db_query("INSERT INTO nodes ($f1) VALUES ($v1)");
db_query("INSERT INTO nodes ($f1) VALUES ($v1)"); if ($nid = db_insert_id()) {
if ($nid = db_insert_id()) { $lid = db_query("INSERT INTO $node[type] ($f2, node) VALUES ($v2, $nid)");
$lid = db_query("INSERT INTO $node[type] ($f2, node) VALUES ($v2, $nid)"); if ($lid = db_insert_id()) {
if ($lid = db_insert_id()) { db_query("UPDATE nodes SET lid = '$lid' WHERE nid = '$nid'");
db_query("UPDATE nodes SET lid = '$lid' WHERE nid = '$nid'"); }
} else {
else { db_query("DELETE FROM nodes WHERE nid = '$nid'");
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) { if ($node->type) {
$function = $node->type ."_view"; $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 visit(site) { ...@@ -122,7 +134,7 @@ function visit(site) {
</SCRIPT> </SCRIPT>
<?php <?php
$choices = array("/node.php?id=$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 .= "<FORM METHOD=\"get\" ACTION=\"\">\n"; $output .= "<FORM METHOD=\"get\" ACTION=\"\">\n";
foreach ($choices as $key => $value) $options .= "<OPTION VALUE=\"$key\"". ($key == $REQUEST_URI ? " SELECTED" : "") .">". check_select($value) ."</OPTION>\n"; foreach ($choices as $key => $value) $options .= "<OPTION VALUE=\"$key\"". ($key == $REQUEST_URI ? " SELECTED" : "") .">". check_select($value) ."</OPTION>\n";
...@@ -133,8 +145,8 @@ function visit(site) { ...@@ -133,8 +145,8 @@ function visit(site) {
} }
function node_visible($node) { function node_visible($node) {
global $user; global $user, $status;
return ($node->status == 2) || ($node->status == 1 && $user->id) || user_access($user, "node"); return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->id) || user_access($user, "node");
} }
function node_post_threshold($node, $threshold = 5) { function node_post_threshold($node, $threshold = 5) {
......
...@@ -14,7 +14,7 @@ function search_data($keys, $type) { ...@@ -14,7 +14,7 @@ function search_data($keys, $type) {
$result = module_execute($type, "find", $keys); $result = module_execute($type, "find", $keys);
foreach ($result as $entry) { foreach ($result as $entry) {
$output .= "<P>\n"; $output .= "<P>\n";
$output .= " <B><U><A HREF=\"$entry[link]\">$entry[subject]</A></U></B><BR>"; $output .= " <B><U><A HREF=\"$entry[link]\">$entry[title]</A></U></B><BR>";
$output .= " <SMALL>$site_url$entry[link]". ($entry[user] ? " - ". format_username($entry[user]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</SMALL>"; $output .= " <SMALL>$site_url$entry[link]". ($entry[user] ? " - ". format_username($entry[user]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</SMALL>";
$output .= "</P>\n"; $output .= "</P>\n";
} }
......
...@@ -75,13 +75,13 @@ function theme_account($theme) { ...@@ -75,13 +75,13 @@ function theme_account($theme) {
function theme_blocks($region, $theme) { function theme_blocks($region, $theme) {
global $id, $PHP_SELF, $user; global $id, $PHP_SELF, $status, $user;
switch (strrchr($PHP_SELF, "/")) { switch (strrchr($PHP_SELF, "/")) {
case "/node.php": case "/node.php":
if ($region != "left") { if ($region != "left") {
if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM nodes WHERE nid = '$id'")); 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); // else theme_new_headlines($theme);
} }
break; break;
...@@ -113,6 +113,10 @@ function theme_moderation_results($theme, $node) { ...@@ -113,6 +113,10 @@ function theme_moderation_results($theme, $node) {
} }
} }
/*
//
// depricated -> new block strategy
//
function theme_new_headlines($theme, $num = 10) { 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"); $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 .= "<LI><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></LI>\n"; while ($node = db_fetch_object($result)) $content .= "<LI><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></LI>\n";
...@@ -132,5 +136,6 @@ function theme_old_headlines($theme, $num = 10) { ...@@ -132,5 +136,6 @@ function theme_old_headlines($theme, $num = 10) {
} }
$theme->box(t("Older headlines"), $content); $theme->box(t("Older headlines"), $content);
} }
*/
?> ?>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
$date = ($date > 0) ? $date : time(); $date = ($date > 0) ? $date : time();
// Perform query: // 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: // Display nodes:
$theme->header(); $theme->header();
......
...@@ -58,18 +58,18 @@ function account_blocks($id) { ...@@ -58,18 +58,18 @@ function account_blocks($id) {
return $output; return $output;
} }
function account_stories($id) { function account_nodes($id) {
$result = db_query("SELECT * FROM stories WHERE author = $id ORDER BY timestamp DESC"); $result = db_query("SELECT * FROM nodes WHERE author = $id ORDER BY timestamp DESC");
while ($story = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"story.php?id=$story->id\">$story->subject</A></LI>\n"; $output .= "<LI><A HREF=\"node.php?id=$node->nid\">$node->title</A> ($node->type)</LI>\n";
} }
return $output; return $output;
} }
function account_comments($id) { 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)) { while ($comment = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"story.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">$comment->subject</A></LI>\n"; $output .= "<LI><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">$comment->subject</A></LI>\n";
} }
return $output; return $output;
} }
...@@ -153,7 +153,7 @@ function account_view($name) { ...@@ -153,7 +153,7 @@ function account_view($name) {
$output .= " <TR><TH>Theme:</TH><TD>". check_output($account->theme) ."</TD></TR>\n"; $output .= " <TR><TH>Theme:</TH><TD>". check_output($account->theme) ."</TD></TR>\n";
$output .= " <TR><TH>Timezone:</TH><TD>". check_output($account->timezone / 3600) ."</TD></TR>\n"; $output .= " <TR><TH>Timezone:</TH><TD>". check_output($account->timezone / 3600) ."</TD></TR>\n";
$output .= " <TR><TH>Selected blocks:</TH><TD>". check_output(account_blocks($account->id)) ."</TD></TR>\n"; $output .= " <TR><TH>Selected blocks:</TH><TD>". check_output(account_blocks($account->id)) ."</TD></TR>\n";
$output .= " <TR><TH>Submitted stories:</TH><TD>". check_output(account_stories($account->id)) ."</TD></TR>\n"; $output .= " <TR><TH>Submitted nodes:</TH><TD>". check_output(account_nodes($account->id)) ."</TD></TR>\n";
$output .= " <TR><TH>Submitted comments:</TH><TD>". check_output(account_comments($account->id)) ."</TD></TR>\n"; $output .= " <TR><TH>Submitted comments:</TH><TD>". check_output(account_comments($account->id)) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\"><INPUT TYPE=\"hidden\" NAME=\"name\" VALUE=\"$account->userid\"><INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Edit account\"><INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Delete account\"></TD></TR>\n"; $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\"><INPUT TYPE=\"hidden\" NAME=\"name\" VALUE=\"$account->userid\"><INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Edit account\"><INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Delete account\"></TD></TR>\n";
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";
......
...@@ -15,7 +15,7 @@ function affiliate_block() { ...@@ -15,7 +15,7 @@ function affiliate_block() {
$result = db_query("SELECT * FROM affiliates ORDER BY name"); $result = db_query("SELECT * FROM affiliates ORDER BY name");
$content .= "<SCRIPT TYPE=\"\">\n"; $content .= "<SCRIPT>\n";
$content .= " <!--//\n"; $content .= " <!--//\n";
$content .= " function gotosite(site) {\n"; $content .= " function gotosite(site) {\n";
$content .= " if (site != \"\") {\n"; $content .= " if (site != \"\") {\n";
......
...@@ -2,8 +2,21 @@ ...@@ -2,8 +2,21 @@
$module = array("find" => "book_find", $module = array("find" => "book_find",
"page" => "book_page", "page" => "book_page",
"user" => "book_user",
"admin" => "book_admin"); "admin" => "book_admin");
class Book {
function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) {
$this->nid = $nid;
$this->userid = $userid;
$this->title = $title;
$this->body = $body;
$this->parent = $parent;
$this->weight = $weight;
$this->timestamp = $timestamp;
}
}
function book_navigation($node) { function book_navigation($node) {
if ($node->nid) { if ($node->nid) {
$next = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC")); $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC"));
...@@ -17,49 +30,39 @@ function book_navigation($node) { ...@@ -17,49 +30,39 @@ function book_navigation($node) {
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";
return $output; return $output;
} }
function book_update($node) { function theme_book($node) {
return ($node->nid ? "<A HREF=\"module.php?mod=book&op=update&id=$node->nid\">". t("update") ."</A>" : t("update"));
}
function theme_book($node, $small = 0) {
global $theme; global $theme;
if ($small) { if ($node->title) {
print "<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>"; $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
$output .= " <TR><TD><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_username($node->userid) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD><TD ALIGN=\"right\">". node_info($node) ."</TD></TR>\n";
$output .= "</TABLE>\n";
} }
else { if ($node->body) {
if ($node->title && $node->body) { $output .= "<P>". check_output($node->body, 1) ."</P>";
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
$output .= " <TR><TD><B><BIG>". check_output($node->title) ."</BIG></B><BR><SMALL><I>Last updated by ". format_username($node->userid) ." on ". format_date($node->timestamp) ."</I></SMALL></TD><TD ALIGN=\"right\">". node_info($node) ."</TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<P>". check_output($node->body, 1) ."</P>";
}
$theme->box(t("Documentation book"), $output ."". book_overview($node->nid) ."". book_navigation($node));
} }
}
function book_view($node) { $theme->box(t("Documentation book"), $output ."". book_overview($node->nid) ."". book_navigation($node));
global $op; }