You are here

spambot.install in Spambot 7

Same filename and directory in other branches
  1. 8 spambot.install
  2. 6.3 spambot.install

Install and update hooks for Spambot module.

File

spambot.install
View source
<?php

/**
 * @file
 * Install and update hooks for Spambot module.
 */

/**
 * Implements hook_schema().
 */
function spambot_schema() {
  $schema['node_spambot'] = array(
    'description' => 'Node table to track author IP addresses. For use by spambot only.',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'hostname' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
    ),
  );
  $schema['cache_spambot'] = drupal_get_schema_unprocessed('system', 'cache');
  $schema['cache_spambot']['description'] = 'Cache table for the Spambot module to store responses from www.stopforumspam.com';
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function spambot_uninstall() {
  db_delete('variable')
    ->condition('name', 'spambot_%', 'LIKE')
    ->execute();
}

/**
 * Update variables, create new table 'node_spambot'.
 */
function spambot_update_7101() {
  $messages = array();
  variable_del('spambot_user_register_report');
  $messages[] = t('Deleted variable <em>spambot_user_register_report.</em>');
  $message = variable_get('spambot_blocked_message', FALSE);
  if ($message !== FALSE) {
    variable_set('spambot_blocked_message_email', $message);
    variable_set('spambot_blocked_message_username', $message);
    variable_set('spambot_blocked_message_ip', $message);
    variable_del('spambot_blocked_message');
    $messages[] = t('Transferred user registration blocked message to new format.');
  }

  // Create new table node_spambot.
  if (!db_table_exists('node_spambot')) {
    $node_spambot = array(
      'description' => t('Node table to track author IP addresses. For use by spambot only.'),
      'fields' => array(
        'nid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'uid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
          'default' => 0,
        ),
        'hostname' => array(
          'type' => 'varchar',
          'length' => 128,
          'not null' => FALSE,
        ),
      ),
      'primary key' => array(
        'nid',
      ),
      'indexes' => array(
        'uid' => array(
          'uid',
        ),
      ),
    );
    db_create_table('node_spambot', $node_spambot);
    $messages[] = t('Created new table <em>node_spambot</em>.');
  }
  return implode('<br />', $messages);
}

/**
 * Adds a cache table for storage of StopForumSpam.com responses.
 */
function spambot_update_7102() {
  if (!db_table_exists('cache_spambot')) {
    $schema = array();
    $schema['cache_spambot'] = drupal_get_schema_unprocessed('system', 'cache');
    $schema['cache_spambot']['description'] = 'Cache table for the Spambot module to store responses from www.stopforumspam.com';
    db_create_table('cache_spambot', $schema['cache_spambot']);
  }
}

Functions

Namesort descending Description
spambot_schema Implements hook_schema().
spambot_uninstall Implements hook_uninstall().
spambot_update_7101 Update variables, create new table 'node_spambot'.
spambot_update_7102 Adds a cache table for storage of StopForumSpam.com responses.