You are here

function captcha_after_update_6001 in CAPTCHA After 6

Same name and namespace in other branches
  1. 7 captcha_after.install \captcha_after_update_6001()

Implementation of hook_update_N()

File

./captcha_after.install, line 59
Install, update and uninstall functions for the CAPTCHA After module.

Code

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;
}