You are here

notify.install in Notify 5

File

notify.install
View source
<?php

/**
 * Implementation of hook_install()
 */
function notify_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $created = db_query("CREATE TABLE IF NOT EXISTS {notify} (\n        uid INT(10) UNSIGNED NOT NULL DEFAULT '0',\n        status TINYINT(2) NOT NULL DEFAULT '0',\n        node TINYINT(2) NOT NULL DEFAULT '0',\n        comment TINYINT(2) NOT NULL DEFAULT '0',\n        attempts TINYINT(4) NOT NULL DEFAULT '0',\n        teasers TINYINT(4) NOT NULL DEFAULT '0',\n        PRIMARY KEY (uid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $created = db_query("CREATE TABLE {notify} (\n        uid integer NOT NULL DEFAULT '0',\n        status integer NOT NULL DEFAULT '0',\n        node integer NOT NULL DEFAULT '0',\n        comment integer NOT NULL DEFAULT '0',\n        attempts integer NOT NULL DEFAULT '0',\n        teasers integer NOT NULL DEFAULT '0',\n        PRIMARY KEY (uid)\n      );");
      break;
  }
  if ($created) {
    drupal_set_message(t('Notify module installed successfully.'));
  }
  else {
    drupal_set_message(t('Table installation for the Notify module was unsuccessful. The tables may need to be installed by hand.'), 'error');
  }

  // Set the module weight so that the cron job will be executed after
  // scheduler if it is installed.
  $weight = (int) db_result(db_query("SELECT weight FROM {system} WHERE name = 'scheduler'"));
  $weight += 10;
  db_query("UPDATE {system} SET weight = %d WHERE name = 'notify'", $weight);
}

/**
 * Alter weight of notify to run after scheduler.
 */
function notify_update_1() {
  $ret = array();
  $weight = (int) db_result(db_query("SELECT weight FROM {system} WHERE name = 'scheduler'"));
  $weight += 10;

  // update_sql() doesn't take other parameters, but this is safe, since $weight
  // is guaranteed to be an integer.
  $ret[] = update_sql("UPDATE {system} SET weight = {$weight} WHERE name = 'notify'");
  return $ret;
}

Functions

Namesort descending Description
notify_install Implementation of hook_install()
notify_update_1 Alter weight of notify to run after scheduler.