summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaslouski Yauheni2011-10-06 23:56:45 (GMT)
committer Maslouski Yauheni2011-10-06 23:56:45 (GMT)
commit9070e08abe362fd94a70ed55b0afc09a81424198 (patch)
treee257689f3fde7e1ee70f234bc8f2ced29cbf251b
parent83d1014feedba2831879980bc6414db05b0397bb (diff)
by Spleshka: word list captcha was ported to 7.x7.x-1.0-alpha1
-rw-r--r--text_captcha/phrase_captcha/phrase_captcha.info2
-rw-r--r--text_captcha/phrase_captcha/phrase_captcha.install2
-rw-r--r--text_captcha/word_list_captcha/word_list_captcha.admin.inc17
-rw-r--r--text_captcha/word_list_captcha/word_list_captcha.info7
-rw-r--r--text_captcha/word_list_captcha/word_list_captcha.install8
-rw-r--r--text_captcha/word_list_captcha/word_list_captcha.module37
6 files changed, 43 insertions, 30 deletions
diff --git a/text_captcha/phrase_captcha/phrase_captcha.info b/text_captcha/phrase_captcha/phrase_captcha.info
index 93278d8..1295324 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 fd7d361..7a68250 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 956837d..6cef9c0 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 @@
<?php
/**
+ * @file
+ * Functionality and helper functions for WORD LIST CAPTCHA administration.
+ */
+
+/**
* Function for the settings form
*/
function word_list_captcha_settings_form() {
drupal_set_message(t('WARNING: this module is not completely ported to Drupal 6 and does not work yet.'), 'warning');
$form = array();
- // form element for the number of words in the word list
+ // Form element for the number of words in the word list
$form['word_list_captcha_list_size'] = array(
'#type' => '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 401c91a..9d405c4 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 60dff47..88f9033 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 @@
<?php
/**
- * On uninstall: remove module variables and clear variable cache
+ * @file
+ * Install, update and uninstall functions for the WORD LIST CAPTCHA module.
+ */
+
+/**
+ * Implements hook_uninstall().
+ * On uninstall: remove module variables and clear variables cache
*/
function word_list_captcha_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'word_list_captcha_%'");
diff --git a/text_captcha/word_list_captcha/word_list_captcha.module b/text_captcha/word_list_captcha/word_list_captcha.module
index f160b33..6090949 100644
--- a/text_captcha/word_list_captcha/word_list_captcha.module
+++ b/text_captcha/word_list_captcha/word_list_captcha.module
@@ -1,27 +1,27 @@
<?php
-require_once(drupal_get_path('module', 'word_list_captcha') .'/../text_captcha.inc');
+require_once(drupal_get_path('module', 'word_list_captcha') . '/../text_captcha.inc');
define('WORD_LIST_CAPTCHA_WORD_POOL1', 'green red blue yellow black white magenta cyan orange violet purple gold brown pink');
define('WORD_LIST_CAPTCHA_WORD_POOL2', 'bird elephant dog cat crocodile lion fish cow horse sheep frog beetle worm spider bat giraffe lizard goat monkey rabbit chimpanzee');
/**
- * Implementation of hook_help().
+ * Implements hook_help().
*/
function word_list_captcha_help($path, $arg) {
switch ($path) {
- case 'admin/user/captcha/word_list_captcha':
- return '<p>'. 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.') .'</p>';
+ case 'admin/config/people/captcha/word_list_captcha':
+ return '<p>' . 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.') . '</p>';
}
}
/**
- * 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;
}
}