| 1 |
<?php
|
| 2 |
// $Id: cas_server.install,v 1.44 2008/07/31 15:20:41 metzlerd Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file Cas Server Schema Install
|
| 6 |
*
|
| 7 |
*/
|
| 8 |
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Inastall db tables.
|
| 12 |
*
|
| 13 |
*/
|
| 14 |
function cas_server_install() {
|
| 15 |
switch ($GLOBALS['db_type']) {
|
| 16 |
case 'mysql':
|
| 17 |
case 'mysqli':
|
| 18 |
// the {tablename} syntax is so multisite installs can add a
|
| 19 |
// prefix to the table name as set in the settings.php file
|
| 20 |
db_query("CREATE TABLE {cas_server_tickets} (
|
| 21 |
service varchar(256) NOT NULL default '',
|
| 22 |
ticket varchar(256) NOT NULL default '',
|
| 23 |
uid int unsigned NOT NULL,
|
| 24 |
timestamp int NOT NULL,
|
| 25 |
PRIMARY KEY (ticket)
|
| 26 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 27 |
break;
|
| 28 |
|
| 29 |
case 'pgsql':
|
| 30 |
db_query("CREATE TABLE {cas_server_tickets} (
|
| 31 |
service varchar(256) NOT NULL default '',
|
| 32 |
ticket varchar(256) NOT NULL default '',
|
| 33 |
uid integer NOT NULL CHECK (uid >= 0),
|
| 34 |
timestamp integer NOT NULL,
|
| 35 |
PRIMARY KEY (ticket)
|
| 36 |
)");
|
| 37 |
|
| 38 |
// Pgsql requires keys and indexes to be defined separately.
|
| 39 |
// It's important to name the index as {tablename}_fieldname_idx
|
| 40 |
// (the trailing _idx!) so update scripts can be written easily
|
| 41 |
db_query("CREATE INDEX {cas_server_tickets}_uid_idx
|
| 42 |
ON {cas_server_tickets} (uid)");
|
| 43 |
break;
|
| 44 |
}
|
| 45 |
}
|
| 46 |
|
| 47 |
function cas_server_update_1() {
|
| 48 |
switch ($GLOBALS['db_type']) {
|
| 49 |
case 'mysql':
|
| 50 |
case 'mysqli':
|
| 51 |
$items = array();
|
| 52 |
$items[] = update_sql("CREATE TABLE {cas_server_tickets} (
|
| 53 |
service varchar(256) NOT NULL default '',
|
| 54 |
ticket varchar(256) NOT NULL default '',
|
| 55 |
uid int unsigned NOT NULL,
|
| 56 |
timestamp int NOT NULL,
|
| 57 |
PRIMARY KEY (ticket)
|
| 58 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 59 |
return $items;
|
| 60 |
break;
|
| 61 |
|
| 62 |
case 'pgsql':
|
| 63 |
$items = array();
|
| 64 |
$items[] = update_sql("CREATE TABLE {cas_server_tickets} (
|
| 65 |
service varchar(256) NOT NULL default '',
|
| 66 |
ticket varchar(256) NOT NULL default '',
|
| 67 |
uid integer NOT NULL CHECK (uid >= 0),
|
| 68 |
timestamp integer NOT NULL,
|
| 69 |
PRIMARY KEY (ticket)
|
| 70 |
)");
|
| 71 |
|
| 72 |
// Pgsql requires keys and indexes to be defined separately.
|
| 73 |
// It's important to name the index as {tablename}_fieldname_idx
|
| 74 |
// (the trailing _idx!) so update scripts can be written easily
|
| 75 |
$items[] = update_sql("CREATE INDEX {cas_server_tickets}_uid_idx
|
| 76 |
ON {cas_server_tickets} (uid)");
|
| 77 |
return $items;
|
| 78 |
break;
|
| 79 |
}
|
| 80 |
}
|
| 81 |
|
| 82 |
function cas_server_uninstall() {
|
| 83 |
if ($GLOBALS['db_type'] == 'pgsql') {
|
| 84 |
db_query('DROP INDEX {cas_server_tickets}_uid_idx');
|
| 85 |
}
|
| 86 |
db_query('DROP TABLE {cas_server_tickets}');
|
| 87 |
}
|