You are here

function riddler_settings in Captcha Riddler 6

Same name and namespace in other branches
  1. 5 riddler.module \riddler_settings()
  2. 7 riddler.module \riddler_settings()
1 string reference to 'riddler_settings'
riddler_menu in ./riddler.module
Implementation of hook_menu().

File

./riddler.module, line 53
Adds a question and answer type to the Captcha module.

Code

function riddler_settings() {
  $form = array();
  $form['riddler_weight'] = array(
    '#type' => 'select',
    '#title' => t('Weight'),
    '#default_value' => variable_get('riddler_weight', 0),
    '#options' => drupal_map_assoc(range(-10, 10)),
    '#description' => t('Weight of the Riddler form element'),
    '#required' => TRUE,
  );
  $form['riddler_groups'] = array(
    '#type' => 'fieldset',
    '#title' => t('Riddles'),
    '#description' => t('If you need more riddles, just submit the form, 3 empty riddles will appear.'),
  );
  $form['riddler_groups']['riddler_group_0'] = array(
    '#type' => 'fieldset',
    '#title' => variable_get('riddler_question_0', '') ? 'Default riddle: ' . variable_get('riddler_question_0', '') : t('Riddle !i', array(
      '!i' => 1,
    )),
    '#description' => t('Empty question and answer to erase this group.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['riddler_groups']['riddler_group_0']['riddler_question_0'] = array(
    '#type' => 'textfield',
    '#title' => t('Question'),
    '#description' => t('A question that you require anonymous users to answer'),
    '#default_value' => variable_get('riddler_question_0', 'Do you hate spam? (yes or no)'),
    '#required' => FALSE,
  );
  $form['riddler_groups']['riddler_group_0']['riddler_answer_0'] = array(
    '#type' => 'textfield',
    '#title' => t('Answer'),
    '#default_value' => variable_get('riddler_answer_0', 'yes'),
    '#description' => t('Answer to the above question. You may allow more than one correct answer by entering a comma or space-separated list. Answers are not case sensitive. Answers must be only one word.'),
    '#required' => FALSE,
  );
  $number = variable_get('riddler_number', 1);
  for ($i = 1; $i < $number + 3; $i++) {
    $form['riddler_groups']['riddler_group_' . $i] = array(
      '#type' => 'fieldset',
      '#title' => variable_get('riddler_question_' . $i, '') ? 'Riddle ' . $i . ': ' . variable_get('riddler_question_' . $i, '') : t('Riddle !i', array(
        '!i' => $i,
      )),
      '#description' => t('Empty question and answer to erase this group.'),
      '#collapsible' => TRUE,
      '#collapsed' => $i < $number,
    );
    $form['riddler_groups']['riddler_group_' . $i]['riddler_question_' . $i] = array(
      '#type' => 'textfield',
      '#title' => t('Question'),
      '#description' => t('A question that you require anonymous users to answer'),
      '#default_value' => variable_get('riddler_question_' . $i, ''),
      '#required' => FALSE,
    );
    $form['riddler_groups']['riddler_group_' . $i]['riddler_answer_' . $i] = array(
      '#type' => 'textfield',
      '#title' => t('Answer'),
      '#default_value' => variable_get('riddler_answer_' . $i, ''),
      '#description' => t('Answer to the above question. You may allow more than one correct answer by entering a comma or space-separated list. Answers are not case sensitive.  Answers must be only one word.'),
      '#required' => FALSE,
    );
  }
  $form['#validate'][] = 'riddler_settings_validate';
  $form['#submit'][] = 'riddler_settings_submit';
  return system_settings_form($form);
}