Parcourir la source

Add custom ffdn_common module with captcha implementation.

opi il y a 8 ans
Parent
commit
3ff792608f

+ 5 - 0
sites/all/modules/custom/ffdn_common/ffdn_common.info

@@ -0,0 +1,5 @@
+name = FFDN Common module
+description = Common module for ffdn.org website
+package = Custom
+;dependencies[] = captcha
+core = 7.x

+ 43 - 0
sites/all/modules/custom/ffdn_common/ffdn_common.module

@@ -0,0 +1,43 @@
+<?php
+
+
+
+
+/* *********************************************************************
+ * DEFINES, INCLUDES & INIT
+ * ********************************************************************/
+
+define('FFDN_CUSTOM_CAPTCHA', "FFDN Custom CAPTCHA");
+
+
+
+
+
+/* *********************************************************************
+ * CAPTCHA
+ * ********************************************************************/
+
+/**
+ * Implementation of hook_captcha().
+ */
+function ffdn_common_captcha($op, $captcha_type='') {
+  switch ($op) {
+    case 'list':
+      return array(
+        FFDN_CUSTOM_CAPTCHA
+      );
+    case 'generate':
+      if ($captcha_type == FFDN_CUSTOM_CAPTCHA) {
+        $captcha = array();
+        $captcha['solution'] = 'FFDN';
+        $captcha['form']['captcha_response'] = array(
+          '#type' => 'textfield',
+          '#title' => t("What is the Federation FDN's acronym? (4 letters)"),
+          '#description' => t("This is a basic anti-spam system ;)"),
+          '#required' => TRUE,
+        );
+        return $captcha;
+      }
+      break;
+  }
+}