PHP Classes

File: engine/modules/contrib/captcha/captcha.hook.inc

Recommend this page to a friend!
  Classes of Aldo Tripiciano  >  Quanta CMS  >  engine/modules/contrib/captcha/captcha.hook.inc  >  Download  
File: engine/modules/contrib/captcha/captcha.hook.inc
Role: Example script
Content type: text/plain
Description: Example script
Class: Quanta CMS
Manage content that works without a database
Author: By
Last change:
Date: 3 years ago
Size: 1,176 bytes
 

Contents

Class file image Download
<?php
/**
 * Implements hook_load_includes().
 *
 * @param Environment $env
 * The Environment.
 *
 * @param $vars
 * An array of variables.
 */
function captcha_load_includes($env, $vars) {
 
$module_path = $env->getModulePath('captcha');
 
$env->addInclude($module_path . '/css/captcha.css');
}

/**
 * Implements hook_user_register().
 *
 * @param Environment $env
 * The Environment.
 *
 * @param $vars
 * An array of variables.
 */
function captcha_shadow_user_register($env, $vars) {
 
/** @var Shadow $shadow */
 
$shadow = $vars['shadow'];
 
$captcha = new Captcha($env, CAPTCHA_MATH);
 
$shadow->prependToTab(USER_ACTION_REGISTER, $captcha->render());
}

/**
 * Implements hook_user_validate().
 *
 * @param Environment $env
 * The Environment.
 *
 * @param $vars
 * An array of variables.
 */
function captcha_user_validate($env, $vars) {
  if (
$vars['user']->context == USER_ACTION_REGISTER) {
    if (!
Captcha::validate($vars['form_data']['edit-captcha'], $vars['form_data']['edit-captcha_math'])) {
     
$env->setData(USER_VALIDATION_ERROR, TRUE);
      new
Message($env, 'The math answer is not valid. Please retry', MESSAGE_WARNING);
    }
  }
}

For more information send a message to info at phpclasses dot org.