You are here

function imagecache_install in ImageCache 5

Same name and namespace in other branches
  1. 5.2 imagecache.install \imagecache_install()
  2. 6.2 imagecache.install \imagecache_install()

File

./imagecache.install, line 3

Code

function imagecache_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret1 = db_query('CREATE TABLE {imagecache_preset} (
            presetid INT UNSIGNED NOT NULL PRIMARY KEY,
            presetname VARCHAR(255) NOT NULL DEFAULT \'\' )
            /*!40100 DEFAULT CHARACTER SET utf8 */');
      $ret2 = db_query('CREATE TABLE {imagecache_action} (
            actionid INT UNSIGNED NOT NULL PRIMARY KEY,
            presetid INT UNSIGNED NOT NULL DEFAULT 0,
            weight INT NOT NULL DEFAULT 0,
            data TEXT NOT NULL)
            /*!40100 DEFAULT CHARACTER SET utf8 */');
      break;
    case 'pgsql':
      $ret1 = db_query('CREATE TABLE {imagecache_preset} (
            presetid INTEGER NOT NULL CHECK (presetid > 0),
            presetname VARCHAR(255) NOT NULL DEFAULT \'\',
            PRIMARY KEY (presetid));');
      $ret2 = db_query('CREATE TABLE {imagecache_action} (
            actionid INTEGER NOT NULL CHECK (actionid > 0),
            presetid INTEGER NOT NULL DEFAULT 0,
            weight INTEGER NOT NULL DEFAULT 0,
            data TEXT NOT NULL DEFAULT \'\',
            PRIMARY KEY (actionid));');
      db_query("CREATE SEQUENCE imagecache_preset_presetid_seq INCREMENT 1 START 1;");
      db_query("CREATE SEQUENCE imagecache_action_actionid_seq INCREMENT 1 START 1;");
      break;
  }
  if ($ret1 && $ret2) {
    drupal_set_message(t('Imagecache module installed succesfully.'));
  }
  else {
    drupal_set_message(t('Imagecache module installation was unsuccessfull. Necessary database tables should be created by hand.', 'error'));
  }
  return $ret;
}