You are here

node_expire.install in Node expire 5

File

node_expire.install
View source
<?php

/**
 * Implamentation of hook_install()
 */
function node_expire_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {node_expire} (\n        nid int(10) unsigned NOT NULL,\n        expire datetime default NULL,\n        expiresec varchar(10) NOT NULL,\n        expiremode enum('date','onupdate','none') NOT NULL default 'none',\n        isroot tinyint(1) unsigned NOT NULL default '0',\n        lastnotify int(10) unsigned NOT NULL default '0',\n        PRIMARY KEY  (nid),\n        KEY expire (expire),\n        KEY expiremode (expiremode),\n        KEY lastnotify (lastnotify)\n      );");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {node_expire} (\n        nid int_unsigned NOT NULL,\n        expire timestamp without time zone,\n        expiresec character varying(10) NOT NULL,\n        expiremode character varying(8) NOT NULL DEFAULT 'none'::character varying CHECK(expiremode IN('date','onupdate','none')),\n        isroot smallint_unsigned NOT NULL DEFAULT 0::smallint,\n        lastnotify int_unsigned NOT NULL DEFAULT 0,\n        CONSTRAINT node_expire_pkey PRIMARY KEY (nid)\n      );");
      db_query("CREATE INDEX expire ON {node_expire} USING btree (expire);");
      db_query("CREATE INDEX expiremode ON {node_expire} USING btree (expiremode);");
      db_query("CREATE INDEX lastnotify ON node_expire USING btree (lastnotify);");
      break;
  }
}

/**
 * Migrate from old HEAD revision to my new version.
 */
function node_expire_update_1() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {node_expire}\n        CHANGE nid nid INT( 10 ) NOT NULL,\n        ADD expiresec VARCHAR(10) NOT NULL,\n        ADD expiremode ENUM( 'date', 'onupdate', 'none' ) NOT NULL DEFAULT 'none',\n        ADD isroot TINYINT( 1 ) NOT NULL DEFAULT '0',\n        ADD lastnotify INT( 10 ) NOT NULL DEFAULT '0',\n        DROP INDEX nid,\n        ADD PRIMARY KEY (nid);");
      break;
  }

  // The old version didn't have the e-mail feature so
  // let's disable it by default. The end user can always
  // reenable it later.
  variable_set('node-expire-enable-email', 0);
  return $ret;
}

/**
 * Handle database changes from 5.x-1.1
 */
function node_expire_update_2() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {node_expire}\n        CHANGE isroot isroot TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',\n        CHANGE lastnotify lastnotify INT( 10 ) UNSIGNED NOT NULL DEFAULT '0',\n        ADD INDEX (expire),\n        ADD INDEX (expiremode),\n        ADD INDEX (lastnotify);");
      break;
  }
  return $ret;
}

/**
 * Implamentation of hook_uninstall()
 */
function node_expire_uninstall() {
  db_query('DROP TABLE {node_expire}');
  variable_del('node-expire-body');
  variable_del('node-expire-book-props');
  variable_del('node-expire-cc');
  variable_del('node-expire-enable-email');
  variable_del('node-expire-node-visibility');
  variable_del('node-expire-renotify');
  variable_del('node-expire-subject');
  variable_del('node-expire-unpublishtime');
}

Functions

Namesort descending Description
node_expire_install Implamentation of hook_install()
node_expire_uninstall Implamentation of hook_uninstall()
node_expire_update_1 Migrate from old HEAD revision to my new version.
node_expire_update_2 Handle database changes from 5.x-1.1