You are here

captcha_after.install in CAPTCHA After 7

Same filename and directory in other branches
  1. 6 captcha_after.install

Install, update and uninstall functions for the CAPTCHA After module.

File

captcha_after.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the CAPTCHA After module.
 */

/**
 * Implementation of hook_schema().
 */
function captcha_after_schema() {
  $schema['captcha_after'] = array(
    'description' => 'This table holds configuration option for captcha_after forms.',
    'fields' => array(
      'form_id' => array(
        'description' => 'The form_id of the form to add a CAPTCHA to.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'enable' => array(
        'description' => 'Is captcha_after enabled for this form.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'size' => 'tiny',
      ),
      'options' => array(
        'description' => 'captcha_after options for form.',
        'type' => 'text',
        'size' => 'medium',
      ),
    ),
    'primary key' => array(
      'form_id',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function captcha_after_install() {
}

/**
 * Implementation of hook_uninstall().
 */
function captcha_after_uninstall() {
  db_query("DELETE FROM {variable} WHERE name LIKE 'captcha_after_%'");
}

/**
 * Implementation of hook_update_N()
 * Update from 6.x-1.0 to 6.x-2.x. Update number was maded 6001 by error, it 
 * should be 6200. 
 */
function captcha_after_update_6001() {

  // Create table.
  $schema['captcha_after'] = array(
    'description' => 'This table holds configuration option for captcha_after forms.',
    'fields' => array(
      'form_id' => array(
        'description' => 'The form_id of the form to add a CAPTCHA to.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'enable' => array(
        'description' => 'Is captcha_after enabled for this form.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'size' => 'tiny',
      ),
      'options' => array(
        'description' => 'captcha_after options for form.',
        'type' => 'text',
        'size' => 'medium',
      ),
    ),
    'primary key' => array(
      'form_id',
    ),
  );
  db_create_table('captcha_after', $schema['captcha_after']);

  // Transfer data from captcha_after_forms variable to new table;
  $captcha_after_forms = variable_get('captcha_after_forms', array());
  foreach ($captcha_after_forms as $form_id) {
    db_insert('captcha_after')
      ->fields(array(
      'form_id' => $form_id,
      'enable' => 1,
    ))
      ->execute();
  }
  variable_del('captcha_after_forms');
}

Functions

Namesort descending Description
captcha_after_install Implementation of hook_install().
captcha_after_schema Implementation of hook_schema().
captcha_after_uninstall Implementation of hook_uninstall().
captcha_after_update_6001 Implementation of hook_update_N() Update from 6.x-1.0 to 6.x-2.x. Update number was maded 6001 by error, it should be 6200.