| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* @file
|
| 4 |
* Install file for the onlinestatus module.
|
| 5 |
*
|
| 6 |
* This File contains the install Routines for the Drupal
|
| 7 |
* Onlinestatus Indicator Module.
|
| 8 |
* This file is part of Onlinestatus Indicator.
|
| 9 |
*
|
| 10 |
* Onlinestatus Indicator is free software; you can redistribute it and/or modify
|
| 11 |
* it under the terms of the GNU General Public License as published by
|
| 12 |
* the Free Software Foundation; either version 2 of the License, or
|
| 13 |
* any later version.
|
| 14 |
*
|
| 15 |
* Onlinestatus Indicator is distributed in the hope that it will be useful,
|
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
* GNU General Public License for more details.
|
| 19 |
*
|
| 20 |
* You should have received a copy of the GNU General Public License
|
| 21 |
* along with Onlinestatus Indicator; if not, write to the Free Software
|
| 22 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
| 23 |
*
|
| 24 |
* @author Steve McKenzie
|
| 25 |
* @version $Revision: 1.4 $
|
| 26 |
*/
|
| 27 |
|
| 28 |
/**
|
| 29 |
* Install Hook for onlinestatus
|
| 30 |
*
|
| 31 |
* This function will be called when the somebody activates the onlinestatus
|
| 32 |
* Module for the first time in admin/modules.
|
| 33 |
* @return boolean false
|
| 34 |
**/
|
| 35 |
function onlinestatus_install() {
|
| 36 |
//add some default values
|
| 37 |
variable_set('onlinestatus_messengers',array('aim', 'icq', 'yahoo'));
|
| 38 |
variable_set('onlinestatus_osiserver','http://www.example.com:8080');
|
| 39 |
variable_set('onlinestatus_cachetime',60);
|
| 40 |
variable_set('onlinestatus_registration',false);
|
| 41 |
variable_set('onlinestatus_imagepath','modules/onlinestatus/images/%im-%status.png');
|
| 42 |
|
| 43 |
//create the DB Table.
|
| 44 |
switch ($GLOBALS['db_type']) {
|
| 45 |
case 'mysql':
|
| 46 |
case 'mysqli':
|
| 47 |
$result = db_query("CREATE TABLE {onlinestatus} (
|
| 48 |
`uid` int(10) unsigned NOT NULL,
|
| 49 |
`messenger` varchar(16) NOT NULL,
|
| 50 |
`status` varchar(32) NOT NULL default 'unknown',
|
| 51 |
`changed` int(11) unsigned NOT NULL,
|
| 52 |
PRIMARY KEY (`uid`,`messenger`)
|
| 53 |
)TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 54 |
break;
|
| 55 |
case 'pgsql':
|
| 56 |
$result = db_query("CREATE TABLE {onlinestatus} (
|
| 57 |
uid integer NOT NULL,
|
| 58 |
messenger varchar(16) NOT NULL,
|
| 59 |
status varchar(32) NOT NULL default 'unknown',
|
| 60 |
changed integer NOT NULL,
|
| 61 |
PRIMARY KEY (uid, messenger));");
|
| 62 |
break;
|
| 63 |
}
|
| 64 |
if ($result) {
|
| 65 |
drupal_set_message(t("onlinestatus module installed successfully."));
|
| 66 |
} else {
|
| 67 |
drupal_set_message(t("onlinestatus module was not installed. Please view the onlinestatus module folder and read the README"), 'error');
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
| 71 |
function onlinestatus_uninstall() {
|
| 72 |
db_query("DROP TABLE {onlinestatus}");
|
| 73 |
}
|
| 74 |
?>
|