Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.731
diff -u -F^f -r1.731 user.module
--- modules/user/user.module	12 Dec 2006 10:11:43 -0000	1.731
+++ modules/user/user.module	13 Dec 2006 03:54:01 -0000
@@ -809,7 +809,7 @@ function user_menu($may_cache) {
           'callback' => 'drupal_get_form', 'callback arguments' => array('user_edit'),
           'access' => $admin_access || $user->uid == arg(1), 'type' => MENU_LOCAL_TASK);
         $items[] = array('path' => 'user/'. arg(1) .'/delete', 'title' => t('Delete'),
-          'callback' => 'user_edit', 'access' => $admin_access,
+          'callback' => 'user_edit', 'access' => $admin_access && arg(1) != 1,
           'type' => MENU_CALLBACK);
 
         if (arg(2) == 'edit') {
@@ -1285,8 +1285,10 @@ function user_register_submit($form_id, 
 }
 
 function user_edit_form($uid, $edit, $register = FALSE) {
+  global $user;
   $admin = user_access('administer users');
-
+  $account = user_load(array('uid' => $uid));
+  
   // Account information:
   $form['account'] = array('#type' => 'fieldset',
     '#title' => t('Account information'),
@@ -1319,7 +1321,7 @@ function user_edit_form($uid, $edit, $re
       '#required' => TRUE,
     );
   }
-  if ($admin) {
+  if ($admin && $account->uid != $user->uid) {
     $form['account']['status'] = array('#type' => 'radios', '#title' => t('Status'), '#default_value' => isset($edit['status']) ? $edit['status'] : 1, '#options' => array(t('Blocked'), t('Active')));
   }
   if (user_access('administer access control')) {
@@ -1424,7 +1426,7 @@ function user_edit($category = 'account'
   $form['_category'] = array('#type' => 'value', '#value' => $category);
   $form['_account'] = array('#type' => 'value', '#value' => $account);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 30);
-  if (user_access('administer users')) {
+  if (user_access('administer users') && $account->uid != 1) {
     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'), '#weight' => 31);
   }
   $form['#attributes']['enctype'] = 'multipart/form-data';
@@ -2114,10 +2116,14 @@ function user_admin_account_submit($form
 }
 
 function user_admin_account_validate($form_id, $form_values) {
+  global $user;
   $form_values['accounts'] = array_filter($form_values['accounts']);
   if (count($form_values['accounts']) == 0) {
     form_set_error('', t('No users selected.'));
   }
+  else if (in_array($user->uid, $form_values['accounts']) && $form_values['operation'] == 'block') {
+    form_set_error('', t('You cannot block yourself.'));
+  }
 }
 
 /**
@@ -2324,7 +2330,13 @@ function user_admin($callback_arg = '') 
       break;
     default:
       if ($_POST['accounts'] && $_POST['operation'] == 'delete') {
-        $output = drupal_get_form('user_multiple_delete_confirm');
+        if (in_array(1, $_POST['accounts'])) {
+          drupal_set_message(t('You cannot delete the first user account.'), 'error');
+          drupal_goto('admin/user/user');
+        }
+        else {
+          $output = drupal_get_form('user_multiple_delete_confirm');
+        }
       }
       else {
         $output = drupal_get_form('user_filter_form');
