You are here

function spam_install_filter in Spam 5.3

Same name and namespace in other branches
  1. 6 spam.module \spam_install_filter()

Install the named spam filter, making it available for detecting spam content. It will be configured per any defaults defined by the filter.

Parameters

$filter array: array - must contain 'name' and 'module' elements

1 call to spam_install_filter()
spam_init_filters in ./spam.module
Check if any new spam filters are available for installation.

File

./spam.module, line 928

Code

function spam_install_filter($filter) {

  // Typically we install a filter that's never been installed before.  But
  // it's also possible to use this function to restore a filter to its default
  // settings.
  db_query("DELETE FROM {spam_filters} WHERE name = '%s' AND module = '%s'", $filter['name'], $filter['module']);
  $default['name'] = $filter['name'];
  $default['module'] = $filter['module'];
  $default['status'] = SPAM_FILTER_ENABLED;
  $default['weight'] = 0;
  $default['gain'] = 100;

  // Allow module to override defaults.  The module can also set other defaults
  // when this hook is called.
  $defaults = spam_invoke_module($filter['module'], 'filter_install', NULL, array(), array(), $default);
  foreach ($defaults as $key => $value) {
    $default[$key] = $value;
  }
  db_query("INSERT INTO {spam_filters} (name, module, status, weight, gain) VALUES('%s', '%s', %d, %d, %d)", $default['name'], $default['module'], $default['status'], $default['weight'], $default['gain']);
}