You are here

function user_edit_form in Drupal 5

Same name and namespace in other branches
  1. 4 modules/user.module \user_edit_form()
  2. 6 modules/user/user.module \user_edit_form()
2 calls to user_edit_form()
user_register in modules/user/user.module
user_user in modules/user/user.module
Implementation of hook_user().

File

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

Code

function user_edit_form($uid, $edit, $register = FALSE) {
  $admin = user_access('administer users');

  // Account information:
  $form['account'] = array(
    '#type' => 'fieldset',
    '#title' => t('Account information'),
  );
  if (user_access('change own username') || $admin || $register) {
    $form['account']['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Username'),
      '#default_value' => $edit['name'],
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#description' => t('Your preferred username; punctuation is not allowed except for periods, hyphens, and underscores.'),
      '#required' => TRUE,
    );
  }
  $form['account']['mail'] = array(
    '#type' => 'textfield',
    '#title' => t('E-mail address'),
    '#default_value' => $edit['mail'],
    '#maxlength' => EMAIL_MAX_LENGTH,
    '#description' => t('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.'),
    '#required' => TRUE,
  );
  if (!$register) {
    $form['account']['pass'] = array(
      '#type' => 'password_confirm',
      '#description' => t('To change the current user password, enter the new password in both fields.'),
      '#size' => 25,
    );
  }
  elseif (!variable_get('user_email_verification', TRUE) || $admin) {
    $form['account']['pass'] = array(
      '#type' => 'password_confirm',
      '#description' => t('Provide a password for the new account in both fields.'),
      '#required' => TRUE,
      '#size' => 25,
    );
  }
  if ($admin) {
    $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')) {
    $roles = user_roles(1);
    unset($roles[DRUPAL_AUTHENTICATED_RID]);
    if ($roles) {
      $form['account']['roles'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Roles'),
        '#default_value' => array_keys((array) $edit['roles']),
        '#options' => $roles,
        '#description' => t('The user receives the combined permissions of the %au role, and all roles selected here.', array(
          '%au' => t('authenticated user'),
        )),
      );
    }
  }

  // Picture/avatar:
  if (variable_get('user_pictures', 0) && !$register) {
    $form['picture'] = array(
      '#type' => 'fieldset',
      '#title' => t('Picture'),
      '#weight' => 1,
    );
    $picture = theme('user_picture', (object) $edit);
    if ($picture) {
      $form['picture']['current_picture'] = array(
        '#value' => $picture,
      );
      $form['picture']['picture_delete'] = array(
        '#type' => 'checkbox',
        '#title' => t('Delete picture'),
        '#description' => t('Check this box to delete your current picture.'),
      );
    }
    else {
      $form['picture']['picture_delete'] = array(
        '#type' => 'hidden',
      );
    }
    $form['picture']['picture_upload'] = array(
      '#type' => 'file',
      '#title' => t('Upload picture'),
      '#size' => 48,
      '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array(
        '%dimensions' => variable_get('user_picture_dimensions', '85x85'),
        '%size' => variable_get('user_picture_file_size', '30'),
      )) . ' ' . variable_get('user_picture_guidelines', ''),
    );
  }
  return $form;
}