You are here

similar.install in Similar Entries 6.2

Installation hook implementations for Similar entries module.

File

similar.install
View source
<?php

/**
 * @file
 * Installation hook implementations for Similar entries module.
 */

/**
 * Implements hook_install().
 *
 * Add FULLTEXT index to MySQL MyISAM tables.
 * The module does not support InnoDB or PostgreSQL, so no changes for it.
 */
function similar_install() {
  include_once dirname(__FILE__) . '/similar.module';
  db_query('ALTER TABLE {node_revisions} ENGINE = MYISAM');
  db_query('ALTER TABLE {node_revisions} ADD FULLTEXT `similar_title` (`title`)');
  db_query('ALTER TABLE {node_revisions} ADD FULLTEXT `similar_body` (`body`)');
  similar_cron();
}

/**
 * Implements hook_uninstall().
 */
function similar_uninstall() {
  db_drop_index($ret, 'node_revisions', 'similar_title');
  db_drop_index($ret, 'node_revisions', 'similar_body');
  $ret = array();
  foreach (variable_get('similar_indices', array()) as $table => $column) {
    @db_drop_index($ret, $table, "similar_{$column}");
  }
  return $ret;
}

/**
 * Add a FULLTEXT index to the title and body fields in the node_revisions table.
 */
function similar_update_1() {
  $ret = array();
  $ret[] = update_sql('ALTER TABLE {node_revisions} DROP INDEX `title`, ADD FULLTEXT `similar` (`title`, `body`)');
  return $ret;
}

/**
 * Use D6's core block caching system and remove old custom cache config.
 * @link http://drupal.org/node/253299 @endlink
 */
function similar_update_6000() {
  variable_del('similar_cache');
  variable_del('similar_cache_lifetime');
  variable_del('similar_clear_on_insert');
  variable_del('similar_clear_on_update');
  variable_del('similar_clear_node_only');
  variable_del('similar_clear_on_delete');
  $ret = array();

  // 5 == BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE
  $ret[] = update_sql("UPDATE {blocks} SET cache = 5 WHERE module = 'similar'");
  return $ret;
}

/**
 * Remove the existing Similar entries block.
 */
function similar_update_6200() {
  variable_del('similar_node_types');
  variable_del('similar_num_display');
  variable_del('similar_rel_nofollow');
  variable_del('similar_taxonomy_filter');
  variable_del('similar_taxonomy_tids');
  variable_del('similar_teaser_enabled');
  $ret = array();
  $ret[] = update_sql("DELETE FROM {blocks} WHERE module = 'similar'");
  cache_clear_all('*', 'cache_block', TRUE);
  return $ret;
}

/**
 * Clear the Views cache to pick up new handler changes.
 */
function similar_update_6201() {
  cache_clear_all('*', 'cache_views', TRUE);
}

/**
 * Update indexes on node title and body fields.
 */
function similar_update_6202() {
  $ret = array();
  db_drop_index($ret, 'node_revisions', 'similar');
  db_query('ALTER TABLE {node_revisions} ADD FULLTEXT `similar_title` (`title`)');
  db_query('ALTER TABLE {node_revisions} ADD FULLTEXT `similar_body` (`body`)');
}

Functions

Namesort descending Description
similar_install Implements hook_install().
similar_uninstall Implements hook_uninstall().
similar_update_1 Add a FULLTEXT index to the title and body fields in the node_revisions table.
similar_update_6000 Use D6's core block caching system and remove old custom cache config. http://drupal.org/node/253299
similar_update_6200 Remove the existing Similar entries block.
similar_update_6201 Clear the Views cache to pick up new handler changes.
similar_update_6202 Update indexes on node title and body fields.