gotwo.install in Go - url redirects 5
Same filename and directory in other branches
Installation script for the go.module
File
gotwo.installView source
<?php
/**
* @file
* Installation script for the go.module
*/
function gotwo_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {gotwo} (\n gid int(10) unsigned NOT NULL default 0,\n src varchar(128) NOT NULL default '',\n dst varchar(128) NOT NULL default '',\n cnt int(10) unsigned NOT NULL default 0,\n PRIMARY KEY (gid),\n UNIQUE KEY src (src)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
db_query("CREATE TABLE {gotwo} (\n gid int(10) unsigned NOT NULL default 0,\n src varchar(128) NOT NULL default '',\n dst varchar(128) NOT NULL default '',\n cnt int(10) unsigned NOT NULL default 0,\n PRIMARY KEY (gid)\n );");
db_query("CREATE UNIQUE INDEX gotwo_src_idx ON {gotwo}(src);");
break;
}
}
/**
* Implementation of hook_uninstall().
*/
function gotwo_uninstall() {
db_query('DROP TABLE {gotwo}');
variable_del('gotwo_numeric');
variable_del('gotwo_max_length');
variable_del('gotwo_disclaimer_boolean');
variable_del('gotwo_disclaimer_time');
variable_del('gotwo_disclaimer_text');
}
# update the permissions table, to reflect changes to hook_perm
function gotwo_update_5100() {
$ret = array();
$res = db_query("SELECT rid,perm FROM {permission}");
$perms = array();
while ($p = db_fetch_object($res)) {
$perm = $p->perm;
$perm = preg_replace('/Administrative Settings/', 'administer gotwo', $perm);
$perm = preg_replace('/view entry list/', 'view gotwo entries', $perm);
$perm = preg_replace('/edit entries/', 'edit gotwo entries', $perm);
$perms[$p->rid] = $perm;
}
foreach (array_keys($perms) as $rid) {
db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $perms[$rid], $rid);
}
return $ret;
}
Functions
Name![]() |
Description |
---|---|
gotwo_install | @file Installation script for the go.module |
gotwo_uninstall | Implementation of hook_uninstall(). |
gotwo_update_5100 |