You are here

spam_filter_bayesian.install in Spam 6

Bayesian filter module install Copyright(c) 2007-2008 Jeremy Andrews <jeremy@tag1consulting.com>. All rights reserved.

Provides a generic Bayesian filter for use with other modules. Defines hooks for use with the Spam API.

File

filters/spam_filter_bayesian/spam_filter_bayesian.install
View source
<?php

/**
 * @file
 * Bayesian filter module install
 * Copyright(c) 2007-2008
 *  Jeremy Andrews <jeremy@tag1consulting.com>.  All rights reserved.
 *
 * Provides a generic Bayesian filter for use with other modules.
 *  Defines hooks for use with the Spam API.
 */

/**
 * Implementation of hook_schema().
 */
function spam_filter_bayesian_schema() {
  $schema['spam_filter_bayesian_tokens'] = array(
    'description' => t('TODO'),
    'fields' => array(
      'tid' => array(
        'description' => t('TODO'),
        'type' => 'serial',
        'unsigned' => 1,
        'not null' => TRUE,
      ),
      'class' => array(
        'description' => t('TODO'),
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'token' => array(
        'description' => t('TODO'),
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'yes_count' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => 1,
        'not null' => TRUE,
        'default' => 0,
      ),
      'no_count' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => 1,
        'not null' => TRUE,
        'default' => 0,
      ),
      'probability' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => 1,
        'not null' => TRUE,
        'default' => 0,
      ),
      'last' => array(
        'description' => t('TODO'),
        'type' => 'int',
        'unsigned' => 1,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'yes_count' => array(
        'yes_count',
      ),
      'no_count' => array(
        'no_count',
      ),
      'probability' => array(
        'probability',
      ),
      'last' => array(
        'last',
      ),
    ),
    'unique keys' => array(
      'token' => array(
        'class',
        'token',
      ),
    ),
    'primary key' => array(
      'tid',
    ),
  );
  return $schema;
}

/**
 * Install bayesian module schema.
 */
function spam_filter_bayesian_install() {

  // Create tables.
  drupal_install_schema('spam_filter_bayesian');
}

/**
 * Completely uninstall the spam module.
 */
function spam_filter_bayesian_uninstall() {

  // Remove tables.
  drupal_uninstall_schema('spam_filter_bayesian');
  variable_del('spam_filter_bayesian_overlap_cjk');
  variable_del('spam_filter_bayesian_minimum_token_length');
  variable_del('spam_filter_bayesian_tokenizer');
  variable_del('spam_filter_bayesian_default_probability');
  drupal_set_message(t('All bayesian module configuration data and tables have been deleted.'));
}

/**
 * Fix variable namespacing.
 */
function spam_filter_bayesian_update_6101() {
  $ret = array();
  $old_vars = array(
    'bayesian_default_probability',
    'bayesian_interesting_tokens',
    'bayesian_minimum_token_length',
    'bayesian_tokenizer',
  );
  foreach ($old_vars as $var) {
    $test = variable_get($var, null);
    if (!empty($test) && !strcmp(substr($var, 0, 12), "spam_filter_")) {
      $ret[] = update_sql('UPDATE {variables} SET name = %s WHERE name = %s', 'spam_filter_' . $var, $var);
    }
  }
  return $ret;
}

Functions

Namesort descending Description
spam_filter_bayesian_install Install bayesian module schema.
spam_filter_bayesian_schema Implementation of hook_schema().
spam_filter_bayesian_uninstall Completely uninstall the spam module.
spam_filter_bayesian_update_6101 Fix variable namespacing.