You are here

function captcha_point_admin_form in CAPTCHA 6

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. 7 captcha.admin.inc \captcha_point_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 187

Code

function captcha_point_admin_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 of the form to add the CAPTCHA to.'),
      '#value' => check_plain($captcha_point_form_id),
      '#disabled' => TRUE,
    );
    $result = db_query("SELECT * FROM {captcha_points} WHERE form_id = '%s'", $captcha_point_form_id);
    $captcha_point = db_fetch_object($result);
    if ($captcha_point) {
      $default_captcha_type = "{$captcha_point->module}/{$captcha_point->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 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/user/captcha';

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