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

Contents of /contributions/modules/notifications/notifications.install

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


Revision 1.4 - (show annotations) (download) (as text)
Thu Feb 14 16:54:32 2008 UTC (21 months, 2 weeks ago) by jareyero
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
Changes since 1.3: +16 -0 lines
File MIME type: text/x-php
Left files in latest commit
1 <?php
2
3 /**
4 * Implementation of hook_install().
5 */
6 function notifications_install() {
7 switch ($GLOBALS['db_type']) {
8 case 'mysql':
9 case 'mysqli':
10 db_query("CREATE TABLE {notifications} (
11 `sid` int(10) unsigned NOT NULL auto_increment,
12 `uid` int(11) NOT NULL,
13 `type` varchar(255) default NULL,
14 `event_type` varchar(255) default NULL,
15 `conditions` int(10) unsigned NOT NULL,
16 `send_interval` int(11) default NULL,
17 `send_method` varchar(255) NOT NULL,
18 `cron` TINYINT UNSIGNED NOT NULL DEFAULT 0,
19 `module` VARCHAR(255) DEFAULT NULL,
20 `status` int NOT NULL default 1,
21 PRIMARY KEY (`sid`)
22 )/*!40100 DEFAULT CHARACTER SET utf8 */");
23
24 db_query("CREATE TABLE {notifications_fields} (
25 `sid` int(10) unsigned NOT NULL,
26 `field` varchar(255) NOT NULL,
27 `value` varchar(255) NOT NULL,
28 PRIMARY KEY (`sid`,`field`)
29 )/*!40100 DEFAULT CHARACTER SET utf8 */");
30
31 db_query("CREATE TABLE {notifications_queue} (
32 `sqid` int(10) unsigned NOT NULL auto_increment,
33 `eid` int(11) unsigned NOT NULL default '0',
34 `sid` int(11) unsigned NOT NULL default '0',
35 `uid` int(11) default NULL,
36 `language` varchar(255) default NULL,
37 `type` varchar(255) default NULL,
38 `send_interval` int(11) default NULL,
39 `send_method` varchar(255) default NULL,
40 `sent` int(10) unsigned NOT NULL default '0',
41 `created` int(10) unsigned NOT NULL default '0',
42 `cron` TINYINT UNSIGNED NOT NULL DEFAULT 0,
43 `conditions` INTEGER UNSIGNED NOT NULL DEFAULT 0,
44 `module` VARCHAR(255) DEFAULT NULL,
45 PRIMARY KEY (`sqid`)
46 )/*!40100 DEFAULT CHARACTER SET utf8 */");
47
48 db_query("CREATE TABLE {notifications_event} (
49 `eid` int(11) unsigned NOT NULL auto_increment,
50 `module` varchar(255) default NULL,
51 `type` varchar(255) default NULL,
52 `action` varchar(255) default NULL,
53 `oid` int(11) unsigned NOT NULL default '0',
54 `language` varchar(255) default NULL,
55 `uid` int(11) default NULL,
56 `params` text,
57 `created` int(11) unsigned NOT NULL default '0',
58 PRIMARY KEY (`eid`)
59 )/*!40100 DEFAULT CHARACTER SET utf8 */");
60
61 db_query("CREATE TABLE {notifications_sent} (
62 `uid` int(11) NOT NULL default '0',
63 `send_interval` int(10) NOT NULL default '0',
64 `send_method` varchar(50) NOT NULL,
65 `sent` int(10) unsigned NOT NULL default '0',
66 PRIMARY KEY (`uid`,`send_interval`,`send_method`)
67 )/*!40100 DEFAULT CHARACTER SET utf8 */");
68 break;
69 case 'pgsql':
70 drupal_set_message('Sorry, no install script for pgsql yet.', 'error');
71 break;
72 }
73 }
74
75 /**
76 * Implementation of hook_uninstall().
77 */
78 function notifications_uninstall() {
79 db_query("DROP TABLE {notifications}");
80 db_query("DROP TABLE {notifications_fields}");
81 db_query("DROP TABLE {notifications_queue}");
82 db_query("DROP TABLE {notifications_event}");
83 db_query("DROP TABLE {notifications_sent}");
84 }
85
86 /**
87 * Update: Add cron flag for processing
88 */
89 function notifications_update_1() {
90 $ret = array();
91 // Add field
92 $ret[] = update_sql("ALTER TABLE {notifications} ADD COLUMN `cron` TINYINT UNSIGNED NOT NULL DEFAULT 0");
93 $ret[] = update_sql("ALTER TABLE {notifications_queue} ADD COLUMN `cron` TINYINT UNSIGNED NOT NULL DEFAULT 0");
94 // Populate field, this is new so all stored rows till now should be intended for cron processing
95 $ret[] = update_sql("UPDATE {notifications} SET cron = 1");
96 $ret[] = update_sql("UPDATE {notifications_queue} SET cron = 1");
97 return $ret;
98 }
99
100 /**
101 * Update:
102 * - Remove unused table and fields
103 * - Add conditions field for mysql4 compatibility
104 * - Updated variable name
105 */
106 function notifications_update_2() {
107 $ret = array();
108 $ret[] = update_sql("DROP TABLE {notifications_user}");
109 $ret[] = update_sql("ALTER TABLE {notifications_queue} DROP COLUMN `name`;");
110 $ret[] = update_sql("ALTER TABLE {notifications_queue} DROP COLUMN `field`;");
111 $ret[] = update_sql("ALTER TABLE {notifications_queue} DROP COLUMN `value`;");
112 $ret[] = update_sql("ALTER TABLE {notifications_queue} DROP COLUMN `author`;");
113 $ret[] = update_sql("ALTER TABLE {notifications_queue} ADD COLUMN `conditions` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `cron`");
114 variable_set('notifications_default_auto', variable_get('notifications_autoset', 0));
115 variable_del('notifications_autoset');
116 return $ret;
117 }
118
119 /**
120 * - Added status and module fields
121 */
122 function notifications_update_3() {
123 $ret[] = update_sql("ALTER TABLE {notifications} ADD COLUMN `module` VARCHAR(255) AFTER `cron`;");
124 $ret[] = update_sql("ALTER TABLE {notifications} ADD COLUMN `status` INT NOT NULL DEFAULT 1 AFTER `module`;");
125 $ret[] = update_sql("ALTER TABLE {notifications_queue} ADD COLUMN `module` VARCHAR(255);");
126 // Set default module to 'notifications'
127 $ret[] = update_sql("UPDATE {notifications} SET module = 'notifications'");
128 $ret[] = update_sql("UPDATE {notifications_queue} SET module = 'notifications'");
129 return $ret;
130 }

  ViewVC Help
Powered by ViewVC 1.1.2