You are here

function captcha_after_update_6001 in CAPTCHA After 7

Same name and namespace in other branches
  1. 6 captcha_after.install \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.

File

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

Code

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