You are here

function user_edit in Drupal 4

Same name and namespace in other branches
  1. 5 modules/user/user.module \user_edit()
  2. 6 modules/user/user.pages.inc \user_edit()
1 string reference to 'user_edit'
user_menu in modules/user.module
Implementation of hook_menu().

File

modules/user.module, line 1400
Enables the user registration and login system.

Code

function user_edit($category = 'account') {
  global $user;
  $account = user_load(array(
    'uid' => arg(1),
  ));
  if ($account === FALSE) {
    drupal_set_message(t('The account does not exist or has already been deleted.'));
    drupal_goto('admin/user');
  }
  $edit = $_POST['op'] ? $_POST['edit'] : (array) $account;
  if (arg(2) == 'delete') {
    $form = array();
    $form['account'] = array(
      '#type' => 'value',
      '#value' => $account,
    );
    return confirm_form('user_confirm_delete', $form, t('Are you sure you want to delete the account %name?', array(
      '%name' => theme('placeholder', $account->name),
    )), 'user/' . $account->uid, t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'), t('Delete'), t('Cancel'));
  }
  else {
    if ($_POST['op'] == t('Delete')) {
      if ($_REQUEST['destination']) {
        $destination = drupal_get_destination();
        unset($_REQUEST['destination']);
      }

      // Note: we redirect from user/uid/edit to user/uid/delete to make the tabs disappear.
      drupal_goto("user/{$account->uid}/delete", $destination);
    }
  }
  $form = _user_forms($edit, $account, $category);
  $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')) {
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#weight' => 31,
    );
  }
  $form['#attributes']['enctype'] = 'multipart/form-data';
  drupal_set_title(check_plain($account->name));
  return drupal_get_form('user_edit', $form);
}