You are here

function notify_install in Notify 5

Same name and namespace in other branches
  1. 5.2 notify.install \notify_install()
  2. 6 notify.install \notify_install()

Implementation of hook_install()

File

./notify.install, line 6

Code

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);
}