scanner.install 1.13 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
<?php
// $Id$

/**
 * @file
 * Search and Replace Scanner install - creates necessary tables.
 */

/**
 * Implementation of hook_install().
 */
function scanner_install() {
  $ret = array();

  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $ret[] = db_query("
        CREATE TABLE {scanner} (
          undo_id int(11) NOT NULL,
          undo_data longtext NOT NULL,
          undone tinyint(4) NOT NULL,
          searched varchar(256) NOT NULL,
          replaced varchar(256) NOT NULL,
          count int(11) NOT NULL,
          time int(11) NOT NULL,
          PRIMARY KEY  (undo_id)
        ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
      break;
  }

  if (!in_array(false, $ret)) {
    drupal_set_message(t('Scanner module installed successfully.'));
  }
  else {
    drupal_set_message(t('The installation of the scanner module was unsuccessful due to a database error. You may have to install the tables by hand.'), 'error');
  }
}

/**
 * Implementation of hook_uninstall().
 */
function scanner_uninstall() {
  db_query('DROP TABLE {scanner}');
  db_query("DELETE FROM {variable} WHERE name LIKE 'scanner_%'");
}