You are here

function captcha_update_6200 in CAPTCHA 7

Same name and namespace in other branches
  1. 6.2 captcha.install \captcha_update_6200()

Implements of hook_update_N().

File

./captcha.install, line 174
Install, update and uninstall functions for the CAPTCHA module.

Code

function captcha_update_6200() {
  $items = array();

  // Table for the CAPTCHA sessions.
  $schema['captcha_sessions'] = array(
    'description' => 'Stores the data about CAPTCHA sessions (solution, IP address, timestamp, ...).',
    'fields' => array(
      'csid' => array(
        'description' => 'CAPTCHA session ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => "User's {users}.uid.",
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'sid' => array(
        'description' => "Session ID of the user.",
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'ip_address' => array(
        'description' => 'IP address of the visitor.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
      ),
      'timestamp' => array(
        'description' => 'A Unix timestamp indicating when the challenge was generated.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'form_id' => array(
        'description' => 'The form_id of the form where the CAPTCHA is added to.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
      ),
      'solution' => array(
        'description' => 'Solution of the challenge.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'status' => array(
        'description' => 'Status of the CAPTCHA session (unsolved, solved, ...)',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'attempts' => array(
        'description' => 'The number of attempts.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'csid',
    ),
    'indexes' => array(
      'csid_ip' => array(
        'csid',
        'ip_address',
      ),
    ),
  );
  db_create_table($items, 'captcha_sessions', $schema['captcha_sessions']);
  return $items;
}