You are here

xmlsitemap_user.install in XML sitemap 5.2

XML sitemap user install file

File

xmlsitemap_user/xmlsitemap_user.install
View source
<?php

/**
 * @file
 * XML sitemap user install file
 */

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

/**
 * Implementation of hook_enable().
 */
function xmlsitemap_user_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_user'", ++$weight);
  }
  db_query("INSERT INTO {xmlsitemap_user} (uid, last_changed)\n    SELECT u.uid, u.created FROM {users} u\n    LEFT JOIN {xmlsitemap_user} xu ON xu.uid = u.uid\n    WHERE u.uid <> 0 AND xu.uid IS NULL");
  db_query("INSERT INTO {xmlsitemap_user_role} (rid)\n    SELECT r.rid FROM {role} r\n    LEFT JOIN {xmlsitemap_user_role} xur ON xur.rid = r.rid\n    WHERE r.rid > 2 AND xur.rid IS NULL");
  xmlsitemap_flag_sitemap();
}

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

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

/**
 * Implementation of hook_update_N().
 */
function xmlsitemap_user_update_2() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE {xmlsitemap_user} DROP pid");
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {xmlsitemap_user_role} CHANGE priority priority float");
      break;
    case 'pgsql':
      db_change_column($ret, 'xmlsitemap_user_role', 'priority', 'priority', 'real');
      break;
  }
  return $ret;
}

/**
 * Implementation of hook_uninstall().
 */
function xmlsitemap_user_uninstall() {
  db_query("DROP TABLE {xmlsitemap_user}");
  db_query("DROP TABLE {xmlsitemap_user_role}");
  db_query("DELETE FROM {variable} WHERE name LIKE 'xmlsitemap\\_user\\_%'");
}

Functions

Namesort descending Description
xmlsitemap_user_disable Implementation of hook_disable().
xmlsitemap_user_enable Implementation of hook_enable().
xmlsitemap_user_install Implementation of hook_install().
xmlsitemap_user_uninstall Implementation of hook_uninstall().
xmlsitemap_user_update_2 Implementation of hook_update_N().