From e688dfe6dbb5338a6cfe13775aacba70534e9a36 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Mon, 13 Oct 2003 19:18:39 +0000
Subject: [PATCH] - Fixed prefix problem with the book module.  Patch by Moshe.

- Usability improvements to the user module: removed some redundant menu
  items by taking advantage of the column sorting, added status messages
  and so on.  Patch by Moshe plus some fixes.

- Made the profile module use the table() function.  Patch by Moshe.

- Fixed breadcrumb spacing.  Patch by Moshe.

- Fixed colspan problem with node overview table.  Patch by Stefan.

- Fixed inconsistency with table sorting.  Patch 0122 by Al.
---
 includes/tablesort.inc         |  3 ++
 misc/drupal.css                |  3 ++
 modules/book.module            |  2 +-
 modules/book/book.module       |  2 +-
 modules/node.module            |  2 +-
 modules/node/node.module       |  2 +-
 modules/profile.module         | 18 +++----
 modules/profile/profile.module | 18 +++----
 modules/user.module            | 94 +++++++++++-----------------------
 modules/user/user.module       | 94 +++++++++++-----------------------
 10 files changed, 86 insertions(+), 152 deletions(-)

diff --git a/includes/tablesort.inc b/includes/tablesort.inc
index 2e16d8a8d329..44a0db9489d8 100644
--- a/includes/tablesort.inc
+++ b/includes/tablesort.inc
@@ -35,6 +35,9 @@ function tablesort($cell, $header) {
     $image = "&nbsp;<img border=\"0\" src=\"". theme("image", "arrow-". $ts["sort"]. ".gif"). "\"></img>";
     $dir = array("asc" => "ascending", "desc" => "descending");
     $title = t("sort ". $dir[$ts["sort"]]);
+  } else {
+    // If the user clicks a different header, we want to sort ascending initially.
+    $ts["sort"] = "asc";
   }
 
   $cell["data"] = l($cell["data"] . $image, $_GET["q"], array("title" => $title), "sort=". $ts["sort"]. "&order=". urlencode($cell["data"]). $ts["query_string"]);
diff --git a/misc/drupal.css b/misc/drupal.css
index 8a76bbb540b7..c9063222680d 100644
--- a/misc/drupal.css
+++ b/misc/drupal.css
@@ -33,6 +33,9 @@ th {
 #pager div {
   padding: 0.5em;
 }
+.breadcrumb {
+  padding-bottom: .5em
+}
 .book {
   margin-bottom: 2em;
 }
diff --git a/modules/book.module b/modules/book.module
index cdf123098ee3..ce5de3faf685 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -650,7 +650,7 @@ function book_page() {
 
 function book_print($id = "", $depth = 1) {
   global $base_url;
-  $result = db_query("SELECT n.nid FROM {node} n INNER JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id);
+  $result = db_query("SELECT n.nid FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id);
 
   while ($page = db_fetch_object($result)) {
     // load the node:
diff --git a/modules/book/book.module b/modules/book/book.module
index cdf123098ee3..ce5de3faf685 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -650,7 +650,7 @@ function book_page() {
 
 function book_print($id = "", $depth = 1) {
   global $base_url;
-  $result = db_query("SELECT n.nid FROM {node} n INNER JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id);
+  $result = db_query("SELECT n.nid FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id);
 
   while ($page = db_fetch_object($result)) {
     // load the node:
diff --git a/modules/node.module b/modules/node.module
index 45ff4dbb727a..89a5a33d2cbd 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -689,7 +689,7 @@ function node_admin_nodes() {
   }
 
   if ($pager = pager_display(NULL, 50, 0, "admin")) {
-    $rows[] = array(array("data" => $pager, "colspan" => 6));
+    $rows[] = array(array("data" => $pager, "colspan" => 7));
   }
 
   $output .= "<h3>". $filters[$filter][0] ."</h3>";
diff --git a/modules/node/node.module b/modules/node/node.module
index 45ff4dbb727a..89a5a33d2cbd 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -689,7 +689,7 @@ function node_admin_nodes() {
   }
 
   if ($pager = pager_display(NULL, 50, 0, "admin")) {
-    $rows[] = array(array("data" => $pager, "colspan" => 6));
+    $rows[] = array(array("data" => $pager, "colspan" => 7));
   }
 
   $output .= "<h3>". $filters[$filter][0] ."</h3>";
diff --git a/modules/profile.module b/modules/profile.module
index 8a59cfe0b271..74de3729a0ff 100644
--- a/modules/profile.module
+++ b/modules/profile.module
@@ -62,17 +62,17 @@ function profile_settings() {
   $profile_required_fields = variable_get("profile_required_fields", array());
   $profile_register_fields = variable_get("profile_register_fields", array());
 
-  $output = "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
-  $output .= "<tr><th>field</th><th>enable</th><th>public</th><th>required</th><th>show in registration form</th></tr>\n";
+  $header = array (t("field"), t("enable"), t("public"), t("required"), t("show in registration form"));
+  $i=0;
   foreach ($profile_fields as $key => $field) {
-    $output .= "<tr><td>$field[1]</td>";
-    $output .= "<td style=\"text-align: center;\">". form_checkbox("", "profile_private_fields][", $key, in_array($key, $profile_private_fields)) ."</td>";
-    $output .= "<td style=\"text-align: center;\">". form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields)) ."</td>";
-    $output .= "<td style=\"text-align: center;\">". form_checkbox("", "profile_required_fields][", $key, in_array($key, $profile_required_fields)) ."</td>";
-    $output .= "<td style=\"text-align: center;\">". form_checkbox("", "profile_register_fields][", $key, in_array($key, $profile_register_fields)) ."</td>";
-    $output .= "</tr>\n";
+    $row[$i][] = $field[1];
+    $row[$i][] = form_checkbox("", "profile_private_fields][", $key, in_array($key, $profile_private_fields));
+    $row[$i][] = form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields));
+    $row[$i][] = form_checkbox("", "profile_required_fields][", $key, in_array($key, $profile_required_fields));
+    $row[$i][] = form_checkbox("", "profile_register_fields][", $key, in_array($key, $profile_register_fields));
+    $i++;
   }
-  $output .= "</table>\n";
+  $output .= table($header, $row);
 
   $output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "misc/avatars/"), 30, 255, t("Path for avatar directory; it must be writable and visible from the web."));
   $output .= form_textfield(t("Avatar maximum dimensions"), "profile_avatar_dimensions", variable_get("profile_avatar_dimensions", "85x85"), 10, 10, t("Maximum dimensions for avatars."));
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 8a59cfe0b271..74de3729a0ff 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -62,17 +62,17 @@ function profile_settings() {
   $profile_required_fields = variable_get("profile_required_fields", array());
   $profile_register_fields = variable_get("profile_register_fields", array());
 
-  $output = "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
-  $output .= "<tr><th>field</th><th>enable</th><th>public</th><th>required</th><th>show in registration form</th></tr>\n";
+  $header = array (t("field"), t("enable"), t("public"), t("required"), t("show in registration form"));
+  $i=0;
   foreach ($profile_fields as $key => $field) {
-    $output .= "<tr><td>$field[1]</td>";
-    $output .= "<td style=\"text-align: center;\">". form_checkbox("", "profile_private_fields][", $key, in_array($key, $profile_private_fields)) ."</td>";
-    $output .= "<td style=\"text-align: center;\">". form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields)) ."</td>";
-    $output .= "<td style=\"text-align: center;\">". form_checkbox("", "profile_required_fields][", $key, in_array($key, $profile_required_fields)) ."</td>";
-    $output .= "<td style=\"text-align: center;\">". form_checkbox("", "profile_register_fields][", $key, in_array($key, $profile_register_fields)) ."</td>";
-    $output .= "</tr>\n";
+    $row[$i][] = $field[1];
+    $row[$i][] = form_checkbox("", "profile_private_fields][", $key, in_array($key, $profile_private_fields));
+    $row[$i][] = form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields));
+    $row[$i][] = form_checkbox("", "profile_required_fields][", $key, in_array($key, $profile_required_fields));
+    $row[$i][] = form_checkbox("", "profile_register_fields][", $key, in_array($key, $profile_register_fields));
+    $i++;
   }
-  $output .= "</table>\n";
+  $output .= table($header, $row);
 
   $output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "misc/avatars/"), 30, 255, t("Path for avatar directory; it must be writable and visible from the web."));
   $output .= form_textfield(t("Avatar maximum dimensions"), "profile_avatar_dimensions", variable_get("profile_avatar_dimensions", "85x85"), 10, 10, t("Maximum dimensions for avatars."));
diff --git a/modules/user.module b/modules/user.module
index 000524eb478f..6537ea99c46e 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -490,7 +490,7 @@ function user_link($type) {
   $links = array();
 
   if ($type == "page") {
-    $links[] = l(t("user account"), "user", array("title" => t("Create a user account, request a new password or edit your account settings.")));
+    $links[] = l(t("my account"), "user", array("title" => t("Create a user account, request a new password or edit your account settings.")));
   }
 
   if ($type == "system") {
@@ -502,21 +502,14 @@ function user_link($type) {
     if (user_access("administer users")) {
       menu("admin/user", t("accounts"), "user_admin", 2);
       menu("admin/user/create", t("new user"), "user_admin", 1);
-      menu("admin/user/account", t("users"), "user_admin", 2);
       menu("admin/user/access", t("access rules"), NULL, 3);
-      menu("admin/user/access/mail", t("by e-mail"), "user_admin");
-      menu("admin/user/access/user", t("by name"), "user_admin");
+      menu("admin/user/access/mail", t("e-mail rules"), "user_admin");
+      menu("admin/user/access/user", t("name rules"), "user_admin");
       menu("admin/user/role", t("roles"), "user_admin", 4);
       menu("admin/user/permission", t("permissions"), "user_admin", 5);
       menu("admin/user/search", t("search"), "user_admin", 8);
       menu("admin/user/help", t("help"), "user_help", 9);
       menu("admin/user/edit", t("edit user account"), "user_admin", 0, 1); // hidden menu
-      menu("admin/user/account/1", t("blocked users"), "user_admin", 3);
-
-      $i = 2;
-      foreach (user_roles(1) as $key => $value) {
-        menu("admin/user/account/$i", t("users with role '%role'", array("%role" => $value)), "user_admin", 4);
-      }
     }
   }
 
@@ -1050,7 +1043,7 @@ function user_edit($edit = array()) {
 
           $user = user_save($user, array_merge($edit, $data));
 
-          $output .= t("Your user information changes have been saved.");
+          $output .= status(t("Your user information changes have been saved."));
         }
       }
     }
@@ -1302,57 +1295,47 @@ function user_admin_access($edit = array()) {
     return;
   }
 
-  if ($type == "mail") {
-    $output .= "<h3>". t("E-mail rules") ."</h3>";
-  }
-
-  if ($type == "user") {
-    $output .= "<h3>". t("Username rules") ."</h3>";
-  }
-
   if ($op == t("Add rule")) {
     db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $edit["mask"], $type, $edit["status"]);
+    $output .= status(t("Access rule added"));
   }
   else if ($op == t("Check")) {
     if (user_deny($type, $edit["test"])) {
-      $message = "<b>'". $edit["test"] ."' is not allowed.</b><p />";
+      $output .= status(t("<i>%test</i> is not allowed.", array ("%test" => $edit["test"])));
     }
     else {
-      $message = "<b>'". $edit["test"] ."' is allowed.</b><p />";
+      $output .= status(t("<i>%test</i> is allowed.", array ("%test" => $edit["test"])));
     }
   }
   else if ($id) {
     db_query("DELETE FROM {access} WHERE aid = %d", $id);
+    $output .= status(t("Access rule deleted"));
   }
 
   $header = array(t("type"), t("mask"), t("operations"));
-
   $result = db_query("SELECT * FROM {access} WHERE type = '%s' AND status = '1' ORDER BY mask", $type);
-
   while ($rule = db_fetch_object($result)) {
     $rows[] = array(t("Allow"), $rule->mask, array("data" => l(t("delete rule"), "admin/user/access/$type/$rule->aid"), "align" => "center"));
   }
 
   $result = db_query("SELECT * FROM {access} WHERE type = '%s' AND status = '0' ORDER BY mask", $type);
-
   while ($rule = db_fetch_object($result)) {
     $rows[] = array(t("Deny"), $rule->mask, l(t("delete rule"), "admin/user/access/$type/$rule->aid"));
   }
 
-  $rows[] = array("<select name=\"edit[status]\"><option value=\"1\">". t("Allow") ."</option><option value=\"0\">". t("Deny") ."</option></select>", "<input size=\"32\" maxlength=\"64\" name=\"edit[mask]\" />", "<input type=\"submit\" name=\"op\" value=\"". t("Add rule") ."\" />");
-
+  $options = array ("1" => t("Allow"), "0" => t("Deny"));
+  $rows[] = array(form_select(NUll, "status", $edit["status"], $options), form_textfield(NULL, "mask", $edit["mask"], 32, 64), form_submit(t("Add rule")));
   $output .= table($header, $rows);
 
   $output .= "<p><small>%: ". t("Matches any number of characters, even zero characters") .".<br />_: ". t("Matches exactly one character.") ."</small></p>";
 
   if ($type != "user") {
-    $output .= "<h3>". t("Check e-mail address") ."</h3>";
+    $title = t("Check e-mail address");
   }
   else {
-    $output .= "<h3>". t("Check username") ."</h3>";
+    $title = t("Check username");
   }
-
-  $output .= "$message<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"edit[test]\" value=\"". $edit["test"] ."\" /><input type=\"submit\" name=\"op\" value=\"". t("Check") ."\" />";
+  $output .= form_textfield($title, "mask", $edit["test"], 32, 64). form_submit(t("Check"));
 
   return form($output);
 }
@@ -1594,32 +1577,27 @@ function user_admin_edit($edit = array()) {
 }
 
 function user_admin_account() {
-  $query = arg(3);
-
-  $queries[] = "";
-  $queries[] = "WHERE u.status = 0";
-  foreach (user_roles(1) as $key => $value) {
-    $queries[] = "WHERE r.name = '$value'";
-  }
-
-  $sql = "SELECT u.uid, u.name, u.timestamp FROM {role} r INNER JOIN {users} u ON r.rid = u.rid ". $queries[$query ? $query : 0];
 
   $header = array(
-    array ("data" => t("uid"), "field" => "u.uid"),
+    array ("data" => t("ID"), "field" => "u.uid"),
     array ("data" => t("username"), "field" => "u.name"),
+    array ("data" => t("status"), "field" => "u.status"),
+    array ("data" => t("role"), "field" => "u.rid"),
     array ("data" => t("last access"), "field"  => "u.timestamp", "sort" => "desc"),
     t("operations")
   );
+  $sql = "SELECT u.uid, u.name, u.status, u.timestamp, r.name AS rolename FROM {role} r INNER JOIN {users} u ON r.rid = u.rid ";
   $sql .= tablesort_sql($header);
   $result = pager_query($sql, 50);
 
+  $status = array (t("blocked"), t("active"));
   while ($account = db_fetch_object($result)) {
-    $rows[] = array($account->uid, format_name($account), format_date($account->timestamp, "small"), l(t("edit account"), "admin/user/edit/$account->uid"));
+    $rows[] = array($account->uid, format_name($account), $status[$account->status], $account->rolename, format_date($account->timestamp, "small"), l(t("edit account"), "admin/user/edit/$account->uid"));
   }
 
   $pager = pager_display(NULL, 50, 0, "admin", tablesort_pager());
   if (!empty($pager)) {
-    $rows[] = array(array("data" => $pager, "colspan" => 4));
+    $rows[] = array(array("data" => $pager, "colspan" => 6));
   }
   return table($header, $rows);
 }
@@ -1659,11 +1637,12 @@ function user_admin() {
       case t("Add rule"):
       case t("Check"):
       case "access":
-        $output = user_admin_access($edit);
+        $output .= user_admin_access($edit);
         break;
       case t("Save permissions"):
+        $output = status(t("User permissions saved."));
       case "permission":
-        $output = user_admin_perm($edit);
+        $output .= user_admin_perm($edit);
         break;
       case t("Create account"):
       case "create":
@@ -1672,8 +1651,9 @@ function user_admin() {
       case t("Add role"):
       case t("Delete role"):
       case t("Save role"):
+        $output = status(t("Your role changes were saved."));
       case "role":
-        $output = user_admin_role($edit);
+        $output .= user_admin_role($edit);
         break;
       case t("Delete account"):
       case t("Save account"):
@@ -1697,32 +1677,16 @@ function user_help($section = "admin/help#user") {
 
   switch ($section) {
     case 'admin/user':
-      $output .= t("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.<br />Click on either the \"username\" or \"edit account\" to edit a user's information.");
+      $output .= t("<p>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.</p>");
+      $output .= t("<p>Click on either the <i>username</i> or <i>edit account</i> to edit a user's information.</p>");
+      $output .= t("<p>Sort accounts by registration time by clicking on the <i>ID</i> header</p>");
       break;
     case 'admin/user/create':
     case 'admin/user/account/create':
       $output .= t("This web page allows the administrators to register a new users by hand.<br />Note:<ul><li>You cannot have a user where either the e-mail address or the username match another user in the system.</li></ul>");
       break;
-    case (preg_match("/^admin\/user\/account.*/i", $section) ? $section : !$section):
-      $output .= t("This page allows you to review and edit %role-name. To edit a profile click on either the \"username\" or \"edit account\".");
-
-      $role = substr(strrchr($section, "/"), 1);
-
-      if ($role == "account") {
-        $replace = t("any user's profile");
-      }
-      else if ($role == "1") {
-        $replace = t("a blocked user's profile");
-      }
-      else {
-        $output = strtr($output, array("%role-name" => t("a user with the '%role-name' role")));
-        $role_names = user_roles(1);
-        $replace = $role_names[$role];
-      }
-      $output = strtr($output, array("%role-name" => $replace));
-      break;
     case 'admin/user/access':
-      $output .= t("Access rules allow Drupal administrators to choose usernames and e-mail address that are prevented from using drupal. To enter the mask for e-mail addresses click on %e-mail, for the username mask click on %username.", array("%e-mail" => l(t("e-mail rules"), "admin/user/access/mail"), "%username" => l(t("username rules"), "admin/user/access/user")));
+      $output .= t("Access rules allow Drupal administrators to choose usernames and e-mail address that are prevented from using drupal. To enter the mask for e-mail addresses click on %e-mail, for the username mask click on %username.", array("%e-mail" => l(t("e-mail rules"), "admin/user/access/mail"), "%username" => l(t("name rules"), "admin/user/access/user")));
       break;
     case 'admin/user/access/mail':
       $output .= t("Setup and test the e-mail access rules. The access function checks if you match a deny and <b>not</b> an allow. If you match <b>only</b> a deny then it is denied. Any other case, such as both a deny and an allow pattern matching, allows the pattern.<br />Notes: <ul><li>To delete a rule click on \"delete rule\".</li><li>The order of the rules does <b>not</b> matter.</li></ul>");
diff --git a/modules/user/user.module b/modules/user/user.module
index 000524eb478f..6537ea99c46e 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -490,7 +490,7 @@ function user_link($type) {
   $links = array();
 
   if ($type == "page") {
-    $links[] = l(t("user account"), "user", array("title" => t("Create a user account, request a new password or edit your account settings.")));
+    $links[] = l(t("my account"), "user", array("title" => t("Create a user account, request a new password or edit your account settings.")));
   }
 
   if ($type == "system") {
@@ -502,21 +502,14 @@ function user_link($type) {
     if (user_access("administer users")) {
       menu("admin/user", t("accounts"), "user_admin", 2);
       menu("admin/user/create", t("new user"), "user_admin", 1);
-      menu("admin/user/account", t("users"), "user_admin", 2);
       menu("admin/user/access", t("access rules"), NULL, 3);
-      menu("admin/user/access/mail", t("by e-mail"), "user_admin");
-      menu("admin/user/access/user", t("by name"), "user_admin");
+      menu("admin/user/access/mail", t("e-mail rules"), "user_admin");
+      menu("admin/user/access/user", t("name rules"), "user_admin");
       menu("admin/user/role", t("roles"), "user_admin", 4);
       menu("admin/user/permission", t("permissions"), "user_admin", 5);
       menu("admin/user/search", t("search"), "user_admin", 8);
       menu("admin/user/help", t("help"), "user_help", 9);
       menu("admin/user/edit", t("edit user account"), "user_admin", 0, 1); // hidden menu
-      menu("admin/user/account/1", t("blocked users"), "user_admin", 3);
-
-      $i = 2;
-      foreach (user_roles(1) as $key => $value) {
-        menu("admin/user/account/$i", t("users with role '%role'", array("%role" => $value)), "user_admin", 4);
-      }
     }
   }
 
@@ -1050,7 +1043,7 @@ function user_edit($edit = array()) {
 
           $user = user_save($user, array_merge($edit, $data));
 
-          $output .= t("Your user information changes have been saved.");
+          $output .= status(t("Your user information changes have been saved."));
         }
       }
     }
@@ -1302,57 +1295,47 @@ function user_admin_access($edit = array()) {
     return;
   }
 
-  if ($type == "mail") {
-    $output .= "<h3>". t("E-mail rules") ."</h3>";
-  }
-
-  if ($type == "user") {
-    $output .= "<h3>". t("Username rules") ."</h3>";
-  }
-
   if ($op == t("Add rule")) {
     db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $edit["mask"], $type, $edit["status"]);
+    $output .= status(t("Access rule added"));
   }
   else if ($op == t("Check")) {
     if (user_deny($type, $edit["test"])) {
-      $message = "<b>'". $edit["test"] ."' is not allowed.</b><p />";
+      $output .= status(t("<i>%test</i> is not allowed.", array ("%test" => $edit["test"])));
     }
     else {
-      $message = "<b>'". $edit["test"] ."' is allowed.</b><p />";
+      $output .= status(t("<i>%test</i> is allowed.", array ("%test" => $edit["test"])));
     }
   }
   else if ($id) {
     db_query("DELETE FROM {access} WHERE aid = %d", $id);
+    $output .= status(t("Access rule deleted"));
   }
 
   $header = array(t("type"), t("mask"), t("operations"));
-
   $result = db_query("SELECT * FROM {access} WHERE type = '%s' AND status = '1' ORDER BY mask", $type);
-
   while ($rule = db_fetch_object($result)) {
     $rows[] = array(t("Allow"), $rule->mask, array("data" => l(t("delete rule"), "admin/user/access/$type/$rule->aid"), "align" => "center"));
   }
 
   $result = db_query("SELECT * FROM {access} WHERE type = '%s' AND status = '0' ORDER BY mask", $type);
-
   while ($rule = db_fetch_object($result)) {
     $rows[] = array(t("Deny"), $rule->mask, l(t("delete rule"), "admin/user/access/$type/$rule->aid"));
   }
 
-  $rows[] = array("<select name=\"edit[status]\"><option value=\"1\">". t("Allow") ."</option><option value=\"0\">". t("Deny") ."</option></select>", "<input size=\"32\" maxlength=\"64\" name=\"edit[mask]\" />", "<input type=\"submit\" name=\"op\" value=\"". t("Add rule") ."\" />");
-
+  $options = array ("1" => t("Allow"), "0" => t("Deny"));
+  $rows[] = array(form_select(NUll, "status", $edit["status"], $options), form_textfield(NULL, "mask", $edit["mask"], 32, 64), form_submit(t("Add rule")));
   $output .= table($header, $rows);
 
   $output .= "<p><small>%: ". t("Matches any number of characters, even zero characters") .".<br />_: ". t("Matches exactly one character.") ."</small></p>";
 
   if ($type != "user") {
-    $output .= "<h3>". t("Check e-mail address") ."</h3>";
+    $title = t("Check e-mail address");
   }
   else {
-    $output .= "<h3>". t("Check username") ."</h3>";
+    $title = t("Check username");
   }
-
-  $output .= "$message<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"edit[test]\" value=\"". $edit["test"] ."\" /><input type=\"submit\" name=\"op\" value=\"". t("Check") ."\" />";
+  $output .= form_textfield($title, "mask", $edit["test"], 32, 64). form_submit(t("Check"));
 
   return form($output);
 }
@@ -1594,32 +1577,27 @@ function user_admin_edit($edit = array()) {
 }
 
 function user_admin_account() {
-  $query = arg(3);
-
-  $queries[] = "";
-  $queries[] = "WHERE u.status = 0";
-  foreach (user_roles(1) as $key => $value) {
-    $queries[] = "WHERE r.name = '$value'";
-  }
-
-  $sql = "SELECT u.uid, u.name, u.timestamp FROM {role} r INNER JOIN {users} u ON r.rid = u.rid ". $queries[$query ? $query : 0];
 
   $header = array(
-    array ("data" => t("uid"), "field" => "u.uid"),
+    array ("data" => t("ID"), "field" => "u.uid"),
     array ("data" => t("username"), "field" => "u.name"),
+    array ("data" => t("status"), "field" => "u.status"),
+    array ("data" => t("role"), "field" => "u.rid"),
     array ("data" => t("last access"), "field"  => "u.timestamp", "sort" => "desc"),
     t("operations")
   );
+  $sql = "SELECT u.uid, u.name, u.status, u.timestamp, r.name AS rolename FROM {role} r INNER JOIN {users} u ON r.rid = u.rid ";
   $sql .= tablesort_sql($header);
   $result = pager_query($sql, 50);
 
+  $status = array (t("blocked"), t("active"));
   while ($account = db_fetch_object($result)) {
-    $rows[] = array($account->uid, format_name($account), format_date($account->timestamp, "small"), l(t("edit account"), "admin/user/edit/$account->uid"));
+    $rows[] = array($account->uid, format_name($account), $status[$account->status], $account->rolename, format_date($account->timestamp, "small"), l(t("edit account"), "admin/user/edit/$account->uid"));
   }
 
   $pager = pager_display(NULL, 50, 0, "admin", tablesort_pager());
   if (!empty($pager)) {
-    $rows[] = array(array("data" => $pager, "colspan" => 4));
+    $rows[] = array(array("data" => $pager, "colspan" => 6));
   }
   return table($header, $rows);
 }
@@ -1659,11 +1637,12 @@ function user_admin() {
       case t("Add rule"):
       case t("Check"):
       case "access":
-        $output = user_admin_access($edit);
+        $output .= user_admin_access($edit);
         break;
       case t("Save permissions"):
+        $output = status(t("User permissions saved."));
       case "permission":
-        $output = user_admin_perm($edit);
+        $output .= user_admin_perm($edit);
         break;
       case t("Create account"):
       case "create":
@@ -1672,8 +1651,9 @@ function user_admin() {
       case t("Add role"):
       case t("Delete role"):
       case t("Save role"):
+        $output = status(t("Your role changes were saved."));
       case "role":
-        $output = user_admin_role($edit);
+        $output .= user_admin_role($edit);
         break;
       case t("Delete account"):
       case t("Save account"):
@@ -1697,32 +1677,16 @@ function user_help($section = "admin/help#user") {
 
   switch ($section) {
     case 'admin/user':
-      $output .= t("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.<br />Click on either the \"username\" or \"edit account\" to edit a user's information.");
+      $output .= t("<p>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.</p>");
+      $output .= t("<p>Click on either the <i>username</i> or <i>edit account</i> to edit a user's information.</p>");
+      $output .= t("<p>Sort accounts by registration time by clicking on the <i>ID</i> header</p>");
       break;
     case 'admin/user/create':
     case 'admin/user/account/create':
       $output .= t("This web page allows the administrators to register a new users by hand.<br />Note:<ul><li>You cannot have a user where either the e-mail address or the username match another user in the system.</li></ul>");
       break;
-    case (preg_match("/^admin\/user\/account.*/i", $section) ? $section : !$section):
-      $output .= t("This page allows you to review and edit %role-name. To edit a profile click on either the \"username\" or \"edit account\".");
-
-      $role = substr(strrchr($section, "/"), 1);
-
-      if ($role == "account") {
-        $replace = t("any user's profile");
-      }
-      else if ($role == "1") {
-        $replace = t("a blocked user's profile");
-      }
-      else {
-        $output = strtr($output, array("%role-name" => t("a user with the '%role-name' role")));
-        $role_names = user_roles(1);
-        $replace = $role_names[$role];
-      }
-      $output = strtr($output, array("%role-name" => $replace));
-      break;
     case 'admin/user/access':
-      $output .= t("Access rules allow Drupal administrators to choose usernames and e-mail address that are prevented from using drupal. To enter the mask for e-mail addresses click on %e-mail, for the username mask click on %username.", array("%e-mail" => l(t("e-mail rules"), "admin/user/access/mail"), "%username" => l(t("username rules"), "admin/user/access/user")));
+      $output .= t("Access rules allow Drupal administrators to choose usernames and e-mail address that are prevented from using drupal. To enter the mask for e-mail addresses click on %e-mail, for the username mask click on %username.", array("%e-mail" => l(t("e-mail rules"), "admin/user/access/mail"), "%username" => l(t("name rules"), "admin/user/access/user")));
       break;
     case 'admin/user/access/mail':
       $output .= t("Setup and test the e-mail access rules. The access function checks if you match a deny and <b>not</b> an allow. If you match <b>only</b> a deny then it is denied. Any other case, such as both a deny and an allow pattern matching, allows the pattern.<br />Notes: <ul><li>To delete a rule click on \"delete rule\".</li><li>The order of the rules does <b>not</b> matter.</li></ul>");
-- 
GitLab