You are here

profanity.install in Profanity 7

Install file for profanity.

File

profanity.install
View source
<?php

/**
 * @file
 * Install file for profanity.
 */

/**
 * Implements hook_schema().
 */
function profanity_schema() {
  $schema['profanity_list'] = array(
    'description' => 'Word lists for the Profanity module.',
    'export' => array(
      'key' => 'name',
      'key name' => 'Name',
      'primary key' => 'name',
      'admin_title' => 'title',
      'identifier' => 'list',
      // Function hook name.
      'default hook' => 'default_profanity_list',
      'api' => array(
        'owner' => 'profanity',
        'api' => 'default_profanity_lists',
        'minimum_version' => 1,
        'current_version' => 1,
      ),
    ),
    'fields' => array(
      'name' => array(
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
        'description' => 'Machine name.',
      ),
      'title' => array(
        'description' => 'The human-readable title for this list.',
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
        'default' => '',
      ),
      'words' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'replacement_mode' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'A number which indicates the replacement mode, characters repeated or replace with phrase.',
      ),
      'replacement_character' => array(
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
        'description' => 'Repeating character to replace bad words with.',
      ),
      'replacement_phrase' => array(
        'type' => 'varchar',
        'length' => '128',
        'not null' => TRUE,
        'description' => 'Replacement phrase for found bad words.',
      ),
      'case_sensitive' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'A boolean to indicate if this list should replace in a case sensitive manner.',
      ),
      'match_partial' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
        'description' => 'A boolean to indicate if the word filtering should only be done if the word is not part of another word.',
      ),
    ),
    'primary key' => array(
      'name',
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function profanity_uninstall() {
  variable_del('profanity_protect_the_titles');
  variable_del('profanity_title_entities');
  variable_del('profanity_title_lists');
  variable_del('profanity_protect_user_reg');
  variable_del('profanity_protect_user_reg_lists');
  variable_del('profanity_protect_user_reg_message');
  variable_del('profanity_supply_entity_properties');
  variable_del('profanity_supply_entity_properties_lists');
}

/**
 * Add the missing CTEX title field, remove incorrect id field and
 * switch up the index.
 */
function profanity_update_7100() {
  if (!db_field_exists('profanity_list', 'title')) {
    db_drop_index('profanity_list', 'name');
    db_drop_primary_key('profanity_list');
    db_add_primary_key('profanity_list', array(
      'name',
    ));
    db_drop_field('profanity_list', 'id');
    db_add_field('profanity_list', 'title', array(
      'description' => 'The human-readable title for this list.',
      'type' => 'varchar',
      'length' => '255',
      'not null' => FALSE,
      'default' => '',
    ));
    db_query('UPDATE {profanity_list} SET title = name');
  }
}

Functions

Namesort descending Description
profanity_schema Implements hook_schema().
profanity_uninstall Implements hook_uninstall().
profanity_update_7100 Add the missing CTEX title field, remove incorrect id field and switch up the index.