Index: modules/user/user.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v
retrieving revision 1.116
diff -u -p -r1.116 user.admin.inc
--- modules/user/user.admin.inc	29 Jul 2010 01:39:32 -0000	1.116
+++ modules/user/user.admin.inc	26 Aug 2010 14:47:02 -0000
@@ -6,24 +6,18 @@
  * Admin page callback file for the user module.
  */
 
-function user_admin($callback_arg = '') {
-  $op = isset($_POST['op']) ? $_POST['op'] : $callback_arg;
-
-  switch ($op) {
-    case t('Create new account'):
-    case 'create':
-      $build['user_register'] = drupal_get_form('user_register_form');
-      break;
-    default:
-      if (!empty($_POST['accounts']) && isset($_POST['operation']) && ($_POST['operation'] == 'cancel')) {
-        $build['user_multiple_cancel_confirm'] = drupal_get_form('user_multiple_cancel_confirm');
-      }
-      else {
-        $build['user_filter_form'] = drupal_get_form('user_filter_form');
-        $build['user_admin_account'] = drupal_get_form('user_admin_account');
-      }
+/**
+ * Form builder; Return user administration forms.
+ *
+ * @ingroup forms
+ */
+function user_admin_form($form, &$form_state) {
+  if (!empty($form_state['values']['accounts']) && isset($form_state['values']['operation']) && ($form_state['values']['operation'] == 'cancel')) {
+    return array_merge($form, user_multiple_cancel_confirm($form, $form_state));
   }
-  return $build;
+  $form = array_merge($form, user_filter_form());
+  $form['user_admin_account'] = user_admin_account();
+  return $form;
 }
 
 /**
@@ -36,6 +30,8 @@ function user_filter_form() {
   $session = isset($_SESSION['user_overview_filter']) ? $_SESSION['user_overview_filter'] : array();
   $filters = user_filters();
 
+  $form['#submit'][] = 'user_filter_form_submit';
+
   $i = 0;
   $form['filters'] = array(
     '#type' => 'fieldset',
@@ -92,8 +88,6 @@ function user_filter_form() {
     );
   }
 
-  drupal_add_js('misc/form.js');
-
   return $form;
 }
 
@@ -127,9 +121,6 @@ function user_filter_form_submit($form, 
     case t('Update'):
       return;
   }
-
-  $form_state['redirect'] = 'admin/people';
-  return;
 }
 
 /**
@@ -165,6 +156,8 @@ function user_admin_account() {
     ->setCountQuery($count_query);
   $result = $query->execute();
 
+  $form['#theme'] = 'user_admin_account';
+
   $form['options'] = array(
     '#type' => 'fieldset',
     '#title' => t('Update options'),
@@ -183,6 +176,8 @@ function user_admin_account() {
   $form['options']['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Update'),
+    '#validate' => array('user_admin_account_validate'),
+    '#submit' => array('user_admin_account_submit'),
   );
 
   $destination = drupal_get_destination();
@@ -239,6 +234,11 @@ function user_admin_account_submit($form
 
     drupal_set_message(t('The update has been performed.'));
   }
+  else {
+    // We need to rebuild the form to go to a second step. For example, to
+    // show the confirmation form for deletion.
+    $form_state['rebuild'] = TRUE;
+  }
 }
 
 function user_admin_account_validate($form, &$form_state) {
@@ -1055,3 +1055,106 @@ function theme_user_filters($variables) 
 
   return $output;
 }
+
+/**
+ * Form builder; Mass-account cancellation form.
+ *
+ * @ingroup forms
+ * @see user_multiple_cancel_confirm_submit()
+ */
+function user_multiple_cancel_confirm($form, &$form_state) {
+  $edit = $form_state['input'];
+
+  $form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
+  $accounts = user_load_multiple(array_keys(array_filter($edit['accounts'])));
+  foreach ($accounts as $uid => $account) {
+    // Prevent user 1 from being canceled.
+    if ($uid <= 1) {
+      continue;
+    }
+    $form['accounts'][$uid] = array(
+      '#type' => 'hidden',
+      '#value' => $uid,
+      '#prefix' => '<li>',
+      '#suffix' => check_plain($account->name) . "</li>\n",
+    );
+  }
+
+  // Output a notice that user 1 cannot be canceled.
+  if (isset($accounts[1])) {
+    $redirect = (count($accounts) == 1);
+    $message = t('The user account %name cannot be cancelled.', array('%name' => $accounts[1]->name));
+    drupal_set_message($message, $redirect ? 'error' : 'warning');
+    // If only user 1 was selected, redirect to the overview.
+    if ($redirect) {
+      drupal_goto('admin/people');
+    }
+  }
+
+  $form['operation'] = array('#type' => 'hidden', '#value' => 'cancel');
+
+  module_load_include('inc', 'user', 'user.pages');
+  $form['user_cancel_method'] = array(
+    '#type' => 'item',
+    '#title' => t('When cancelling these accounts'),
+  );
+  $form['user_cancel_method'] += user_cancel_methods();
+  // Remove method descriptions.
+  foreach (element_children($form['user_cancel_method']) as $element) {
+    unset($form['user_cancel_method'][$element]['#description']);
+  }
+
+  // Allow to send the account cancellation confirmation mail.
+  $form['user_cancel_confirm'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Require e-mail confirmation to cancel account.'),
+    '#default_value' => FALSE,
+    '#description' => t('When enabled, the user must confirm the account cancellation via e-mail.'),
+  );
+  // Also allow to send account canceled notification mail, if enabled.
+  $form['user_cancel_notify'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Notify user when account is canceled.'),
+    '#default_value' => FALSE,
+    '#access' => variable_get('user_mail_status_canceled_notify', FALSE),
+    '#description' => t('When enabled, the user will receive an e-mail notification after the account has been cancelled.'),
+  );
+
+  return confirm_form($form,
+    t('Are you sure you want to cancel these user accounts?'),
+    'admin/people',
+    t('This action cannot be undone.'),
+    t('Cancel accounts'),
+    t('Cancel'));
+}
+
+/**
+ * Submit handler for mass-account cancellation form.
+ *
+ * @see user_multiple_cancel_confirm()
+ * @see user_cancel_confirm_form_submit()
+ */
+function user_multiple_cancel_confirm_submit($form, &$form_state) {
+  global $user;
+
+  if ($form_state['values']['confirm']) {
+    foreach ($form_state['values']['accounts'] as $uid => $value) {
+      // Prevent programmatic form submissions from cancelling user 1.
+      if ($uid <= 1) {
+        continue;
+      }
+      // Prevent user administrators from deleting themselves without confirmation.
+      if ($uid == $user->uid) {
+        $admin_form_state = $form_state;
+        unset($admin_form_state['values']['user_cancel_confirm']);
+        $admin_form_state['values']['_account'] = $user;
+        user_cancel_confirm_form_submit(array(), $admin_form_state);
+      }
+      else {
+        user_cancel($form_state['values'], $uid, $form_state['values']['user_cancel_method']);
+      }
+    }
+  }
+  $form_state['redirect'] = 'admin/people';
+}
+
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1196
diff -u -p -r1.1196 user.module
--- modules/user/user.module	26 Aug 2010 09:14:33 -0000	1.1196
+++ modules/user/user.module	26 Aug 2010 14:47:54 -0000
@@ -1573,8 +1573,8 @@ function user_menu() {
   $items['admin/people'] = array(
     'title' => 'People',
     'description' => 'Manage user accounts, roles, and permissions',
-    'page callback' => 'user_admin',
-    'page arguments' => array('list'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_admin_form'),
     'access arguments' => array('administer users'),
     'position' => 'left',
     'weight' => -4,
@@ -1588,6 +1588,13 @@ function user_menu() {
     'weight' => -10,
     'file' => 'user.admin.inc',
   );
+  $items['admin/people/create'] = array(
+    'title' => 'Add user',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_register_form'),
+    'access arguments' => array('administer users'),
+    'type' => MENU_LOCAL_ACTION,
+  );
 
   // Permissions and role forms.
   $items['admin/people/permissions'] = array(
@@ -1632,13 +1639,6 @@ function user_menu() {
     'file' => 'user.admin.inc',
   );
 
-  $items['admin/people/create'] = array(
-    'title' => 'Add user',
-    'page arguments' => array('create'),
-    'access arguments' => array('administer users'),
-    'type' => MENU_LOCAL_ACTION,
-  );
-
   // Administration pages.
   $items['admin/config/people'] = array(
    'title' => 'People',
@@ -2926,6 +2926,7 @@ function user_user_operations($form = ar
     ),
     'cancel' => array(
       'label' => t('Cancel the selected user accounts'),
+      'callback' => NULL,
     ),
   );
 
@@ -3038,100 +3039,6 @@ function user_multiple_role_edit($accoun
   }
 }
 
-function user_multiple_cancel_confirm($form, &$form_state) {
-  $edit = $form_state['input'];
-
-  $form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
-  $accounts = user_load_multiple(array_keys(array_filter($edit['accounts'])));
-  foreach ($accounts as $uid => $account) {
-    // Prevent user 1 from being canceled.
-    if ($uid <= 1) {
-      continue;
-    }
-    $form['accounts'][$uid] = array(
-      '#type' => 'hidden',
-      '#value' => $uid,
-      '#prefix' => '<li>',
-      '#suffix' => check_plain($account->name) . "</li>\n",
-    );
-  }
-
-  // Output a notice that user 1 cannot be canceled.
-  if (isset($accounts[1])) {
-    $redirect = (count($accounts) == 1);
-    $message = t('The user account %name cannot be cancelled.', array('%name' => $accounts[1]->name));
-    drupal_set_message($message, $redirect ? 'error' : 'warning');
-    // If only user 1 was selected, redirect to the overview.
-    if ($redirect) {
-      drupal_goto('admin/people');
-    }
-  }
-
-  $form['operation'] = array('#type' => 'hidden', '#value' => 'cancel');
-
-  module_load_include('inc', 'user', 'user.pages');
-  $form['user_cancel_method'] = array(
-    '#type' => 'item',
-    '#title' => t('When cancelling these accounts'),
-  );
-  $form['user_cancel_method'] += user_cancel_methods();
-  // Remove method descriptions.
-  foreach (element_children($form['user_cancel_method']) as $element) {
-    unset($form['user_cancel_method'][$element]['#description']);
-  }
-
-  // Allow to send the account cancellation confirmation mail.
-  $form['user_cancel_confirm'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Require e-mail confirmation to cancel account.'),
-    '#default_value' => FALSE,
-    '#description' => t('When enabled, the user must confirm the account cancellation via e-mail.'),
-  );
-  // Also allow to send account canceled notification mail, if enabled.
-  $form['user_cancel_notify'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Notify user when account is canceled.'),
-    '#default_value' => FALSE,
-    '#access' => variable_get('user_mail_status_canceled_notify', FALSE),
-    '#description' => t('When enabled, the user will receive an e-mail notification after the account has been cancelled.'),
-  );
-
-  return confirm_form($form,
-                      t('Are you sure you want to cancel these user accounts?'),
-                      'admin/people', t('This action cannot be undone.'),
-                      t('Cancel accounts'), t('Cancel'));
-}
-
-/**
- * Submit handler for mass-account cancellation form.
- *
- * @see user_multiple_cancel_confirm()
- * @see user_cancel_confirm_form_submit()
- */
-function user_multiple_cancel_confirm_submit($form, &$form_state) {
-  global $user;
-
-  if ($form_state['values']['confirm']) {
-    foreach ($form_state['values']['accounts'] as $uid => $value) {
-      // Prevent programmatic form submissions from cancelling user 1.
-      if ($uid <= 1) {
-        continue;
-      }
-      // Prevent user administrators from deleting themselves without confirmation.
-      if ($uid == $user->uid) {
-        $admin_form_state = $form_state;
-        unset($admin_form_state['values']['user_cancel_confirm']);
-        $admin_form_state['values']['_account'] = $user;
-        user_cancel_confirm_form_submit(array(), $admin_form_state);
-      }
-      else {
-        user_cancel($form_state['values'], $uid, $form_state['values']['user_cancel_method']);
-      }
-    }
-  }
-  $form_state['redirect'] = 'admin/people';
-}
-
 /**
  * Retrieve a list of all user setting/information categories and sort them by weight.
  */
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.74
diff -u -p -r1.74 user.pages.inc
--- modules/user/user.pages.inc	11 Jul 2010 22:14:28 -0000	1.74
+++ modules/user/user.pages.inc	26 Aug 2010 14:48:51 -0000
@@ -274,7 +274,7 @@ function user_profile_form($form, &$form
     $form['actions']['cancel'] = array(
       '#type' => 'submit',
       '#value' => t('Cancel account'),
-      '#submit' => array('user_edit_cancel_submit'),
+      '#submit' => array('user_profile_form_cancel_submit'),
       '#access' => $account->uid > 1 && (($account->uid == $user->uid && user_access('cancel account')) || user_access('administer users')),
     );
   }
@@ -324,7 +324,7 @@ function user_profile_form_submit($form,
 /**
  * Submit function for the 'Cancel account' button on the user edit form.
  */
-function user_edit_cancel_submit($form, &$form_state) {
+function user_profile_form_cancel_submit($form, &$form_state) {
   $destination = array();
   if (isset($_GET['destination'])) {
     $destination = drupal_get_destination();
@@ -338,7 +338,7 @@ function user_edit_cancel_submit($form, 
  * Form builder; confirm form for cancelling user account.
  *
  * @ingroup forms
- * @see user_edit_cancel_submit()
+ * @see user_profile_form_cancel_submit()
  */
 function user_cancel_confirm_form($form, &$form_state, $account) {
   global $user;
