captcha_after.install in CAPTCHA After 6
Same filename and directory in other branches
Install, update and uninstall functions for the CAPTCHA After module.
File
captcha_after.installView 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() {
drupal_install_schema('captcha_after');
}
/**
* Implementation of hook_uninstall().
*/
function captcha_after_uninstall() {
drupal_uninstall_schema('captcha_after');
db_query("DELETE FROM {variable} WHERE name LIKE 'captcha_after_%'");
}
/**
* Implementation of hook_update_N()
*/
function captcha_after_update_6001() {
// Create table.
$items = array();
$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($items, '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) {
$items[] = update_sql('INSERT INTO {captcha_after} (form_id, enable) VALUES ("' . $form_id . '", 1)');
}
variable_del('captcha_after_forms');
return $items;
}
Functions
Name | 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() |