summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/account.module11
-rw-r--r--modules/book.module69
-rw-r--r--modules/book/book.module69
-rw-r--r--modules/comment.module11
-rw-r--r--modules/comment/comment.module11
-rw-r--r--modules/diary.module11
-rw-r--r--modules/rating.module33
-rw-r--r--modules/story.module11
-rw-r--r--modules/story/story.module11
9 files changed, 77 insertions, 160 deletions
diff --git a/modules/account.module b/modules/account.module
index 5fd8f85ad..e893726a1 100644
--- a/modules/account.module
+++ b/modules/account.module
@@ -46,12 +46,6 @@ function account_find($keys) {
return $find;
}
-function account_search() {
- global $keys, $mod;
- print search_form($keys);
- print search_data($keys, $mod);
-}
-
function account_ac_add($edit) {
db_query("INSERT INTO access (mask, type, reason) VALUES ('". check_input($edit[mask]) ."', '". check_input($edit[type]) ."', '". check_input($edit[reason]) ."')", 1);
}
@@ -225,7 +219,7 @@ function account_view($name) {
}
function account_admin() {
- global $op, $edit, $id, $order, $name;
+ global $op, $edit, $id, $mod, $keys, $order, $name;
print "<SMALL> <A HREF=\"admin.php?mod=account&op=access\">access control</A> | <A HREF=\"admin.php?mod=account&op=search\">search account</A> | <A HREF=\"admin.php?mod=account\">overview</A> | <A HREF=\"admin.php?mod=account&op=help\">help</A></SMALL><HR>\n";
@@ -258,7 +252,8 @@ function account_admin() {
print account_help();
break;
case "search":
- print account_search();
+ print search_form($keys);
+ print search_data($keys, $mod);
break;
case "View account":
case "view":
diff --git a/modules/book.module b/modules/book.module
index ed0972bd0..62662ee8f 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -17,21 +17,6 @@ class Book {
}
}
-function book_navigation($node) {
- if ($node->nid && $node->parent && $node->weight) {
- $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 .= "<HR>";
- $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
- $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>" : "") ."</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>" : "") ."</TD></TR>\n";
- $output .= "</TABLE>\n";
-
- 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) {
@@ -41,7 +26,7 @@ function book_location($node, $nodes = array()) {
return $nodes;
}
-function theme_book($node) {
+function book_view($node, $page = 1) {
global $theme;
if ($node->nid && $node->parent) {
@@ -72,19 +57,9 @@ function theme_book($node) {
$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";
+ if ($page) $theme->header();
$theme->box(t("Handbook"), $output);
-}
-
-function book_view($node, $page = 1) {
- if ($page) {
- global $theme;
- $theme->header();
- theme_book($node);
- $theme->footer();
- }
- else {
- theme_book($node);
- }
+ if ($page) $theme->footer();
}
function book_find($keys) {
@@ -97,12 +72,6 @@ function book_find($keys) {
return $find;
}
-function book_search() {
- global $keys, $mod;
- print search_form($keys);
- print search_data($keys, $mod);
-}
-
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");
@@ -203,7 +172,7 @@ function book_list() {
}
function book_admin() {
- global $op, $id, $edit, $user;
+ global $op, $id, $edit, $mod, $keys, $user;
print "<SMALL><A HREF=\"admin.php?mod=book&op=add\">add new page</A> | <A HREF=\"admin.php?mod=book&op=search\">search book</A> | <A HREF=\"admin.php?mod=book&op=list\">list overview</A> | <A HREF=\"admin.php?mod=book\">tree overview</A></SMALL><HR>\n";
@@ -218,7 +187,8 @@ function book_admin() {
print book_form(node_get_array(nid, $id));
break;
case "search":
- book_search();
+ print search_form($keys);
+ print search_data($keys, $mod);
break;
case t("Preview"):
book_view(new Book(($edit[nid] ? $edit[nid] : -1), ($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
@@ -238,24 +208,41 @@ function book_page($id = 0) {
book_view(node_get_object("nid", $nid));
}
+function book_update($id) {
+ global $status;
+
+ if ($node = node_get_object("nid", $id)) {
+ if ($node->status != $status[posted]) {
+ return t("You can only update accepted pages: pages that are still queued or already expired can not be updated.");
+ }
+ else if (db_result(db_query("SELECT COUNT(nid) FROM node WHERE pid = '$node->nid' AND status = '$status[queued]'"))) {
+ return t("There is already an update for this node queued: we can only process one update at the time.");
+ }
+ else {
+ return book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent));
+ }
+ }
+}
+
function book_user() {
global $edit, $id, $op, $theme, $user;
+ $title = t("Submit a book page");
+
switch($op) {
case "update":
- $node = node_get_object("nid", $id);
- $theme->box("Update a book page", book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent)));
+ $theme->box($title, book_update($id));
break;
case t("Preview"):
book_view(new Book(($edit[nid] ? $edit[nid] : -1), $user->userid, $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
- $theme->box("Submit a book page", book_form($edit));
+ $theme->box($title, book_form($edit));
break;
case t("Submit"):
book_save($edit);
- $theme->box(t("Submit a book page"), t("Thank you for your submission."));
+ $theme->box($title, t("Thank you for your submission."));
break;
default:
- $theme->box("Submit a book page", book_form());
+ $theme->box($title, book_form());
}
}
diff --git a/modules/book/book.module b/modules/book/book.module
index ed0972bd0..62662ee8f 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -17,21 +17,6 @@ class Book {
}
}
-function book_navigation($node) {
- if ($node->nid && $node->parent && $node->weight) {
- $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 .= "<HR>";
- $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
- $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>" : "") ."</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>" : "") ."</TD></TR>\n";
- $output .= "</TABLE>\n";
-
- 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) {
@@ -41,7 +26,7 @@ function book_location($node, $nodes = array()) {
return $nodes;
}
-function theme_book($node) {
+function book_view($node, $page = 1) {
global $theme;
if ($node->nid && $node->parent) {
@@ -72,19 +57,9 @@ function theme_book($node) {
$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";
+ if ($page) $theme->header();
$theme->box(t("Handbook"), $output);
-}
-
-function book_view($node, $page = 1) {
- if ($page) {
- global $theme;
- $theme->header();
- theme_book($node);
- $theme->footer();
- }
- else {
- theme_book($node);
- }
+ if ($page) $theme->footer();
}
function book_find($keys) {
@@ -97,12 +72,6 @@ function book_find($keys) {
return $find;
}
-function book_search() {
- global $keys, $mod;
- print search_form($keys);
- print search_data($keys, $mod);
-}
-
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");
@@ -203,7 +172,7 @@ function book_list() {
}
function book_admin() {
- global $op, $id, $edit, $user;
+ global $op, $id, $edit, $mod, $keys, $user;
print "<SMALL><A HREF=\"admin.php?mod=book&op=add\">add new page</A> | <A HREF=\"admin.php?mod=book&op=search\">search book</A> | <A HREF=\"admin.php?mod=book&op=list\">list overview</A> | <A HREF=\"admin.php?mod=book\">tree overview</A></SMALL><HR>\n";
@@ -218,7 +187,8 @@ function book_admin() {
print book_form(node_get_array(nid, $id));
break;
case "search":
- book_search();
+ print search_form($keys);
+ print search_data($keys, $mod);
break;
case t("Preview"):
book_view(new Book(($edit[nid] ? $edit[nid] : -1), ($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
@@ -238,24 +208,41 @@ function book_page($id = 0) {
book_view(node_get_object("nid", $nid));
}
+function book_update($id) {
+ global $status;
+
+ if ($node = node_get_object("nid", $id)) {
+ if ($node->status != $status[posted]) {
+ return t("You can only update accepted pages: pages that are still queued or already expired can not be updated.");
+ }
+ else if (db_result(db_query("SELECT COUNT(nid) FROM node WHERE pid = '$node->nid' AND status = '$status[queued]'"))) {
+ return t("There is already an update for this node queued: we can only process one update at the time.");
+ }
+ else {
+ return book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent));
+ }
+ }
+}
+
function book_user() {
global $edit, $id, $op, $theme, $user;
+ $title = t("Submit a book page");
+
switch($op) {
case "update":
- $node = node_get_object("nid", $id);
- $theme->box("Update a book page", book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent)));
+ $theme->box($title, book_update($id));
break;
case t("Preview"):
book_view(new Book(($edit[nid] ? $edit[nid] : -1), $user->userid, $edit[title], $edit[body], $edit[parent], $edit[weight], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
- $theme->box("Submit a book page", book_form($edit));
+ $theme->box($title, book_form($edit));
break;
case t("Submit"):
book_save($edit);
- $theme->box(t("Submit a book page"), t("Thank you for your submission."));
+ $theme->box($title, t("Thank you for your submission."));
break;
default:
- $theme->box("Submit a book page", book_form());
+ $theme->box($title, book_form());
}
}
diff --git a/modules/comment.module b/modules/comment.module
index 26e7e5aab..cee88f998 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -13,12 +13,6 @@ function comment_find($keys) {
return $find;
}
-function comment_search() {
- global $keys, $mod;
- print search_form($keys);
- print search_data($keys, $mod);
-}
-
function comment_edit($id) {
$result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'");
@@ -84,7 +78,7 @@ function comment_display($order = "date") {
}
function comment_admin() {
- global $op, $id, $subject, $comment, $order;
+ global $op, $id, $mod, $keys, $subject, $comment, $order;
print "<SMALL><A HREF=\"admin.php?mod=comment\">overview</A> | <A HREF=\"admin.php?mod=comment&op=search\">search comment</A></SMALL><HR>\n";
@@ -93,7 +87,8 @@ function comment_admin() {
comment_edit($id);
break;
case "search":
- comment_search();
+ print search_form($keys);
+ print search_data($keys, $mod);
break;
case "Save comment":
comment_save(check_input($id), check_input($subject), check_input($comment));
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 26e7e5aab..cee88f998 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -13,12 +13,6 @@ function comment_find($keys) {
return $find;
}
-function comment_search() {
- global $keys, $mod;
- print search_form($keys);
- print search_data($keys, $mod);
-}
-
function comment_edit($id) {
$result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'");
@@ -84,7 +78,7 @@ function comment_display($order = "date") {
}
function comment_admin() {
- global $op, $id, $subject, $comment, $order;
+ global $op, $id, $mod, $keys, $subject, $comment, $order;
print "<SMALL><A HREF=\"admin.php?mod=comment\">overview</A> | <A HREF=\"admin.php?mod=comment&op=search\">search comment</A></SMALL><HR>\n";
@@ -93,7 +87,8 @@ function comment_admin() {
comment_edit($id);
break;
case "search":
- comment_search();
+ print search_form($keys);
+ print search_data($keys, $mod);
break;
case "Save comment":
comment_save(check_input($id), check_input($subject), check_input($comment));
diff --git a/modules/diary.module b/modules/diary.module
index 75210c839..a706a106f 100644
--- a/modules/diary.module
+++ b/modules/diary.module
@@ -21,12 +21,6 @@ function diary_find($keys) {
}
-function diary_search() {
- global $keys, $mod;
- print search_form($keys);
- print search_data($keys, $mod);
-}
-
function diary_page_overview($num = 20) {
global $theme, $user;
@@ -316,7 +310,7 @@ function diary_admin_display($order = "date") {
function diary_admin() {
- global $op, $id, $text, $order;
+ global $op, $id, $mod, $keys, $text, $order;
print "<SMALL><A HREF=\"admin.php?mod=diary\">overview</A> | <A HREF=\"admin.php?mod=diary&op=search\">search diary</A> | <A HREF=\"admin.php?mod=diary&op=help\">help</A></SMALL><HR>\n";
@@ -332,7 +326,8 @@ function diary_admin() {
diary_help();
break;
case "search":
- diary_search();
+ print search_form($keys);
+ print search_data($keys, $mod);
break;
case "Save diary entry":
diary_admin_save(check_input($id), check_input($text));
diff --git a/modules/rating.module b/modules/rating.module
index eadf1483c..a78df4ce3 100644
--- a/modules/rating.module
+++ b/modules/rating.module
@@ -6,37 +6,10 @@ $module = array("cron" => "rating_cron",
"block" => "rating_block");
function rating_cron() {
- global $status;
+ $result = db_query("SELECT id FROM users");
- $period = 5184000; // 60 days
- $number = 30; // 30 comments
- $offset = 5; // 5 comments
-
- $r1 = db_query("SELECT id, userid FROM users");
- while ($rating = db_fetch_object($r1)) {
- unset($bonus); unset($votes); unset($score); unset($value); unset($weight);
-
- $r2 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'");
- if ($story = db_fetch_object($r2)) {
- $bonus += $story->number / 2;
- }
-
- $r3 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'");
- if ($story = db_fetch_object($r3)) {
- $bonus -= $story->number / 2;
- }
-
- $r4 = db_query("SELECT score, votes FROM comments WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) ORDER BY timestamp LIMIT $number");
- while ($comment = db_fetch_object($r4)) {
- $weight++;
- $score += $weight * $comment->score;
- $votes += $weight * $comment->votes;
- }
-
- if ($weight >= $offset && $votes > 0) {
- $value = ($score + $weight) / $votes + $bonus;
- db_query("UPDATE users SET rating = '$value' WHERE id = '$rating->id'");
- }
+ while ($account = db_fetch_object($result)) {
+ db_query("UPDATE users SET rating = '". user_gravity($account->id) ."' WHERE id = '$account->id'");
}
}
diff --git a/modules/story.module b/modules/story.module
index 82254440b..fbe8a12f4 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -29,12 +29,6 @@ function story_find($keys) {
return $find;
}
-function story_search() {
- global $keys, $mod;
- print search_form($keys);
- print search_data($keys, $mod);
-}
-
function story_help() {
?>
<P>Queued stories: user-contributed stories are automatically whisked away to a submission queue for moderators (i.e. registered user) to frown at. Moderators vote whether or not a story should be posted to the front page for discussion.</P>
@@ -194,7 +188,7 @@ function story_overview() {
}
function story_admin() {
- global $id, $edit, $op, $theme, $user;
+ global $id, $edit, $mod, $keys, $op, $theme, $user;
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n";
@@ -213,7 +207,8 @@ function story_admin() {
story_help();
break;
case "search":
- story_search();
+ print search_form($keys);
+ print search_data($keys, $mod);
break;
case t("Preview"):
story_view(new Story(($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[abstract], $edit[body], $edit[section], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
diff --git a/modules/story/story.module b/modules/story/story.module
index 82254440b..fbe8a12f4 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -29,12 +29,6 @@ function story_find($keys) {
return $find;
}
-function story_search() {
- global $keys, $mod;
- print search_form($keys);
- print search_data($keys, $mod);
-}
-
function story_help() {
?>
<P>Queued stories: user-contributed stories are automatically whisked away to a submission queue for moderators (i.e. registered user) to frown at. Moderators vote whether or not a story should be posted to the front page for discussion.</P>
@@ -194,7 +188,7 @@ function story_overview() {
}
function story_admin() {
- global $id, $edit, $op, $theme, $user;
+ global $id, $edit, $mod, $keys, $op, $theme, $user;
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n";
@@ -213,7 +207,8 @@ function story_admin() {
story_help();
break;
case "search":
- story_search();
+ print search_form($keys);
+ print search_data($keys, $mod);
break;
case t("Preview"):
story_view(new Story(($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[abstract], $edit[body], $edit[section], ($edit[timestamp] ? $edit[timestamp] : time())), 0);