You are here

function regcode_admin_create in Registration codes 7

Same name and namespace in other branches
  1. 6.2 regcode.admin.php \regcode_admin_create()
  2. 6 regcode.admin.php \regcode_admin_create()
  3. 7.2 regcode.admin.inc \regcode_admin_create()

Create registration codes form.

1 string reference to 'regcode_admin_create'
regcode_menu in ./regcode.module
Implements hook_menu().

File

./regcode.admin.php, line 126
Functions and pages needed for the admin UI of regcode module.

Code

function regcode_admin_create() {
  $form = array();

  // Basics.
  $form['regcode_create'] = array(
    '#type' => 'fieldset',
    '#title' => t('Create code'),
  );
  $form['regcode_create']['regcode_create_code'] = array(
    '#type' => 'textfield',
    '#title' => t("Registration code"),
    '#description' => t('Leave blank to have code generated. Used as prefix when <em>Number of codes</em> is greater than 1.'),
  );
  $form['regcode_create']['regcode_create_maxuses'] = array(
    '#type' => 'textfield',
    '#title' => t("Maximum uses"),
    '#default_value' => 1,
    '#size' => 10,
    '#required' => TRUE,
    '#description' => t('How many times this code can be used to register (enter 0 for unlimited).'),
  );
  $form['regcode_create']['regcode_create_begins'] = array(
    '#type' => 'date',
    '#title' => t("Active from"),
    '#description' => t('When this code should activate (leave blank to activate immediately). Accepts any date format that strtotime can handle.'),
    '#default_value' => array(
      'day' => 0,
      'month' => 0,
      'year' => 0,
    ),
    '#after_build' => array(
      '_regcode_date_optional',
    ),
    '#element_validate' => array(
      '_regcode_date_validate',
    ),
  );
  $form['regcode_create']['regcode_create_expires'] = array(
    '#type' => 'date',
    '#title' => t("Expires on"),
    '#description' => t('When this code should expire (leave blank for no expiry). Accepts any date format that strtotime can handle.'),
    '#default_value' => array(
      'day' => 0,
      'month' => 0,
      'year' => 0,
    ),
    '#after_build' => array(
      '_regcode_date_optional',
    ),
    '#element_validate' => array(
      '_regcode_date_validate',
    ),
  );
  $params = array(
    '!url' => url('admin/structure/taxonomy/regcode'),
  );
  $form['regcode_create']['regcode_create_tags'] = array(
    '#type' => 'checkboxes',
    '#title' => t("Tags"),
    '#options' => regcode_get_vocab_terms(),
    '#description' => t('You may assign tags to help manage your codes (or <a href="!url">create some tags</a>).', $params),
  );

  // Bulk.
  $form['regcode_create_bulk'] = array(
    '#type' => 'fieldset',
    '#title' => t('Bulk creation'),
    '#description' => t('Multiple codes can be created at once, use these settings to configure the code generation.'),
  );
  $form['regcode_create_bulk']['regcode_create_number'] = array(
    '#type' => 'textfield',
    '#title' => t("Number of codes to generate"),
    '#size' => 10,
    '#default_value' => 1,
  );
  $form['regcode_create_bulk']['regcode_create_length'] = array(
    '#type' => 'textfield',
    '#title' => t("Code size"),
    '#size' => 10,
    '#default_value' => 10,
  );
  $form['regcode_create_bulk']['regcode_create_format'] = array(
    '#type' => 'select',
    '#default_value' => variable_get('regcode_generate_format', 'alpha'),
    '#title' => t('Format of the generated codes'),
    '#options' => array(
      'alpha' => t('Letters'),
      'numeric' => t('Numbers'),
      'alphanum' => t('Numbers & Letters'),
      'hexadec' => t('Hexadecimal'),
    ),
  );
  $form['regcode_create_bulk']['regcode_create_case'] = array(
    '#type' => 'checkbox',
    '#title' => t('Uppercase generated codes'),
    '#default_value' => variable_get('regcode_generate_case', ''),
  );
  $form['regcode_create_bulk_submit'] = array(
    '#type' => 'submit',
    '#value' => t("Create codes"),
  );
  return $form;
}