| 1 |
<?php
|
| 2 |
|
| 3 |
// $Id: lm_paypal_donations.install,v 1.23 2006/10/08 20:51:08 leemcl Exp $
|
| 4 |
|
| 5 |
/**
|
| 6 |
* @file
|
| 7 |
*
|
| 8 |
* Install or update the PayPal donations interface.
|
| 9 |
*
|
| 10 |
* Lee McLoughlin <lee@lmmrtech.com>. July 2006
|
| 11 |
*/
|
| 12 |
|
| 13 |
function lm_paypal_donations_install() {
|
| 14 |
$mysql_create_donations = "
|
| 15 |
CREATE TABLE {lm_paypal_donations} (
|
| 16 |
udid int unsigned not null auto_increment,
|
| 17 |
uid int(10) unsigned null,
|
| 18 |
datepaid int(11) not null,
|
| 19 |
txn_id varchar(20) not null default '', # Paypal generated transaction id
|
| 20 |
mc_gross decimal(10,2) default '0.00' not null,
|
| 21 |
mc_fee decimal(10,2) default '0.00' not null,
|
| 22 |
mc_currency varchar(3) default null,
|
| 23 |
item_name varchar(127) not null default '',
|
| 24 |
|
| 25 |
primary key(udid)
|
| 26 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;";
|
| 27 |
|
| 28 |
$ret = '';
|
| 29 |
switch ($GLOBALS['db_type']) {
|
| 30 |
case 'mysql':
|
| 31 |
case 'mysqli':
|
| 32 |
$ret .= lm_paypal_donations_create_table('lm_paypal_donations', $mysql_create_donations);
|
| 33 |
break;
|
| 34 |
|
| 35 |
case 'pgsql':
|
| 36 |
watchdog('lm_paypal_donations', t('pgsql not supported yet'), WATCHDOG_ERROR);
|
| 37 |
return;
|
| 38 |
break;
|
| 39 |
}
|
| 40 |
if ($ret == '') {
|
| 41 |
$msg = t('lm_paypal_donations created tables');
|
| 42 |
}
|
| 43 |
else {
|
| 44 |
$msg = t('lm_paypal_donations FAILED to create tables:') . $ret;
|
| 45 |
}
|
| 46 |
drupal_set_message($msg);
|
| 47 |
}
|
| 48 |
|
| 49 |
function lm_paypal_donations_create_table($table, $sql) {
|
| 50 |
$res = db_query($sql);
|
| 51 |
if (!$res) {
|
| 52 |
$ret = t('Failed to create table:') . $table . t('. ');
|
| 53 |
watchdog('lm_paypal', $ret, WATCHDOG_ERROR);
|
| 54 |
return $ret;
|
| 55 |
}
|
| 56 |
return '';
|
| 57 |
}
|
| 58 |
|
| 59 |
function lm_paypal_donations_update_1() {
|
| 60 |
$items = array();
|
| 61 |
$items[] = update_sql("ALTER TABLE {lm_paypal_donations} ADD item_name varchar(127) not null default '' AFTER mc_currency");
|
| 62 |
return $items;
|
| 63 |
}
|
| 64 |
|
| 65 |
?>
|