/[drupal]/contributions/modules/promotion/promotion.install
ViewVC logotype

Contents of /contributions/modules/promotion/promotion.install

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


Revision 1.4 - (show annotations) (download) (as text)
Mon Jun 4 17:00:38 2007 UTC (2 years, 5 months ago) by hanenkamp
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.3: +0 -0 lines
File MIME type: text/x-php
Issue #149217, promotional cods may be given directly in the URL like user/register/CODE.
1 <?php
2 // $Id$
3
4 function promotion_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysql':
7 case 'mysqli':
8 db_query("CREATE TABLE {promotion_codes} (
9 pid int unsigned NOT NULL default '0',
10 name varchar(128) NOT NULL,
11 description text NULL,
12 active_promotion int(1) NOT NULL default '1',
13 start_date int NULL,
14 end_date int NULL,
15 activate_when int(1) unsigned NOT NULL default '1',
16 activation_date int NULL,
17 accounts_expire int(1) unsigned NOT NULL default '0',
18 expiration_date int NULL,
19 expiration_action int(1) unsigned NOT NULL default '0',
20 code_type int(1) unsigned NOT NULL default '0',
21 simple_code varchar(30) NOT NULL default '',
22 advanced_validator text NULL,
23 max_use_count int unsigned NULL,
24 bypass_verification int(1) unsigned NOT NULL default '0',
25 bypass_administrator int(1) unsigned NOT NULL default '0',
26 linked_code int(1) unsigned NOT NULL default '0',
27 code_link varchar(150) NULL,
28 PRIMARY KEY (pid),
29 UNIQUE (name)
30 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
31
32 db_query("CREATE TABLE {promotion_codes_roles} (
33 pid int unsigned NOT NULL default '0',
34 rid int unsigned NOT NULL default '0',
35 promotion int(1) unsigned NOT NULL default '0',
36 PRIMARY KEY (pid, rid, promotion)
37 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
38
39 db_query("CREATE TABLE {promotion_codes_users} (
40 pid int unsigned NOT NULL default '0',
41 uid int unsigned NOT NULL default '0',
42 code_used varchar(30) NOT NULL default '',
43 status int(1) unsigned NOT NULL default '0',
44 PRIMARY KEY (pid, uid)
45 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
46 break;
47 }
48 }
49
50 function promotion_update_1() {
51 $items = array();
52 switch ($GLOBALS['db_type']) {
53 case 'mysql':
54 case 'mysqli':
55 $items[] = update_sql("ALTER TABLE {promotion_codes_users}
56 ADD status int(1) unsigned NOT NULL default '0';");
57
58 // Up to this point, accounts were instantly activated and never expired,
59 // so it's safe to make all accounts active.
60 $items[] = update_sql("
61 UPDATE {promotion_codes_users}
62 SET status = 1
63 ");
64 break;
65 }
66
67 return $items;
68 }
69
70 function promotion_update_2() {
71 $items = array();
72 switch ($GLOBALS['db_type']) {
73 case 'mysql':
74 case 'mysqli':
75 $items[] = update_sql("ALTER TABLE {promotion_codes}
76 ADD activate_when int(1) unsigned NOT NULL default '1';");
77
78 $items[] = update_sql("ALTER TABLE {promotion_codes}
79 ADD activation_date int NULL;");
80
81 break;
82 }
83 return $items;
84 }
85
86 ?>

  ViewVC Help
Powered by ViewVC 1.1.2