You are here

function captcha_point_admin_form in CAPTCHA 7

Same name and namespace in other branches
  1. 5.3 captcha.module \captcha_point_admin_form()
  2. 6.2 captcha.admin.inc \captcha_point_admin_form()
  3. 6 captcha.admin.inc \captcha_point_admin_form()

Admin form.

1 string reference to 'captcha_point_admin_form'
captcha_point_admin in ./captcha.admin.inc
Central handler for CAPTCHA point administration (adding, disabling, deleting).

File

./captcha.admin.inc, line 449
Functionality and helper functions for CAPTCHA administration.

Code

function captcha_point_admin_form($form, $form_state, $captcha_point_form_id = NULL) {
  $form = array();
  $default_captcha_type = 'none';
  if (isset($captcha_point_form_id)) {

    // Use given CAPTCHA point form_id.
    $form['captcha_point_form_id'] = array(
      '#type' => 'textfield',
      '#title' => t('Form ID'),
      '#description' => t('The Drupal form_id or base_form_id of the form to add the CAPTCHA to.'),
      '#value' => check_plain($captcha_point_form_id),
      '#disabled' => TRUE,
    );
    $captcha_point = captcha_get_form_id_setting($captcha_point_form_id);
    if ($captcha_point) {
      $default_captcha_type = "{$captcha_point->module}/{$captcha_point->captcha_type}";
    }
  }
  else {

    // Textfield for CAPTCHA point form_id.
    $form['captcha_point_form_id'] = array(
      '#type' => 'textfield',
      '#title' => t('Form ID'),
      '#description' => t('The Drupal form_id or base_form_id of the form to add the CAPTCHA to.'),
    );
  }

  // Select widget for CAPTCHA type.
  $form['captcha_type'] = array(
    '#type' => 'select',
    '#title' => t('Challenge type'),
    '#description' => t('The CAPTCHA type to use for this form.'),
    '#default_value' => $default_captcha_type,
    '#options' => _captcha_available_challenge_types(),
  );

  // Redirect to general CAPTCHA settings page after submission.
  $form['#redirect'] = 'admin/config/people/captcha';

  // Submit button.
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}