You are here

location_fax.install in Location 5.3

Installation routines.

File

contrib/location_fax/location_fax.install
View source
<?php

/**
 * @file
 * Installation routines.
 */

/**
 * Implementation of hook_install().
 */
function location_fax_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("\n      CREATE TABLE {location_fax} (\n        lid int(10) unsigned NOT NULL default '0',\n        fax varchar(31) default NULL,\n        PRIMARY KEY  (lid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;\n      ");
      break;
    case 'pgsql':
      db_query("\n        CREATE TABLE {location_fax} (\n          lid int NOT NULL default '0' CHECK (lid >= 0),\n          fax varchar(31) default NULL,\n          PRIMARY KEY  (lid)\n        )");
      break;
  }

  // Change weight so we execute after location.
  db_query("UPDATE {system} SET weight = 1 WHERE name = '%s' AND type = '%s'", 'location_fax', 'module');
  drupal_set_message(t('Installed tables for module location_fax'));
}

/**
 * Implementation of hook_uninstall().
 */
function location_fax_uninstall() {
  db_query('DROP TABLE {location_fax}');
}

/**
 * Location 3.0 update 1.
 * Fix pgsql -- The table definition was broken.
 */
function location_fax_update_5300() {
  $ret = array();
  if ($GLOBALS['db_type'] == 'pgsql') {

    // If the table wasn't created (i.e. error from previous install)
    if (!db_table_exists('location_fax')) {
      $ret[] = update_sql("\n        CREATE TABLE {location_fax} (\n          lid int NOT NULL default '0' CHECK (lid >= 0),\n          fax varchar(31) default NULL,\n          PRIMARY KEY (lid)\n        )");
    }
  }
  return $ret;
}

/**
 * Location 3.0 update 2.
 * Change weight of module.
 */
function location_fax_update_5301() {
  $ret = array();

  // This update was moved to update 5302.
  return $ret;
}

/**
 * Location 3.0 update 2.
 * Change weight of module.
 */
function location_fax_update_5302() {
  $ret = array();

  // Change weight.
  $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'location_fax' AND type = 'module'");
  return $ret;
}

Functions

Namesort descending Description
location_fax_install Implementation of hook_install().
location_fax_uninstall Implementation of hook_uninstall().
location_fax_update_5300 Location 3.0 update 1. Fix pgsql -- The table definition was broken.
location_fax_update_5301 Location 3.0 update 2. Change weight of module.
location_fax_update_5302 Location 3.0 update 2. Change weight of module.