| 1 |
<?php
|
| 2 |
// $Id: activitystream.install,v 1.1.2.8 2008/08/12 04:58:25 akalsey Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install()
|
| 6 |
*
|
| 7 |
* This will automatically install the database tables for the Activity Stream
|
| 8 |
* module for MySQL.
|
| 9 |
*
|
| 10 |
* If you are using another database, you will have to install the
|
| 11 |
* tables by hand, using the queries below as a reference.
|
| 12 |
*
|
| 13 |
* Note that the curly braces around table names are a drupal-specific
|
| 14 |
* feature to allow for automatic database table prefixing, and will
|
| 15 |
* need to be removed.
|
| 16 |
*/
|
| 17 |
|
| 18 |
function activitystream_install() {
|
| 19 |
switch ($GLOBALS['db_type']) {
|
| 20 |
case 'mysqli':
|
| 21 |
case 'mysql':
|
| 22 |
$q1 = db_query("CREATE TABLE IF NOT EXISTS {activitystream_accounts} (
|
| 23 |
uid int(10) unsigned NOT NULL default '0',
|
| 24 |
module varchar(255) default '',
|
| 25 |
userid varchar(255) default '',
|
| 26 |
password varchar(255) default '',
|
| 27 |
feed varchar(255) default '',
|
| 28 |
lastfetch timestamp NOT NULL
|
| 29 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 30 |
$q2 = db_query("CREATE TABLE IF NOT EXISTS {activitystream} (
|
| 31 |
nid int(10) unsigned NOT NULL default '0',
|
| 32 |
module varchar(255) default '',
|
| 33 |
link varchar(255) default '',
|
| 34 |
data text default '',
|
| 35 |
guid varchar(32) default '',
|
| 36 |
PRIMARY KEY (guid)
|
| 37 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 38 |
break;
|
| 39 |
case 'pgsql':
|
| 40 |
$q1 = db_query("CREATE TABLE {activitystream_accounts} (
|
| 41 |
uid integer NOT NULL default 0,
|
| 42 |
module varchar(255) default '',
|
| 43 |
userid varchar(255) default '',
|
| 44 |
password varchar(255) default '',
|
| 45 |
feed varchar(255) default '',
|
| 46 |
lastfetch timestamp NOT NULL default now()
|
| 47 |
);");
|
| 48 |
$q2 = db_query("CREATE TABLE {activitystream} (
|
| 49 |
nid integer NOT NULL default 0,
|
| 50 |
module varchar(255) default '',
|
| 51 |
link varchar(255) default '',
|
| 52 |
data text default '',
|
| 53 |
guid varchar(32) default '' PRIMARY KEY
|
| 54 |
);");
|
| 55 |
break;
|
| 56 |
}
|
| 57 |
if ($q1 && $q2) {
|
| 58 |
drupal_set_message(t('Activity Stream module installed successfully.' . $warning));
|
| 59 |
}
|
| 60 |
else {
|
| 61 |
drupal_set_message(t('Table installation for the Activity Stream module was unsuccessful. The tables may need to be installed by hand. See the activitystream.install file for a list of the installation queries.'), 'error');
|
| 62 |
}
|
| 63 |
}
|
| 64 |
|
| 65 |
function activitystream_uninstall() {
|
| 66 |
if (db_table_exists('activitystream')) {
|
| 67 |
db_query("DROP TABLE {activitystream}");
|
| 68 |
}
|
| 69 |
if (db_table_exists('activitystream_accounts')) {
|
| 70 |
db_query("DROP TABLE {activitystream_accounts}");
|
| 71 |
}
|
| 72 |
$variables = db_query("SELECT name FROM {variable} WHERE name LIKE 'activityfeed%%'");
|
| 73 |
while ($variable = db_fetch_object($variables)) {
|
| 74 |
variable_del($variable->name);
|
| 75 |
}
|
| 76 |
db_query("DELETE FROM {system} WHERE name like '%activitystream'");
|
| 77 |
}
|
| 78 |
|
| 79 |
/*
|
| 80 |
Instead of using the dummy category, we now use hook_user's categories $op switch.
|
| 81 |
So we can remove the dummy category from the database.
|
| 82 |
*/
|
| 83 |
function activitystream_update_1() {
|
| 84 |
$ret[] = update_sql("DELETE FROM {profile_fields} WHERE title = 'Placeholder' and name = 'profile_activitystream_placeholder'");
|
| 85 |
return $ret;
|
| 86 |
}
|
| 87 |
|
| 88 |
/*
|
| 89 |
Instead of using the dummy category, we now use hook_user's categories $op switch.
|
| 90 |
So we can remove the dummy category from the database.
|
| 91 |
*/
|
| 92 |
function activitystream_update_2() {
|
| 93 |
$ret[] = update_sql("ALTER TABLE {activitystream} ADD COLUMN `changed` int(11) NOT NULL default '0'");
|
| 94 |
$ret[] = update_sql("ALTER TABLE {activitystream} ADD KEY `nid` (`nid`)");
|
| 95 |
return $ret;
|
| 96 |
}
|