| 1 |
<?php
|
| 2 |
// $Id: helptip.install,v 1.1 2006/03/30 19:30:57 yogadex Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Install code for helptip module
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* hook_install()
|
| 11 |
*
|
| 12 |
* Could someone with postgres please provide a patch?
|
| 13 |
*/
|
| 14 |
function helptip_install() {
|
| 15 |
global $db_type;
|
| 16 |
if ($db_type == 'mysqli' ||
|
| 17 |
$db_type == 'mysql') {
|
| 18 |
$query[] = <<<QUERY
|
| 19 |
CREATE TABLE IF NOT EXISTS {helptip} (
|
| 20 |
nid int(10) unsigned NOT NULL default '0',
|
| 21 |
path varchar(255) NOT NULL default '',
|
| 22 |
weight tinyint(4) NOT NULL default '0',
|
| 23 |
settings mediumtext NOT NULL default '',
|
| 24 |
PRIMARY KEY (nid),
|
| 25 |
KEY path (path)
|
| 26 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;
|
| 27 |
QUERY;
|
| 28 |
|
| 29 |
// Here's a table storing simple relationships between users and
|
| 30 |
// nodes. Drupal should provide something like this for all modules
|
| 31 |
// to use, but it does not :(
|
| 32 |
$query[] = <<<QUERY
|
| 33 |
CREATE TABLE IF NOT EXISTS {helptip_user_data} (
|
| 34 |
nid int(10) unsigned NOT NULL default '0',
|
| 35 |
uid int(10) unsigned NOT NULL default '0',
|
| 36 |
relation varchar(64) NOT NULL default '',
|
| 37 |
PRIMARY KEY (nid, uid, relation)
|
| 38 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;
|
| 39 |
QUERY;
|
| 40 |
|
| 41 |
}
|
| 42 |
else {
|
| 43 |
// TODO: handle other databases
|
| 44 |
drupal_set_message(t('Unable to install helptip database schema to a database of type: %type', array('%type' => $db_type)), 'error');
|
| 45 |
}
|
| 46 |
foreach ($query as $q) {
|
| 47 |
$status = db_query ($q);
|
| 48 |
if (!$status) {
|
| 49 |
drupal_set_message(t('Error installing helptip: %error %query',
|
| 50 |
array('%query' => '<pre>'.$q.'</pre>',
|
| 51 |
'%error' => db_error())),
|
| 52 |
'error');
|
| 53 |
}
|
| 54 |
}
|
| 55 |
}
|
| 56 |
?>
|