summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaslouski Yauheni2011-10-06 22:24:17 (GMT)
committer Maslouski Yauheni2011-10-06 22:24:17 (GMT)
commit0b5db0b6767e16482491b4b78d2e428bdf766046 (patch)
tree68502975cbdbd623942a4df8a642af6d954ad861
parent8fa4f13bfb8a6b8ebf52cd6bbdea29a644214710 (diff)
by Spleshka: foo captcha was ported to 7.x
-rw-r--r--foo_captcha/foo_capcha.admin.inc19
-rw-r--r--foo_captcha/foo_captcha.info7
-rw-r--r--foo_captcha/foo_captcha.install8
-rw-r--r--foo_captcha/foo_captcha.module31
4 files changed, 39 insertions, 26 deletions
diff --git a/foo_captcha/foo_capcha.admin.inc b/foo_captcha/foo_capcha.admin.inc
new file mode 100644
index 0000000..44e0a2e
--- /dev/null
+++ b/foo_captcha/foo_capcha.admin.inc
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * @file
+ * Functionality and helper functions for FOO CAPTCHA administration.
+ */
+
+/**
+ * Function for the settings form
+ */
+function foo_captcha_settings_form() {
+ $form = array();
+ $form['foo_captcha_ignore_spaces'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Ignore spaces in the response'),
+ '#default_value' => variable_get('foo_captcha_ignore_spaces', FALSE),
+ );
+ return system_settings_form($form);
+} \ No newline at end of file
diff --git a/foo_captcha/foo_captcha.info b/foo_captcha/foo_captcha.info
index f9d2349..69550fc 100644
--- a/foo_captcha/foo_captcha.info
+++ b/foo_captcha/foo_captcha.info
@@ -1,5 +1,6 @@
-name = "Foo CAPTCHA"
-description = "The foo CAPTCHA requires the user to enter the word 'foo'."
+name = Foo CAPTCHA
+description = The foo CAPTCHA requires the user to enter the word 'foo'.
package = "Spam control"
dependencies[] = captcha
-core = 6.x
+core = 7.x
+configure = admin/config/people/captcha/foo_captcha
diff --git a/foo_captcha/foo_captcha.install b/foo_captcha/foo_captcha.install
index 029de4c..62a82b3 100644
--- a/foo_captcha/foo_captcha.install
+++ b/foo_captcha/foo_captcha.install
@@ -1,7 +1,13 @@
<?php
/**
- * On uninstall: remove module variables and clear variable cache
+ * @file
+ * Install, update and uninstall functions for the FOO CAPTCHA module.
+ */
+
+/**
+ * Implements hook_uninstall().
+ * On uninstall: remove module variables and clear variables cache
*/
function foo_captcha_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'foo_captcha_%'");
diff --git a/foo_captcha/foo_captcha.module b/foo_captcha/foo_captcha.module
index 41a414a..399eeeb 100644
--- a/foo_captcha/foo_captcha.module
+++ b/foo_captcha/foo_captcha.module
@@ -1,51 +1,38 @@
<?php
/**
- * Implementation of hook_help().
+ * Implements hook_help().
*/
function foo_captcha_help($path, $arg) {
switch ($path) {
- case 'admin/user/captcha/foo_captcha':
- return '<p>'. t('This is a very simple CAPTCHA, which requires users to enter "foo" in a textfield.') .'</p>';
+ case 'admin/config/people/captcha/foo_captcha':
+ return '<p>' . t('This is a very simple CAPTCHA, which requires users to enter "foo" in a textfield.') . '</p>';
}
}
/**
- * Implementation of hook_menu().
+ * Implements hook_menu().
*/
function foo_captcha_menu() {
$items = array();
- $items['admin/user/captcha/foo_captcha'] = array(
+ $items['admin/config/people/captcha/foo_captcha'] = array(
'title' => 'Foo CAPTCHA',
'page callback' => 'drupal_get_form',
'page arguments' => array('foo_captcha_settings_form'),
'access arguments' => array('administer CAPTCHA settings'),
+ 'file' => 'foo_captcha.admin.inc',
'type' => MENU_LOCAL_TASK,
);
return $items;
}
/**
- * Function for the settings form
+ * Implements hook_captcha().
*/
-function foo_captcha_settings_form() {
- $form = array();
- $form['foo_captcha_ignore_spaces'] = array(
- '#type' => 'checkbox',
- '#title' => t('Ignore spaces in the response'),
- '#default_value' => variable_get('foo_captcha_ignore_spaces', FALSE),
- );
- return system_settings_form($form);
-}
-
-/**
- * Implementation of hook_captcha().
- */
-function foo_captcha_captcha($op, $captcha_type='') {
+function foo_captcha_captcha($op, $captcha_type = '') {
switch ($op) {
case 'list':
return array('Foo CAPTCHA');
- break;
case 'generate':
if ($captcha_type == 'Foo CAPTCHA') {
$captcha = array();
@@ -65,7 +52,7 @@ function foo_captcha_captcha($op, $captcha_type='') {
/**
* Process the response to the foo CAPTCHA before validation.
*/
-function foo_captcha_process($element, $edit, &$form_state, $complete_form) {
+function foo_captcha_process($element, $edit) {
if (variable_get('foo_captcha_ignore_spaces', FALSE)) {
$element['#value'] = preg_replace('/\s*/', '', $element['#value']);
}