You are here

function captcha_schema in CAPTCHA 8

Same name and namespace in other branches
  1. 6.2 captcha.install \captcha_schema()
  2. 6 captcha.install \captcha_schema()
  3. 7 captcha.install \captcha_schema()

Implements hook_schema().

File

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

Code

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