diff options
Diffstat (limited to 'modules')
30 files changed, 189 insertions, 743 deletions
diff --git a/modules/access.module b/modules/access.module deleted file mode 100644 index e75e4474d..000000000 --- a/modules/access.module +++ /dev/null @@ -1,175 +0,0 @@ -<?php - -function access_help() { - ?> - <H3>Roles</H3> - <P>Users have roles that define what kinds of actions they can take. Roles define classes of users such as <I>anonymous user</I>, <I>authenticated user</I>, <I>moderator</I>, <I>administrator</I> and so on. Every user can have one role.</P> - <P>Roles make it easier for you to manage security. Instead of defining what every single user can do, you can simply set a couple different permissions for different user roles.</P> - <P>Drupal comes with three built-in roles:</P> - <UL> - <LI>Anonymous user: this role is used for users that don't have a user account or that are not authenticated.</LI> - <LI>Registered user: this role is assigned automatically to authenticated users. Most users will belong to this user role unless specified otherwise.</LI> - </UL> - <P>For basic Drupal sites you can get by with <I>anonymous user</I> and <I>authenticated user</I> but for more complex sites where you want other users to be able to perform maintainance or administrative duties, you may want to create your own roles to classify your users into different groups.</P> - - <H3>Permissions</H3> - <P>Each Drupal's permission describes a fine-grained logical operation such as <I>access administration pages</I> or <I>add and modify user accounts</I>. You could say a permission represents access granted to a user to perform a set of operations.</P> - - <H3>Access control</H3> - <P>Roles tie users to permissions. The combination of roles and permissions represent a way to tie user authorization to the performance of actions, which is how Drupal can determine what users can do.</P> - <?php -} - -function access_perm() { - return array("access administration pages", "administer roles and permissions"); -} - -function access_link($type) { - if ($type == "admin" && user_access("administer roles and permissions")) { - $links[] = "<a href=\"admin.php?mod=access\">roles and permissions</a>"; - } - - return $links ? $links : array(); -} - -function access_get_role($rid) { - return db_fetch_array(db_query("SELECT * FROM role WHERE rid = '". check_input($rid) ."'")); -} - -function access_get_roles() { - $result = db_query("SELECT * FROM role ORDER BY name"); - while ($role = db_fetch_object($result)) { - $roles[$role->name] = $role->name; - } - return $roles; -} - -function access_role_form($edit = array()) { - global $REQUEST_URI; - - $form .= form_textfield("Role name", "name", $edit[name], 50, 64, "The name for this role. Example: 'moderator', 'editorial board', 'site architect'."); - $form .= form_submit("Submit"); - - if ($edit[rid]) { - $form .= form_submit(t("Delete")); - $form .= form_hidden("rid", $edit[rid]); - } - - return form($REQUEST_URI, $form); -} - -function access_role_save($edit) { - if ($edit[rid] && $edit[name]) { - db_query("UPDATE role SET name = '". check_input($edit[name]) ."' WHERE rid = '$edit[rid]'"); - } - else if ($edit[rid]) { - db_query("DELETE FROM role WHERE rid = '". check_input($edit[rid]) ."'"); - } - else { - db_query("INSERT INTO role (name) VALUES ('". check_input($edit[name]) ."')"); - } -} - -function access_role_view() { - $result = db_query("SELECT * FROM role ORDER BY name"); - $output .= "<TABLE BORDER=\"1\" CELLSPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>name</TH><TH>operations</TH></TR>\n"; - while ($role = db_fetch_object($result)) { - $output .= "<TR><TD>". check_output($role->name) ."</TD><TD><A HREF=\"admin.php?mod=access&op=edit&id=$role->rid\">edit role</A></TD></TR>\n"; - } - $output .= "</TABLE>\n"; - - return $output; -} - -function access_perm_form() { - global $REQUEST_URI; - - // Compile permission array: - foreach (module_list() as $name) { - if (module_hook($name, "perm")) { - $perms = array_merge($perms, module_invoke($name, "perm")); - } - } - asort($perms); - - // Compile role array: - $result = db_query("SELECT * FROM role ORDER BY name"); - while ($role = db_fetch_object($result)) $roles[$role->name] = $role->perm; - - // Render roles / permission table: - $output .= "<TABLE BORDER=\"1\" CELLSPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH> </TH><TH>". implode("</TH><TH>", array_keys($roles)) ."</TH></TR>\n"; - foreach ($perms as $perm) { - $output .= " <TR>\n"; - $output .= " <TD>". check_output($perm) ."</TD>\n"; - foreach ($roles as $name => $value) { - $output .= " <TD ALIGN=\"center\"><INPUT TYPE=\"checkbox\" NAME=\"edit[$name][$perm]\"". (strstr($value, $perm) ? " CHECKED" : "") ."></TD>\n"; - } - $output .= " </TR>\n"; - } - $output .= "</TABLE>\n"; - $output .= form_submit("Save permissions"); - - return form($REQUEST_URI, $output); -} - -function access_perm_save($edit) { - $result = db_query("SELECT * FROM role"); - while ($role = db_fetch_object($result)) { - $perm = $edit[$role->name] ? implode(", ", array_keys($edit[$role->name])) : ""; - db_query("UPDATE role SET perm = '$perm' WHERE name = '$role->name'"); - } - - return "permissions have been saved."; -} - -function access_init() { - $role = db_fetch_object(db_query("SELECT * FROM role WHERE name = 'anonymous user'")); - if (!$role) db_query("INSERT INTO role (name) VALUES ('anonymous user')"); - - $role = db_fetch_object(db_query("SELECT * FROM role WHERE name = 'authenticated user'")); - if (!$role) db_query("INSERT INTO role (name) VALUES ('authenticated user')"); -} - -function access_admin() { - global $edit, $op, $id; - - if (user_access("administer roles and permissions")) { - - print "<SMALL><A HREF=\"admin.php?mod=access&op=add\">add new role</A> | <A HREF=\"admin.php?mod=access&op=role\">role overview</A> | <A HREF=\"admin.php?mod=access&op=perm\">permission overview</A> | <A HREF=\"admin.php?mod=access&op=help\">help</A></SMALL><HR>\n"; - - access_init(); - - switch ($op) { - case "add": - print access_role_form(); - break; - case "edit": - print access_role_form(access_get_role($id)); - break; - case "help": - print access_help(); - break; - case "Delete": - $edit[name] = 0; - // fall through: - case "Submit": - print status(access_role_save($edit)); - // fall through: - case "role": - print access_role_view(); - break; - case "Save permissions": - print status(access_perm_save($edit)); - // fall through: - default: - print access_perm_form(); - } - } - else { - print message_access(); - } -} - -?>
\ No newline at end of file diff --git a/modules/account.module b/modules/account.module deleted file mode 100644 index c5b38f0ab..000000000 --- a/modules/account.module +++ /dev/null @@ -1,382 +0,0 @@ -<?php - -function account_help() { - ?> - <P>The account-module is responsible for maintaining the user database. It automatically handles tasks like registration, authentication, access control, password retrieval, user settings and much more.</P> - <P>The required administration can be accomplished through the "account" interface of the administration section. From here administrators can get a quick overview of all registered users and view/edit specific accounts using the links provided. Some useful operations include blocking specific accounts (e.g. a troublesome user) and giving/taking administration permissions. Note that you should only give these permissions to people you trust!</P> - <P>Check the documentation page for detailed information about user management.</P> - <H3>Regular expressions</H3> - <P>A <I>regular expression</I> (or <I>regexp</I>, or <I>pattern</I>) is a text string that describes some (mathematical) set of strings. A regexp <CODE>R</CODE> "matches" a string <CODE>S</CODE> if <CODE>S</CODE> is in the set of strings described by <CODE>R</CODE>.</P> - <P>Regular expressions are very powerful but often get complicated and nothing in this write-up can change that. - <P>A complete explanation of regular expressions is beyond the scope of this help system. A regular expression may use any of the following special characters/constructs:</P> - <TABLE BORDER="1"> - <TR><TD>^</TD><TD>Matches the beginning of a string.</TD></TR> - <TR><TD>$</TD><TD>Matches the end of a string.</TD></TR> - <TR><TD>.</TD><TD>Matches any character (including newline). For example the regular expression a.c would match the strings abc, adb, axb, but not axxc.<TD></TR> - <TR><TD>a*</TD><TD>Matches any sequence of zero or more a characters.</TD></TR> - <TR><TD>a+</TD><TD>Matches any sequence of one or more a characters.</TD></TR> - <TR><TD>a?</TD><TD>Matches either zero or one a character.</TD></TR> - <TR><TD>ab|cd</TD><TD>Matches either of the sequences "ab" or "cd".</TD></TR> - <TR><TD>(abc)*</TD><TD>Matches zero or more instances of the sequence abc.</TD></TR> - <TR><TD>[abc]</TD><TD>Matches any one of the characters between the brackets: a, b or c. Ranges of characters can specified by using a hyphen. For example, the regular expression [0-9] means match any digit. Multiple ranges can be specified as well. The regular expression [A-Za-z] means match any upper or lower case letter. To match any character except those in the range, the complement range, use the caret as the first character after the opening bracket. For example, the expression [^269A-Z] will match any characters except 2, 6, 9, and upper case letters.</TD></TR> - <TR><TD>{num}</TD><TD>Matches the preceding element num times.</TD></TR> - <TR><TD>{min, max}</TD><TD>Matches the preceding element at least min times, but not more than max times.</TD></TR> - </TABLE> - <P><B>Examples:</B></P> - <TABLE BORDER="1"> - <TR><TD>apple</TD><TD>Matches any string that has the text "apple" in it.</TD></TR> - <TR><TD>^apple$</TD><TD>Matches the exact string "apple".</TD></TR> - <TR><TD>^apple</TD><TD>Matches any string that starts with "apple".</TD></TR> - <TR><TD>domain\.com$</TD><TD>Matches any string that ends with "domain.com". Note that you have to escape the dot in domain.com.</TD></TR> - </TABLE> - <?php -} - -function account_perm() { - return array("administer users"); -} - -function account_link($type) { - if ($type == "admin" && user_access("administer users")) { - $links[] = "<a href=\"admin.php?mod=account\">user accounts</a>"; - } - - return $links ? $links : array(); -} - -function account_conf_options() { - $output .= form_select(t("Public accounts"), "account_register", variable_get("account_register", 1), array("Disabled", "Enabled"), "If enabled, everyone can create a new user account. If disabled, new user accounts can only be created by site administrators."); - return $output; -} - -function account_search($keys) { - $result = db_query("SELECT * FROM users WHERE name LIKE '%$keys%' LIMIT 20"); - while ($account = db_fetch_object($result)) { - $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; -} - -function account_ac_add($edit) { - db_query("INSERT INTO access (mask, type, reason) VALUES ('". check_input($edit[mask]) ."', '". check_input($edit[type]) ."', '". check_input($edit[reason]) ."')"); -} - -function account_ac_del($id) { - db_query("DELETE FROM access WHERE id = '$id'"); -} - -function account_ac_check($edit) { - return "\"$edit[text]\" ". (($rule = user_ban($edit[text], $edit[category])) ? "matched with access rule '$rule->mask'" : "did not match any of the existing access rules") ."."; -} - -function account_ac() { - $access = array("e-mail address", "hostname", "username"); - - $result = db_query("SELECT * FROM access"); - - foreach ($access as $value) $type .= " <OPTION VALUE=\"$value\">$value</OPTION>\n"; - - $output .= "<FORM ACTION=\"admin.php?mod=account&op=access\" METHOD=\"post\">\n"; - $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; - $output .= " <TR><TH>mask</TH><TH>type</TH><TH>reason</TH><TH>operations</TH></TR>\n"; - while ($rule = db_fetch_object($result)) { - $output .= " <TR><TD>$rule->mask</TD><TD ALIGN=\"center\">$rule->type</TD><TD>". check_output($rule->reason) ."</TD><TD><A HREF=\"admin.php?mod=account&op=delete&id=$rule->id\">delete rule</A></TD></TR>\n"; - } - $output .= " <TR><TD><INPUT TYPE=\"text\" NAME=\"edit[mask]\"></TD><TD><SELECT NAME=\"edit[type]\">\n$type</SELECT></TD><TD><INPUT TYPE=\"text\" NAME=\"edit[reason]\"></TD><TD><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Add rule\"></TD></TR>\n"; - $output .= " <TR><TD COLSPAN=\"4\"><SMALL><I>Use <A HREF=\"admin.php?mod=account&op=help\">regular expressions</A> (regexs) to specify the mask pattern.</I></SMALL></TD></TR>\n"; - $output .= "</TABLE>\n"; - $output .= "<BR><BR>\n"; - $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; - $output .= " <TR><TH COLSPAN=\"3\">check access rules</TH></TR>\n"; - $output .= " <TR><TD><INPUT TYPE=\"text\" NAME=\"edit[text]\"></TD><TD><SELECT NAME=\"edit[category]\">\n$type</SELECT></TD><TD><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Check\"></TD></TR>\n"; - $output .= "</TABLE>\n"; - $output .= "</FORM>\n"; - - return $output; -} - -function account_overview($query = array()) { - - $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_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"; - - return $output; -} - -function account_blocks($id) { - $result = db_query("SELECT * FROM layout WHERE user = '$id'"); - while ($layout = db_fetch_object($result)) { - $output .= "<LI>$layout->block</LI>\n"; - } - return $output; -} - -function account_nodes($id) { - $result = db_query("SELECT * FROM node WHERE author = $id ORDER BY timestamp DESC LIMIT 30"); - while ($node = db_fetch_object($result)) { - $output .= "<LI><A HREF=\"node.php?id=$node->nid\">$node->title</A> ($node->type)</LI>\n"; - } - return $output; -} - -function account_comments($id) { - $result = db_query("SELECT * FROM comments WHERE author = '$id' ORDER BY timestamp DESC LIMIT 30"); - while ($comment = db_fetch_object($result)) { - $output .= "<LI><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">$comment->subject</A></LI>\n"; - } - return $output; -} - -function account_delete($name) { - $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_name($name) ."': the account must be blocked first."; - } -} - -function account_form($account = 0) { - - $form .= $account->id ? form_item("ID", $account->id) . form_hidden("id", $account->id) : ""; - $form .= form_item(t("Name"), check_output($account->name) ." (". check_output($account->userid) .")"); - $form .= form_select(t("Status"), "status", $account->status, array("blocked", "not confirmed", "open")); - $form .= form_select(t("Role"), "role", $account->role, access_get_roles()); - $form .= form_textfield(t("Real e-mail address"), "real_email", $account->real_email, 30, 55); - $form .= form_textfield(t("Fake e-mail address"), "fake_email", $account->fake_email, 30, 55); - $form .= form_textfield(t("Homepage"), "url", $account->url, 30, 55); - $form .= form_textarea(t("Bio"), "bio", $account->bio, 35, 5); - $form .= form_textarea(t("Signature"), "signature", $account->signature, 35, 5); - - $form .= form_hidden("userid", $account->userid); - $form .= form_hidden("name", $account->name); - - if ($account) { - $form .= form_submit("View account"); - } - $form .= form_submit("Save account"); - - return form("admin.php?mod=account", $form); -} - -function account_save($edit) { - if ($edit[id]) { - // Updating existing account - foreach ($edit as $key=>$value) { - $query[] = "$key = '". addslashes($value) ."'"; - } - db_query("UPDATE users SET ". implode(", ", $query) ." WHERE id = $edit[id]"); - watchdog("account", "account: modified user '$edit[name]'"); - return $edit[name]; - } - else { - if ($error = account_validate($edit)) { - print status($error); - return 0; - } - else { - $edit[passwd] = user_password(); - $edit[hash] = substr(md5("$edit[userid]. ". time()), 0, 12); - - $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"))); - $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 knot 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[userid], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $edit[passwd])); - - watchdog("account", "new account: `$edit[userid]' <$edit[real_email]>"); - - if ($edit[status] == 1) mail($edit[real_email], $subject, $message, "From: noreply"); - - return $edit[userid]; - } - } -} - -function account_edit($name) { - $result = db_query("SELECT * FROM users WHERE name = '$name'"); - - if ($account = db_fetch_object($result)) { - return account_form($account); - } -} - -function account_add() { - global $REQUEST_URI; - - $form .= form_textfield("Username", "name", "", 30, 55); - $form .= form_textfield("E-mail address", "mail", "", 30, 55); - $form .= form_textfield("Password", "pass", "", 30, 55); - - $form .= form_submit("Create account"); - - return form($REQUEST_URI, $form); - -} - -function account_create($edit) { - - if ($error = user_validate_name($edit[name])) { - return $error; - } - else if ($error = user_validate_mail($edit[mail])) { - return $error; - } - else if (empty($edit[pass])) { - return "password should be non-empty."; - } - else if (db_num_rows(db_query("SELECT userid FROM users WHERE (LOWER(userid) = LOWER('$edit[name]') OR LOWER(name) = LOWER('$edit[name]'))")) > 0) { - return "the username '$edit[name]' is already taken."; - } - else if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email) = LOWER('$edit[mail]')")) > 0) { - return "the e-mail address '$edit[mail]' is already in use by another account."; - } - else { - $user = user_save("", array("userid" => $edit[name], "name" => $edit[name], "real_email" => $edit[mail], "passwd" => $edit[pass], "role" => "authenticated user", "status" => 2)); - } - -} - -function account_view($name) { - $status = array(0 => "blocked", 1 => "not confirmed", 2 => "open"); - - $result = db_query("SELECT * FROM users WHERE name = '$name'"); - - if ($account = db_fetch_object($result)) { - $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>Name:</TH><TD>". check_output($account->name) ." (". check_output($account->userid) .")</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 e-mail address:</TH><TD>". format_email($account->real_email) ."</TD></TR>\n"; - $output .= " <TR><TH>Fake e-mail address:</TH><TD>". check_output($account->fake_email) ."</TD></TR>\n"; - $output .= " <TR><TH>Homepage:</TH><TD>". format_url($account->url) ."</TD></TR>\n"; - $output .= " <TR><TH>Last access:</TH><TD>". format_date($account->last_access) ." from ". check_output($account->last_host) ."</TD></TR>\n"; - $output .= " <TR><TH>User rating:</TH><TD>". check_output($account->rating) ."</TD></TR>\n"; - $output .= " <TR><TH>Bio:</TH><TD>". check_output($account->bio) ."</TD></TR>\n"; - $output .= " <TR><TH>Signature:</TH><TD>". check_output($account->signature) ."</TD></TR>\n"; - $output .= " <TR><TH>Theme:</TH><TD>". check_output($account->theme) ."</TD></TR>\n"; - $output .= " <TR><TH>Timezone:</TH><TD>". check_output($account->timezone / 3600) ."</TD></TR>\n"; - $output .= " <TR><TH>Selected blocks:</TH><TD>". check_output(account_blocks($account->id)) ."</TD></TR>\n"; - $output .= " <TR><TH>Recent nodes:</TH><TD>". check_output(account_nodes($account->id)) ."</TD></TR>\n"; - $output .= " <TR><TH>Recent comments:</TH><TD>". check_output(account_comments($account->id)) ."</TD></TR>\n"; - $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">". form("admin.php?mod=account", $form) ."</TD></TR>\n"; - $output .= "</TABLE>\n"; - - return $output; - } -} - -function account_query($type = "") { - $queries = array(array("users recently visiting", "ORDER BY last_access DESC"), array("users recently joining", "ORDER BY id DESC"), array("users with pending accounts", "WHERE status = 1 ORDER BY last_access DESC"), array("users with blocked accounts", "WHERE status = 0 ORDER BY last_access DESC")); - 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; - - if (user_access("administer users")) { - print "<SMALL><A HREF=\"admin.php?mod=account&op=access\">access control</A> | <A HREF=\"admin.php?mod=account&op=add\">add new account</A> | <A HREF=\"admin.php?mod=account&op=listing\">account listings</A> | <A HREF=\"admin.php?mod=account&op=search\">search account</A> | <A HREF=\"admin.php?mod=account\">overview</A> | <A HREF=\"admin.php?mod=account&op=help\">help</A></SMALL><HR>"; - - $query = $query ? $query : 0; - $name = $name ? $name : $edit[name]; - - switch ($op) { - case "access": - print account_ac(); - break; - case "Add rule": - print status(account_ac_add($edit)); - print account_ac(); - break; - case "Check": - print status(account_ac_check($edit)); - print account_ac(); - break; - case "delete": - print status(account_ac_del($id)); - print account_ac(); - break; - case "Delete account": - print status(account_delete($name)); - print account_overview(account_query($query)); - break; - case "Create account": - if ($error = account_create($edit)) { - print status($error); - print account_add($edit); - } - else { - print account_edit($edit[name]); - } - break; - case "add": - print account_add(); - break; - case "Edit account": - case "edit": - print account_edit($name); - break; - case "help": - print account_help(); - break; - case "listing": - print node_listing(account_query()); - break; - case "search": - print search_form($keys); - print search_data($keys, $mod); - break; - case "Save account": - $name = account_save($edit); - if ($name) - print account_view($name); - else { - foreach ($edit as $key=>$value) { - $account->$key = $value; - } - print account_form($account); - } - break; - case "View account": - case "view": - print account_view($name); - break; - default: - print account_overview(account_query($query)); - } - } - else { - print message_access(); - } -} - -?> diff --git a/modules/aggregator.module b/modules/aggregator.module index 6bcc96825..98228f8ca 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -50,7 +50,7 @@ function import_update() { function import_format_item($item, $feed = 0) { global $theme, $user; - if ($user->id && user_access("post blogs")) { + if ($user->uid && user_access("post blogs")) { $output .= "<a href=\"submit.php?mod=blog&type=import&id=$item->iid\"><img src=\"". $theme->image("blog.gif") ."\" border=\"0\" width=\"12\" height=\"16\" alt=\"" . t("Blog this item") . "\" /></a> "; } @@ -602,7 +602,7 @@ function import_page_sources() { while ($feed = db_fetch_object($result)) { $output .= format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title); - $output .= "<p><div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div></p>"; + $output .= "<div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div><br />"; } $output .= "<a href=\"module.php?mod=import&op=fd\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a><br />\n"; diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 6bcc96825..98228f8ca 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -50,7 +50,7 @@ function import_update() { function import_format_item($item, $feed = 0) { global $theme, $user; - if ($user->id && user_access("post blogs")) { + if ($user->uid && user_access("post blogs")) { $output .= "<a href=\"submit.php?mod=blog&type=import&id=$item->iid\"><img src=\"". $theme->image("blog.gif") ."\" border=\"0\" width=\"12\" height=\"16\" alt=\"" . t("Blog this item") . "\" /></a> "; } @@ -602,7 +602,7 @@ function import_page_sources() { while ($feed = db_fetch_object($result)) { $output .= format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title); - $output .= "<p><div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div></p>"; + $output .= "<div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div><br />"; } $output .= "<a href=\"module.php?mod=import&op=fd\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a><br />\n"; diff --git a/modules/blog.module b/modules/blog.module index d036679c0..c8126d2f8 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -26,20 +26,28 @@ function blog_summary($node) { return $node->body; } -function blog_feed_user($name = 0, $date = 0) { +function blog_feed_user($uid = 0, $date = 0) { global $user; - $name = check_input($name ? $name : $user->name); - $date = check_input($date ? $date : time()); + if ($uid) { + $account = user_load(array("uid" => $uid, "status" => 1)); + } + else { + $account = $user; + } + + if (!$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.name = '$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, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid WHERE u.uid = '$uid' 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); } $output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; $output .= "<rss version=\"0.91\">\n"; - $output .= format_rss_channel("$name's blog", path_uri() ."module.php?mod=blog&op=view&name=". urlencode($name), "$name's blog", $items); + $output .= format_rss_channel("$account->name's blog", path_uri() ."module.php?mod=blog&op=view&id=$account->uid", "$account->name's blog", $items); $output .= "</rss>\n"; header("Content-Type: text/xml"); @@ -49,9 +57,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.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"); + $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid 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->name), $blog->body); + $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&id=". urlencode($blog->uid), $blog->body); } $output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; @@ -65,13 +73,21 @@ function blog_feed_last() { } -function blog_page_user($name = 0, $date = 0) { +function blog_page_user($uid = 0, $date = 0) { global $theme, $user; - $name = check_input($name ? $name : $user->name); - $date = check_input($date ? $date : time()); + if ($uid) { + $account = user_load(array("uid" => $uid, "status" => 1)); + } + else { + $account = $user; + } - $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"); + if (!$date) { + $date = time(); + } + + $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid LEFT JOIN comments c ON n.nid = c.lid WHERE u.uid = '$account->uid' 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\">"; @@ -81,14 +97,14 @@ function blog_page_user($name = 0, $date = 0) { if ($date != date("dny", $blog->timestamp)) { $date = date("dny", $blog->timestamp); - $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&name=". urlencode($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>"; + $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&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->name == $name) { + if ($user->uid && $user->name == $name) { $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>"; } - if ($user->id && user_access("post blogs")) { + if ($user->uid && user_access("post blogs")) { $links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>"; } @@ -102,15 +118,15 @@ function blog_page_user($name = 0, $date = 0) { } $output .= "</table>"; - $output .= "<a href=\"module.php?mod=blog&op=feed&name=". urlencode($name) ."\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n"; + $output .= "<a href=\"module.php?mod=blog&op=feed&id=$account->uid\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n"; - $theme->box(strtr(t("%a's blog"), array("%a" => $name)), $output, "main"); + $theme->box(sprintf(t("%s's blog"), $account->name), $output, "main"); } 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.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"); + $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid 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,13 +134,13 @@ function blog_page_last() { $links = array(); - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($blog->name) ."\">". strtr(t("%a's blog"), array("%a" => $blog->name)) ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&id=$blog->uid\">". sprintf("%s's blog", $blog->name) ."</a>"; - if ($blog->author == $user->id) { + if ($blog->uid == $user->uid) { $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>"; } - if ($user->id && user_access("post blogs")) { + if ($user->uid && user_access("post blogs")) { $links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>"; } @@ -148,7 +164,7 @@ function blog_remove($nid) { $blog = node_get_object(array(nid => $nid, type => "blog")); - if ($blog && $blog->author == $user->id) { + if ($blog && $blog->uid == $user->uid) { node_save(array(nid => $nid), array(status => $status[dumped])); node_del(array(type => "blog", nid => $nid)); } @@ -163,7 +179,7 @@ function blog_view($node, $main = 0) { function blog_form($edit = array()) { global $REQUEST_URI, $id, $mod, $type, $user, $theme; - if ($user->id && (user_access("administer blogs") || user_access("post blogs"))) { + if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) { if ($mod == "node" || $edit[type] == "blog") { // do nothing } @@ -217,12 +233,12 @@ function blog_form($edit = array()) { function blog_save($edit) { global $status, $user; - if ($user->id && (user_access("administer blogs") || user_access("post blogs"))) { + if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) { if ($edit["nid"]) { node_save($edit, array(title, body, type => "blog")); } else { - node_save($edit, array(attributes => node_attributes_save("blog", $edit), author => $user->id, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0)); + node_save($edit, array(attributes => node_attributes_save("blog", $edit), author => $user->uid, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0)); } } } @@ -230,7 +246,7 @@ function blog_save($edit) { function blog_edit_history($nid) { global $user; - $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.author = '". check_input($user->id) ."' AND n.nid <= '". check_input($nid) ."' 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 WHERE n.author = '$user->uid' AND n.nid <= '". check_input($nid) ."' ORDER BY b.lid DESC LIMIT 15"); $output .= "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\" width=\"100%\">"; while ($blog = db_fetch_object($result)) { @@ -242,13 +258,13 @@ function blog_edit_history($nid) { } function blog_page() { - global $theme, $op, $name, $date; + global $theme, $id, $op, $date; if (user_access("access blogs")) { switch ($op) { case "feed": - if ($name) { - blog_feed_user($name, $date); + if ($id) { + blog_feed_user($id, $date); } else { blog_feed_last(); @@ -256,8 +272,8 @@ function blog_page() { break; default: $theme->header(); - if ($name) { - blog_page_user($name, $date); + if ($id) { + blog_page_user($id, $date); } else { blog_page_last(); @@ -280,7 +296,7 @@ function blog_user() { switch ($op) { case "delete": blog_remove($id); - blog_page_user($user->name, time()); + blog_page_user($user->uid, time()); break; case "edit": $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main"); @@ -291,7 +307,7 @@ function blog_user() { break; case t("Submit"): blog_save($edit); - blog_page_user($user->name, time()); + blog_page_user($user->uid, time()); break; default: $theme->box(t("Submit a blog"), blog_form($edit), "main"); @@ -309,11 +325,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->name) ."\">". t("view your blog") ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\">". t("view your blog") ."</a>"; } if ($type == "node" && $node->type == "blog") { - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&id=$node->uid\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>"; } return $links ? $links : array(); @@ -321,11 +337,12 @@ function blog_link($type, $node = 0) { function blog_block() { - global $name, $date, $user, $mod; + global $user; + + $result = db_query("SELECT u.uid, u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN user u ON n.author = u.uid 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->name) ."\">". check_output($node->title) ."</a><br />\n"; + $output .= "<a href=\"module.php?mod=blog&op=view&id=$node->nid\">". check_output($node->title) ."</a><br />\n"; } $block[0]["subject"] = "<a href=\"module.php?mod=blog\">". t("User blogs") ."</a>"; @@ -333,23 +350,13 @@ function blog_block() { $block[0]["info"] = t("User blogs"); $block[0]["link"] = "module.php?mod=blog"; - $date = $date ? $date : time(); - $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($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"); - } - return $block; } function blog_search($keys) { - global $status, $user; + global $status; + $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->name, "date" => $blog->timestamp); diff --git a/modules/blog/blog.module b/modules/blog/blog.module index d036679c0..c8126d2f8 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -26,20 +26,28 @@ function blog_summary($node) { return $node->body; } -function blog_feed_user($name = 0, $date = 0) { +function blog_feed_user($uid = 0, $date = 0) { global $user; - $name = check_input($name ? $name : $user->name); - $date = check_input($date ? $date : time()); + if ($uid) { + $account = user_load(array("uid" => $uid, "status" => 1)); + } + else { + $account = $user; + } + + if (!$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.name = '$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, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid WHERE u.uid = '$uid' 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); } $output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; $output .= "<rss version=\"0.91\">\n"; - $output .= format_rss_channel("$name's blog", path_uri() ."module.php?mod=blog&op=view&name=". urlencode($name), "$name's blog", $items); + $output .= format_rss_channel("$account->name's blog", path_uri() ."module.php?mod=blog&op=view&id=$account->uid", "$account->name's blog", $items); $output .= "</rss>\n"; header("Content-Type: text/xml"); @@ -49,9 +57,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.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"); + $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid 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->name), $blog->body); + $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&id=". urlencode($blog->uid), $blog->body); } $output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"; @@ -65,13 +73,21 @@ function blog_feed_last() { } -function blog_page_user($name = 0, $date = 0) { +function blog_page_user($uid = 0, $date = 0) { global $theme, $user; - $name = check_input($name ? $name : $user->name); - $date = check_input($date ? $date : time()); + if ($uid) { + $account = user_load(array("uid" => $uid, "status" => 1)); + } + else { + $account = $user; + } - $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"); + if (!$date) { + $date = time(); + } + + $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid LEFT JOIN comments c ON n.nid = c.lid WHERE u.uid = '$account->uid' 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\">"; @@ -81,14 +97,14 @@ function blog_page_user($name = 0, $date = 0) { if ($date != date("dny", $blog->timestamp)) { $date = date("dny", $blog->timestamp); - $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&name=". urlencode($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>"; + $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&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->name == $name) { + if ($user->uid && $user->name == $name) { $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>"; } - if ($user->id && user_access("post blogs")) { + if ($user->uid && user_access("post blogs")) { $links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>"; } @@ -102,15 +118,15 @@ function blog_page_user($name = 0, $date = 0) { } $output .= "</table>"; - $output .= "<a href=\"module.php?mod=blog&op=feed&name=". urlencode($name) ."\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n"; + $output .= "<a href=\"module.php?mod=blog&op=feed&id=$account->uid\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a>\n"; - $theme->box(strtr(t("%a's blog"), array("%a" => $name)), $output, "main"); + $theme->box(sprintf(t("%s's blog"), $account->name), $output, "main"); } 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.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"); + $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN user u ON n.author = u.uid 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,13 +134,13 @@ function blog_page_last() { $links = array(); - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($blog->name) ."\">". strtr(t("%a's blog"), array("%a" => $blog->name)) ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&id=$blog->uid\">". sprintf("%s's blog", $blog->name) ."</a>"; - if ($blog->author == $user->id) { + if ($blog->uid == $user->uid) { $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>"; } - if ($user->id && user_access("post blogs")) { + if ($user->uid && user_access("post blogs")) { $links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>"; } @@ -148,7 +164,7 @@ function blog_remove($nid) { $blog = node_get_object(array(nid => $nid, type => "blog")); - if ($blog && $blog->author == $user->id) { + if ($blog && $blog->uid == $user->uid) { node_save(array(nid => $nid), array(status => $status[dumped])); node_del(array(type => "blog", nid => $nid)); } @@ -163,7 +179,7 @@ function blog_view($node, $main = 0) { function blog_form($edit = array()) { global $REQUEST_URI, $id, $mod, $type, $user, $theme; - if ($user->id && (user_access("administer blogs") || user_access("post blogs"))) { + if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) { if ($mod == "node" || $edit[type] == "blog") { // do nothing } @@ -217,12 +233,12 @@ function blog_form($edit = array()) { function blog_save($edit) { global $status, $user; - if ($user->id && (user_access("administer blogs") || user_access("post blogs"))) { + if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) { if ($edit["nid"]) { node_save($edit, array(title, body, type => "blog")); } else { - node_save($edit, array(attributes => node_attributes_save("blog", $edit), author => $user->id, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0)); + node_save($edit, array(attributes => node_attributes_save("blog", $edit), author => $user->uid, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0)); } } } @@ -230,7 +246,7 @@ function blog_save($edit) { function blog_edit_history($nid) { global $user; - $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.author = '". check_input($user->id) ."' AND n.nid <= '". check_input($nid) ."' 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 WHERE n.author = '$user->uid' AND n.nid <= '". check_input($nid) ."' ORDER BY b.lid DESC LIMIT 15"); $output .= "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\" width=\"100%\">"; while ($blog = db_fetch_object($result)) { @@ -242,13 +258,13 @@ function blog_edit_history($nid) { } function blog_page() { - global $theme, $op, $name, $date; + global $theme, $id, $op, $date; if (user_access("access blogs")) { switch ($op) { case "feed": - if ($name) { - blog_feed_user($name, $date); + if ($id) { + blog_feed_user($id, $date); } else { blog_feed_last(); @@ -256,8 +272,8 @@ function blog_page() { break; default: $theme->header(); - if ($name) { - blog_page_user($name, $date); + if ($id) { + blog_page_user($id, $date); } else { blog_page_last(); @@ -280,7 +296,7 @@ function blog_user() { switch ($op) { case "delete": blog_remove($id); - blog_page_user($user->name, time()); + blog_page_user($user->uid, time()); break; case "edit": $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main"); @@ -291,7 +307,7 @@ function blog_user() { break; case t("Submit"): blog_save($edit); - blog_page_user($user->name, time()); + blog_page_user($user->uid, time()); break; default: $theme->box(t("Submit a blog"), blog_form($edit), "main"); @@ -309,11 +325,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->name) ."\">". t("view your blog") ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\">". t("view your blog") ."</a>"; } if ($type == "node" && $node->type == "blog") { - $links[] = "<a href=\"module.php?mod=blog&op=view&name=". urlencode($node->name) ."\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>"; + $links[] = "<a href=\"module.php?mod=blog&op=view&id=$node->uid\">". strtr(t("%a's blog"), array("%a" => $node->name)) ."</a>"; } return $links ? $links : array(); @@ -321,11 +337,12 @@ function blog_link($type, $node = 0) { function blog_block() { - global $name, $date, $user, $mod; + global $user; + + $result = db_query("SELECT u.uid, u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN user u ON n.author = u.uid 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->name) ."\">". check_output($node->title) ."</a><br />\n"; + $output .= "<a href=\"module.php?mod=blog&op=view&id=$node->nid\">". check_output($node->title) ."</a><br />\n"; } $block[0]["subject"] = "<a href=\"module.php?mod=blog\">". t("User blogs") ."</a>"; @@ -333,23 +350,13 @@ function blog_block() { $block[0]["info"] = t("User blogs"); $block[0]["link"] = "module.php?mod=blog"; - $date = $date ? $date : time(); - $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($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"); - } - return $block; } function blog_search($keys) { - global $status, $user; + global $status; + $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->name, "date" => $blog->timestamp); diff --git a/modules/book.module b/modules/book.module index 8b70a166a..f2cd01153 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_name($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) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n"; } if ($node->body) { @@ -83,7 +83,7 @@ function book_view($node, $main = 0) { function book_search($keys) { global $status; - $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"); + $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 user u ON n.author = u.uid 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->name, "date" => $node->timestamp); } @@ -128,7 +128,7 @@ function book_form($edit = array()) { $form .= book_view(new Book(node_preview($edit))); } - $form .= form_item(t("Author"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_item(t("Author"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous")))); $form .= form_hidden(name, $edit[name]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); @@ -168,7 +168,7 @@ function book_save($edit) { global $status, $user; if (!$edit[nid]) { - node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight)); + node_save($edit, array(author => $user->uid, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight)); } else if (user_access("administer nodes")) { node_save($edit, array(body, log, parent, title, type => "book", weight)); diff --git a/modules/book/book.module b/modules/book/book.module index 8b70a166a..f2cd01153 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_name($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) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n"; } if ($node->body) { @@ -83,7 +83,7 @@ function book_view($node, $main = 0) { function book_search($keys) { global $status; - $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"); + $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 user u ON n.author = u.uid 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->name, "date" => $node->timestamp); } @@ -128,7 +128,7 @@ function book_form($edit = array()) { $form .= book_view(new Book(node_preview($edit))); } - $form .= form_item(t("Author"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_item(t("Author"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous")))); $form .= form_hidden(name, $edit[name]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); @@ -168,7 +168,7 @@ function book_save($edit) { global $status, $user; if (!$edit[nid]) { - node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight)); + node_save($edit, array(author => $user->uid, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight)); } else if (user_access("administer nodes")) { node_save($edit, array(body, log, parent, title, type => "book", weight)); diff --git a/modules/box.module b/modules/box.module index 6618f6b60..8c0ba63a5 100644 --- a/modules/box.module +++ b/modules/box.module @@ -18,7 +18,7 @@ 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->id) { + if ($user->uid) { return "Welcome $user->name, ... welcome message goes here ..."; } else { @@ -44,7 +44,6 @@ function box_block() { $blocks[$i]["subject"] = check_output($block->title); $blocks[$i]["content"] = ($block->type == 2) ? eval($block->body) : $block->body; $blocks[$i]["info"] = check_output($block->info); - $blocks[$i]["link"] = check_output($block->link); $i++; } return $blocks; @@ -65,7 +64,6 @@ function box_display() { $output .= " <TR><TH>Body:</TH><TD>". nl2br(htmlentities($block->body)) ."</TD></TR>\n"; $output .= " <TR><TH>Type:</TH><TD>". $type[$block->type] ."</TD></TR>\n"; $output .= " <TR><TH>Description:</TH><TD>". check_output($block->info) ."</TD></TR>\n"; - $output .= " <TR><TH>Link:</TH><TD>". format_url($block->link) ."</TD></TR>\n"; $output .= " <TR><TH>Operations:</TH><TD><A HREF=\"admin.php?mod=box&op=edit&id=$block->bid\">edit</A></TD></TR>\n"; $output .= "</TABLE>\n"; $output .= "<BR><BR>\n"; @@ -76,13 +74,13 @@ function box_display() { function box_save($edit) { if ($edit[bid] && $edit[title]) { - db_query("UPDATE boxes SET title = '". check_input($edit[title]) ."', body = '". check_input($edit[body]) ."', info = '". check_input($edit[info]) ."', link = '". check_input($edit[link]) ."', type = '". check_input($edit[type]) ."' WHERE bid = '". check_input($edit[bid]) ."'"); + db_query("UPDATE boxes SET title = '". check_input($edit[title]) ."', body = '". check_input($edit[body]) ."', info = '". check_input($edit[info]) ."', type = '". check_input($edit[type]) ."' WHERE bid = '". check_input($edit[bid]) ."'"); } else if ($edit[bid]) { db_query("DELETE FROM boxes WHERE bid = '". check_input($edit[bid]) ."'"); } else { - db_query("INSERT INTO boxes (title, body, info, link, type) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[body]) ."', '". check_input($edit[info]) ."', '". check_input($link) ."', '". check_input($edit[type]) ."')"); + db_query("INSERT INTO boxes (title, body, info, type) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[body]) ."', '". check_input($edit[info]) ."', '". check_input($edit[type]) ."')"); } } @@ -95,7 +93,6 @@ function box_form($edit = array()) { $form .= form_textfield("Description", "info", $edit[info], 50, 64); $form .= form_textarea("Body", "body", $edit[body], 70, 10); $form .= form_select("Type", "type", $edit[type], $type); - $form .= form_textfield("Link", "link", $edit[link], 50, 64); if ($edit[bid]) { $form .= form_submit("Delete"); diff --git a/modules/comment.module b/modules/comment.module index 1ffb7a884..02bd25f43 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -1,8 +1,7 @@ <?php function comment_search($keys) { - global $user; - $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"); + $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid 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->name, "date" => $comment->timestamp); } @@ -24,10 +23,10 @@ function comment_link($type) { function comment_edit($id) { global $REQUEST_URI; - $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'"); + $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$id'"); $comment = db_fetch_object($result); - $form .= form_item(t("Author"), format_name($comment->name)); + $form .= form_item(t("Author"), format_name($comment)); $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 +40,12 @@ function comment_save($id, $edit) { } function comment_overview() { - $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"); + $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON u.uid = 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_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 .= " <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) ."</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 1ffb7a884..02bd25f43 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1,8 +1,7 @@ <?php function comment_search($keys) { - global $user; - $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"); + $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid 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->name, "date" => $comment->timestamp); } @@ -24,10 +23,10 @@ function comment_link($type) { function comment_edit($id) { global $REQUEST_URI; - $result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.cid = '$id'"); + $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$id'"); $comment = db_fetch_object($result); - $form .= form_item(t("Author"), format_name($comment->name)); + $form .= form_item(t("Author"), format_name($comment)); $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 +40,12 @@ function comment_save($id, $edit) { } function comment_overview() { - $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"); + $result = db_query("SELECT c.*, u.name, u.uid FROM comments c LEFT JOIN user u ON u.uid = 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_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 .= " <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) ."</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/forum.module b/modules/forum.module index ecf0f52bd..79ffc6ded 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -4,7 +4,6 @@ function forum_status() { return array(dumped, posted); } - function forum_link($type) { if ($type == "page" && user_access("access content")) { $links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>"; @@ -33,7 +32,7 @@ function forum_form($edit = array()) { function forum_save($edit) { global $user, $status; - node_save($edit, array(author => $user->id, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0)); + node_save($edit, array(author => $user->uid, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0)); } function forum_num_comments($nid) { diff --git a/modules/forum/forum.module b/modules/forum/forum.module index ecf0f52bd..79ffc6ded 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -4,7 +4,6 @@ function forum_status() { return array(dumped, posted); } - function forum_link($type) { if ($type == "page" && user_access("access content")) { $links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>"; @@ -33,7 +32,7 @@ function forum_form($edit = array()) { function forum_save($edit) { global $user, $status; - node_save($edit, array(author => $user->id, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0)); + node_save($edit, array(author => $user->uid, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0)); } function forum_num_comments($nid) { diff --git a/modules/help.module b/modules/help.module index 1b26fd7ad..9f6af47f0 100644 --- a/modules/help.module +++ b/modules/help.module @@ -11,7 +11,7 @@ function help_link($type) { function help_admin() { foreach (module_list() as $name) { if (module_hook($name, "help")) { - print "<H2>". ucfirst($name) ." module</H2>"; + print "<h2>". ucfirst($name) ." module</h2>"; print module_invoke($name, "help"); } } diff --git a/modules/help/help.module b/modules/help/help.module index 1b26fd7ad..9f6af47f0 100644 --- a/modules/help/help.module +++ b/modules/help/help.module @@ -11,7 +11,7 @@ function help_link($type) { function help_admin() { foreach (module_list() as $name) { if (module_hook($name, "help")) { - print "<H2>". ucfirst($name) ." module</H2>"; + print "<h2>". ucfirst($name) ." module</h2>"; print module_invoke($name, "help"); } } diff --git a/modules/import.module b/modules/import.module index 6bcc96825..98228f8ca 100644 --- a/modules/import.module +++ b/modules/import.module @@ -50,7 +50,7 @@ function import_update() { function import_format_item($item, $feed = 0) { global $theme, $user; - if ($user->id && user_access("post blogs")) { + if ($user->uid && user_access("post blogs")) { $output .= "<a href=\"submit.php?mod=blog&type=import&id=$item->iid\"><img src=\"". $theme->image("blog.gif") ."\" border=\"0\" width=\"12\" height=\"16\" alt=\"" . t("Blog this item") . "\" /></a> "; } @@ -602,7 +602,7 @@ function import_page_sources() { while ($feed = db_fetch_object($result)) { $output .= format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title); - $output .= "<p><div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div></p>"; + $output .= "<div style=\"margin-left: 20px;\">". check_output($feed->description, 1) ."</div><br />"; } $output .= "<a href=\"module.php?mod=import&op=fd\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" align=\"right\" border=\"0\" /></a><br />\n"; diff --git a/modules/node.module b/modules/node.module index b15516e43..c84c86d2f 100644 --- a/modules/node.module +++ b/modules/node.module @@ -108,7 +108,7 @@ function node_overview($query) { $color = array("#ffffff", "#e5e5e5"); $query = node_query($query ? $query : 0); - $result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50"); + $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN user u ON n.author = u.uid $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_name($node->name) ."</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) ."</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"; @@ -126,7 +126,6 @@ function node_overview($query) { } function node_edit_option($id) { - global $user; $node = node_get_object(array("nid" => $id)); @@ -141,7 +140,6 @@ function node_edit_option($id) { } function node_edit_attribute($id) { - global $user; $node = node_get_object(array("nid" => $id)); diff --git a/modules/node/node.module b/modules/node/node.module index b15516e43..c84c86d2f 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -108,7 +108,7 @@ function node_overview($query) { $color = array("#ffffff", "#e5e5e5"); $query = node_query($query ? $query : 0); - $result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50"); + $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN user u ON n.author = u.uid $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_name($node->name) ."</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) ."</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"; @@ -126,7 +126,6 @@ function node_overview($query) { } function node_edit_option($id) { - global $user; $node = node_get_object(array("nid" => $id)); @@ -141,7 +140,6 @@ function node_edit_option($id) { } function node_edit_attribute($id) { - global $user; $node = node_get_object(array("nid" => $id)); diff --git a/modules/page.module b/modules/page.module index 0929e2ec2..e931cbe7b 100644 --- a/modules/page.module +++ b/modules/page.module @@ -73,7 +73,7 @@ function page_form($edit = array()) { function page_save($edit) { global $status, $user; - node_save($edit, array(author => $user->id, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0)); + node_save($edit, array(author => $user->uid, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0)); } ?>
\ No newline at end of file diff --git a/modules/page/page.module b/modules/page/page.module index 0929e2ec2..e931cbe7b 100644 --- a/modules/page/page.module +++ b/modules/page/page.module @@ -73,7 +73,7 @@ function page_form($edit = array()) { function page_save($edit) { global $status, $user; - node_save($edit, array(author => $user->id, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0)); + node_save($edit, array(author => $user->uid, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0)); } ?>
\ No newline at end of file diff --git a/modules/poll.module b/modules/poll.module index 24477f341..28cebb4ae 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -186,7 +186,7 @@ function poll_form($edit = array(), $nocheck = 0) { $form .= form_submit(t("Preview")) . "<br><br><br>"; /* Main form */ - $form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous")))); $form .= form_hidden("name", $edit[name]); $form .= form_textfield(t("Question"), "title", $edit[title], 50, 127); diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 24477f341..28cebb4ae 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -186,7 +186,7 @@ function poll_form($edit = array(), $nocheck = 0) { $form .= form_submit(t("Preview")) . "<br><br><br>"; /* Main form */ - $form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous")))); $form .= form_hidden("name", $edit[name]); $form .= form_textfield(t("Question"), "title", $edit[title], 50, 127); diff --git a/modules/queue.module b/modules/queue.module index dea9a50d6..3da3fcb2d 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->id)) { + if (!field_get($node->users, $user->uid)) { // Update submission's score- and votes-field: - db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->id, $vote) ."' WHERE nid = $id"); + db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $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.name, 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.uid FROM node n LEFT JOIN user u ON n.author = u.uid 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->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"; + if ($user->uid == $node->author || field_get($node->users, $user->uid)) $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) ."</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) ."</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->id)) { + if ($user->uid == $node->author || field_get($node->users, $user->uid)) { header("Location: node.php?id=$node->nid"); } else { @@ -118,7 +118,7 @@ function queue_node($id) { function queue_page() { global $user, $id, $op, $theme, $vote; - if ($user->id && user_access("access submission queue")) { + if ($user->uid && user_access("access submission queue")) { switch($op) { case "Vote"; queue_vote(check_input($id), check_input($vote)); diff --git a/modules/rating.module b/modules/rating.module index 6f791dba3..44b02d08a 100644 --- a/modules/rating.module +++ b/modules/rating.module @@ -29,17 +29,17 @@ function rating_cron() { if (time() - variable_get("rating_cron_last", 0) > variable_get("rating_cron_time", time())) { variable_set("rating_cron_last", time()); - $r1 = db_query("SELECT id FROM users ORDER BY rating DESC"); + $r1 = db_query("SELECT uid FROM user ORDER BY rating DESC"); while ($account = db_fetch_object($r1)) { - db_query("UPDATE users SET rating = '". rating_gravity($account->id) ."' WHERE id = '$account->id'"); - $rating[$account->id] = ++$i; + db_query("UPDATE user SET rating = '". rating_gravity($account->uid) ."' WHERE id = '$account->uid'"); + $rating[$account->uid] = ++$i; } db_query("DELETE FROM rating"); - $r2 = db_query("SELECT id FROM users ORDER BY rating DESC"); + $r2 = db_query("SELECT uid FROM user ORDER BY rating DESC"); while ($account = db_fetch_object($r2)) { - db_query("INSERT INTO rating (user, new, old) VALUES ('$account->id', '". ++$j ."', '". $rating[$account->id] ."')"); + db_query("INSERT INTO rating (user, new, old) VALUES ('$account->uid', '". ++$j ."', '". $rating[$account->uid] ."')"); } } } @@ -79,12 +79,12 @@ function rating_gravity($id) { } function rating_list($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"); + $result = db_query("SELECT u.rating, u.name, u.uid, r.* FROM user u LEFT JOIN rating r ON u.uid = 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_name($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) ."</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 a6bae74d2..1f76aab78 100644 --- a/modules/story.module +++ b/modules/story.module @@ -13,7 +13,7 @@ function story_status() { } function story_search($keys) { - global $status, $user; + global $status; $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->name, "date" => $story->timestamp); @@ -46,7 +46,7 @@ function story_form($edit = array()) { story_view(new Story(node_preview($edit))); } - $form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous")))); $form .= form_hidden("name", $edit[name]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); $form .= node_attributes_edit("story", $edit); @@ -80,7 +80,7 @@ function story_save($edit) { global $status, $user; if (!$edit[nid]) { - node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->id, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0)); + node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->uid, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0)); } else if (user_access("administer nodes")) { node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story")); @@ -88,7 +88,7 @@ function story_save($edit) { } function story_user() { - global $edit, $op, $theme, $user; + global $edit, $op, $theme; switch($op) { case t("Preview"): diff --git a/modules/story/story.module b/modules/story/story.module index a6bae74d2..1f76aab78 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -13,7 +13,7 @@ function story_status() { } function story_search($keys) { - global $status, $user; + global $status; $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->name, "date" => $story->timestamp); @@ -46,7 +46,7 @@ function story_form($edit = array()) { story_view(new Story(node_preview($edit))); } - $form .= form_item(t("Your name"), format_name(($edit[name] ? $edit[name] : $user->name))); + $form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous")))); $form .= form_hidden("name", $edit[name]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); $form .= node_attributes_edit("story", $edit); @@ -80,7 +80,7 @@ function story_save($edit) { global $status, $user; if (!$edit[nid]) { - node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->id, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0)); + node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->uid, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0)); } else if (user_access("administer nodes")) { node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story")); @@ -88,7 +88,7 @@ function story_save($edit) { } function story_user() { - global $edit, $op, $theme, $user; + global $edit, $op, $theme; switch($op) { case t("Preview"): diff --git a/modules/user.module b/modules/user.module index 0fb4a8aaa..048556be6 100644 --- a/modules/user.module +++ b/modules/user.module @@ -864,7 +864,7 @@ function user_admin_create($edit = array()) { function user_admin_access($edit = array()) { global $op, $id, $type, $REQUEST_URI; - $output .= "<small><a href=\"admin.php?mod=user&op=access&type=mail\">e-mail rules</a>, <a href=\"admin.php?mod=user&op=access&type=user\">username rules</a></small><hr />"; + $output .= "<small><a href=\"admin.php?mod=user&op=access&type=mail\">e-mail rules</a> :: <a href=\"admin.php?mod=user&op=access&type=user\">username rules</a></small><hr />"; if ($type != "user") { $output .= "<h3>E-mail rules</h3>"; diff --git a/modules/user/user.module b/modules/user/user.module index 0fb4a8aaa..048556be6 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -864,7 +864,7 @@ function user_admin_create($edit = array()) { function user_admin_access($edit = array()) { global $op, $id, $type, $REQUEST_URI; - $output .= "<small><a href=\"admin.php?mod=user&op=access&type=mail\">e-mail rules</a>, <a href=\"admin.php?mod=user&op=access&type=user\">username rules</a></small><hr />"; + $output .= "<small><a href=\"admin.php?mod=user&op=access&type=mail\">e-mail rules</a> :: <a href=\"admin.php?mod=user&op=access&type=user\">username rules</a></small><hr />"; if ($type != "user") { $output .= "<h3>E-mail rules</h3>"; diff --git a/modules/watchdog.module b/modules/watchdog.module index b3b6cbc50..974914dba 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -30,16 +30,16 @@ function watchdog_cron() { } 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'"); + $color = array(user => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C"); + $query = array(user => "WHERE type = 'user'", 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.name 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, u.uid FROM watchdog w LEFT JOIN user u ON w.user = u.uid ". ($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_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 .= " <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) ."</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.name FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'"); + $result = db_query("SELECT l.*, u.name, u.uid FROM watchdog l LEFT JOIN user u ON l.user = u.uid 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_name($watchdog->name) ."</TD></TR>\n"; + $output .= " <TR><TH>User:</TH><TD>". format_name($watchdog) ."</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"; @@ -69,7 +69,7 @@ function watchdog_admin() { if (user_access("administer watchdog")) { - print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=account\">account messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n"; + print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=user\">user messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n"; switch ($op) { case "help": diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index b3b6cbc50..974914dba 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -30,16 +30,16 @@ function watchdog_cron() { } 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'"); + $color = array(user => "#FFEEAA", message => "#FFFFFF", special => "#A49FFF", warning => "#FFAA22", httpd => "#99DD99", error => "#EE4C4C"); + $query = array(user => "WHERE type = 'user'", 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.name 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, u.uid FROM watchdog w LEFT JOIN user u ON w.user = u.uid ". ($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_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 .= " <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) ."</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.name FROM watchdog l LEFT JOIN users u ON l.user = u.id WHERE l.id = '$id'"); + $result = db_query("SELECT l.*, u.name, u.uid FROM watchdog l LEFT JOIN user u ON l.user = u.uid 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_name($watchdog->name) ."</TD></TR>\n"; + $output .= " <TR><TH>User:</TH><TD>". format_name($watchdog) ."</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"; @@ -69,7 +69,7 @@ function watchdog_admin() { if (user_access("administer watchdog")) { - print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=account\">account messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n"; + print "<SMALL><A HREF=\"admin.php?mod=watchdog&type=user\">user messages</A> | <A HREF=\"admin.php?mod=watchdog&type=regular\">regular messages</A> | <A HREF=\"admin.php?mod=watchdog&type=special\">special messages</A> | <A HREF=\"admin.php?mod=watchdog&type=warning\">warning messages</A> | <A HREF=\"admin.php?mod=watchdog&type=error\">error messages</A> | <A HREF=\"admin.php?mod=watchdog&type=httpd\">httpd messages</A> | <A HREF=\"admin.php?mod=watchdog\">overview</A> | <A HREF=\"admin.php?mod=watchdog&op=help\">help</A></SMALL><HR>\n"; switch ($op) { case "help": |