You are here

botcha.module in BOTCHA Spam Prevention 6.4

BOTCHA - Spam Prevention It modifies forms by adding various botcha's.

File

botcha.module
View source
<?php

/**
 * @file
 * BOTCHA - Spam Prevention
 * It modifies forms by adding various botcha's.
 */
function botcha_boot() {

  // It is necessary to be loaded during bootstrap.
}

/**
 * Process form callback for BOTCHA form.
 * Using hooking mechanism that is a hack - we want to come in before #process,
 * but our _form_alter() is way too early (we want to let it use cache for all other
 * modules & data). Ideal would be to have #process callback
 * work on the form, but FAPI does not call it on forms, despite the
 * documentation stating that it does. In fact, D6 code needs '#input'=TRUE on
 * the element to get into calling #process callbacks. So we set '#input'=>TRUE
 * on the form when inserting our callback into form['#process'], and it forces
 * the FAPI to call that code path and we get our intercept. Works like a charm!
 */
function botcha_fprocess($element, $edit, &$form_state, $complete_form) {

  // Prevent caching of the page with BOTCHA elements.
  // This needs to be done even if the BOTCHA will be ommitted later:
  // other untrusted users should not get a cached page.
  global $conf;
  $conf['cache'] = CACHE_DISABLED;

  // This temporarily disables cache (for this page request)
  unset($element['#cache']);
  return $element;
}
function botcha_system_info_alter(&$info, $file) {
  switch ($file->name) {
    case 'botcha_base':

      // Replace with appropriate version.
      $info['core'] = '6.x';

      // Add additional dependencies.
      $additional_dependencies = array(
        'autoload',
        'dbtng',
      );
      foreach ($additional_dependencies as $additional_dependency) {
        if (!in_array($additional_dependency, $info['dependencies'])) {
          $info['dependencies'][] = $additional_dependency;
        }
      }
      break;
    case 'botcha':
      if (!in_array('botcha_base', $info['dependencies'])) {

        // Add a dependency after enabling.
        $info['dependencies'][] = 'botcha_base';
      }
      break;
  }
}

// END

Functions

Namesort descending Description
botcha_boot @file BOTCHA - Spam Prevention It modifies forms by adding various botcha's.
botcha_fprocess Process form callback for BOTCHA form. Using hooking mechanism that is a hack - we want to come in before #process, but our _form_alter() is way too early (we want to let it use cache for all other modules & data). Ideal would be to have #process…
botcha_system_info_alter