diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-08-11 14:54:39 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-08-11 14:54:39 +0000 |
commit | 808b6b6cae71afd741023a0c08a6c925f2198752 (patch) | |
tree | d17e890898959601d841227fecd538f135371bfc | |
parent | 876536a955b783c4f82185dc45557ef3b1bd949f (diff) | |
download | brdo-808b6b6cae71afd741023a0c08a6c925f2198752.tar.gz brdo-808b6b6cae71afd741023a0c08a6c925f2198752.tar.bz2 |
- Changed the authentication and login scheme as discussed on the mailing
list.
- Fixed the export function in book.module (patch my Julian).
- Fixed the comment alignment (comments got truncated).
37 files changed, 583 insertions, 467 deletions
diff --git a/account.php b/account.php index f68ae948a..56532a1b3 100644 --- a/account.php +++ b/account.php @@ -4,51 +4,63 @@ include_once "includes/common.inc"; page_header(); -function account_get_user($uname) { - $result = db_query("SELECT * FROM users WHERE userid = '$uname'"); - return db_fetch_object($result); +function account_get_user($name) { + return db_fetch_object(db_query("SELECT * FROM users WHERE name = '". check_input($name) ."'")); } -function account_email() { - $output .= "<P>". t("Lost your password? Fill out your username and e-mail address, and your password will be mailed to you.") ."</P>\n"; - $output .= "<FORM ACTION=\"account.php\" METHOD=\"post\">\n"; - $output .= "<B>". t("Username") .":</B><BR>\n"; - $output .= "<INPUT NAME=\"userid\"><P>\n"; - $output .= "<B>". t("E-mail address") .":</B><BR>\n"; - $output .= "<INPUT NAME=\"email\"><P>\n"; - $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"". t("E-mail new password") ."\">\n"; - $output .= "</FORM>\n"; - - return $output; +function account_email_form() { + global $REQUEST_URI; + + $output .= "<p>". t("Lost your password? Fill out your username and e-mail address, and your password will be mailed to you.") ."</p>\n"; + + $output .= form_textfield(t("Username"), "login", $edit[login], 30, 64, t("Enter your full name or username.")); + $output .= form_textfield(t("E-mail address"), "email", $edit[email], 30, 64, t("You will be sent a new password.")); + $output .= form_submit(t("E-mail new password")); + + return form($REQUEST_URI, $output); } -function account_create($error = "") { +function account_page() { global $theme; + $theme->header(); + + if (variable_get("account_register", 1)) { + $theme->box(t("Create user account"), account_create_form()); + } + + if (variable_get("account_password", 1)) { + $theme->box(t("E-mail new password"), account_email_form()); + } + + $theme->footer(); +} + +function account_create_form($edit = array(), $error = "") { + global $theme, $REQUEST_URI; + if ($error) { - $output .= "<P><FONT COLOR=\"red\">". t("Failed to create account") .": ". check_output($error) ."</FONT></P>\n"; - watchdog("account", "failed to create account: $error"); + $output .= "<p><font color=\"red\">". t("Failed to create new account") .": ". check_output($error) ."</font></p>\n"; + watchdog("account", "failed to create new account: $error"); } else { - $output .= "<P>". t("Registering allows you to comment, to moderate comments and pending submissions, to customize the look and feel of the site and generally helps you interact with the site more efficiently.") ."</P><P>". t("To create an account, simply fill out this form an click the 'Create account' button below. An e-mail will then be sent to you with instructions on how to validate your account.") ."</P>\n"; + $output .= "<p>". t("Registering allows you to comment, to moderate comments and pending submissions, to customize the look and feel of the site and generally helps you interact with the site more efficiently.") ."</p><p>". t("To create an account, simply fill out this form an click the 'Create new account' button below. An e-mail will then be sent to you with instructions on how to validate your account.") ."</p>\n"; } - $output .= "<FORM ACTION=\"account.php\" METHOD=\"post\">\n"; - $output .= "<B>". t("Username") .":</B><BR>\n"; - $output .= "<INPUT NAME=\"userid\"><BR>\n"; - $output .= "<SMALL><I>". t("Enter your desired username: only letters, numbers and common special characters are allowed.") ."</I></SMALL><P>\n"; - $output .= "<B>". t("E-mail address") .":</B><BR>\n"; - $output .= "<INPUT NAME=\"email\"><BR>\n"; - $output .= "<SMALL><I>". t("You will be sent instructions on how to validate your account via this e-mail address: make sure it is accurate.") ."</I></SMALL><P>\n"; - $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"". t("Create account") ."\">\n"; - $output .= "</FORM>\n"; + $output .= form_textfield(t("Username"), "login", $edit[login], 30, 64, t("Enter your full name or username: only letters, numbers and common special characters like spaces are allowed.")); + $output .= form_textfield(t("E-mail address"), "email", $edit[email], 30, 64, t("You will be sent instructions on how to validate your account via this e-mail address: make sure it is accurate.")); + $output .= form_submit(t("Create new account")); - return $output; + return form($REQUEST_URI, $output); } function account_session_start($userid, $passwd) { global $user; - if ($userid && $passwd) $user = new User($userid, $passwd); + + if ($userid && $passwd) { + $user = new User($userid, $passwd); + } + if ($user->id) { if ($rule = user_ban($user->userid, "username")) { watchdog("account", "failed to login for '$user->userid': banned by $rule->type rule '$rule->mask'"); @@ -61,7 +73,9 @@ function account_session_start($userid, $passwd) { watchdog("account", "session opened for '$user->userid'"); } } - else watchdog("account", "failed to login for '$userid': invalid username - password combination"); + else { + watchdog("account", "failed to login for '$userid': invalid password"); + } } function account_session_close() { @@ -72,13 +86,17 @@ function account_session_close() { unset($user); } -function account_info_edit() { +function account_info_edit($error = 0) { global $theme, $user; if ($user->id) { - // construct form: - $form .= form_item(t("Username"), $user->userid, t("Required, unique, and can not be changed.")); - // $form .= form_textfield(t("Real name"), "name", $user->name, 30, 55, t("Optional")); + + if ($error) { + $form .= "<p><font color=\"red\">$error</font></p>\n"; + } + + $form .= form_textfield(t("Username"), "userid", $user->userid, 30, 55, t("Required, a unique name that can be used to log on.")); + $form .= form_textfield(t("Name"), "name", $user->name, 30, 55, t("Required, a unique name displayed with your contributions.")); $form .= form_item(t("Real e-mail address"), $user->real_email, t("Required, unique, can not be changed.") ." ". t("Your real e-mail address is never displayed publicly: only needed in case you lose your password.")); $form .= form_textfield(t("Fake e-mail address"), "fake_email", $user->fake_email, 30, 55, t("Optional") .". ". t("Displayed publicly so you may spam proof your real e-mail address if you want.")); $form .= form_textfield(t("Homepage"), "url", $user->url, 30, 55, t("Optional") .". ". t("Make sure you enter fully qualified URLs only. That is, remember to include \"http://\".")); @@ -87,23 +105,32 @@ function account_info_edit() { $form .= form_item(t("Password"), "<INPUT TYPE=\"password\" NAME=\"edit[pass1]\" SIZE=\"10\" MAXLENGTH=\"20\"> <INPUT TYPE=\"password\" NAME=\"edit[pass2]\" SIZE=\"10\" MAXLENGTH=\"20\">", t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password.")); $form .= form_submit(t("Save user information")); - // display form: $theme->header(); $theme->box(t("Edit user information"), form("account.php", $form)); $theme->footer(); } else { - $theme->header(); - $theme->box(t("Create user account"), account_create()); - $theme->box(t("E-mail new password"), account_email()); - $theme->footer(); + account_page(); } } function account_info_save($edit) { global $user; - if ($user->id) { - $user = user_save($user, array("name" => $edit[name], "fake_email" => $edit[fake_email], "url" => $edit[url], "bio" => $edit[bio], "signature" => $edit[signature])); + + if ($error = user_validate_name($edit[userid])) { + return t("Invalid name") .": $error"; + } + else if ($error = user_validate_name($edit[name])) { + return t("Invalid name") .": $error"; + } + else if (db_num_rows(db_query("SELECT userid FROM users WHERE id != '$user->id' AND (LOWER(userid) = LOWER('$edit[userid]') OR LOWER(name) = LOWER('$edit[userid]'))")) > 0) { + return t("Invalid username") .": the username '$edit[userid]' is already taken."; + } + else if (db_num_rows(db_query("SELECT name FROM users WHERE id != '$user->id' AND (LOWER(userid) = LOWER('$edit[name]') OR LOWER(name) = LOWER('$edit[name]'))")) > 0) { + return t("Invalid name") .": the name '$edit[name]' is already taken."; + } + else if ($user->id) { + $user = user_save($user, array("userid" => $edit[userid], "name" => $edit[name], "fake_email" => $edit[fake_email], "url" => $edit[url], "bio" => $edit[bio], "signature" => $edit[signature])); if ($edit[pass1] && $edit[pass1] == $edit[pass2]) $user = user_save($user, array("passwd" => $edit[pass1])); } } @@ -112,7 +139,6 @@ function account_settings_edit() { global $cmodes, $corder, $theme, $themes, $languages, $user; if ($user->id) { - // construct form: foreach ($themes as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". (($user->theme == $key) ? " SELECTED" : "") .">$key - $value[1]</OPTION>\n"; $form .= form_item(t("Theme"), "<SELECT NAME=\"edit[theme]\">$options</SELECT>", t("Selecting a different theme will change the look and feel of the site.")); for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")"; @@ -125,24 +151,22 @@ function account_settings_edit() { $form .= form_select(t("Comment filter"), "threshold", $user->threshold, $threshold, t("Comments that scored less than this threshold setting will be ignored. Anonymous comments start at 0, comments of people logged on start at 1 and moderators can add and subtract points.")); $form .= form_submit(t("Save site settings")); - // display form: $theme->header(); $theme->box(t("Edit your preferences"), form("account.php", $form)); $theme->footer(); } else { - $theme->header(); - if (variable_get("account_register", 1)) $theme->box(t("Create user account"), account_create()); - $theme->box(t("E-mail new password"), account_email()); - $theme->footer(); + account_page(); } } function account_settings_save($edit) { global $user; + if ($user->id) { $user = user_save($user, array("theme" => $edit[theme], "timezone" => $edit[timezone], "language" => $edit[language], "nodes" => $edit[nodes], "mode" => $edit[mode], "sort" => $edit[sort], "threshold" => $edit[threshold])); } + } function account_blocks_edit() { @@ -153,7 +177,7 @@ function account_blocks_edit() { $result = db_query("SELECT * FROM blocks WHERE status = 1 ORDER BY module"); while ($block = db_fetch_object($result)) { $entry = db_fetch_object(db_query("SELECT * FROM layout WHERE block = '". check_input($block->name) ."' AND user = '$user->id'")); - $options .= "<INPUT TYPE=\"checkbox\" NAME=\"edit[$block->name]\"". ($entry->user ? " CHECKED" : "") ."> ". t($block->name) ."<BR>\n"; + $options .= "<input type=\"checkbox\" name=\"edit[$block->name]\"". ($entry->user ? " checked=\"checked\"" : "") ." /> ". t($block->name) ."<br />\n"; } $form .= form_item(t("Blocks in side bars"), $options, t("Enable the blocks you would like to see displayed in the side bars.")); @@ -165,10 +189,7 @@ function account_blocks_edit() { $theme->footer(); } else { - $theme->header(); - $theme->box(t("Create user account"), account_create()); - $theme->box(t("E-mail new password"), account_email()); - $theme->footer(); + account_page(); } } @@ -182,13 +203,13 @@ function account_blocks_save($edit) { } } -function account_user($uname) { +function account_user($name) { global $user, $theme; - if ($user->id && $user->userid == $uname) { + if ($user->id && $user->name == $name) { $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= " <TR><TD ALIGN=\"right\"><B>". t("Username") .":</B></TD><TD>$user->userid</TD></TR>\n"; - $output .= " <TR><TD ALIGN=\"right\"><B>". t("Real name") .":</B></TD><TD>". check_output($user->name) ."</TD></TR>\n"; + $output .= " <TR><TD ALIGN=\"right\"><B>". t("Name") .":</B></TD><TD>". check_output($user->name) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>". t("E-mail") .":</B></TD><TD>". format_email($user->fake_email) ."</A></TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>". t("Homepage") .":</B></TD><TD>". format_url($user->url) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>". t("Bio") .":</B></TD><TD>". check_output($user->bio, 1) ."</TD></TR>\n"; @@ -200,19 +221,19 @@ function account_user($uname) { $theme->box(t("Personal information"), $output); $theme->footer(); } - elseif ($uname && $account = account_get_user($uname)) { + elseif ($name && $account = account_get_user($name)) { $theme->header(); // Display account information: $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n"; $output .= " <TR><TD ALIGN=\"right\"><B>". t("Username") .":</B></TD><TD>". check_output($account->userid) ."</TD></TR>\n"; - $output .= " <TR><TD ALIGN=\"right\"><B>". t("Real name") .":</B></TD><TD>". check_output($account->name) ."</TD></TR>\n"; + $output .= " <TR><TD ALIGN=\"right\"><B>". t("Name") .":</B></TD><TD>". check_output($account->name) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>". t("E-mail") .":</B></TD><TD>". format_email($account->fake_email) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>". t("Homepage") .":</B></TD><TD>". format_url($account->url) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>". t("Bio") .":</B></TD><TD>". check_output($account->bio) ."</TD></TR>\n"; $output .= "</TABLE>\n"; - $theme->box(strtr(t("%a's user information"), array("%a" => $uname)), $output); + $theme->box(strtr(t("%a's user information"), array("%a" => $name)), $output); // Display contributions: if (user_access("access contents")) { @@ -227,7 +248,7 @@ function account_user($uname) { $nodes .= "<P>\n"; } - $theme->box(strtr(t("%a's contributions"), array("%a" => $uname)), ($nodes ? $nodes : t("Not posted any nodes."))); + $theme->box(strtr(t("%a's contributions"), array("%a" => $name)), ($nodes ? $nodes : t("Not posted any nodes."))); } if (user_access("access comments")) { @@ -244,44 +265,54 @@ function account_user($uname) { $comments .= " </UL>\n"; } - $theme->box(strtr(t("%a's comments"), array("%a" => $uname)), ($comments ? $comments : t("Not posted any comments."))); + $theme->box(strtr(t("%a's comments"), array("%a" => $name)), ($comments ? $comments : t("Not posted any comments."))); } $theme->footer(); } else { - // Display login form: - $theme->header(); - if (variable_get("account_register", 1)) $theme->box(t("Create user account"), account_create()); - $theme->box(t("E-mail new password"), account_email()); - $theme->footer(); + account_page(); } } -function account_email_submit($userid, $email) { +function account_email_submit($edit) { global $theme; - $result = db_query("SELECT id FROM users WHERE userid = '$userid' AND real_email = '$email'"); + $result = db_query("SELECT id FROM users WHERE (userid = '". check_input($edit[login]) ."' OR name = '". check_input($edit[login]) ."') AND real_email = '". check_input($edit[email]) ."'"); if ($account = db_fetch_object($result)) { + + /* + ** Generate a password and a confirmation hash: + */ + $passwd = user_password(); $hash = substr(md5("$userid. ". time() .""), 0, 12); $status = 1; - db_query("UPDATE users SET passwd = PASSWORD('$passwd'), hash = '$hash', status = '$status' WHERE userid = '$userid'"); + /* + ** Update the user account in the database: + */ - $link = path_uri() ."account.php?op=confirm&name=$userid&hash=$hash"; - $subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal"))); - $message = strtr(t("%a,\n\n\nyou requested us to e-mail you a new password for your account at %b. You will need to re-confirm your account or you will not be able to login. To confirm your account updates visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team"), array("%a" => $userid, "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $passwd)); + db_query("UPDATE users SET passwd = PASSWORD('$passwd'), hash = '$hash', status = '$status' WHERE userid = '". check_input($edit[login]) ."'"); - watchdog("account", "new password: `$userid' <$email>"); + /* + ** Send out an e-mail with the account details: + */ + + $link = path_uri() ."account.php?op=confirm&name=". urlencode($edit[login]) ."&hash=$hash"; + $subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal"))); + $message = strtr(t("%a,\n\n\nyou requested us to e-mail you a new password for your account at %b. You will need to re-confirm your account or you will not be able to login. To confirm your account updates visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team"), array("%a" => $edit[login], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $passwd)); mail($email, $subject, $message, "From: noreply"); + watchdog("account", "new password: `$edit[login]' <$edit[email]>"); + $output = t("Your password and further instructions have been sent to your e-mail address."); } else { - watchdog("account", "new password: '$userid' and <$email> do not match"); + watchdog("account", "new password: '$edit[login]' and <$edit[email]> do not match"); + $output = t("Could not sent password: no match for the specified username and e-mail address."); } @@ -290,33 +321,61 @@ function account_email_submit($userid, $email) { $theme->footer(); } -function account_create_submit($userid, $email) { +function account_create_submit($edit) { global $theme, $HTTP_HOST, $REQUEST_URI; - $new[userid] = $userid; - $new[real_email] = $email; + if (variable_get("account_register", 1)) { - if ($error = user_validate($new)) { $theme->header(); - $theme->box(t("Create user account"), account_create($error)); - $theme->footer(); - } - else { - $new[passwd] = user_password(); - $new[hash] = substr(md5("$new[userid]. ". time()), 0, 12); - $user = user_save("", array("userid" => $new[userid], "real_email" => $new[real_email], "passwd" => $new[passwd], "role" => "authenticated user", "status" => 1, "hash" => $new[hash])); + if ($error = user_validate_name($edit[login])) { + $theme->box(t("Create user account"), account_create_form($edit, $error)); + } + else if ($error = user_validate_mail($edit[email])) { + $theme->box(t("Create user account"), account_create_form($edit, $error)); + } + else if ($ban = user_ban($edit[login], "username")) { + $theme->box(t("Create user account"), account_create_form($edit, t("the username '$edit[login]' is banned") .": <i>$ban->reason</i>.")); + } + else if ($ban = user_ban($edit[real_email], "e-mail address")) { + $theme->box(t("Create user account"), account_create_form($edit, t("the username '$edit[email]' is banned") .": <i>$ban->reason</i>.")); + } + else if (db_num_rows(db_query("SELECT userid FROM users WHERE (LOWER(userid) = LOWER('$edit[login]') OR LOWER(name) = LOWER('$edit[login]'))")) > 0) { + $theme->box(t("Create user account"), account_create_form($edit, t("the username '$edit[login]' is already taken."))); + } + else if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email) = LOWER('$edit[email]')")) > 0) { + $theme->box(t("Create user account"), account_create_form($edit, t("the e-mail address '$edit[email]' is already in use by another account."))); + } + else { - $link = path_uri() ."account.php?op=confirm&name=$new[userid]&hash=$new[hash]"; - $subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal"))); - $message = strtr(t("%a,\n\n\nsomeone signed up for a user account on %b and supplied this e-mail address as their contact. If it wasn't you, don't get your panties in a bundle and simply ignore this mail. If this was you, you will have to confirm your account first or you will not be able to login. To confirm your account visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team\n"), array("%a" => $new[userid], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $new[passwd])); + /* + ** Generate a password and a confirmation hash: + */ - watchdog("account", "new account: `$new[userid]' <$new[real_email]>"); + $edit[passwd] = user_password(); + $edit[hash] = substr(md5("$new[userid]. ". time()), 0, 12); - mail($new[real_email], $subject, $message, "From: noreply"); + /* + ** Create the new user account in the database: + */ + + $user = user_save("", array("userid" => $edit[login], "name" => $edit[login], "real_email" => $edit[email], "passwd" => $edit[passwd], "role" => "authenticated user", "status" => 1, "hash" => $edit[hash])); + + /* + ** Send out an e-mail with the account details: + */ + + $link = path_uri() ."account.php?op=confirm&name=". urlencode($edit[login]) ."&hash=$edit[hash]"; + $subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal"))); + $message = strtr(t("%a,\n\n\nsomeone signed up for a user account on %b and supplied this e-mail address as their contact. If it wasn't you, don't get your panties in a bundle and simply ignore this mail. If this was you, you will have to confirm your account first or you will not be able to login. To confirm your account visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team\n"), array("%a" => $edit[login], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $edit[passwd])); + + mail($edit[email], $subject, $message, "From: noreply"); + + watchdog("account", "new account: `$edit[login]' <$edit[email]>"); + + $theme->box(t("Create user account"), t("Congratulations! Your member account has been successfully created and further instructions on how to confirm your account have been sent to your e-mail address. You have to confirm your account first or you will not be able to login.")); + } - $theme->header(); - $theme->box(t("Create user account"), t("Congratulations! Your member account has been successfully created and further instructions on how to confirm your account have been sent to your e-mail address. You have to confirm your account first or you will not be able to login.")); $theme->footer(); } } @@ -407,7 +466,7 @@ function account_track_site() { $cresult = db_query("SELECT c.subject, c.cid, c.pid, u.userid, u.name FROM comments c LEFT JOIN users u ON u.id = c.author WHERE c.lid = $node->nid ORDER BY c.timestamp DESC LIMIT $node->count"); $output .= "<UL>\n"; while ($comment = db_fetch_object($cresult)) { - $output .= " <LI>'<A HREF=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>' ". t("by") ." ". format_username($comment->userid, $comment->name) ."</LI>\n"; + $output .= " <LI>'<A HREF=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>' ". t("by") ." ". format_name($comment->name) ."</LI>\n"; } $output .= "</UL>\n"; } @@ -422,7 +481,7 @@ function account_track_site() { $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n"; $output .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Status") ."</TH></TR>\n"; while ($node = db_fetch_object($result)) { - $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid, $node->name) ."</TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD></TR>"; + $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node->name) ."</TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD></TR>"; } $output .= "</TABLE>"; } @@ -434,14 +493,18 @@ function account_track_site() { switch ($op) { case t("E-mail new password"): - account_email_submit(check_input($userid), check_input($email)); + account_email_submit($edit); break; - case t("Create account"): - if (variable_get("account_register", 1)) account_create_submit(check_input($userid), check_input($email)); + case t("Create new account"): + account_create_submit($edit); break; case t("Save user information"): - account_info_save($edit); - account_user($user->userid); + if ($error = account_info_save($edit)) { + account_info_edit($error); + } + else { + account_user($user->name); + } break; case t("Save site settings"): account_settings_save($edit); @@ -449,7 +512,7 @@ switch ($op) { break; case t("Save block settings"): account_blocks_save($edit); - account_user($user->userid); + account_user($user->name); break; case "confirm": account_create_confirm(check_input($name), check_input($hash)); @@ -465,7 +528,7 @@ switch ($op) { case "view": switch ($type) { case "information": - account_user($user->userid); + account_user($user->name); break; case "site": account_track_site(); @@ -493,7 +556,7 @@ switch ($op) { } break; default: - account_user($user->userid); + account_user($user->name); } page_footer(); diff --git a/database/database.mysql b/database/database.mysql index 57fbafa91..959c80010 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -1,3 +1,12 @@ +# MySQL dump 7.1 +# +# Host: localhost Database: drop +#-------------------------------------------------------- +# Server version 3.22.32 + +# +# Table structure for table 'access' +# CREATE TABLE access ( id tinyint(10) DEFAULT '0' NOT NULL auto_increment, mask varchar(255) DEFAULT '' NOT NULL, @@ -7,6 +16,9 @@ CREATE TABLE access ( PRIMARY KEY (id) ); +# +# Table structure for table 'blocks' +# CREATE TABLE blocks ( name varchar(64) DEFAULT '' NOT NULL, module varchar(64) DEFAULT '' NOT NULL, @@ -18,6 +30,9 @@ CREATE TABLE blocks ( PRIMARY KEY (name) ); +# +# Table structure for table 'blog' +# CREATE TABLE blog ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -25,6 +40,9 @@ CREATE TABLE blog ( PRIMARY KEY (lid) ); +# +# Table structure for table 'book' +# CREATE TABLE book ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -37,6 +55,9 @@ CREATE TABLE book ( PRIMARY KEY (lid) ); +# +# Table structure for table 'boxes' +# CREATE TABLE boxes ( bid tinyint(4) DEFAULT '0' NOT NULL auto_increment, title varchar(64) DEFAULT '' NOT NULL, @@ -49,6 +70,9 @@ CREATE TABLE boxes ( PRIMARY KEY (bid) ); +# +# Table structure for table 'bundle' +# CREATE TABLE bundle ( bid int(11) DEFAULT '0' NOT NULL auto_increment, title varchar(255) DEFAULT '' NOT NULL, @@ -57,6 +81,9 @@ CREATE TABLE bundle ( PRIMARY KEY (bid) ); +# +# Table structure for table 'cache' +# CREATE TABLE cache ( url varchar(255) DEFAULT '' NOT NULL, data text NOT NULL, @@ -64,6 +91,9 @@ CREATE TABLE cache ( PRIMARY KEY (url) ); +# +# Table structure for table 'category' +# CREATE TABLE category ( cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, name varchar(32) DEFAULT '' NOT NULL, @@ -78,6 +108,9 @@ CREATE TABLE category ( PRIMARY KEY (cid) ); +# +# Table structure for table 'channel' +# CREATE TABLE channel ( id int(11) DEFAULT '0' NOT NULL auto_increment, site varchar(255) DEFAULT '' NOT NULL, @@ -91,6 +124,9 @@ CREATE TABLE channel ( PRIMARY KEY (id) ); +# +# Table structure for table 'chatevents' +# CREATE TABLE chatevents ( id int(11) DEFAULT '0' NOT NULL auto_increment, body varchar(255) DEFAULT '' NOT NULL, @@ -98,6 +134,9 @@ CREATE TABLE chatevents ( PRIMARY KEY (id) ); +# +# Table structure for table 'chatmembers' +# CREATE TABLE chatmembers ( id int(11) DEFAULT '0' NOT NULL auto_increment, nick varchar(32) DEFAULT '' NOT NULL, @@ -105,6 +144,9 @@ CREATE TABLE chatmembers ( PRIMARY KEY (id) ); +# +# Table structure for table 'collection' +# CREATE TABLE collection ( cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, name varchar(32) DEFAULT '' NOT NULL, @@ -113,6 +155,9 @@ CREATE TABLE collection ( PRIMARY KEY (cid) ); +# +# Table structure for table 'comments' +# CREATE TABLE comments ( cid int(6) DEFAULT '0' NOT NULL auto_increment, pid int(6) DEFAULT '0' NOT NULL, @@ -130,6 +175,9 @@ CREATE TABLE comments ( KEY lid (lid) ); +# +# Table structure for table 'cvs' +# CREATE TABLE cvs ( user varchar(32) DEFAULT '' NOT NULL, files text, @@ -138,6 +186,9 @@ CREATE TABLE cvs ( timestamp int(11) DEFAULT '0' NOT NULL ); +# +# Table structure for table 'diaries' +# CREATE TABLE diaries ( id int(5) DEFAULT '0' NOT NULL auto_increment, author int(6) DEFAULT '0' NOT NULL, @@ -146,6 +197,9 @@ CREATE TABLE diaries ( PRIMARY KEY (id) ); +# +# Table structure for table 'diary' +# CREATE TABLE diary ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -153,6 +207,9 @@ CREATE TABLE diary ( PRIMARY KEY (lid) ); +# +# Table structure for table 'entry' +# CREATE TABLE entry ( eid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, name varchar(32) DEFAULT '' NOT NULL, @@ -162,6 +219,9 @@ CREATE TABLE entry ( PRIMARY KEY (eid) ); +# +# Table structure for table 'feed' +# CREATE TABLE feed ( fid int(11) DEFAULT '0' NOT NULL auto_increment, title varchar(255) DEFAULT '' NOT NULL, @@ -177,6 +237,9 @@ CREATE TABLE feed ( PRIMARY KEY (fid) ); +# +# Table structure for table 'file' +# CREATE TABLE file ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -189,6 +252,9 @@ CREATE TABLE file ( PRIMARY KEY (lid) ); +# +# Table structure for table 'forum' +# CREATE TABLE forum ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -196,6 +262,9 @@ CREATE TABLE forum ( PRIMARY KEY (lid) ); +# +# Table structure for table 'item' +# CREATE TABLE item ( iid int(11) DEFAULT '0' NOT NULL auto_increment, fid int(11) DEFAULT '0' NOT NULL, @@ -208,11 +277,17 @@ CREATE TABLE item ( PRIMARY KEY (iid) ); +# +# Table structure for table 'layout' +# CREATE TABLE layout ( user int(11) DEFAULT '0' NOT NULL, block varchar(64) DEFAULT '' NOT NULL ); +# +# Table structure for table 'locales' +# CREATE TABLE locales ( id int(11) DEFAULT '0' NOT NULL auto_increment, location varchar(128) DEFAULT '' NOT NULL, @@ -228,11 +303,17 @@ CREATE TABLE locales ( PRIMARY KEY (id) ); +# +# Table structure for table 'modules' +# CREATE TABLE modules ( name varchar(64) DEFAULT '' NOT NULL, PRIMARY KEY (name) ); +# +# Table structure for table 'node' +# CREATE TABLE node ( nid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, lid int(10) DEFAULT '0' NOT NULL, @@ -259,6 +340,9 @@ CREATE TABLE node ( KEY status (status) ); +# +# Table structure for table 'page' +# CREATE TABLE page ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -268,6 +352,9 @@ CREATE TABLE page ( PRIMARY KEY (lid) ); +# +# Table structure for table 'poll' +# CREATE TABLE poll ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -277,6 +364,9 @@ CREATE TABLE poll ( PRIMARY KEY (lid) ); +# +# Table structure for table 'poll_choices' +# CREATE TABLE poll_choices ( chid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -286,6 +376,9 @@ CREATE TABLE poll_choices ( PRIMARY KEY (chid) ); +# +# Table structure for table 'rating' +# CREATE TABLE rating ( user int(6) DEFAULT '0' NOT NULL, new int(6) DEFAULT '0' NOT NULL, @@ -293,11 +386,17 @@ CREATE TABLE rating ( PRIMARY KEY (user) ); +# +# Table structure for table 'referer' +# CREATE TABLE referer ( url varchar(255) DEFAULT '' NOT NULL, timestamp int(11) DEFAULT '0' NOT NULL ); +# +# Table structure for table 'role' +# CREATE TABLE role ( rid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, name varchar(32) DEFAULT '' NOT NULL, @@ -306,17 +405,24 @@ CREATE TABLE role ( PRIMARY KEY (rid) ); +# +# Table structure for table 'site' +# CREATE TABLE site ( sid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, - title varchar(128) DEFAULT '' NOT NULL, - url varchar(255) DEFAULT '' NOT NULL, + name varchar(128) DEFAULT '' NOT NULL, + link varchar(255) DEFAULT '' NOT NULL, size text NOT NULL, timestamp int(11) DEFAULT '0' NOT NULL, - UNIQUE title (title), - UNIQUE url (url), + feed varchar(255) DEFAULT '' NOT NULL, + UNIQUE title (name), + UNIQUE url (link), PRIMARY KEY (sid) ); +# +# Table structure for table 'story' +# CREATE TABLE story ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -325,6 +431,9 @@ CREATE TABLE story ( PRIMARY KEY (lid) ); +# +# Table structure for table 'tag' +# CREATE TABLE tag ( tid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, name varchar(32) DEFAULT '' NOT NULL, @@ -334,6 +443,9 @@ CREATE TABLE tag ( PRIMARY KEY (tid) ); +# +# Table structure for table 'topic' +# CREATE TABLE topic ( tid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, pid int(10) unsigned DEFAULT '0' NOT NULL, @@ -343,6 +455,9 @@ CREATE TABLE topic ( PRIMARY KEY (tid) ); +# +# Table structure for table 'users' +# CREATE TABLE users ( id int(10) unsigned DEFAULT '0' NOT NULL auto_increment, name varchar(60) DEFAULT '' NOT NULL, @@ -366,15 +481,24 @@ CREATE TABLE users ( rating decimal(8,2), language char(2) DEFAULT '' NOT NULL, role varchar(32) DEFAULT '' NOT NULL, - PRIMARY KEY (id) + PRIMARY KEY (id), + UNIQUE name (name), + UNIQUE userid (userid), + UNIQUE real_email (real_email) ); +# +# Table structure for table 'variable' +# CREATE TABLE variable ( name varchar(32) DEFAULT '' NOT NULL, value text NOT NULL, PRIMARY KEY (name) ); +# +# Table structure for table 'watchdog' +# CREATE TABLE watchdog ( id int(5) DEFAULT '0' NOT NULL auto_increment, user int(6) DEFAULT '0' NOT NULL, diff --git a/includes/comment.inc b/includes/comment.inc index 757a27c89..1e9853325 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -10,8 +10,8 @@ $cmodes = array(1 => "List - min", 2 => "List - max", 3 => "Threaded - min", 4 = $corder = array(1 => "Date - new", 2 => "Date - old", 3 => "Rate - high", 4 => "Rate - low"); class Comment { - function Comment($userid, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid, $lid) { - $this->userid = $userid; + function Comment($name, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid, $lid) { + $this->name = $name; $this->subject = $subject; $this->comment = $comment; $this->timestamp = $timestamp; @@ -35,8 +35,8 @@ function comment_moderate($moderate) { $id = check_output($id); $vote = check_output($vote); $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = '$id'")); - if ($comment && !field_get($comment->users, $user->userid)) { - $result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->userid, $vote) ."' WHERE cid = '$id'"); + if ($comment && !field_get($comment->users, $user->id)) { + $result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->id, $vote) ."' WHERE cid = '$id'"); } } } @@ -52,7 +52,7 @@ function comment_form($edit) { global $REQUEST_URI, $user; // name field: - $form .= form_item(t("Your name"), format_username($user->userid, $user->name)); + $form .= form_item(t("Your name"), format_name($user->name)); // subject field: $form .= form_textfield(t("Subject"), "subject", $edit[subject], 50, 64); @@ -79,8 +79,8 @@ function comment_reply($pid, $id) { global $theme; if ($pid) { - $item = db_fetch_object(db_query("SELECT comments.*, users.userid FROM comments LEFT JOIN users ON comments.author = users.id WHERE comments.cid = '$pid'")); - comment_view(new Comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment")); + $item = db_fetch_object(db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$pid'")); + comment_view(new Comment($item->name, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment")); } else { node_view(node_get_object(array("nid" => $id))); @@ -99,7 +99,7 @@ function comment_preview($edit) { global $REQUEST_URI, $theme, $user; // Preview comment: - comment_view(new Comment($user->userid, check_preview($edit[subject]), check_preview($edit[comment]), time(), check_preview($user->url), check_preview($user->fake_email), 0, 0, 0, 0), t("reply to this comment")); + comment_view(new Comment($user->name, check_preview($edit[subject]), check_preview($edit[comment]), time(), check_preview($user->url), check_preview($user->fake_email), 0, 0, 0, 0), t("reply to this comment")); $theme->box(t("Reply"), comment_form($edit)); } @@ -125,7 +125,7 @@ function comment_post($edit) { watchdog("special", "comment: added '$edit[subject]'"); // add comment to database: - db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->id', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->userid ? 1 : 0) ."')"); + db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->id', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->name ? 1 : 0) ."')"); // clear cache: cache_clear(); @@ -150,7 +150,7 @@ function comment_moderation($comment) { // preview comment: $output .= " "; } - else if ($user->id && $user->userid != $comment->userid && !field_get($comment->users, $user->userid)) { + else if ($user->id && $user->name != $comment->name && !field_get($comment->users, $user->id)) { // comment hasn't been moderated yet: foreach ($comment_votes as $key=>$value) $options .= " <OPTION VALUE=\"$value\">$key</OPTION>\n"; $output .= "<SELECT NAME=\"moderate[$comment->cid]\">$options</SELECT>\n"; @@ -216,7 +216,7 @@ function comment_view($comment, $folded = 0) { // display comment: if ($folded) $theme->comment($comment, $folded); - else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_username($comment->userid, $comment->name) ." <SMALL>($comment->score)</SMALL><P>"; + else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_name($comment->name) ." <SMALL>($comment->score)</SMALL><P>"; } function comment_thread_min($cid, $threshold) { @@ -235,14 +235,33 @@ function comment_thread_min($cid, $threshold) { function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) { global $user; + /* + ** We had quite a few browser specific issues with expanded comments below + ** the top level getting truncated on the right hand side. A range of + ** solutions have been suggested and tried but either the right margins of + ** the comments didn't line up as well, or the heavily nested tables made + ** for slow rendering and cluttered HTML. This is the best work-around in + ** terms of speed and size. + */ + $result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid"); + if ($level > 1) { + print "</td></tr></table>\n"; + } + + print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"". ($level * 25) ."\"> </td><td>\n"; + while ($comment = db_fetch_object($result)) { - print "<table width=100%><tr><td><ul>"; comment_view($comment, (comment_visible($comment, $threshold) ? comment_links($comment, 0) : 0)); + // print "comment at level $level\n"; comment_thread_max($comment->cid, $mode, $threshold, $level + 1, $dummy + 1); - print "</ul></td></tr></table>"; } + + if ($level < 2) { + print "</td></tr></table>\n"; + } + } function comment_render($lid, $cid) { @@ -278,7 +297,7 @@ function comment_render($lid, $cid) { print " <TR><TH>Subject</TH><TH>Author</TH><TH>Date</TH><TH>Score</TH></TR>\n"; while ($comment = db_fetch_object($result)) { if (comment_visible($comment, $threshold)) { - print " <TR><TD><A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid, $comment->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n"; + print " <TR><TD><A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n"; } } print "</TABLE>\n"; diff --git a/includes/common.inc b/includes/common.inc index a46ae405b..d347cc64f 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -204,9 +204,17 @@ function format_date($timestamp, $type = "medium", $format = "") { return $date; } -function format_username($username, $realname="") { - if ($username) return (user_access("administer users") ? "<A HREF=\"admin.php?mod=account&op=view&name=". urlencode($username) ."\">". check_output($realname ? $realname : $username) ."</A>" : "<A HREF=\"account.php?op=view&name=". urlencode($username) ."\">". check_output($realname ? $realname : $username) ."</A>"); - else return variable_get(anonymous, "Anonymous"); +function format_name($username, $realname = "") { + if ($realname) { + watchdog("special", "format_name - FIX ME"); + return "<font color=\"red\">FIX ME</font>\n"; + } + else if ($username) { + return (user_access("administer users") ? "<a href=\"admin.php?mod=account&op=view&name=". urlencode($username) ."\">". $username ."</a>" : "<a href=\"account.php?op=view&name=". urlencode($username) ."\">$username</a>"); + } + else { + return variable_get(anonymous, "Anonymous"); + } } function format_email($address) { diff --git a/includes/node.inc b/includes/node.inc index de8b36f19..70a0472af 100644 --- a/includes/node.inc +++ b/includes/node.inc @@ -16,7 +16,7 @@ function _node_get($conditions) { } if ($type) { - return db_query("SELECT n.*, l.*, u.userid, u.name FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id WHERE $where ORDER BY n.timestamp DESC"); + return db_query("SELECT n.*, l.*, u.name FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id WHERE $where ORDER BY n.timestamp DESC"); } } diff --git a/includes/search.inc b/includes/search.inc index 5be56fb48..8e74cd4f7 100644 --- a/includes/search.inc +++ b/includes/search.inc @@ -14,7 +14,7 @@ function search_data($keys, $type) { foreach ($result as $entry) { $output .= "<p>\n"; $output .= " <b><u><a href=\"$entry[link]\" />$entry[title]</a></u></b><br />"; - $output .= " <small>$entry[link]". ($entry[user] ? " - ". format_username($entry[user], $entry[name]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</small>"; + $output .= " <small>$entry[link]". ($entry[user] ? " - ". format_name($entry[user], $entry[name]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</small>"; $output .= "</p>\n"; } } diff --git a/includes/theme.inc b/includes/theme.inc index 6950e9712..1ff536d18 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -8,7 +8,7 @@ class BaseTheme { function image($name) { return "misc/$name"; } - + function comment_controls($threshold = 1, $mode = 3, $order = 1) { global $REQUEST_URI, $user; $output .= "<DIV ALIGN=\"CENTER\">\n"; @@ -67,7 +67,7 @@ function theme_account($region, $theme) { $content .= "<a href=\"account.php?op=logout\">". t("logout") ."</a>\n"; $content .= "</td></tr></table>\n"; - $theme->box($user->userid, $content, $region); + $theme->box($user->name, $content, $region); } else { $output .= "<div align=\"center\">\n"; @@ -109,7 +109,8 @@ function theme_moderation_results($theme, $node, $region) { foreach (explode(",", $node->users) as $vote) { if ($vote) { $data = explode("=", $vote); - $output .= format_username($data[0]) ." voted '$data[1]'.<br />"; + $account = user_get($data[0]); + $output .= format_name($account->name) ." voted '$data[1]'.<br />"; } } diff --git a/includes/user.inc b/includes/user.inc index 721ccfd25..c6fc7249c 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -3,7 +3,7 @@ class User { function User($userid, $passwd = 0) { if ($passwd) { - $result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE LOWER(userid) = LOWER('$userid') && passwd = PASSWORD('$passwd') AND status = 2"); + $result = db_query("SELECT u.*, r.perm FROM users u LEFT JOIN role r ON u.role = r.name WHERE (LOWER(u.userid) = LOWER('$userid') OR LOWER(u.name) = LOWER('$userid')) AND u.passwd = PASSWORD('$passwd') AND u.status = 2"); if (db_num_rows($result) == 1) { foreach (db_fetch_row($result) as $key=>$value) { $field = mysql_field_name($result, $key); $this->$field = stripslashes($value); $this->field[] = $field; } db_query("UPDATE users SET last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]' WHERE id = $this->id"); @@ -19,6 +19,10 @@ class User { } } +function user_get($uid) { + return db_fetch_object(db_query("SELECT * FROM users WHERE id = '". check_output($uid) ."'")); +} + function user_init() { global $db_name; session_name($db_name); @@ -49,7 +53,7 @@ function user_save($account, $array) { else db_query("INSERT INTO users SET $query last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]'"); // return account: - return user_load(($account->userid ? $account->userid : $array[userid])); + return user_load($array[userid] ? $array[userid] : $account->userid); } function user_access($perm) { @@ -92,20 +96,4 @@ function user_validate_mail($mail) { if (!eregi("^[_+\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $mail)) return t("the e-mail address '$email' is not valid."); } -function user_validate($user) { - // Verify username: - 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."); -} - ?>
\ No newline at end of file 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"; @@ -77,7 +77,7 @@ function node_failure() { function node_history($node) { global $status; if ($node->status == $status[expired] || $node->status == $status[posted]) { - $output .= "<DT><B>". format_date($node->timestamp) ." by ". format_username($node->userid, $node->name) .":</B></DT><DD>". check_output($node->log, 1) ."<P></DD>"; + $output .= "<dt><b>". format_date($node->timestamp) ." by ". format_name($node->name) .":</b></dt><dd>". check_output($node->log, 1) ."<p /></dd>"; } if ($node->pid) { $output .= node_history(node_get_object(array("nid" => $node->pid))); @@ -88,11 +88,11 @@ function node_history($node) { $number = ($title ? db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title' AND status = $status[posted]")) : 1); if ($number > 1) { - $result = db_query("SELECT n.*, u.userid, u.name FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.title = '$title'"); + $result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.title = '$title'"); while ($node = db_fetch_object($result)) { if (node_access($node)) { - $output .= "<P><B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B><BR><SMALL>$node->type - ". format_username($node->userid, $node->name) ." - ". format_date($node->timestamp, "small") ."</SMALL></P>"; + $output .= "<P><B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B><BR><SMALL>$node->type - ". format_name($node->name) ." - ". format_date($node->timestamp, "small") ."</SMALL></P>"; } } diff --git a/themes/example/example.theme b/themes/example/example.theme index 0a34d71b9..8c2b4e9db 100644 --- a/themes/example/example.theme +++ b/themes/example/example.theme @@ -63,7 +63,7 @@ <TD> <?php - echo strtr(t("by %a on %b"), array("%a" => format_username($node->userid, $node->name), "%b" => format_date($node->timestamp, "small"))); + echo strtr(t("by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp, "small"))); ?> </TD> @@ -120,7 +120,7 @@ echo t("Author") .":"; echo " </TD>"; echo " <TD COLSPAN=\"2\">"; - echo format_username($comment->userid, $comment->name) ." on ". format_date($comment->timestamp); + echo format_name($comment->name) ." on ". format_date($comment->timestamp); echo " </TD>"; echo " </TR>"; diff --git a/themes/goofy/goofy.theme b/themes/goofy/goofy.theme index 6c338b18a..8277b38f6 100644 --- a/themes/goofy/goofy.theme +++ b/themes/goofy/goofy.theme @@ -102,7 +102,7 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\" function node($node, $main = 0) { echo "\n<!-- node: \"$node->title\" -->\n"; $title = check_output($node->title); - $subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_username($node->userid, $node->name), "%b" => format_date($node->timestamp, "large"))); + $subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp, "large"))); $subright = node_index($node); $body = check_output($node->body, 1) . ($main ? "<hr color=\"#404040\" size=\"1\"><div align=\"right\">[ " . $this->links(link_node($node)) . " ]</div>" : ""); print "<script language=\"JavaScript\"><!--\ns(\"". $this->stripbreaks(addslashes($title)) ."\",\"". $this->stripbreaks(addslashes($subleft)) ."\",\"". $this->stripbreaks(addslashes($subright)) ."\",\"". $this->stripbreaks(addslashes($body)) ."\"); // -->\n</script>\n"; @@ -112,8 +112,8 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\" function comment($comment, $link = "") { echo "<A NAME=\"$comment->cid\"></A>\n"; - $author = "<b>" . format_username($comment->userid, $comment->name) . "</b>"; - if ($comment->userid) { + $author = "<b>" . format_name($comment->name) . "</b>"; + if ($comment->name) { if ($comment->fake_email) $info[] = format_email($comment->fake_email); if (eregi("http://",$comment->url)) $info[] = format_url($comment->url); if ($info) $author .= "<br>[ ". implode(" | ",$info) . " ]"; diff --git a/themes/jeroen/jeroen.theme b/themes/jeroen/jeroen.theme index b91cd71f8..55717c8db 100644 --- a/themes/jeroen/jeroen.theme +++ b/themes/jeroen/jeroen.theme @@ -117,7 +117,7 @@ case 12: $how = "Forged"; break; default: $how = "Sneaked through"; } - echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_username($node->userid, $node->name), "%b" => format_date($node->timestamp), "large")) ."</FONT>"; + echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp), "large")) ."</FONT>"; ?> </FONT> </td> @@ -192,8 +192,8 @@ // Author: echo " <tr>"; - echo " <td align=\"right\"><FONT COLOR=\"#FEFEFE\">". t("Author") .":</FONT></td><td><B>". format_username($comment->userid, $comment->name) ."</B> "; - if ($comment->userid) { + echo " <td align=\"right\"><FONT COLOR=\"#FEFEFE\">". t("Author") .":</FONT></td><td><B>". format_name($comment->name) ."</B> "; + if ($comment->name) { // Display extra information line: if ($comment->fake_email) $info .= format_email($comment->fake_email); if (eregi("http://",$comment->url)) $info .= " | " . format_url($comment->url); diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme index a595fb1ff..a902a6360 100644 --- a/themes/marvin/marvin.theme +++ b/themes/marvin/marvin.theme @@ -55,7 +55,7 @@ print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\">\n"; print " <tr><td colspan=\"2\"><img src=\"themes/marvin/images/drop.gif\" alt=\"\" /> <b>". check_output($node->title) ."</b></td></tr>\n"; print " <tr valign=\"bottom\"><td colspan=\"2\" bgcolor=\"#000000\" width=\"100%\"><img src=\"themes/marvin/images/pixel.gif\" width=\"1\" height=\"0\" alt=\"\" /></td></tr>\n"; - print " <tr><td><font color=\"#7C7C7C\"><small>". strtr(t("Submitted by %a on %b"), array("%a" => format_username($node->userid, $node->name), "%b" => format_date($node->timestamp, "large"))); ?><?php print "</small></font></td><td align=\"right\" valign=\"top\" nowrap><small>". node_index($node) ."</small></td></tr>\n"; + print " <tr><td><font color=\"#7C7C7C\"><small>". strtr(t("Submitted by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp, "large"))); ?><?php print "</small></font></td><td align=\"right\" valign=\"top\" nowrap><small>". node_index($node) ."</small></td></tr>\n"; print " <tr><td colspan=\"2\"> </td></tr>\n"; print " <tr><td colspan=\"2\"><p>". check_output($node->body, 1) ."</p></td></tr>\n"; print " <tr><td colspan=\"2\"> </tr></tr>\n"; @@ -89,7 +89,7 @@ // Author: print " <tr>\n"; - print " <td align=\"right\" valign=\"top\">". t("Author") .":</td><td>". format_username($comment->userid, $comment->name) ."</td>\n"; + print " <td align=\"right\" valign=\"top\">". t("Author") .":</td><td>". format_name($comment->name) ."</td>\n"; print " </tr>\n"; // Date diff --git a/themes/unconed/unconed.theme b/themes/unconed/unconed.theme index 23e2b9c53..f8374c31b 100644 --- a/themes/unconed/unconed.theme +++ b/themes/unconed/unconed.theme @@ -90,7 +90,7 @@ <TR><TD COLSPAN="2" BGCOLOR="<?php echo $this->bgcolor1; ?>" WIDTH="100%"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><FONT COLOR="<?php echo $this->fgcolor1; ?>"><B><?php echo "". check_output($node->title) .""; ?></B></FONT></td><td valign="middle" align="center"><IMG SRC="themes/<?php print $this->themename; ?>/images/icon.gif" valign="middle"></td></tr></table></TD></TR> <TR BGCOLOR="<?php echo $this->bgcolor2; ?>"> <?php - print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\"><SMALL>" . strtr(t("Submitted by %a on %b"), array("%a" => format_username($node->userid, $node->name), "%b" => format_date($node->timestamp, "large"))) . "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\" NOWRAP><B>". node_index($node) ."</B>"; + print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\"><SMALL>" . strtr(t("Submitted by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp, "large"))) . "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\" NOWRAP><B>". node_index($node) ."</B>"; ?> </TD> </TR> @@ -112,7 +112,7 @@ function comment($comment, $link) { print "<A NAME=\"$comment->cid\"></A>\n"; - print "\n<!-- Comment: \"$comment->subject\" by $comment->userid -->\n"; + print "\n<!-- Comment: \"$comment->subject\" by $comment->name -->\n"; ?> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="<?php echo $this->brcolor1; ?>" WIDTH="100%"> @@ -139,8 +139,8 @@ // Author: echo " <TR>"; - echo " <TD ALIGN=\"right\" VALIGN=\"top\">" . t("Author") . ":</TD><TD><B>" . format_username($comment->userid, $node->name) . "</B> "; - if ($comment->userid) { + echo " <TD ALIGN=\"right\" VALIGN=\"top\">" . t("Author") . ":</TD><TD><B>" . format_name($node->name) . "</B> "; + if ($comment->name) { // Display extra information line: if ($comment->fake_email) $info .= format_email($comment->fake_email); if (eregi("http://",$comment->url)) $info .= ($info?" | ":"") . format_url($comment->url); diff --git a/themes/yaroon/yaroon.theme b/themes/yaroon/yaroon.theme index a404e1c2a..fee63a65a 100644 --- a/themes/yaroon/yaroon.theme +++ b/themes/yaroon/yaroon.theme @@ -131,7 +131,7 @@ <tr> <td> <a href="index.php?topic=<?php echo $node->tid; ?>"><img src="themes/yaroon/images/<?php echo $img; ?>" border="0" /></a> <b style="font-size: 12pt"><?php echo check_output($node->title); ?></b> - <?php echo strtr(t("by %a on %b"), array("%a" => format_username($node->userid), "%b" => format_date($node->timestamp), "small")); ?> + <?php echo strtr(t("by %a on %b"), array("%a" => format_name($node->name), "%b" => format_date($node->timestamp), "small")); ?> </td> </tr> <tr><td bgcolor="<?php echo $color; ?>"><img src="themes/yaroon/images/pixel.gif" width="1" height="1" alt="" border="0" /></td></tr> @@ -168,7 +168,7 @@ <tr> <td valign="bottom" class="box"> <img src="themes/yaroon/images/square.gif" /> <b><?php echo check_output($comment->subject); ?></b> - <font size="-1"><?php echo strtr(t(" by %a on %b"), array("%a" => format_username($comment->userid), "%b" => format_date($comment->timestamp), "small")); ?></font> + <font size="-1"><?php echo strtr(t(" by %a on %b"), array("%a" => format_name($comment->name), "%b" => format_date($comment->timestamp), "small")); ?></font> </td> <td align="right"><?php echo comment_moderation($comment); ?></td> </tr> diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql index 2d101152c..7a58c6a08 100644 --- a/updates/2.00-to-x.xx.sql +++ b/updates/2.00-to-x.xx.sql @@ -334,3 +334,9 @@ ALTER TABLE site ADD feed varchar(255) DEFAULT '' NOT NULL; #17/06/01 ALTER TABLE page ADD link varchar(128) DEFAULT '' NOT NULL AFTER nid; + +#09/08/01 +ALTER TABLE users ADD UNIQUE name (name); +ALTER TABLE users ADD UNIQUE userid (userid); +ALTER TABLE users ADD UNIQUE real_email (real_email); +UPDATE users SET name = userid WHERE name = ''; |