cas.install in CAS 6.2
Same filename and directory in other branches
CAS Install
File
cas.installView source
<?php
/**
* @file CAS Install
*
*/
/**
* Inastall db tables.
*
*/
function cas_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_login_data} (\n\t\t cas_session_id varchar(255) NOT NULL default '',\n\t\t uid int unsigned NOT NULL,\n PRIMARY KEY (cas_session_id)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
db_query("CREATE TABLE {cas_login_data} (\n \t cas_session_id varchar(255) NOT NULL default '',\n \t uid integer NOT NULL CHECK (uid >= 0),\n PRIMARY KEY (cas_session_id)\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_login_data}_uid_idx\n ON {cas_login_data} (uid)");
break;
}
}
function cas_update_1() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$items = array();
$items[] = update_sql("CREATE TABLE {cas_login_data} (\n cas_session_id varchar(255) NOT NULL default '',\n uid int unsigned NOT NULL,\n PRIMARY KEY (cas_session_id)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
return $items;
break;
case 'pgsql':
$items = array();
$items[] = update_sql("CREATE TABLE {cas_login_data} (\n \t cas_session_id varchar(255) NOT NULL default '',\n \t uid integer NOT NULL CHECK (uid >= 0),\n PRIMARY KEY (cas_session_id)\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_login_data}_uid_idx\n ON {cas_login_data} (uid)");
return $items;
break;
}
}
function cas_uninstall() {
if ($GLOBALS['db_type'] == 'pgsql') {
db_query('DROP INDEX {cas_login_data}_uid_idx');
}
db_query('DROP TABLE {cas_login_data}');
}
Functions
Name | Description |
---|---|
cas_install | Inastall db tables. |
cas_uninstall | |
cas_update_1 |