diff --git a/text_captcha/phrase_captcha/phrase_captcha.info b/text_captcha/phrase_captcha/phrase_captcha.info index 93278d8e7d3e1d43dc18e95037bf9aba73ec6952..129532456295184bf03c06ebedd4778f40a7161b 100644 --- a/text_captcha/phrase_captcha/phrase_captcha.info +++ b/text_captcha/phrase_captcha/phrase_captcha.info @@ -3,4 +3,4 @@ description = Provides CAPTCHA that requires to pick for the right word/characte package = "Spam control" dependencies[] = captcha core = 7.x -configure = admin/config/people/captcha/phrase_captcha \ No newline at end of file +configure = admin/config/people/captcha/phrase_captcha diff --git a/text_captcha/phrase_captcha/phrase_captcha.install b/text_captcha/phrase_captcha/phrase_captcha.install index fd7d361f1b3576dd8a4df0325646db7432679979..7a68250246bd76a959abf746893a2fd522989f0e 100644 --- a/text_captcha/phrase_captcha/phrase_captcha.install +++ b/text_captcha/phrase_captcha/phrase_captcha.install @@ -2,7 +2,7 @@ /** * @file - * Install, update and uninstall functions for the Phrase captcha CAPTCHA module. + * Install, update and uninstall functions for the PHRASE CAPTCHA module. */ /** diff --git a/text_captcha/word_list_captcha/word_list_captcha.admin.inc b/text_captcha/word_list_captcha/word_list_captcha.admin.inc index 956837d8432beb30101afbad5e55d78cb002b131..6cef9c08914568cd465adbfbffc5025f3927a112 100644 --- a/text_captcha/word_list_captcha/word_list_captcha.admin.inc +++ b/text_captcha/word_list_captcha/word_list_captcha.admin.inc @@ -1,19 +1,24 @@ 'select', '#title' => t('Number of words in word list'), '#default_value' => variable_get('word_list_captcha_list_size', 5), - '#options' => array(4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10), + '#options' => drupal_map_assoc(array(4, 5, 6, 7, 8, 9, 10)), ); - // form elements for the word pools + // Form elements for the word pools _text_captcha_word_pool_form_items($form, 'word_list_captcha_word_pool_1', t('Word pool @num', array('@num' => 1)), @@ -28,9 +33,9 @@ function word_list_captcha_settings_form() { WORD_LIST_CAPTCHA_WORD_POOL2, 2 ); - // add additional validation handler + // Add additional validation handler $form['#validate'][] = 'word_list_captcha_settings_form_validate'; - // add buttons and return + // Add buttons and return return system_settings_form($form); } @@ -38,7 +43,7 @@ function word_list_captcha_settings_form() { * Validation function for the settings form */ function word_list_captcha_settings_form_validate($form, &$form_state) { - // check the number of words in the pools + // Check the number of words in the pools $list_size = (int) $form_state['values']['word_list_captcha_list_size']; _text_captcha_word_pool_validate('word_list_captcha_word_pool_1', $form_state['values'], $list_size, 0, ''); _text_captcha_word_pool_validate('word_list_captcha_word_pool_2', $form_state['values'], $list_size, 0, ''); diff --git a/text_captcha/word_list_captcha/word_list_captcha.info b/text_captcha/word_list_captcha/word_list_captcha.info index 401c91aae523eed6200d7b9f83b359537c1b7d30..9d405c49dcda4f4a2f0a748dad72d360797c0a81 100644 --- a/text_captcha/word_list_captcha/word_list_captcha.info +++ b/text_captcha/word_list_captcha/word_list_captcha.info @@ -1,5 +1,6 @@ -name = "Word list CAPTCHA" -description = "Provides CAPTCHA like 'which word does not belong in the list [green red bird blue]?'." +name = Word list CAPTCHA +description = Provides CAPTCHA like 'which word does not belong in the list [green red bird blue]?'. package = "Spam control" dependencies[] = captcha -core = 6.x \ No newline at end of file +core = 7.x +configure = admin/config/people/captcha/word_list_captcha \ No newline at end of file diff --git a/text_captcha/word_list_captcha/word_list_captcha.install b/text_captcha/word_list_captcha/word_list_captcha.install index 60dff47d66306f782e95feb86f81d7951a78c0c4..88f903349c537544396d3edbf0b7f6de2887a893 100644 --- a/text_captcha/word_list_captcha/word_list_captcha.install +++ b/text_captcha/word_list_captcha/word_list_captcha.install @@ -1,7 +1,13 @@ '. t('The unrelated word CAPTCHA consists of a list of closely related words with one non-related word, which the user has to select. To generate this list, two word pools are needed: one for the related words and one for the non-related word.') .'

'; + case 'admin/config/people/captcha/word_list_captcha': + return '

' . t('The unrelated word CAPTCHA consists of a list of closely related words with one non-related word, which the user has to select. To generate this list, two word pools are needed: one for the related words and one for the non-related word.') . '

'; } } /** - * Implementation of hook_menu(). + * Implements hook_menu(). */ function word_list_captcha_menu() { $items = array(); - // add an administration tab for phrase_captcha - $items['admin/user/captcha/word_list_captcha'] = array( + // Add an administration tab for phrase_captcha + $items['admin/config/people/captcha/word_list_captcha'] = array( 'title' => 'Unrelated word', 'file' => 'word_list_captcha.admin.inc', 'page callback' => 'drupal_get_form', @@ -33,7 +33,7 @@ function word_list_captcha_menu() { } /** - * helper function for generating a word list CAPTCHA + * Helper function for generating a word list CAPTCHA */ function _word_list_captcha_get_word_list_captcha($list_size) { if (mt_rand(0, 1)) { @@ -53,18 +53,18 @@ function _word_list_captcha_get_word_list_captcha($list_size) { } /** - * Implementation of hook_captcha(). + * Implements hook_captcha(). */ -function word_list_captcha_captcha($op, $captcha_type='', $post_data=array()) { +function word_list_captcha_captcha($op, $captcha_type = '') { switch ($op) { case 'list': return array('Pick the unrelated word'); break; case 'generate': if ($captcha_type == 'Pick the unrelated word') { - $list_size = (int) variable_get('word_list_captcha_list_size', 5); + $list_size = variable_get('word_list_captcha_list_size', 5); list($word_list, $wrong_word) = _word_list_captcha_get_word_list_captcha($list_size); - // build options list + // Build options list $options = array(); foreach ($word_list as $word) { $options[$word] = $word; @@ -75,10 +75,10 @@ function word_list_captcha_captcha($op, $captcha_type='', $post_data=array()) { '#type' => 'radios', '#title' => t('Which word does not belong to the list?'), '#options' => $options, - // extra class needed for additional CSS'ing of the options - '#attributes' => array('class' => 'text-captcha-word-list-radios'), + // Extra class needed for additional CSS'ing of the options + '#attributes' => array('class' => array('text-captcha-word-list-radios')), // TODO: the following needs to be ported to Drupal 6, which does not - // support DANGEROUS_SKIP_CHECK anymore + // Support DANGEROUS_SKIP_CHECK anymore // // The following entry '#DANGEROUS_SKIP_CHECK' is needed to prevent // that Drupal checks during validation phase if a submitted option @@ -89,10 +89,11 @@ function word_list_captcha_captcha($op, $captcha_type='', $post_data=array()) { '#DANGEROUS_SKIP_CHECK' => TRUE, // '#required' => TRUE, ); - // additional text CAPTCHA CSS rules - drupal_add_css(drupal_get_path('module', 'word_list_captcha') .'/../text_captcha.css'); + // Add css to form + $captcha['#attached']['css'] = array( + drupal_get_path('module', 'word_list_captcha') . '/../text_captcha.css', + ); return $captcha; } - break; } }