/[drupal]/contributions/modules/lm_paypal/lm_paypal_subscriptions.install
ViewVC logotype

Contents of /contributions/modules/lm_paypal/lm_paypal_subscriptions.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.27 - (show annotations) (download) (as text)
Fri Jul 20 19:37:17 2007 UTC (2 years, 4 months ago) by leemcl
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, DRUPAL-4-7--1-0, DRUPAL-4-7--1-1, HEAD
Branch point for: DRUPAL-5, DRUPAL-4-7, DRUPAL-6--1
Changes since 1.26: +16 -5 lines
File MIME type: text/x-php
avoid sized text fields
1 <?php
2
3 // $Id: lm_paypal_subscriptions.install,v 1.26 2007/06/14 00:39:58 leemcl Exp $
4
5 /**
6 * @file
7 *
8 * Install or update the PayPal Subscriptions interface.
9 *
10 * Lee McLoughlin <lee@lmmrtech.com>. July 2006
11 */
12
13 function lm_paypal_subscriptions_install() {
14 $mysql_create_subscribers = "
15 CREATE TABLE {lm_paypal_subscribers} (
16 usid int unsigned not null auto_increment,
17 kind int unsigned not null default 0,
18 uid int(10) unsigned not null,
19 nid int(10) unsigned not null default 0,
20 subid mediumint unsigned not null,
21 started int(11) unsigned not null default 0,
22 status int(4) unsigned not null,
23 subscr_id varchar(20) default null, # ID generated by PayPal for this subscription
24 email_sent int(1) unsigned not null default '0',
25
26 KEY uid (uid),
27 KEY subscr_id (subscr_id),
28 PRIMARY KEY(usid)
29 ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
30
31 $mysql_create_subscriptions = "
32 CREATE TABLE {lm_paypal_subscriptions} (
33 subid mediumint unsigned not null auto_increment,
34 kind int unsigned not null default 0,
35 rid int(10) unsigned not null,
36 item_name varchar(127) not null default '',
37 description varchar(200) default '',
38 a1 decimal(10,2) default null,
39 p1 mediumint unsigned default null,
40 t1 char(1) default null,
41 a2 decimal(10,2) default null,
42 p2 mediumint unsigned default null,
43 t2 char(1) default null,
44 a3 decimal(10,2) default null,
45 p3 mediumint unsigned default null,
46 t3 char(1) default null,
47 src int(1) default null,
48 srt mediumint unsigned default null,
49 currency_code varchar(3) default null,
50 status int(4) not null, # live, defunct
51 return_url varchar(200) default '',
52
53 uid_admin int(10) unsigned not null,
54 send_admin_onsub int(1) unsigned not null default '0',
55 send_admin_onend int(1) unsigned not null default '0',
56
57 send_user_onsub int(1) unsigned not null default '0',
58 send_user_onsub_subject varchar(80) default '',
59 send_user_onsub_body text,
60 nearend_days int unsigned not null default '0',
61 send_user_onnearend int(1) unsigned not null default '0',
62 send_user_onnearend_subject varchar(80) default '',
63 send_user_onnearend_body text,
64 send_user_onend int(1) unsigned not null default '0',
65 send_user_onend_subject varchar(80) default '',
66 send_user_onend_body text,
67
68 terms text,
69
70 primary key(subid)
71 ) /*!40100 DEFAULT CHARACTER SET utf8 */ ;";
72
73 $ret = '';
74 switch ($GLOBALS['db_type']) {
75 case 'mysql':
76 case 'mysqli':
77 $ret .= lm_paypal_subscriptions_create_table('lm_paypal_subscribers', $mysql_create_subscribers);
78 $ret .= lm_paypal_subscriptions_create_table('lm_paypal_subscriptions', $mysql_create_subscriptions);
79 break;
80
81 case 'pgsql':
82 watchdog('lm_paypal_subscriptions', t('pgsql not supported yet'), WATCHDOG_ERROR);
83 return;
84 break;
85 }
86 if ($ret == '') {
87 $msg = t('lm_paypal_subscriptions created tables');
88 }
89 else {
90 $msg = t('lm_paypal_subscriptions FAILED to create tables:') . $ret;
91 }
92 drupal_set_message($msg);
93 }
94
95 function lm_paypal_subscriptions_create_table($table, $sql) {
96 $res = db_query($sql);
97 if (!$res) {
98 $ret = t('Failed to create table:') . $table . t('. ');
99 watchdog('lm_paypal', $ret, WATCHDOG_ERROR);
100 return $ret;
101 }
102 return '';
103 }
104
105 function lm_paypal_subscriptions_update_1() {
106 $items = array();
107 $items[] = update_sql("ALTER TABLE {lm_paypal_subscribers} CHANGE datepaid started int(11) unsigned not null");
108 return $items;
109 }
110
111 function lm_paypal_subscriptions_update_2() {
112 $items = array();
113 $items[] = update_sql("ALTER TABLE {lm_paypal_subscribers} ADD email_sent int(1) unsigned not null default '0'");
114 $items[] = update_sql("ALTER TABLE {lm_paypal_subscribers} CHANGE status status int(4) unsigned not null");
115 return $items;
116 }
117
118 function lm_paypal_subscriptions_update_3() {
119 $items = array();
120 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD uid_admin int(10) unsigned not null ");
121
122 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_admin_onsub int(1) unsigned not null default '0'");
123 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_admin_onend int(1) unsigned not null default '0'");
124
125 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onsub int(1) unsigned not null default '0'");
126 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onsub_subject varchar(80) default ''");
127 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onsub_body varchar(200) default ''");
128
129 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD nearend_days int unsigned not null default '0'");
130 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onnearend int(1) unsigned not null default '0'");
131 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onnearend_subject varchar(80) default ''");
132 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onnearend_body varchar(200) default ''");
133
134 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onend int(1) unsigned not null default '0'");
135 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onend_subject varchar(80) default ''");
136 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD send_user_onend_body varchar(200) default ''");
137
138 return $items;
139 }
140
141 function lm_paypal_subscriptions_update_4() {
142 $items = array();
143 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD kind int unsigned not null default 0 AFTER subid");
144 $items[] = update_sql("ALTER TABLE {lm_paypal_subscribers} ADD kind int unsigned not null default 0 AFTER usid");
145 $items[] = update_sql("ALTER TABLE {lm_paypal_subscribers} ADD nid int(10) unsigned not null default 0 AFTER uid");
146 return $items;
147 }
148
149 function lm_paypal_subscriptions_update_5() {
150 $items = array();
151 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD return_url varchar(200) default '' AFTER subid");
152 return $items;
153 }
154
155 function lm_paypal_subscriptions_update_6() {
156 $items = array();
157 $items[] = update_sql("ALTER TABLE {lm_paypal_subscribers} CHANGE started started int(11) unsigned not null default 0");
158 return $items;
159 }
160
161 function lm_paypal_subscriptions_update_7() {
162 $items = array();
163 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} CHANGE send_user_onsub_body send_user_onsub_body text(2000)");
164 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} CHANGE send_user_onnearend_body send_user_onnearend_body text(2000)");
165 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} CHANGE send_user_onend_body send_user_onend_body text(2000)");
166 return $items;
167 }
168
169 function lm_paypal_subscriptions_update_8() {
170 $items = array();
171 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} ADD terms text(2000) AFTER send_user_onend_body ");
172 return $items;
173 }
174
175 // Sigh... some users report that text(2000) doesn't work so switch to just text
176 function lm_paypal_subscriptions_update_9() {
177 $items = array();
178 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} CHANGE send_user_onsub_body send_user_onsub_body text");
179 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} CHANGE send_user_onnearend_body send_user_onnearend_body text");
180 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} CHANGE send_user_onend_body send_user_onend_body text");
181 $items[] = update_sql("ALTER TABLE {lm_paypal_subscriptions} CHANGE terms terms text");
182 return $items;
183 }
184
185 ?>

  ViewVC Help
Powered by ViewVC 1.1.2