Commit 8d249c5f authored by Dries's avatar Dries

Last night's updates:

 - improved "track drop.org": it has now 2 boxes, one for "track
   comments" and one for "track nodes"
 - various small improvements to the book module based on the
   feedback we got.
 - fixed typo in moderation module
 - ...
parent 97dd9e1c
......@@ -453,10 +453,12 @@ function account_track_nodes() {
}
function account_track_site() {
global $status, $theme, $user, $site_name;
global $nstatus, $status, $theme, $user, $site_name;
$period = 259200; // 3 days
$theme->header();
$sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN node 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 .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>";
......@@ -469,8 +471,21 @@ function account_track_site() {
$output .= "</UL>\n";
}
$theme->header();
$theme->box(strtr(t("Track %a"), array("%a" => $site_name)), ($output ? $output : t("No comments or nodes posted recently.")));
$theme->box(t("Recent comments"), ($output ? $output : t("No comments recently.")));
unset($output);
$result = db_query("SELECT n.title, n.nid, n.type, n.status, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE ". time() ." - n.timestamp < $period ORDER BY n.timestamp DESC LIMIT 10");
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
$output .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Status") ."</TH></TR>\n";
while ($node = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">$node->type</TD><TD>". $nstatus[$node->status] ."</TD></TR>";
}
$output .= "</TABLE>";
$theme->box(t("Recent nodes"), ($output ? $output : t("No nodes recently.")));
$theme->footer();
}
......
......@@ -131,7 +131,7 @@ function node_form($node) {
}
}
function node_info($node) {
function node_control($node) {
global $REQUEST_URI;
?>
......
......@@ -32,19 +32,47 @@ function book_navigation($node) {
return $output;
}
function book_location($node, $nodes = array()) {
$parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.nid = '$node->parent'"));
if ($parent->title) {
$nodes = book_location($parent, $nodes);
array_push($nodes, $parent);
}
return $nodes;
}
function theme_book($node) {
global $theme;
if ($node->nid && $node->parent) {
$next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight > '$node->weight' ORDER BY b.weight ASC"));
$prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight < '$node->weight' ORDER BY b.weight DESC"));
}
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
if ($node->title) {
$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";
foreach (book_location($node) as $level) {
$location .= "$indent <A HREF=\"node.php?id=$level->nid\">$level->title</A><BR>";
$indent .= "-";
}
$output .= " <TR><TD COLSPAN=\"2\">$location</TD><TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD</TR>";
$output .= " <TR><TD COLSPAN=\"3\"><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></TR>\n";
}
if ($node->body) {
$output .= "<P>". check_output($node->body, 1) ."</P>";
$output .= " <TR><TD COLSPAN=\"3\"><BR>". check_output($node->body, 1) ."</TD></TR>";
}
$theme->box(t("Handbook"), $output ."". book_tree($node->nid) ."". book_navigation($node));
$output .= " <TR><TD COLSPAN=\"3\"><BR>". book_tree($node->nid) ."</TD</TR>";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD</TR>";
$output .= " <TR><TD ALIGN=\"left\" WIDTH=\"33%\">". ($prev ? "<A HREF=\"node.php?id=$prev->nid\">". t("previous") ."</A>" : t("previous")) ."</TD><TD ALIGN=\"center\" WIDTH=\"34%\"><A HREF=\"module.php?mod=book\">index</A></TD><TD ALIGN=\"right\" WIDTH=\"33%\">". ($next ? "<A HREF=\"node.php?id=$next->nid\">". t("next") ."</A>" : t("next")) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"left\" WIDTH=\"33%\">". ($prev ? "<SMALL>". check_output($prev->title) ."</SMALL>" : "&nbsp;") ."</TD><TD ALIGN=\"center\" WIDTH=\"34%\">". ($node->parent ? "<A HREF=\"node.php?id=$node->parent\">". t("up") ."</A>" : t("up")) ."</TD><TD ALIGN=\"right\" WIDTH=\"33%\">". ($next ? "<SMALL>". check_output($next->title) ."</SMALL>" : "&nbsp;") ."</TD></TR>\n";
$output .= "</TABLE>\n";
$theme->box(t("Handbook"), $output);
}
function book_view($node, $page = 1) {
......@@ -75,13 +103,13 @@ function book_search() {
print search_data($keys, $mod);
}
function book_toc($parent = 0, $offset = "", $toc = array()) {
function book_toc($parent = 0, $indent = "", $toc = array()) {
global $status;
$result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$toc[$node->nid] = "$offset $node->title";
if ($node->pid) $toc = book_toc($node->pid, "$offset-", $toc);
$toc = book_toc($node->nid, "$offset-", $toc);
$toc[$node->nid] = "$indent $node->title";
if ($node->pid) $toc = book_toc($node->pid, "$indent-", $toc);
$toc = book_toc($node->nid, "$indent-", $toc);
}
return $toc;
}
......@@ -100,14 +128,14 @@ function book_form($edit = array()) {
$output .= "<B>". t("Parent") .":</B><BR>\n";
$output .= "<A HREF=\"node.php?id=$node->id\">". check_output($node->title) ."</A><P>\n";
$output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[parent]\" VALUE=\"$edit[parent]\">\n";
$output .= "<SMALL><I>". t("The parent subject or category the new page belongs in.") ."</I></SMALL><P>\n";
$output .= "<SMALL><I>". t("The parent subject or category the page belongs in.") ."</I></SMALL><P>\n";
}
else {
$output .= "<B>". t("Parent") .":</B><BR>\n";
foreach (book_toc() as $key=>$value) $options2 .= "<OPTION VALUE=\"$key\"". ($edit[parent] == $key ? " SELECTED" : "") .">". check_select($value) ."</OPTION>";
if (user_access($user, "book")) $options2 .= "<OPTION VALUE=\"0\"". ($edit[parent] == 0 ? " SELECTED" : "") .">&nbsp;</OPTION>";
$output .= "<SELECT NAME=\"edit[parent]\">$options2</SELECT><BR>\n";
$output .= "<SMALL><I>". t("The parent subject or category the new page belongs in.") ."</I></SMALL><P>\n";
$output .= "<SMALL><I>". t("The parent subject or category the page belongs in.") ."</I></SMALL><P>\n";
}
$output .= "<B>". t("Subject") .":</B><BR>\n";
......@@ -120,7 +148,7 @@ function book_form($edit = array()) {
if ($edit[pid]) {
$output .= "<B>". t("Log message") .":</B><BR>\n";
$output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"5\" NAME=\"edit[log]\" MAXLENGTH=\"20\">". check_textarea($edit[log]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("A brief explanation of your update.") ."</I></SMALL><P>\n";
$output .= "<SMALL><I>". t("An explanation of the updates being made to help the group understand the changes.") ."</I></SMALL><P>\n";
}
if (user_access($user, "book")) {
......
......@@ -32,19 +32,47 @@ function book_navigation($node) {
return $output;
}
function book_location($node, $nodes = array()) {
$parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.nid = '$node->parent'"));
if ($parent->title) {
$nodes = book_location($parent, $nodes);
array_push($nodes, $parent);
}
return $nodes;
}
function theme_book($node) {
global $theme;
if ($node->nid && $node->parent) {
$next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight > '$node->weight' ORDER BY b.weight ASC"));
$prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight < '$node->weight' ORDER BY b.weight DESC"));
}
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
if ($node->title) {
$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";
foreach (book_location($node) as $level) {
$location .= "$indent <A HREF=\"node.php?id=$level->nid\">$level->title</A><BR>";
$indent .= "-";
}
$output .= " <TR><TD COLSPAN=\"2\">$location</TD><TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD</TR>";
$output .= " <TR><TD COLSPAN=\"3\"><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></TR>\n";
}
if ($node->body) {
$output .= "<P>". check_output($node->body, 1) ."</P>";
$output .= " <TR><TD COLSPAN=\"3\"><BR>". check_output($node->body, 1) ."</TD></TR>";
}
$theme->box(t("Handbook"), $output ."". book_tree($node->nid) ."". book_navigation($node));
$output .= " <TR><TD COLSPAN=\"3\"><BR>". book_tree($node->nid) ."</TD</TR>";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD</TR>";
$output .= " <TR><TD ALIGN=\"left\" WIDTH=\"33%\">". ($prev ? "<A HREF=\"node.php?id=$prev->nid\">". t("previous") ."</A>" : t("previous")) ."</TD><TD ALIGN=\"center\" WIDTH=\"34%\"><A HREF=\"module.php?mod=book\">index</A></TD><TD ALIGN=\"right\" WIDTH=\"33%\">". ($next ? "<A HREF=\"node.php?id=$next->nid\">". t("next") ."</A>" : t("next")) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"left\" WIDTH=\"33%\">". ($prev ? "<SMALL>". check_output($prev->title) ."</SMALL>" : "&nbsp;") ."</TD><TD ALIGN=\"center\" WIDTH=\"34%\">". ($node->parent ? "<A HREF=\"node.php?id=$node->parent\">". t("up") ."</A>" : t("up")) ."</TD><TD ALIGN=\"right\" WIDTH=\"33%\">". ($next ? "<SMALL>". check_output($next->title) ."</SMALL>" : "&nbsp;") ."</TD></TR>\n";
$output .= "</TABLE>\n";
$theme->box(t("Handbook"), $output);
}
function book_view($node, $page = 1) {
......@@ -75,13 +103,13 @@ function book_search() {
print search_data($keys, $mod);
}
function book_toc($parent = 0, $offset = "", $toc = array()) {
function book_toc($parent = 0, $indent = "", $toc = array()) {
global $status;
$result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$toc[$node->nid] = "$offset $node->title";
if ($node->pid) $toc = book_toc($node->pid, "$offset-", $toc);
$toc = book_toc($node->nid, "$offset-", $toc);
$toc[$node->nid] = "$indent $node->title";
if ($node->pid) $toc = book_toc($node->pid, "$indent-", $toc);
$toc = book_toc($node->nid, "$indent-", $toc);
}
return $toc;
}
......@@ -100,14 +128,14 @@ function book_form($edit = array()) {
$output .= "<B>". t("Parent") .":</B><BR>\n";
$output .= "<A HREF=\"node.php?id=$node->id\">". check_output($node->title) ."</A><P>\n";
$output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[parent]\" VALUE=\"$edit[parent]\">\n";
$output .= "<SMALL><I>". t("The parent subject or category the new page belongs in.") ."</I></SMALL><P>\n";
$output .= "<SMALL><I>". t("The parent subject or category the page belongs in.") ."</I></SMALL><P>\n";
}
else {
$output .= "<B>". t("Parent") .":</B><BR>\n";
foreach (book_toc() as $key=>$value) $options2 .= "<OPTION VALUE=\"$key\"". ($edit[parent] == $key ? " SELECTED" : "") .">". check_select($value) ."</OPTION>";
if (user_access($user, "book")) $options2 .= "<OPTION VALUE=\"0\"". ($edit[parent] == 0 ? " SELECTED" : "") .">&nbsp;</OPTION>";
$output .= "<SELECT NAME=\"edit[parent]\">$options2</SELECT><BR>\n";
$output .= "<SMALL><I>". t("The parent subject or category the new page belongs in.") ."</I></SMALL><P>\n";
$output .= "<SMALL><I>". t("The parent subject or category the page belongs in.") ."</I></SMALL><P>\n";
}
$output .= "<B>". t("Subject") .":</B><BR>\n";
......@@ -120,7 +148,7 @@ function book_form($edit = array()) {
if ($edit[pid]) {
$output .= "<B>". t("Log message") .":</B><BR>\n";
$output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"5\" NAME=\"edit[log]\" MAXLENGTH=\"20\">". check_textarea($edit[log]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("A brief explanation of your update.") ."</I></SMALL><P>\n";
$output .= "<SMALL><I>". t("An explanation of the updates being made to help the group understand the changes.") ."</I></SMALL><P>\n";
}
if (user_access($user, "book")) {
......
......@@ -54,7 +54,7 @@ function moderation_overview() {
$result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[queued]'");
$content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
$content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n";
$content .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n";
while ($node = db_fetch_object($result)) {
if ($user->id == $node->author || user_get($user, "history", "n$node->nid")) $content .= " <TR><TD><A HREF=\"module.php?mod=moderation&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". moderation_score($node->nid) ."</TD></TR>\n";
else $content .= " <TR><TD><A HREF=\"module.php?mod=moderation&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=moderation&op=view&id=$node->nid\">". t("vote") ."</A></TD></TR>\n";
......
......@@ -41,7 +41,7 @@ function node_history($node) {
switch ($op) {
case "history":
$theme->header();
$theme->box(t("History"), node_info($node) ."<DL>". node_history($node) ."</DL>");
$theme->box(t("History"), node_control($node) ."<DL>". node_history($node) ."</DL>");
$theme->footer();
break;
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment