You are here

function devel_generate_users_form in Devel 7

Same name and namespace in other branches
  1. 5 devel_generate.module \devel_generate_users_form()
  2. 6 devel_generate.module \devel_generate_users_form()

Generates users using FormAPI.

1 string reference to 'devel_generate_users_form'
devel_generate_menu in devel_generate/devel_generate.module
Implements hook_menu().

File

devel_generate/devel_generate.module, line 53

Code

function devel_generate_users_form() {
  $form['num'] = array(
    '#type' => 'textfield',
    '#title' => t('How many users would you like to generate?'),
    '#default_value' => 50,
    '#size' => 10,
  );
  $form['kill_users'] = array(
    '#type' => 'checkbox',
    '#title' => t('Delete all users (except user id 1) before generating new users.'),
    '#default_value' => FALSE,
  );
  $options = user_roles(TRUE);
  unset($options[DRUPAL_AUTHENTICATED_RID]);
  $form['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Which roles should the users receive?'),
    '#description' => t('Users always receive the <em>authenticated user</em> role.'),
    '#options' => $options,
  );
  $form['pass'] = array(
    '#type' => 'textfield',
    '#title' => t('Password to be set'),
    '#default_value' => NULL,
    '#size' => 32,
    '#description' => t('Leave this field empty if you do not need to set a password.'),
  );
  $options = array(
    1 => t('Now'),
  );
  foreach (array(
    3600,
    86400,
    604800,
    2592000,
    31536000,
  ) as $interval) {
    $options[$interval] = format_interval($interval, 1) . ' ' . t('ago');
  }
  $form['time_range'] = array(
    '#type' => 'select',
    '#title' => t('How old should user accounts be?'),
    '#description' => t('User ages will be distributed randomly from the current time, back to the selected time.'),
    '#options' => $options,
    '#default_value' => 604800,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Generate'),
  );
  return $form;
}