You are here

xmlsitemap_term.install in XML sitemap 5.2

Same filename and directory in other branches
  1. 5 xmlsitemap_term/xmlsitemap_term.install

Install file for XML sitemap term

File

xmlsitemap_term/xmlsitemap_term.install
View source
<?php

/**
 * @file
 * Install file for XML sitemap term
 */

/*****************************************************************************
 * Drupal hooks.
 ****************************************************************************/

/**
 * Implementation of hook_install().
 */
function xmlsitemap_term_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {xmlsitemap_term} (\n        tid int,\n        last_changed int(11),\n        previously_changed int(11),\n        priority_override float,\n        PRIMARY KEY (tid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {xmlsitemap_term} (\n        tid integer,\n        last_changed integer,\n        previously_changed integer,\n        priority_override real,\n        PRIMARY KEY (tid)\n      );");
      break;
  }
}

/**
 * Implementation of hook_enable().
 */
function xmlsitemap_term_enable() {
  $weight = db_result(db_query("SELECT weight FROM {system} WHERE type = 'module' AND name = 'pathauto'"));
  if ($weight !== FALSE) {
    db_query("UPDATE {system} SET weight = %d WHERE type = 'module' AND name = 'xmlsitemap_term'", ++$weight);
  }
  db_query("\n    INSERT INTO {xmlsitemap_term} (tid, last_changed)\n    SELECT td.tid, %d FROM {term_data} td\n    LEFT JOIN {xmlsitemap_term} xt ON xt.tid = td.tid\n    WHERE xt.tid IS NULL\n  ", REQUEST_TIME);
  xmlsitemap_flag_sitemap();
}

/**
 * Implementation of hook_disable().
 */
function xmlsitemap_term_disable() {
  xmlsitemap_flag_sitemap();
}

/**
 * Implementation of hook_update_N().
 *
 * Drop the pid column now that we know how to join on the src index of the
 * url_alias table.
 */
function xmlsitemap_term_update_2() {
  return array(
    update_sql("ALTER TABLE {xmlsitemap_term} DROP pid"),
  );
}

/**
 * Implementation of hook_update_N().
 *
 * Force a sitemap update.
 */
function xmlsitemap_term_update_3() {
  variable_set('xmlsitemap_update', TRUE);
  return array(
    0 => array(
      'success' => TRUE,
      'query' => 'FORCE SITEMAP UPDATE',
    ),
  );
}

/**
 * Implementation of hook_uninstall().
 */
function xmlsitemap_term_uninstall() {
  db_query("DROP TABLE {xmlsitemap_term}");
  $settings = db_query("SELECT name FROM {variable} WHERE name LIKE 'xmlsitemap\\_term\\_%'");
  while ($variable = db_fetch_object($settings)) {
    variable_del($variable->name);
  }
}

Functions

Namesort descending Description
xmlsitemap_term_disable Implementation of hook_disable().
xmlsitemap_term_enable Implementation of hook_enable().
xmlsitemap_term_install Implementation of hook_install().
xmlsitemap_term_uninstall Implementation of hook_uninstall().
xmlsitemap_term_update_2 Implementation of hook_update_N().
xmlsitemap_term_update_3 Implementation of hook_update_N().