diff options
Diffstat (limited to 'modules/user/user.module')
-rw-r--r-- | modules/user/user.module | 183 |
1 files changed, 43 insertions, 140 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index d56e4f514..95f348179 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -393,7 +393,34 @@ function user_link($type) { } if ($type == "admin" && user_access("administer users")) { - $links[] = la(t("user management"), array("mod" => "user")); + $help["user"] = "Drupal allows users to register, login, logout, maintain user profiles, etc. No participant can use his own name to post content until he signs up for a user account. There is several configuration pages that help administrators manage user accounts."; + $help["create"] = "If your site is completely private, and doesn't allow public registration, then you can add new users manually. This web page allows administrator to register a new users."; + $help["view"] = "This page allows you to review and edit any user's profile."; + $help["access"] = "Access rules enable administrators to filter out usernames and e-mail addresses which are not allowed in Drupal. An administrator creates a 'mask' against which each new registration is checked. Disallowed names and e-mail addresses are denied access to the site."; + $help["permission"] = "Each user role has certain things that its users are allowed to do, and some that are disallowed. For example, authenticated users may usually post a story but anonymous users may not. Each permission describes a fine-grained logical operation such as access administration pages or add and modify user accounts. You could say a permission represents access granted to a user to perform a set of operations."; + $help["role"] = "Roles allow you to fine tune the security and administration of drupal. A role defines a group of users which have certain privileges. Examples of roles include: anonymous user, authenticated user, moderator, administrator and so on. By default, Drupal comes with two user roles: <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 registered users will belong to this user role unless specified otherwise.</li></ul>"; + $help["search"] = "On this page you can query any username. For example, one may search for 'br' and Drupal might return 'brian', 'brad', and 'brenda'."; + $help["setting"] = "Administrators may choose to restrict registration to their site. That restriction may be accomplished on this page. Also, the list of words which may be included in a system generated password is also listed on this page. Drupal generates passwords by joining small words from the password list until the new password is greater than 6 characters."; + + menu_add("user management", "admin.php?mod=user", "User management", $help["user"]); + menu_add("create new account", "admin.php?mod=user&op=create", "Create a new user account.", $help["create"], "user management", 1); + menu_add("view user accounts", "admin.php?mod=user&op=account", "Display user account listings.", $help["view"], "user management", 2, 1); + menu_add("access rules", "admin.php?mod=user&op=access", "Configure access rules.", $help["access"], "user management", 3); + menu_add("e-mail rules", "admin.php?mod=user&op=access&type=mail", "Allow or deny certain e-mail addresses.", $help["access"], "access rules"); + menu_add("username rules", "admin.php?mod=user&op=access&type=user", "Allow or deny certain usernames.", $help["access"], "access rules"); + menu_add("user roles", "admin.php?mod=user&op=role", "Configure user roles.", $help["role"], "user management", 4); + menu_add("user permissions", "admin.php?mod=user&op=permission", "Configure user permissions.", $help["permission"], "user management", 5); + menu_add("search account", "admin.php?mod=user&op=search", "Search a user account.", $help["search"], "user management", 5); + menu_add("help", "admin.php?mod=user&op=help", "More information about user management.", NULL, "user management", 7); + + menu_add("active users", "admin.php?mod=user&op=account&query=0", t("Active users."), $help["view"], "view user accounts", 1); + menu_add("new users", "admin.php?mod=user&op=account&query=1", t("New users."), $help["view"], "view user accounts", 2); + menu_add("blocked users", "admin.php?mod=user&op=account&query=2", t("Blocked users."), $help["view"], "view user accounts", 3); + + $i = 3; + foreach (user_roles(1) as $key => $value) { + menu_add("users with role '$value'", "admin.php?mod=user&op=account&query=". $i++, NULL, $help["view"], "view user accounts", 4); + } } return $links ? $links : array(); @@ -810,7 +837,7 @@ function user_register($edit = array()) { $affiliates = implode(", ", $affiliates); $output .= "<p>" . t("Note: If you have an account with one of our affiliates (%s), you may ". lm("login now", array("mod" => "user", "op" => "login")) ." instead of registering.", array("%s" => $affiliates)) ."</p>"; } - $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); + $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Your full name or your preferred username: only letters, numbers and spaces are allowed.")); $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64, t("A password and instructions will be sent to this e-mail address, so make sure it is accurate.")); foreach (module_list() as $module) { if (module_hook($module, "user")) { @@ -924,7 +951,7 @@ function user_edit($edit = array()) { $edit = object2array($user); } - $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 55, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); + $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed.")); $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.")); foreach (module_list() as $module) { @@ -940,7 +967,7 @@ function user_edit($edit = array()) { $output .= form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site.")); for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")"; - $output .= form_select(t("Timezone"), "timezone", $edit["timezone"], $zones, t("Select what time you currently have and your timezone settings will be set appropriate.")); + $output .= form_select(t("Time zone"), "timezone", $edit["timezone"], $zones, t("Select what time you currently have and your time zone settings will be set appropriate.")); $output .= form_select(t("Language"), "language", $edit["language"], $languages, t("Selecting a different language will change the language of the site.")); $output .= form_item(t("Password"), "<input type=\"password\" name=\"edit[pass1]\" size=\"12\" maxlength=\"24\" /> <input type=\"password\" name=\"edit[pass2]\" size=\"12\" maxlength=\"24\" />", t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password.")); $output .= form_submit(t("Save user information")); @@ -1086,33 +1113,6 @@ function user_conf_options() { return $output; } -function user_admin_settings($edit = array()) { - global $op; - - if ($op == t("Save configuration")) { - /* - ** Save the configuration options: - */ - - foreach ($edit as $name => $value) variable_set($name, $value); - } - - if ($op == t("Reset to defaults")) { - /* - ** Reset the configuration options to their default value: - */ - - foreach ($edit as $name=>$value) variable_del($name); - } - - $output .= user_conf_options(); - $output .= form_submit(t("Save configuration")); - $output .= form_submit(t("Reset to defaults")); - - return form($output); - -} - function user_admin_create($edit = array()) { if ($edit["name"] || $edit["mail"]) { @@ -1159,13 +1159,15 @@ function user_admin_create($edit = array()) { function user_admin_access($edit = array()) { global $op, $id, $type; - $output .= "<small>". la(t("e-mail rules"), array("mod" => "user", "op" => "access", "type" => "mail")) ." :: ". la(t("username rules"), array("mod" => "user", "op" => "access", "type" => "user")) ."</small><hr />"; // irc rules, too! + if (empty($type)) { + return; + } - if ($type != "user") { + if ($type == "mail") { $output .= "<h3>" . t("E-mail rules") . "</h3>"; - $type = "mail"; } - else { + + if ($type == "user") { $output .= "<h3>" . t("Username rules") . "</h3>"; } @@ -1418,7 +1420,7 @@ function user_admin_edit($edit = array()) { */ $output .= form_item(t("User ID"), check_output($account->uid)); - $output .= form_textfield(t("Username"), "name", $account->name, 30, 55, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); + $output .= form_textfield(t("Username"), "name", $account->name, 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed.")); $output .= form_textfield(t("E-mail address"), "mail", $account->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.")); foreach (module_list() as $module) { @@ -1433,7 +1435,7 @@ function user_admin_edit($edit = array()) { } $output .= form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site.")); for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")"; - $output .= form_select(t("Timezone"), "timezone", $account->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate.")); + $output .= form_select(t("Time zone"), "timezone", $account->timezone, $zones, t("Select what time you currently have and your time zone settings will be set appropriate.")); $output .= form_select(t("Language"), "language", $account->language, $languages, t("Selecting a different language will change the language of the site.")); $output .= form_item(t("Password"), "<input type=\"password\" name=\"edit[pass1]\" size=\"12\" maxlength=\"24\" /> <input type=\"password\" name=\"edit[pass2]\" size=\"12\" maxlength=\"24\" />", t("Enter a new password twice if you want to change the current password for this user or leave it blank if you are happy with the current password.")); $output .= form_select(t("Status"), "status", $account->status, array(t("Blocked"), t("Active"))); @@ -1455,18 +1457,12 @@ function user_admin_edit($edit = array()) { function user_admin_account() { global $query; - $queries = array(array("ORDER BY timestamp DESC", t("active users")), array("ORDER BY u.uid DESC", t("new users")), array("WHERE status = 0 ORDER BY u.uid DESC", t("blocked users"))); + $queries = array("ORDER BY timestamp DESC", "ORDER BY u.uid DESC", "WHERE status = 0 ORDER BY u.uid DESC"); foreach (user_roles(1) as $key => $value) { - $queries[] = array("WHERE r.name = '$value' ORDER BY u.uid DESC", $value . "s"); + $queries[] = "WHERE r.name = '$value' ORDER BY u.uid DESC"; } - $result = db_query("SELECT u.uid, u.name, u.timestamp FROM users u LEFT JOIN role r ON u.rid = r.rid ". $queries[$query ? $query : 0][0] ." LIMIT 50"); - - foreach ($queries as $key => $value) { - $links[] = la($value[1], array("mod" => "user", "op" => "account", "query" => $key)); - } - - $output .= "<small>". implode(" :: ", $links) ."</small><hr />"; + $result = db_query("SELECT u.uid, u.name, u.timestamp FROM users u LEFT JOIN role r ON u.rid = r.rid ". $queries[$query ? $query : 0] ." LIMIT 50"); $output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">"; $output .= " <tr><th>" . t("username") . "</th><th>" . t("last access") . "</th><th>" . t("operations") . "</th></tr>"; @@ -1501,21 +1497,6 @@ function user_admin() { user_role_init(); - /* - ** Compile a list of the administrative links: - */ - - $links[] = la(t("add new user"), array("mod" => "user", "op" => "create")); - $links[] = la(t("access rules"), array("mod" => "user", "op" => "access")); - $links[] = la(t("user accounts"), array("mod" => "user", "op" => "account")); - $links[] = la(t("user roles"), array("mod" => "user", "op" => "role")); - $links[] = la(t("user permissions"), array("mod" => "user", "op" => "permission")); - $links[] = la(t("search account"), array("mod" => "user", "op" => "search")); - $links[] = la(t("settings"), array("mod" => "user", "op" => "settings")); - $links[] = la(t("help"), array("mod" => "user", "op" => "help")); - - print "<small>". implode(" | ", $links) ."</small><hr />"; - switch ($op) { case "help": print user_help(); @@ -1523,11 +1504,6 @@ function user_admin() { case "search": print search_type("user", drupal_url(array("mod" => "user", "op" => "search"), "admin")); break; - case t("Save configuration"): - case t("Reset to defaults"): - case "settings": - print user_admin_settings($edit); - break; case t("Add rule"): case t("Check"): case "access": @@ -1642,83 +1618,10 @@ function user_help_admin() { utilizing their own preferences for how the pages are structured, how navigation lists and other page components are presented and much more. <br /> </p> -<h3>User administration</h3> -<p>Administrators manage user accounts by clicking on the <i>User management</i> link in - their Admin interface. There, you will find several configuration pages and - reports which help you manage your users. The following pages are available:</p> - -<h4>Add new user</h4> -<p>If your site is completely private, and doesn't allow registration for - any old web user (see <a href="#settings">settings</a> for this feature), then - you'll need to add new users manually. This web page allows any administrator - to register a new user.</p> -<h4>Access rules<a name="access"></a></h4> -<p>Access rules enable administrators to filter out usernames and e-mail addresses - which are not allowed in Drupal. An administrator creates a 'mask' against which - each new registration is checked. Disallowed names and e-mail addresses are denied - access to the site. Another handy use for this page is to disallow registration - to your site from an untrusted external authentication server. Just add their - server address to the username mask section and you've effectively blocked all - logins from that server.</p> -<p>To do describe access rules you can use the following wild-card characters:</p> - <ul> - <li> % : matches any number of characters, including zero characters.</li> - <li> _ : matches exactly one character.</li> - </ul> -<p><u>Examples:</u></p> - <ul> - <li>E-mail address bans <code>%@hotmail.com</code>, <code>%@altavista.%</code>, <code>%@usa.net</code>, etc. Used to prevent users from using free e-mail accounts, which might be used to cause trouble.</li> - <li>Username bans <code>root</code>, <code>webmaster</code>, <code>admin%</code>, etc. Used to prevent administrator impersonators.</li> - </ul> -<p>If no access rules are provided, access control is turned off and everybody will be able to access your website. The 'allow' rules are processed prior to the 'deny' rules and are thus considered to be stronger.</p> -<h4>User accounts</h4> -<p>This page is quite powerful. It allows an administrator to review any user's - profile. In addition, administrators may block any user, or assign him a <a href="#roles">role</a>, - using this page.</p> -<h4>User roles<a name="roles"></a></h4> -<p>Roles allow you to fine tune the security and administration of drupal. A role -defines a group of users which have certain privileges. Examples of roles -include: <I>anonymous user</I>, <I>authenticated user</I>, <I>moderator</I>, -<I>administrator</I> and so on. By default, Drupal comes with two commonly used -roles: -<ul> - <li>Anonymous user: this role is used for users that don't have a user account - or that are not authenticated. - <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> -<p>These common roles will suffice for most sites. However, for a more complex site where you need to give several users different access privileges, you will - need to add a new role by clicking the "add new role" link. Then define what privileges that role will have by clicking the "permission overview" link and checking the appropriate boxes to give that role the permissions you desire. - <p>To attach a specific user to a role, use the "account" section of the drupal Administration. </p> - <p>Note: If you intend for a user to access certain sections of the administration - pages, they must have "access administration page" privileges. </p> -<h4>User permissions<a name="permissions"></a></h4> -<p>Each role has certain things that its users are allowed to do, and some that - are disallowed. For example, authenticated users may usually post a story but - Anonymous users may not. </p> -<p>Each 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> -<h4>Search account</h4> -<p>Search Account enables an admin to query for any username in the user table - and return users which match that query. For example, one may search for 'br' - and Drupal might return 'brian', 'brad', and 'brenda'.</p> -<h4>Settings<a name="settings"></a></h4> -<p>Administrators may choose to restrict registration to their site. That restriction - may be accomplished on this page. Also, the list of words which may be included - in a system generated password is also listed on this page. Drupal generates - passwords by joining small words from the password list until the new password - is greater than 6 characters.</p> -<h4>Active users - report</h4> -<p>All users sorted by most recent login.</p> -<h4>New users - report</h4> -<p>All users sorted by most recent registration</p> -<h4>Blocked users - report</h4> -<p>All users who have been blocked (status = 0) sorted by most recent registration</p> -<h4>Authenticated users, administrators, etc. - reports</h4> -<p>All <a href="#roles">roles</a> present a report listing their members</p> <h3>User preferences and profiles</h3> <p>Drupal comes with a set of user preferences and profile which a user may edit by clicking on the user account link. Of course, a user must be logged into reach those pages. - There, users will find a page for changing their preferred timezone, language, username, e-mail address, password, theme, signature, homepage, and <a href="#da">distributed authentication</a> names. + There, users will find a page for changing their preferred time zone, language, username, e-mail address, password, theme, signature, homepage, and <a href="#da">distributed authentication</a> names. Changes made here take effect immediately. Also, administrators may make profile and preferences changes in the Admin Center on behalf of their users.</p> <p>Module developers are provided several hooks for adding custom fields to the user view/edit pages. These hooks are described in the Developer section of the <a href="http://www.drupal.org">Drupal Handbook</a>. For an example, see the <code>jabber_user()</code> function in <i>/modules/jabber.module</i>. </p> |