diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/account.module | 46 | ||||
-rw-r--r-- | modules/blog.module | 54 | ||||
-rw-r--r-- | modules/blog/blog.module | 54 | ||||
-rw-r--r-- | modules/book.module | 34 | ||||
-rw-r--r-- | modules/book/book.module | 34 | ||||
-rw-r--r-- | modules/box.module | 4 | ||||
-rw-r--r-- | modules/comment.module | 12 | ||||
-rw-r--r-- | modules/comment/comment.module | 12 | ||||
-rw-r--r-- | modules/moderate.module | 121 | ||||
-rw-r--r-- | modules/node.module | 34 | ||||
-rw-r--r-- | modules/node/node.module | 34 | ||||
-rw-r--r-- | modules/page.module | 2 | ||||
-rw-r--r-- | modules/page/page.module | 2 | ||||
-rw-r--r-- | modules/poll.module | 12 | ||||
-rw-r--r-- | modules/poll/poll.module | 12 | ||||
-rw-r--r-- | modules/queue.module | 12 | ||||
-rw-r--r-- | modules/rating.module | 4 | ||||
-rw-r--r-- | modules/story.module | 6 | ||||
-rw-r--r-- | modules/story/story.module | 6 | ||||
-rw-r--r-- | modules/watchdog.module | 8 | ||||
-rw-r--r-- | modules/watchdog/watchdog.module | 8 |
21 files changed, 209 insertions, 302 deletions
diff --git a/modules/account.module b/modules/account.module index 117c71433..3d3a310ac 100644 --- a/modules/account.module +++ b/modules/account.module @@ -50,9 +50,9 @@ function account_conf_options() { } function account_search($keys) { - $result = db_query("SELECT * FROM users WHERE userid LIKE '%$keys%' LIMIT 20"); + $result = db_query("SELECT * FROM users WHERE name LIKE '%$keys%' LIMIT 20"); while ($account = db_fetch_object($result)) { - $find[$i++] = array("title" => $account->userid, "link" => (user_access("administer users") ? "admin.php?mod=account&op=view&name=". urlencode($account->userid) : "account.php?op=view&name=". urlencode($account->userid)), "user" => $account->userid); + $find[$i++] = array("title" => $account->name, "link" => (user_access("administer users") ? "admin.php?mod=account&op=view&name=". urlencode($account->name) : "account.php?op=view&name=". urlencode($account->name)), "user" => $account->name); } return $find; } @@ -97,13 +97,13 @@ function account_ac() { function account_overview($query = array()) { - $result = db_query("SELECT id, userid, last_access FROM users $query[1] LIMIT 50"); + $result = db_query("SELECT id, name, last_access FROM users $query[1] LIMIT 50"); $output .= status($query[0]); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= " <TR><TH>username</TH><TH>last access</TH><TH COLSPAN=\"2\">operations</TH></TR>\n"; while ($account = db_fetch_object($result)) { - $output .= " <TR><TD>". format_username($account->userid) ."</TD><TD>". format_date($account->last_access) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=view&name=". urlencode($account->userid) ."\">view account</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=edit&name=". urlencode($account->userid) ."\">edit account</A></TD></TR>\n"; + $output .= " <TR><TD>". format_name($account->name) ."</TD><TD>". format_date($account->last_access) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=view&name=". urlencode($account->name) ."\">view account</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=edit&name=". urlencode($account->name) ."\">edit account</A></TD></TR>\n"; } $output .= "</TABLE>\n"; @@ -135,12 +135,12 @@ function account_comments($id) { } function account_delete($name) { - $result = db_query("SELECT * FROM users WHERE userid = '$name' AND status = 0 AND id > 1"); + $result = db_query("SELECT * FROM users WHERE name = '$name' AND status = 0 AND id > 1"); if ($account = db_fetch_object($result)) { db_query("DELETE FROM users WHERE id = '$account->id'"); } else { - return "failed to delete account '". format_username($name) ."': the account must be blocked first."; + return "failed to delete account '". format_name($name) ."': the account must be blocked first."; } } @@ -171,15 +171,11 @@ function account_save($edit) { $query[] = "$key = '". addslashes($value) ."'"; } db_query("UPDATE users SET ". implode(", ", $query) ." WHERE id = $edit[id]"); - watchdog("account", "account: modified user '$edit[userid]'"); - return $edit[userid]; + watchdog("account", "account: modified user '$edit[name]'"); + return $edit[name]; } else { - // Adding new account - $edit[userid] = $edit[userid]; - $edit[real_email] = $edit[real_email]; - - if ($error = user_validate($edit)) { + if ($error = account_validate($edit)) { print status($error); return 0; } @@ -187,7 +183,7 @@ function account_save($edit) { $edit[passwd] = user_password(); $edit[hash] = substr(md5("$edit[userid]. ". time()), 0, 12); - $user = user_save("", array("userid" => $edit[userid], "role" => $edit[role], "real_email" => $edit[real_email], "passwd" => $edit[passwd], "status" => $edit[status], "hash" => $edit[hash])); + $user = user_save("", array("name" => $edit[userid], "userid" => $edit[userid], "role" => $edit[role], "real_email" => $edit[real_email], "passwd" => $edit[passwd], "status" => $edit[status], "hash" => $edit[hash])); $link = path_uri() ."account.php?op=confirm&name=". urlencode($edit[userid]) ."&hash=$edit[hash]"; $subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal"))); @@ -217,16 +213,16 @@ function account_add() { function account_view($name) { $status = array(0 => "blocked", 1 => "not confirmed", 2 => "open"); - $result = db_query("SELECT * FROM users WHERE userid = '$name'"); + $result = db_query("SELECT * FROM users WHERE name = '$name'"); if ($account = db_fetch_object($result)) { - $form .= form_hidden("name", $account->userid); + $form .= form_hidden("name", $account->name); $form .= form_submit("Edit account"); $form .= form_submit("Delete account"); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= " <TR><TH>ID:</TH><TD>$account->id</TD></TR>\n"; - $output .= " <TR><TH>Username:</TH><TD>$account->userid</TD></TR>\n"; + $output .= " <TR><TH>Name:</TH><TD>$account->name</TD></TR>\n"; $output .= " <TR><TH>Status:</TH><TD>". $status[$account->status] ."</TD></TR>\n"; $output .= " <TR><TH>Role:</TH><TD>". check_output($account->role) ."</TD></TR>\n"; $output .= " <TR><TH>Real name:</TH><TD>". check_output($account->name) ."</TD></TR>\n"; @@ -254,6 +250,22 @@ function account_query($type = "") { return ($queries[$type] ? $queries[$type] : $queries); } +function account_validate($user) { + if ($error = user_validate_name($user[userid])) return $error; + + // Verify e-mail address: + if ($error = user_validate_mail($user[real_email])) return $error; + + // Check to see whether the username or e-mail address are banned: + if ($ban = user_ban($user[userid], "username")) return t("the username '$user[userid]' is banned") .": <I>$ban->reason</I>."; + if ($ban = user_ban($user[real_email], "e-mail address")) return t("the e-mail address '$user[real_email]' is banned") .": <I>$ban->reason</I>."; + + // Verify whether username and e-mail address are unique: + if (db_num_rows(db_query("SELECT userid FROM users WHERE LOWER(userid) = LOWER('$user[userid]')")) > 0) return t("the username '$user[userid]' is already taken."); + if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email) = LOWER('$user[real_email]')")) > 0) return t("the e-mail address '$user[real_email]' is already in use by another account."); +} + + function account_admin() { global $op, $edit, $id, $mod, $keys, $order, $name, $query; diff --git a/modules/blog.module b/modules/blog.module index 16fb062e8..f5504bccb 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -3,12 +3,8 @@ class Blog { function Blog($blog) { global $user; - $this = new Node($blog); - $this->title = $blog[title]; $this->body = $blog[body]; - $this->userid = $blog[userid] ? $blog[userid] : $user->userid; - $this->timestamp = $blog[timestamp] ? $blog[timestamp] : time(); } } @@ -33,10 +29,10 @@ function blog_summary($node) { function blog_feed_user($name = 0, $date = 0) { global $user; - $name = check_input($name ? $name : $user->userid); + $name = check_input($name ? $name : $user->name); $date = check_input($date ? $date : time()); - $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.userid = '$name' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 15"); + $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.name = '$name' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 15"); while ($blog = db_fetch_object($result)) { $items .= format_rss_item($blog->title, path_uri() ."node.php?id=$blog->nid", $blog->body); } @@ -51,9 +47,9 @@ function blog_feed_user($name = 0, $date = 0) { } function blog_feed_last() { - $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.userid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT 15"); + $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT 15"); while ($blog = db_fetch_object($result)) { - $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&name=". urlencode($blog->userid), $blog->body); + $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&name=". urlencode($blog->name), $blog->body); } $output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; @@ -68,10 +64,10 @@ function blog_feed_last() { function blog_page_user($name = 0, $date = 0) { global $theme, $user; - $name = check_input($name ? $name : $user->userid); + $name = check_input($name ? $name : $user->name); $date = check_input($date ? $date : time()); - $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid WHERE u.userid = '$name' AND n.timestamp < '$date' AND n.timestamp > '". ($date - 2592000) ."' GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20"); + $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid WHERE u.name = '$name' AND n.timestamp < '$date' AND n.timestamp > '". ($date - 2592000) ."' GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20"); $output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">"; @@ -84,7 +80,7 @@ function blog_page_user($name = 0, $date = 0) { $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&name=$name&date=". mktime(23, 59, 59, date("n", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":</a></b></td></tr>"; } - if ($user->id && $user->userid == $name) { + if ($user->id && $user->name == $name) { $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>"; } @@ -110,7 +106,7 @@ function blog_page_user($name = 0, $date = 0) { function blog_page_last() { global $theme, $user; - $result = db_query("SELECT n.author, n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.userid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20"); + $result = db_query("SELECT n.author, n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20"); $output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">"; @@ -118,7 +114,7 @@ function blog_page_last() { $links = array(); - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($blog->userid) ."\">". strtr(t("%a's blog"), array("%a" => $blog->userid)) ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($blog->name) ."\">". strtr(t("%a's blog"), array("%a" => $blog->name)) ."</a>"; if ($blog->author == $user->id) { $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>"; @@ -170,7 +166,7 @@ function blog_form($edit = array()) { else if ($type == "blog") { $item = node_get_object(array(type => "blog", nid => $id)); $edit["title"] = $item->title; - $edit["body"] = "<i>". $item->body ."</i> [<a href=\"module.php?mod=blog&name=". urlencode($item->userid) ."&date=$item->timestamp\">$item->userid</a>]"; + $edit["body"] = "<i>". $item->body ."</i> [<a href=\"module.php?mod=blog&name=". urlencode($item->name) ."&date=$item->timestamp\">$item->name</a>]"; } else if ($type == "import") { $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '". check_input($id) ."' AND i.fid = f.fid")); @@ -280,7 +276,7 @@ function blog_user() { switch ($op) { case "delete": blog_remove($id); - blog_page_user($user->userid, time()); + blog_page_user($user->name, time()); break; case "edit": $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main"); @@ -291,7 +287,7 @@ function blog_user() { break; case t("Submit"): blog_save($edit); - blog_page_user($user->userid, time()); + blog_page_user($user->name, time()); break; default: $theme->box(t("Submit a blog"), blog_form($edit), "main"); @@ -309,11 +305,11 @@ function blog_link($type, $node = 0) { if ($type == "menu" && user_access("post blogs")) { $links[] = "<a href=\"submit.php?mod=blog\">". t("add blog entry") ."</a>"; - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($user->userid) ."\">". t("view your blog") ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($user->name) ."\">". t("view your blog") ."</a>"; } if ($type == "node" && $node->type == "blog") { - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->userid) ."\">". strtr(t("%a's blog"), array("%a" => $node->userid)) ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>"; } return $links ? $links : array(); @@ -323,9 +319,9 @@ function blog_link($type, $node = 0) { function blog_block() { global $name, $date, $user, $mod; - $result = db_query("SELECT u.userid, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); + $result = db_query("SELECT u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); while ($node = db_fetch_object($result)) { - $output .= "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->userid) ."\">". check_output($node->title) ."<br />\n"; + $output .= "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". check_output($node->title) ."<br />\n"; } $block[0]["subject"] = "<a href=\"module.php?mod=blog\">". t("User blogs") ."</a>"; @@ -334,12 +330,12 @@ function blog_block() { $block[0]["link"] = "module.php?mod=blog"; $date = $date ? $date : time(); - $userid = $name ? $name : $user->userid; + $name = $name ? $name : $user->name; if (($mod == "blog") || ($mod == "block")) { // Only show this block on "blog pages" and in the admin block section. - $calendar = new BlogCalendar($userid, $date); - $block[1]["subject"] = "<a href=\"module.php?mod=blog&name=". urlencode($userid) ."\">" . t("Browse blog") . "</a>"; + $calendar = new BlogCalendar($name, $date); + $block[1]["subject"] = "<a href=\"module.php?mod=blog&name=". urlencode($name) ."\">" . t("Browse blog") . "</a>"; $block[1]["content"] = $calendar->display(); $block[1]["info"] = t("Calendar to browse blogs"); } @@ -352,17 +348,17 @@ function blog_search($keys) { global $status, $user; $result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid AND n.lid = b.lid WHERE (n.title LIKE '%$keys%' OR b.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20"); while ($blog = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($blog->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->userid, "date" => $blog->timestamp); + $find[$i++] = array("title" => check_output($blog->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp); } return $find; } class BlogCalendar { var $date; - var $userid; + var $name; - function BlogCalendar($userid, $date) { - $this->userid = urlencode($userid); + function BlogCalendar($name, $date) { + $this->name = urlencode($name); // Prevent future dates: $today = mktime(23, 59, 59, date("n", time()), date("d", time()), date("Y", time())); @@ -397,7 +393,7 @@ class BlogCalendar { // Generate calendar header: $output .= "\n<!-- calendar -->\n"; $output .= "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"1\">\n"; - $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><B><A HREF=\"module.php?mod=blog&name=$this->userid&date=$prev\" STYLE=\"text-decoration: none;\"><<</A> ". date("F Y", $this->date) ." " . ($next <= $thislast ? "<A HREF=\"module.php?mod=blog&name=$this->userid&date=$next\" STYLE=\"text-decoration: none;\">>></A>" : ">>") . "<B></TD></TR>\n"; + $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><B><A HREF=\"module.php?mod=blog&name=$this->name&date=$prev\" STYLE=\"text-decoration: none;\"><<</A> ". date("F Y", $this->date) ." " . ($next <= $thislast ? "<A HREF=\"module.php?mod=blog&name=$this->name&date=$next\" STYLE=\"text-decoration: none;\">>></A>" : ">>") . "<B></TD></TR>\n"; // Generate the days of the week: $output .= " <TR>"; @@ -426,7 +422,7 @@ class BlogCalendar { $date = mktime(23, 59, 59, $month, $nday, $year); if ($date == $this->date) $output .= " <TD ALIGN=\"center\" BGCOLOR=\"#CCCCCC\"><B>$nday</B></TD>\n"; else if ($date > $today) $output .= " <TD ALIGN=\"center\">$nday</TD>\n"; - else $output .= " <TD ALIGN=\"center\"><A HREF=\"module.php?mod=blog&name=$this->userid&date=$date\" STYLE=\"text-decoration: none;\">$nday</A></TD>\n"; + else $output .= " <TD ALIGN=\"center\"><A HREF=\"module.php?mod=blog&name=$this->name&date=$date\" STYLE=\"text-decoration: none;\">$nday</A></TD>\n"; // Start every week on a new line: if ($sday == 6) $output .= " </TR>\n"; diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 16fb062e8..f5504bccb 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -3,12 +3,8 @@ class Blog { function Blog($blog) { global $user; - $this = new Node($blog); - $this->title = $blog[title]; $this->body = $blog[body]; - $this->userid = $blog[userid] ? $blog[userid] : $user->userid; - $this->timestamp = $blog[timestamp] ? $blog[timestamp] : time(); } } @@ -33,10 +29,10 @@ function blog_summary($node) { function blog_feed_user($name = 0, $date = 0) { global $user; - $name = check_input($name ? $name : $user->userid); + $name = check_input($name ? $name : $user->name); $date = check_input($date ? $date : time()); - $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.userid = '$name' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 15"); + $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.name = '$name' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.lid DESC LIMIT 15"); while ($blog = db_fetch_object($result)) { $items .= format_rss_item($blog->title, path_uri() ."node.php?id=$blog->nid", $blog->body); } @@ -51,9 +47,9 @@ function blog_feed_user($name = 0, $date = 0) { } function blog_feed_last() { - $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.userid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT 15"); + $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id ORDER BY b.lid DESC LIMIT 15"); while ($blog = db_fetch_object($result)) { - $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&name=". urlencode($blog->userid), $blog->body); + $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&name=". urlencode($blog->name), $blog->body); } $output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; @@ -68,10 +64,10 @@ function blog_feed_last() { function blog_page_user($name = 0, $date = 0) { global $theme, $user; - $name = check_input($name ? $name : $user->userid); + $name = check_input($name ? $name : $user->name); $date = check_input($date ? $date : time()); - $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid WHERE u.userid = '$name' AND n.timestamp < '$date' AND n.timestamp > '". ($date - 2592000) ."' GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20"); + $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid WHERE u.name = '$name' AND n.timestamp < '$date' AND n.timestamp > '". ($date - 2592000) ."' GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20"); $output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">"; @@ -84,7 +80,7 @@ function blog_page_user($name = 0, $date = 0) { $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&name=$name&date=". mktime(23, 59, 59, date("n", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":</a></b></td></tr>"; } - if ($user->id && $user->userid == $name) { + if ($user->id && $user->name == $name) { $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>"; } @@ -110,7 +106,7 @@ function blog_page_user($name = 0, $date = 0) { function blog_page_last() { global $theme, $user; - $result = db_query("SELECT n.author, n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.userid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20"); + $result = db_query("SELECT n.author, n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid ORDER BY n.nid DESC LIMIT 20"); $output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">"; @@ -118,7 +114,7 @@ function blog_page_last() { $links = array(); - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($blog->userid) ."\">". strtr(t("%a's blog"), array("%a" => $blog->userid)) ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($blog->name) ."\">". strtr(t("%a's blog"), array("%a" => $blog->name)) ."</a>"; if ($blog->author == $user->id) { $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>"; @@ -170,7 +166,7 @@ function blog_form($edit = array()) { else if ($type == "blog") { $item = node_get_object(array(type => "blog", nid => $id)); $edit["title"] = $item->title; - $edit["body"] = "<i>". $item->body ."</i> [<a href=\"module.php?mod=blog&name=". urlencode($item->userid) ."&date=$item->timestamp\">$item->userid</a>]"; + $edit["body"] = "<i>". $item->body ."</i> [<a href=\"module.php?mod=blog&name=". urlencode($item->name) ."&date=$item->timestamp\">$item->name</a>]"; } else if ($type == "import") { $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '". check_input($id) ."' AND i.fid = f.fid")); @@ -280,7 +276,7 @@ function blog_user() { switch ($op) { case "delete": blog_remove($id); - blog_page_user($user->userid, time()); + blog_page_user($user->name, time()); break; case "edit": $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main"); @@ -291,7 +287,7 @@ function blog_user() { break; case t("Submit"): blog_save($edit); - blog_page_user($user->userid, time()); + blog_page_user($user->name, time()); break; default: $theme->box(t("Submit a blog"), blog_form($edit), "main"); @@ -309,11 +305,11 @@ function blog_link($type, $node = 0) { if ($type == "menu" && user_access("post blogs")) { $links[] = "<a href=\"submit.php?mod=blog\">". t("add blog entry") ."</a>"; - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($user->userid) ."\">". t("view your blog") ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($user->name) ."\">". t("view your blog") ."</a>"; } if ($type == "node" && $node->type == "blog") { - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->userid) ."\">". strtr(t("%a's blog"), array("%a" => $node->userid)) ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>"; } return $links ? $links : array(); @@ -323,9 +319,9 @@ function blog_link($type, $node = 0) { function blog_block() { global $name, $date, $user, $mod; - $result = db_query("SELECT u.userid, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); + $result = db_query("SELECT u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); while ($node = db_fetch_object($result)) { - $output .= "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->userid) ."\">". check_output($node->title) ."<br />\n"; + $output .= "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". check_output($node->title) ."<br />\n"; } $block[0]["subject"] = "<a href=\"module.php?mod=blog\">". t("User blogs") ."</a>"; @@ -334,12 +330,12 @@ function blog_block() { $block[0]["link"] = "module.php?mod=blog"; $date = $date ? $date : time(); - $userid = $name ? $name : $user->userid; + $name = $name ? $name : $user->name; if (($mod == "blog") || ($mod == "block")) { // Only show this block on "blog pages" and in the admin block section. - $calendar = new BlogCalendar($userid, $date); - $block[1]["subject"] = "<a href=\"module.php?mod=blog&name=". urlencode($userid) ."\">" . t("Browse blog") . "</a>"; + $calendar = new BlogCalendar($name, $date); + $block[1]["subject"] = "<a href=\"module.php?mod=blog&name=". urlencode($name) ."\">" . t("Browse blog") . "</a>"; $block[1]["content"] = $calendar->display(); $block[1]["info"] = t("Calendar to browse blogs"); } @@ -352,17 +348,17 @@ function blog_search($keys) { global $status, $user; $result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid AND n.lid = b.lid WHERE (n.title LIKE '%$keys%' OR b.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20"); while ($blog = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($blog->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->userid, "date" => $blog->timestamp); + $find[$i++] = array("title" => check_output($blog->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp); } return $find; } class BlogCalendar { var $date; - var $userid; + var $name; - function BlogCalendar($userid, $date) { - $this->userid = urlencode($userid); + function BlogCalendar($name, $date) { + $this->name = urlencode($name); // Prevent future dates: $today = mktime(23, 59, 59, date("n", time()), date("d", time()), date("Y", time())); @@ -397,7 +393,7 @@ class BlogCalendar { // Generate calendar header: $output .= "\n<!-- calendar -->\n"; $output .= "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"1\">\n"; - $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><B><A HREF=\"module.php?mod=blog&name=$this->userid&date=$prev\" STYLE=\"text-decoration: none;\"><<</A> ". date("F Y", $this->date) ." " . ($next <= $thislast ? "<A HREF=\"module.php?mod=blog&name=$this->userid&date=$next\" STYLE=\"text-decoration: none;\">>></A>" : ">>") . "<B></TD></TR>\n"; + $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><B><A HREF=\"module.php?mod=blog&name=$this->name&date=$prev\" STYLE=\"text-decoration: none;\"><<</A> ". date("F Y", $this->date) ." " . ($next <= $thislast ? "<A HREF=\"module.php?mod=blog&name=$this->name&date=$next\" STYLE=\"text-decoration: none;\">>></A>" : ">>") . "<B></TD></TR>\n"; // Generate the days of the week: $output .= " <TR>"; @@ -426,7 +422,7 @@ class BlogCalendar { $date = mktime(23, 59, 59, $month, $nday, $year); if ($date == $this->date) $output .= " <TD ALIGN=\"center\" BGCOLOR=\"#CCCCCC\"><B>$nday</B></TD>\n"; else if ($date > $today) $output .= " <TD ALIGN=\"center\">$nday</TD>\n"; - else $output .= " <TD ALIGN=\"center\"><A HREF=\"module.php?mod=blog&name=$this->userid&date=$date\" STYLE=\"text-decoration: none;\">$nday</A></TD>\n"; + else $output .= " <TD ALIGN=\"center\"><A HREF=\"module.php?mod=blog&name=$this->name&date=$date\" STYLE=\"text-decoration: none;\">$nday</A></TD>\n"; // Start every week on a new line: if ($sday == 6) $output .= " </TR>\n"; diff --git a/modules/book.module b/modules/book.module index 48ce8162b..52260c9cf 100644 --- a/modules/book.module +++ b/modules/book.module @@ -61,7 +61,7 @@ function book_view($node, $main = 0) { $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, $node->name) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n"; + $output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node->name) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n"; } if ($node->body) { @@ -83,9 +83,9 @@ function book_view($node, $main = 0) { function book_search($keys) { global $status; - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); + $result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); while ($node = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); + $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->timestamp); } return $find; } @@ -128,8 +128,8 @@ function book_form($edit = array()) { $form .= book_view(new Book(node_preview($edit))); } - $form .= form_item(t("Author"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); - $form .= form_hidden(userid, $edit[userid]); + $form .= form_item(t("Author"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_hidden(name, $edit[name]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); $form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in.")); @@ -251,7 +251,7 @@ function book_page() { switch ($op) { case "feed": - print book_export_html($i, $depth = 1); + print book_export_html($id, $depth = 1); break; default: book_render(); @@ -301,16 +301,30 @@ function book_user() { } } -function book_export_html($parent = "", $depth = 0) { +function book_export_html($id = "", $depth = 1) { + 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 n.nid = '". check_input($id) ."'"); + + while ($node = db_fetch_object($result)) { + $output .= "<H$depth>". check_output($node->title) ."</H$depth>"; + if ($node->body) $output .= "<blockquote>". check_output($node->body, 1) ."</blockquote>"; + } + $output .= book_export_html_recursive($id, $depth); + + return $output; +} + +function book_export_html_recursive($parent = "", $depth = 1) { 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)) { $output .= "<H$depth>". check_output($node->title) ."</H$depth>"; - if ($node->body) $output .= check_output($node->body, 1); - if ($node->pid) $output .= book_export_html($node->pid, $depth + 1); - $output .= book_export_html($node->nid, $depth + 1); + if ($node->body) $output .= "<blockquote>". check_output($node->body, 1) ."</blockquote>"; + if ($node->pid) $output .= book_export_html_recursive($node->pid, $depth + 1); + $output .= book_export_html_recursive($node->nid, $depth + 1); } return $output; diff --git a/modules/book/book.module b/modules/book/book.module index 48ce8162b..52260c9cf 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -61,7 +61,7 @@ function book_view($node, $main = 0) { $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, $node->name) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n"; + $output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node->name) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n"; } if ($node->body) { @@ -83,9 +83,9 @@ function book_view($node, $main = 0) { function book_search($keys) { global $status; - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); + $result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); while ($node = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp); + $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->timestamp); } return $find; } @@ -128,8 +128,8 @@ function book_form($edit = array()) { $form .= book_view(new Book(node_preview($edit))); } - $form .= form_item(t("Author"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); - $form .= form_hidden(userid, $edit[userid]); + $form .= form_item(t("Author"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_hidden(name, $edit[name]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); $form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in.")); @@ -251,7 +251,7 @@ function book_page() { switch ($op) { case "feed": - print book_export_html($i, $depth = 1); + print book_export_html($id, $depth = 1); break; default: book_render(); @@ -301,16 +301,30 @@ function book_user() { } } -function book_export_html($parent = "", $depth = 0) { +function book_export_html($id = "", $depth = 1) { + 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 n.nid = '". check_input($id) ."'"); + + while ($node = db_fetch_object($result)) { + $output .= "<H$depth>". check_output($node->title) ."</H$depth>"; + if ($node->body) $output .= "<blockquote>". check_output($node->body, 1) ."</blockquote>"; + } + $output .= book_export_html_recursive($id, $depth); + + return $output; +} + +function book_export_html_recursive($parent = "", $depth = 1) { 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)) { $output .= "<H$depth>". check_output($node->title) ."</H$depth>"; - if ($node->body) $output .= check_output($node->body, 1); - if ($node->pid) $output .= book_export_html($node->pid, $depth + 1); - $output .= book_export_html($node->nid, $depth + 1); + if ($node->body) $output .= "<blockquote>". check_output($node->body, 1) ."</blockquote>"; + if ($node->pid) $output .= book_export_html_recursive($node->pid, $depth + 1); + $output .= book_export_html_recursive($node->nid, $depth + 1); } return $output; diff --git a/modules/box.module b/modules/box.module index 9d8c5bc83..6618f6b60 100644 --- a/modules/box.module +++ b/modules/box.module @@ -18,8 +18,8 @@ function box_help() { </PRE> <P>If we are however dealing with a registered user, we can customize the message by using:</P> <PRE> - if ($user->userid) { - return "Welcome $user->userid, ... welcome message goes here ..."; + if ($user->id) { + return "Welcome $user->name, ... welcome message goes here ..."; } else { return "Welcome visitor, ... welcome message goes here ..."; diff --git a/modules/comment.module b/modules/comment.module index 873af4326..1ffb7a884 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -2,9 +2,9 @@ function comment_search($keys) { global $user; - $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20"); + $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20"); while ($comment = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access("administer comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->userid, "date" => $comment->timestamp); + $find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access("administer comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp); } return $find; } @@ -24,10 +24,10 @@ function comment_link($type) { function comment_edit($id) { global $REQUEST_URI; - $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'"); + $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'"); $comment = db_fetch_object($result); - $form .= form_item(t("Author"), format_username($comment->userid)); + $form .= form_item(t("Author"), format_name($comment->name)); $form .= form_textfield(t("Subject"), "subject", $comment->subject, 50, 128); $form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10); $form .= form_submit(t("Submit")); @@ -41,12 +41,12 @@ function comment_save($id, $edit) { } function comment_overview() { - $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY timestamp DESC LIMIT 50"); + $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY timestamp DESC LIMIT 50"); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= " <TR><TH>subject</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n"; while ($comment = db_fetch_object($result)) { - $output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n"; + $output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n"; } $output .= "</TABLE>\n"; diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 873af4326..1ffb7a884 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -2,9 +2,9 @@ function comment_search($keys) { global $user; - $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20"); + $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20"); while ($comment = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access("administer comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->userid, "date" => $comment->timestamp); + $find[$i++] = array("title" => check_output($comment->subject), "link" => (user_access("administer comments") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp); } return $find; } @@ -24,10 +24,10 @@ function comment_link($type) { function comment_edit($id) { global $REQUEST_URI; - $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'"); + $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'"); $comment = db_fetch_object($result); - $form .= form_item(t("Author"), format_username($comment->userid)); + $form .= form_item(t("Author"), format_name($comment->name)); $form .= form_textfield(t("Subject"), "subject", $comment->subject, 50, 128); $form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10); $form .= form_submit(t("Submit")); @@ -41,12 +41,12 @@ function comment_save($id, $edit) { } function comment_overview() { - $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY timestamp DESC LIMIT 50"); + $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY timestamp DESC LIMIT 50"); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= " <TR><TH>subject</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n"; while ($comment = db_fetch_object($result)) { - $output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n"; + $output .= " <TR><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit comment</A></TD><TD><A HREF=\"admin.php?mod=comment&op=delete&id=$comment->cid\">delete comment</A></TD></TR>\n"; } $output .= "</TABLE>\n"; diff --git a/modules/moderate.module b/modules/moderate.module deleted file mode 100644 index bbb3f9489..000000000 --- a/modules/moderate.module +++ /dev/null @@ -1,121 +0,0 @@ -<?php - -function moderate_perm() { - return array("access moderation pages"); -} - -function moderate_link($type) { - if ($type == "admin") { - $links[] = "<a href=\"admin.php?mod=moderate\">moderate content</a>"; - } - - return $links ? $links : array(); -} - -function moderate_comment_access($cid) { - global $user; - return db_fetch_object(db_query("SELECT n.moderate FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.cid = '". check_input($cid) ."' AND n.moderate LIKE '%$user->userid%'")); -} - -function moderate_overview($query = array()) { - global $user; - - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.moderate LIKE '%$user->userid%' ORDER BY n.timestamp DESC LIMIT 15"); - - $output .= status($query[0]); - $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>node</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH>operations</TH></TR>\n"; - - $r1 = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.moderate LIKE '%$user->userid%' ORDER BY n.timestamp DESC LIMIT 30"); - while ($node = db_fetch_object($r1)) { - $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=moderate&type=node&op=edit&id=$node->nid\">edit $node->type</A></TD></TR>\n"; - - $r2 = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.lid = '$node->nid' ORDER BY c.timestamp DESC"); - while ($comment = db_fetch_object($r2)) { - $output .= "<TR><TD COLSPAN=\"3\"> - <A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_username($user->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=moderate&type=comment&op=edit&id=$comment->cid\">edit comment</A></TD></TR>\n"; - } - } - $output .= "</TABLE>\n"; - - return $output; -} - -function moderate_node($edit, $name) { - global $user; - - $node = node_get_array(array("nid" => $edit[nid])); - if ($node && strstr($node[moderate], $user->userid)) { - $edit[type] = $node[type]; - return node_invoke($edit, $name); - } - else { - return status(message_access()); - } -} - -function moderate_node_edit($edit) { - return moderate_node($edit, "form"); -} - -function moderate_node_save($edit) { - return moderate_node($edit, "save"); -} - -function moderate_comment_edit($id) { - if (moderate_comment_access($id)) { - return comment_edit($id); - } - else { - return status(message_access()); - } -} - -function moderate_comment_save($id, $edit) { - if (moderate_comment_access($id)) { - return comment_save($id, $edit); - } - else { - return status(message_access()); - } -} - -function moderate_admin() { - global $op, $id, $edit, $type; - - if (user_access("access moderation pages")) { - - switch ($type) { - case "comment": - switch ($op) { - case "edit": - print moderate_comment_edit($id); - break; - case t("Submit"): - print status(moderate_comment_save($id, $edit)); - // fall through: - default: - print moderate_overview(); - } - break; - default: - switch ($op) { - case "edit": - print moderate_node_edit(node_get_array(array("nid" => $id))); - break; - case t("Preview"): - print moderate_node_edit($edit); - break; - case t("Submit"): - print status(moderate_node_save($edit)); - // fall through: - default: - print moderate_overview(); - } - } - } - else { - print message_access(); - } -} - -?> diff --git a/modules/node.module b/modules/node.module index f9b570bf8..be77614f4 100644 --- a/modules/node.module +++ b/modules/node.module @@ -3,7 +3,7 @@ class Node { function Node($node) { global $user; - $this->userid = $node[userid] ? $node[userid] : $user->userid; + $this->name = $node[name] ? $node[name] : $user->name; $this->title = $node[title]; $this->attributes = $node[attributes]; $this->timestamp = $node[timestamp] ? $node[timestamp] : time(); @@ -108,7 +108,7 @@ function node_overview($query) { $color = array("#ffffff", "#e5e5e5"); $query = node_query($query ? $query : 0); - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50"); + $result = db_query("SELECT n.* FROM node n $query[1] LIMIT 50"); $output .= status($query[0]); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; @@ -117,7 +117,7 @@ function node_overview($query) { while ($node = db_fetch_object($result)) { $bg = $color[$i++ % sizeof($color)]; - $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attributes) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attributes) ."</TD><TD>". format_name($node->name) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", node_links($node->nid, $node->type)) ."</SMALL></TD>\n"; } $output .= "</TABLE>\n"; @@ -134,7 +134,6 @@ function node_edit_option($id) { $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this node."); $form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this node on the main page."); - $form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("A comma-seperated list of the moderators their usernames.")); $form .= form_hidden("nid", $node->nid); $form .= form_submit("Save node"); @@ -187,25 +186,25 @@ function node_delete($id) { } function node_query($type = -1) { - $queries[] = array("all nodes: recent additions", "ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: status set to 'posted'", "WHERE n.status = ". node_status("posted") ." ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: status set to 'queued'", "WHERE n.status = ". node_status("queued") ." ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: status set to 'dumped'", "WHERE n.status = ". node_status("dumped") ." ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: scheduled to be posted", "WHERE n.timestamp_posted > 0 ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: scheduled to be queued", "WHERE n.timestamp_queued > 0 ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: scheduled to be hidden", "WHERE n.timestamp_hidden > 0 ORDER BY n.timestamp DESC"); + $queries[] = array("all nodes: recent additions", "ORDER BY timestamp DESC"); + $queries[] = array("all nodes: status set to 'posted'", "WHERE status = ". node_status("posted") ." ORDER BY timestamp DESC"); + $queries[] = array("all nodes: status set to 'queued'", "WHERE status = ". node_status("queued") ." ORDER BY timestamp DESC"); + $queries[] = array("all nodes: status set to 'dumped'", "WHERE status = ". node_status("dumped") ." ORDER BY timestamp DESC"); + $queries[] = array("all nodes: scheduled to be posted", "WHERE timestamp_posted > 0 ORDER BY timestamp DESC"); + $queries[] = array("all nodes: scheduled to be queued", "WHERE timestamp_queued > 0 ORDER BY timestamp DESC"); + $queries[] = array("all nodes: scheduled to be hidden", "WHERE timestamp_hidden > 0 ORDER BY timestamp DESC"); foreach (module_list() as $name) { if (module_hook($name, "status")) { - $queries[] = array("$name: recent additions", "WHERE n.type = '$name' ORDER BY n.timestamp DESC"); + $queries[] = array("$name: recent additions", "WHERE type = '$name' ORDER BY timestamp DESC"); $statuses = module_invoke($name, "status"); if (is_array($statuses)) { foreach (array_reverse($statuses) as $key=>$status) { - $queries[] = array("$name: status set to '$status'", "WHERE n.type = '$name' AND n.status = '". node_status($status) ."' ORDER BY n.timestamp DESC"); + $queries[] = array("$name: status set to '$status'", "WHERE type = '$name' AND status = '". node_status($status) ."' ORDER BY timestamp DESC"); } - $queries[] = array("$name: scheduled to be posted", "WHERE n.type = '$name' AND n.timestamp_posted > 0 ORDER BY n.timestamp DESC"); - $queries[] = array("$name: scheduled to be queued", "WHERE n.type = '$name' AND n.timestamp_queued > 0 ORDER BY n.timestamp DESC"); - $queries[] = array("$name: scheduled to be hidden", "WHERE n.type = '$name' AND n.timestamp_hidden > 0 ORDER BY n.timestamp DESC"); + $queries[] = array("$name: scheduled to be posted", "WHERE type = '$name' AND timestamp_posted > 0 ORDER BY timestamp DESC"); + $queries[] = array("$name: scheduled to be queued", "WHERE type = '$name' AND timestamp_queued > 0 ORDER BY timestamp DESC"); + $queries[] = array("$name: scheduled to be hidden", "WHERE type = '$name' AND timestamp_hidden > 0 ORDER BY timestamp DESC"); } } } @@ -237,7 +236,6 @@ function node_setting() { $form .= form_select(t("Post threshold"), $name ."_post", variable_get($name ."_post", 4), $threshold_post, "If new submissions are subject to moderation, select a post threshold."); $form .= form_select(t("Dump threshold"), $name ."_dump", variable_get($name ."_dump", -2), $threshold_dump, "If new submissions are subject to moderation, select a dump threshold."); $form .= form_select(t("Expiration threshold"), $name ."_expire", variable_get($name ."_expire", 8), $threshold_expire, "If new submissions are subject to moderation, select a expiration threshold."); - $form .= form_textfield("Moderate", $name ."_moderate", variable_get($name ."_moderate", ""), 35, 255, "A comma-seperated list of the moderators' usernames."); } } @@ -258,7 +256,7 @@ function node_admin_save($edit) { node_save($edit, array(attributes)); } else { - node_save($edit, array(comment, moderate, promote)); + node_save($edit, array(comment, promote)); } } diff --git a/modules/node/node.module b/modules/node/node.module index f9b570bf8..be77614f4 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -3,7 +3,7 @@ class Node { function Node($node) { global $user; - $this->userid = $node[userid] ? $node[userid] : $user->userid; + $this->name = $node[name] ? $node[name] : $user->name; $this->title = $node[title]; $this->attributes = $node[attributes]; $this->timestamp = $node[timestamp] ? $node[timestamp] : time(); @@ -108,7 +108,7 @@ function node_overview($query) { $color = array("#ffffff", "#e5e5e5"); $query = node_query($query ? $query : 0); - $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50"); + $result = db_query("SELECT n.* FROM node n $query[1] LIMIT 50"); $output .= status($query[0]); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; @@ -117,7 +117,7 @@ function node_overview($query) { while ($node = db_fetch_object($result)) { $bg = $color[$i++ % sizeof($color)]; - $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attributes) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attributes) ."</TD><TD>". format_name($node->name) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", node_links($node->nid, $node->type)) ."</SMALL></TD>\n"; } $output .= "</TABLE>\n"; @@ -134,7 +134,6 @@ function node_edit_option($id) { $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type))); $form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this node."); $form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this node on the main page."); - $form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("A comma-seperated list of the moderators their usernames.")); $form .= form_hidden("nid", $node->nid); $form .= form_submit("Save node"); @@ -187,25 +186,25 @@ function node_delete($id) { } function node_query($type = -1) { - $queries[] = array("all nodes: recent additions", "ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: status set to 'posted'", "WHERE n.status = ". node_status("posted") ." ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: status set to 'queued'", "WHERE n.status = ". node_status("queued") ." ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: status set to 'dumped'", "WHERE n.status = ". node_status("dumped") ." ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: scheduled to be posted", "WHERE n.timestamp_posted > 0 ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: scheduled to be queued", "WHERE n.timestamp_queued > 0 ORDER BY n.timestamp DESC"); - $queries[] = array("all nodes: scheduled to be hidden", "WHERE n.timestamp_hidden > 0 ORDER BY n.timestamp DESC"); + $queries[] = array("all nodes: recent additions", "ORDER BY timestamp DESC"); + $queries[] = array("all nodes: status set to 'posted'", "WHERE status = ". node_status("posted") ." ORDER BY timestamp DESC"); + $queries[] = array("all nodes: status set to 'queued'", "WHERE status = ". node_status("queued") ." ORDER BY timestamp DESC"); + $queries[] = array("all nodes: status set to 'dumped'", "WHERE status = ". node_status("dumped") ." ORDER BY timestamp DESC"); + $queries[] = array("all nodes: scheduled to be posted", "WHERE timestamp_posted > 0 ORDER BY timestamp DESC"); + $queries[] = array("all nodes: scheduled to be queued", "WHERE timestamp_queued > 0 ORDER BY timestamp DESC"); + $queries[] = array("all nodes: scheduled to be hidden", "WHERE timestamp_hidden > 0 ORDER BY timestamp DESC"); foreach (module_list() as $name) { if (module_hook($name, "status")) { - $queries[] = array("$name: recent additions", "WHERE n.type = '$name' ORDER BY n.timestamp DESC"); + $queries[] = array("$name: recent additions", "WHERE type = '$name' ORDER BY timestamp DESC"); $statuses = module_invoke($name, "status"); if (is_array($statuses)) { foreach (array_reverse($statuses) as $key=>$status) { - $queries[] = array("$name: status set to '$status'", "WHERE n.type = '$name' AND n.status = '". node_status($status) ."' ORDER BY n.timestamp DESC"); + $queries[] = array("$name: status set to '$status'", "WHERE type = '$name' AND status = '". node_status($status) ."' ORDER BY timestamp DESC"); } - $queries[] = array("$name: scheduled to be posted", "WHERE n.type = '$name' AND n.timestamp_posted > 0 ORDER BY n.timestamp DESC"); - $queries[] = array("$name: scheduled to be queued", "WHERE n.type = '$name' AND n.timestamp_queued > 0 ORDER BY n.timestamp DESC"); - $queries[] = array("$name: scheduled to be hidden", "WHERE n.type = '$name' AND n.timestamp_hidden > 0 ORDER BY n.timestamp DESC"); + $queries[] = array("$name: scheduled to be posted", "WHERE type = '$name' AND timestamp_posted > 0 ORDER BY timestamp DESC"); + $queries[] = array("$name: scheduled to be queued", "WHERE type = '$name' AND timestamp_queued > 0 ORDER BY timestamp DESC"); + $queries[] = array("$name: scheduled to be hidden", "WHERE type = '$name' AND timestamp_hidden > 0 ORDER BY timestamp DESC"); } } } @@ -237,7 +236,6 @@ function node_setting() { $form .= form_select(t("Post threshold"), $name ."_post", variable_get($name ."_post", 4), $threshold_post, "If new submissions are subject to moderation, select a post threshold."); $form .= form_select(t("Dump threshold"), $name ."_dump", variable_get($name ."_dump", -2), $threshold_dump, "If new submissions are subject to moderation, select a dump threshold."); $form .= form_select(t("Expiration threshold"), $name ."_expire", variable_get($name ."_expire", 8), $threshold_expire, "If new submissions are subject to moderation, select a expiration threshold."); - $form .= form_textfield("Moderate", $name ."_moderate", variable_get($name ."_moderate", ""), 35, 255, "A comma-seperated list of the moderators' usernames."); } } @@ -258,7 +256,7 @@ function node_admin_save($edit) { node_save($edit, array(attributes)); } else { - node_save($edit, array(comment, moderate, promote)); + node_save($edit, array(comment, promote)); } } diff --git a/modules/page.module b/modules/page.module index 2c4e04cdb..0929e2ec2 100644 --- a/modules/page.module +++ b/modules/page.module @@ -17,7 +17,7 @@ function page_link($type) { $links[] = "<a href=\"node.php?id=$page->nid\">$page->link</a>"; } } - + return $links ? $links : array(); } diff --git a/modules/page/page.module b/modules/page/page.module index 2c4e04cdb..0929e2ec2 100644 --- a/modules/page/page.module +++ b/modules/page/page.module @@ -17,7 +17,7 @@ function page_link($type) { $links[] = "<a href=\"node.php?id=$page->nid\">$page->link</a>"; } } - + return $links ? $links : array(); } diff --git a/modules/poll.module b/modules/poll.module index a3195294e..24477f341 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -78,7 +78,7 @@ function poll_search($keys) { global $status; $result = db_query("SELECT n.*, p.* FROM poll p LEFT JOIN node n ON n.nid = p.nid AND n.lid = p.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%') LIMIT 20"); while ($poll = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($poll->title), "link" => (user_access("administer nodes") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->userid, "date" => $poll->timestamp); + $find[$i++] = array("title" => check_output($poll->title), "link" => (user_access("administer nodes") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->name, "date" => $poll->timestamp); } return $find; } @@ -104,16 +104,16 @@ function poll_view($node, $main = 0, $block = 0) { $pollop = $op; - if (($node->active) && (!field_get($node->voters, $user->userid))) $voting = 1; + if (($node->active) && (!field_get($node->voters, $user->name))) $voting = 1; if ((!$voting) && ($pollop != "View")) $pollop = "View"; switch ($pollop) { case "Vote": - if (($node->active) && (!field_get($node->voters, $user->userid))) { + if (($node->active) && (!field_get($node->voters, $user->name))) { $result = db_query("UPDATE poll_choices SET chvotes=chvotes+1 WHERE nid='" . $node->nid . "' && chid='" . check_input($chid) . "'"); if (($result) && ($user)) { $new = node_get_array(array("nid" => $node->nid)); - $new[voters] = field_set($node->voters, $user->userid, 1); + $new[voters] = field_set($node->voters, $user->name, 1); node_save($new, array(voters)); $node = node_get_object(array("nid" => $node->nid)); } @@ -186,8 +186,8 @@ function poll_form($edit = array(), $nocheck = 0) { $form .= form_submit(t("Preview")) . "<br><br><br>"; /* Main form */ - $form .= form_item(t("Your name"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); - $form .= form_hidden("userid", $edit[userid]); + $form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_hidden("name", $edit[name]); $form .= form_textfield(t("Question"), "title", $edit[title], 50, 127); for ($a = 0; $a < $choices; $a++) { diff --git a/modules/poll/poll.module b/modules/poll/poll.module index a3195294e..24477f341 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -78,7 +78,7 @@ function poll_search($keys) { global $status; $result = db_query("SELECT n.*, p.* FROM poll p LEFT JOIN node n ON n.nid = p.nid AND n.lid = p.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%') LIMIT 20"); while ($poll = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($poll->title), "link" => (user_access("administer nodes") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->userid, "date" => $poll->timestamp); + $find[$i++] = array("title" => check_output($poll->title), "link" => (user_access("administer nodes") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->name, "date" => $poll->timestamp); } return $find; } @@ -104,16 +104,16 @@ function poll_view($node, $main = 0, $block = 0) { $pollop = $op; - if (($node->active) && (!field_get($node->voters, $user->userid))) $voting = 1; + if (($node->active) && (!field_get($node->voters, $user->name))) $voting = 1; if ((!$voting) && ($pollop != "View")) $pollop = "View"; switch ($pollop) { case "Vote": - if (($node->active) && (!field_get($node->voters, $user->userid))) { + if (($node->active) && (!field_get($node->voters, $user->name))) { $result = db_query("UPDATE poll_choices SET chvotes=chvotes+1 WHERE nid='" . $node->nid . "' && chid='" . check_input($chid) . "'"); if (($result) && ($user)) { $new = node_get_array(array("nid" => $node->nid)); - $new[voters] = field_set($node->voters, $user->userid, 1); + $new[voters] = field_set($node->voters, $user->name, 1); node_save($new, array(voters)); $node = node_get_object(array("nid" => $node->nid)); } @@ -186,8 +186,8 @@ function poll_form($edit = array(), $nocheck = 0) { $form .= form_submit(t("Preview")) . "<br><br><br>"; /* Main form */ - $form .= form_item(t("Your name"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); - $form .= form_hidden("userid", $edit[userid]); + $form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_hidden("name", $edit[name]); $form .= form_textfield(t("Question"), "title", $edit[title], 50, 127); for ($a = 0; $a < $choices; $a++) { diff --git a/modules/queue.module b/modules/queue.module index 84670d391..dea9a50d6 100644 --- a/modules/queue.module +++ b/modules/queue.module @@ -38,10 +38,10 @@ function queue_vote($id, $vote) { if ($node = node_get_object(array(nid => $id))) { - if (!field_get($node->users, $user->userid)) { + if (!field_get($node->users, $user->id)) { // Update submission's score- and votes-field: - db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->userid, $vote) ."' WHERE nid = $id"); + db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->id, $vote) ."' WHERE nid = $id"); $node = node_get_object(array(nid => $id, type => $node->type)); @@ -64,13 +64,13 @@ function queue_vote($id, $vote) { function queue_overview() { global $status, $theme, $user; - $result = db_query("SELECT n.*, u.userid, u.name FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[queued]'"); + $result = db_query("SELECT n.*, u.name, u.name 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><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 || field_get($node->users, $user->userid)) $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid, $node->name) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". queue_score($node->nid) ."</TD></TR>\n"; - else $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid, $node->name) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". t("vote") ."</A></TD></TR>\n"; + if ($user->id == $node->author || field_get($node->users, $user->id)) $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node->name) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". queue_score($node->nid) ."</TD></TR>\n"; + else $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node->name) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". t("vote") ."</A></TD></TR>\n"; } $content .= "</TABLE>\n"; @@ -85,7 +85,7 @@ function queue_node($id) { $node = node_get_object(array(nid => $id)); - if ($user->id == $node->author || field_get($node->users, $user->userid)) { + if ($user->id == $node->author || field_get($node->users, $user->id)) { header("Location: node.php?id=$node->nid"); } else { diff --git a/modules/rating.module b/modules/rating.module index 1cc82c381..6f791dba3 100644 --- a/modules/rating.module +++ b/modules/rating.module @@ -79,12 +79,12 @@ function rating_gravity($id) { } function rating_list($limit) { - $result = db_query("SELECT u.userid, u.rating, u.name, r.* FROM users u LEFT JOIN rating r ON u.id = r.user ORDER BY u.rating DESC LIMIT $limit"); + $result = db_query("SELECT u.rating, u.name, r.* FROM users u LEFT JOIN rating r ON u.id = r.user ORDER BY u.rating DESC LIMIT $limit"); $output .= "<TABLE CELLPADDING=\"1\" CELLSPACING=\"1\">\n"; while ($account = db_fetch_object($result)) { $ranking = $account->old - $account->new; - $output .= "<TR><TD ALIGN=\"right\">". ++$i .".</TD><TD>". format_username($account->userid, $account->name) ."</TD><TD ALIGN=\"right\">". check_output($account->rating) ."</TD><TD>(". ($ranking < 0 ? "" : "+") ."$ranking)</TD></TR>"; + $output .= "<TR><TD ALIGN=\"right\">". ++$i .".</TD><TD>". format_name($account->name) ."</TD><TD ALIGN=\"right\">". check_output($account->rating) ."</TD><TD>(". ($ranking < 0 ? "" : "+") ."$ranking)</TD></TR>"; } $output .= "</TABLE>\n"; return $output; diff --git a/modules/story.module b/modules/story.module index 9ce78fd2c..a6bae74d2 100644 --- a/modules/story.module +++ b/modules/story.module @@ -16,7 +16,7 @@ function story_search($keys) { global $status, $user; $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20"); while ($story = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($story->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp); + $find[$i++] = array("title" => check_output($story->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp); } return $find; } @@ -46,8 +46,8 @@ function story_form($edit = array()) { story_view(new Story(node_preview($edit))); } - $form .= form_item(t("Your name"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); - $form .= form_hidden("userid", $edit[userid]); + $form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_hidden("name", $edit[name]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); $form .= node_attributes_edit("story", $edit); $form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); diff --git a/modules/story/story.module b/modules/story/story.module index 9ce78fd2c..a6bae74d2 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -16,7 +16,7 @@ function story_search($keys) { global $status, $user; $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20"); while ($story = db_fetch_object($result)) { - $find[$i++] = array("title" => check_output($story->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp); + $find[$i++] = array("title" => check_output($story->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp); } return $find; } @@ -46,8 +46,8 @@ function story_form($edit = array()) { story_view(new Story(node_preview($edit))); } - $form .= form_item(t("Your name"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); - $form .= form_hidden("userid", $edit[userid]); + $form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_hidden("name", $edit[name]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); $form .= node_attributes_edit("story", $edit); $form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); diff --git a/modules/watchdog.module b/modules/watchdog.module index 991ff0676..b3b6cbc50 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -33,13 +33,13 @@ function watchdog_overview($type) { $color = array(account => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C"); $query = array(account => "WHERE type = 'account'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'"); - $result = db_query("SELECT w.*, u.userid FROM watchdog w LEFT JOIN users u ON w.user = u.id ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); + $result = db_query("SELECT w.*, u.name FROM watchdog w LEFT JOIN users u ON w.user = u.id ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= " <TR><TH>date</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n"; while ($watchdog = db_fetch_object($result)) { if ($background = $color[$watchdog->type]) { - $output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 64) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n"; + $output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 64) ."</TD><TD ALIGN=\"center\">". format_name($watchdog->name) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n"; } } $output .= "</TABLE>\n"; @@ -48,13 +48,13 @@ function watchdog_overview($type) { } function watchdog_view($id) { - $result = db_query("SELECT l.*, u.userid FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'"); + $result = db_query("SELECT l.*, u.name FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'"); if ($watchdog = db_fetch_object($result)) { $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= " <TR><TH>Type:</TH><TD>". check_output($watchdog->type) ."</TD></TR>\n"; $output .= " <TR><TH>Date:</TH><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n"; - $output .= " <TR><TH>User:</TH><TD>". format_username($watchdog->userid) ."</TD></TR>\n"; + $output .= " <TR><TH>User:</TH><TD>". format_name($watchdog->name) ."</TD></TR>\n"; $output .= " <TR><TH>Location:</TH><TD>". check_output($watchdog->location). "</TD></TR>\n"; $output .= " <TR><TH>Message:</TH><TD>". check_output($watchdog->message) ."</TD></TR>\n"; $output .= " <TR><TH>Hostname:</TH><TD>". check_output($watchdog->hostname) ."</TD></TR>\n"; diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index 991ff0676..b3b6cbc50 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -33,13 +33,13 @@ function watchdog_overview($type) { $color = array(account => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C"); $query = array(account => "WHERE type = 'account'", regular => "WHERE type = 'message'", special => "WHERE type = 'special'", warning => "WHERE type = 'warning'", error => "WHERE type = 'error'", httpd => "WHERE type = 'httpd'"); - $result = db_query("SELECT w.*, u.userid FROM watchdog w LEFT JOIN users u ON w.user = u.id ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); + $result = db_query("SELECT w.*, u.name FROM watchdog w LEFT JOIN users u ON w.user = u.id ". ($type ? $query[$type] : "") ." ORDER BY timestamp DESC LIMIT 1000"); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= " <TR><TH>date</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n"; while ($watchdog = db_fetch_object($result)) { if ($background = $color[$watchdog->type]) { - $output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 64) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n"; + $output .= " <TR BGCOLOR=\"$background\"><TD>". format_date($watchdog->timestamp, "small") ."</TD><TD>". substr(check_output($watchdog->message), 0, 64) ."</TD><TD ALIGN=\"center\">". format_name($watchdog->name) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n"; } } $output .= "</TABLE>\n"; @@ -48,13 +48,13 @@ function watchdog_overview($type) { } function watchdog_view($id) { - $result = db_query("SELECT l.*, u.userid FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'"); + $result = db_query("SELECT l.*, u.name FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'"); if ($watchdog = db_fetch_object($result)) { $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= " <TR><TH>Type:</TH><TD>". check_output($watchdog->type) ."</TD></TR>\n"; $output .= " <TR><TH>Date:</TH><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n"; - $output .= " <TR><TH>User:</TH><TD>". format_username($watchdog->userid) ."</TD></TR>\n"; + $output .= " <TR><TH>User:</TH><TD>". format_name($watchdog->name) ."</TD></TR>\n"; $output .= " <TR><TH>Location:</TH><TD>". check_output($watchdog->location). "</TD></TR>\n"; $output .= " <TR><TH>Message:</TH><TD>". check_output($watchdog->message) ."</TD></TR>\n"; $output .= " <TR><TH>Hostname:</TH><TD>". check_output($watchdog->hostname) ."</TD></TR>\n"; |