You are here

spambot.install in Spambot 6.3

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

File

spambot.install
View source
<?php

/**
 * Implementation of hook_schema().
 */
function spambot_schema() {
  $schema = array();
  $schema['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',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install().
 */
function spambot_install() {
  drupal_install_schema('spambot');
}

/**
 * Implementation of hook_uninstall().
 */
function spambot_uninstall() {
  db_query("DELETE FROM {variable} WHERE name LIKE 'spambot_%'");
  drupal_uninstall_schema('spambot');
}

/**
 * Migrate settings from previous version of spambot (6.x-2.0)
 */
function spambot_update_6300() {
  $ret = array();

  // In previous versions of spambot, the default message was 'Blacklisted. Now go away!'
  // If no custom message was configured, then configure it to 'Blacklisted. Now go away!'
  $message = variable_get('spambot_blocked_message', FALSE);
  if (!$message) {
    variable_set('spambot_blocked_message', t('Blacklisted. Now go away!'));
  }

  // Previous versions of spambot blacklisted on any of the three criteria
  variable_set('spambot_criteria_email', TRUE);
  variable_set('spambot_criteria_username', TRUE);
  variable_set('spambot_criteria_ip', TRUE);
  return $ret;
}
function spambot_update_6301() {
  $ret = array();

  // Change criteria settings from booleans to numbers
  if (variable_set('spambot_criteria_email', TRUE)) {
    variable_set('spambot_criteria_email', 1);
  }
  if (variable_set('spambot_criteria_username', FALSE)) {
    variable_set('spambot_criteria_username', 1);
  }
  if (variable_set('spambot_criteria_ip', FALSE)) {
    variable_set('spambot_criteria_ip', 1);
  }
  return $ret;
}
function spambot_update_6302() {
  $ret = array();
  variable_del('spambot_user_register_report');
  $ret[] = array(
    'success' => TRUE,
    'query' => 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');
    $ret[] = array(
      'success' => TRUE,
      'query' => t('Transferred user registration blocked message to new format.'),
    );
  }

  // Create new table node_spambot
  $schema = array();
  $schema['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($ret, 'node_spambot', $schema['node_spambot']);
  return $ret;
}

Functions

Namesort descending Description
spambot_install Implementation of hook_install().
spambot_schema Implementation of hook_schema().
spambot_uninstall Implementation of hook_uninstall().
spambot_update_6300 Migrate settings from previous version of spambot (6.x-2.0)
spambot_update_6301
spambot_update_6302