| 1 |
<?php
|
| 2 |
// $Id: og_collections.install,v 1.1 2008/03/13 20:12:56 sdboyer Exp $
|
| 3 |
|
| 4 |
function og_collections_install() {
|
| 5 |
switch ($GLOBALS['db_type']) {
|
| 6 |
case 'mysql':
|
| 7 |
case 'mysqli':
|
| 8 |
db_query("CREATE TABLE {og_collections_pcpanel} (
|
| 9 |
did int NOT NULL,
|
| 10 |
pcpid int NOT NULL,
|
| 11 |
grouptype varchar(32) NOT NULL DEFAULT 'default',
|
| 12 |
PRIMARY KEY (did),
|
| 13 |
KEY (pcpid, grouptype)
|
| 14 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 15 |
|
| 16 |
db_query("CREATE TABLE {og_collections} (
|
| 17 |
grouptype varchar(32) NOT NULL,
|
| 18 |
PRIMARY KEY (grouptype)
|
| 19 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 20 |
|
| 21 |
if (is_array(db_fetch_array(db_query('DESCRIBE {og_panels} frompcpanel')))) {
|
| 22 |
$ret[] = db_query("ALTER TABLE {og_panels} ADD COLUMN frompcpanel TEXT NULL");
|
| 23 |
}
|
| 24 |
break;
|
| 25 |
case 'pgsql':
|
| 26 |
db_query("CREATE TABLE {og_collections_pcpanel} (
|
| 27 |
did numeric(11) NOT NULL,
|
| 28 |
pcpid numeric(11) NOT NULL,
|
| 29 |
grouptype varchar(32) NOT NULL DEFAULT 'default',
|
| 30 |
PRIMARY KEY (did)
|
| 31 |
);");
|
| 32 |
|
| 33 |
db_query("CREATE TABLE {og_collections} (
|
| 34 |
grouptype varchar(32) NOT NULL,
|
| 35 |
PRIMARY KEY (grouptype)
|
| 36 |
);");
|
| 37 |
// FIXME can't figure out the pgsql syntax that will enable me to check for the presence of the column in a completely error-proof manner.
|
| 38 |
db_add_column($ret, 'og_panels', 'frompcpanel', 'text', array('not null' => FALSE));
|
| 39 |
break;
|
| 40 |
}
|
| 41 |
db_query("INSERT INTO {og_collections} (grouptype) VALUES ('default')"); // pre-configured panel functions can react badly if there is no default row already created
|
| 42 |
return isset($ret) ? $ret : array();
|
| 43 |
}
|
| 44 |
|
| 45 |
function og_collections_uninstall() {
|
| 46 |
db_query('DROP TABLE {og_collections_pcpanel}');
|
| 47 |
db_query('DROP TABLE {og_collections');
|
| 48 |
db_query('ALTER TABLE {og_panels} DROP frompcpanel');
|
| 49 |
|
| 50 |
// Delete variables
|
| 51 |
$variables = array('og_collections_settings');
|
| 52 |
foreach ($variables as $variable) {
|
| 53 |
variable_del($variable);
|
| 54 |
}
|
| 55 |
}
|
| 56 |
|
| 57 |
/**
|
| 58 |
* Implementation of hook_enable()
|
| 59 |
*
|
| 60 |
*/
|
| 61 |
function og_collections_enable() {
|
| 62 |
drupal_set_message(t('OG Collections has been installed. You can begin configuring your Group Collections at the !link administrative menu.', array('!link' => l(t('OG Collections'), 'admin/og/og_collections'))));
|
| 63 |
}
|