You are here

cas_server.install in CAS 5.4

Cas Server Schema Install

File

cas_server.install
View source
<?php

/**
 * @file Cas Server Schema Install 
 *
 */

/**
 * Inastall db tables. 
 *
 */
function cas_server_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':

      // the {tablename} syntax is so multisite installs can add a
      // prefix to the table name as set in the settings.php file
      db_query("CREATE TABLE {cas_server_tickets} (\n      service varchar(256) NOT NULL default '',\n\t\t  ticket varchar(256) NOT NULL default '',\n\t\t  uid int unsigned NOT NULL,\n\t\t  timestamp int NOT NULL, \n          PRIMARY KEY  (ticket)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {cas_server_tickets} (\n        service varchar(256) NOT NULL default '',\n        ticket varchar(256) NOT NULL default '',\n        uid integer NOT NULL CHECK (uid >= 0),\n        timestamp integer NOT NULL, \n          PRIMARY KEY  (ticket)\n        )");

      // Pgsql requires keys and indexes to be defined separately.
      // It's important to name the index as {tablename}_fieldname_idx
      // (the trailing _idx!) so update scripts can be written easily
      db_query("CREATE INDEX {cas_server_tickets}_uid_idx\n                ON {cas_server_tickets} (uid)");
      break;
  }
}
function cas_server_update_1() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $items = array();
      $items[] = update_sql("CREATE TABLE {cas_server_tickets} (\n      service varchar(256) NOT NULL default '',\n      ticket varchar(256) NOT NULL default '',\n      uid int unsigned NOT NULL,\n      timestamp int NOT NULL,\n        PRIMARY KEY  (ticket)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      return $items;
      break;
    case 'pgsql':
      $items = array();
      $items[] = update_sql("CREATE TABLE {cas_server_tickets} (\n          service varchar(256) NOT NULL default '',\n          ticket varchar(256) NOT NULL default '',\n       \t  uid integer NOT NULL CHECK (uid >= 0),\n       \t  timestamp integer NOT NULL, \n          PRIMARY KEY  (ticket)\n        )");

      // Pgsql requires keys and indexes to be defined separately.
      // It's important to name the index as {tablename}_fieldname_idx
      // (the trailing _idx!) so update scripts can be written easily
      $items[] = update_sql("CREATE INDEX {cas_server_tickets}_uid_idx\n                ON {cas_server_tickets} (uid)");
      return $items;
      break;
  }
}
function cas_server_uninstall() {
  if ($GLOBALS['db_type'] == 'pgsql') {
    db_query('DROP INDEX {cas_server_tickets}_uid_idx');
  }
  db_query('DROP TABLE {cas_server_tickets}');
}

Functions