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

Contents of /contributions/modules/nodetriggers/nodetriggers.install

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


Revision 1.1 - (show annotations) (download) (as text)
Wed Nov 14 22:45:42 2007 UTC (2 years ago) by pfournier
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
Initial checkin of the nodetriggers module
1 <?php
2 // $Id$
3
4 function nodetriggers_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysqli':
7 case 'mysql':
8 $result = db_query(
9 <<<QUERY
10 CREATE TABLE {nodetriggers_configs} (
11 id int NOT NULL default 0,
12 name varchar(255) NOT NULL default '',
13 description varchar(255) NOT NULL default '',
14 priority int NOT NULL,
15 PRIMARY KEY (id)
16 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
17 QUERY
18 );
19
20 $result &= db_query(
21 <<<QUERY
22 CREATE TABLE {nodetriggers_nodes} (
23 config_id int NOT NULL,
24 node_type varchar(255) NOT NULL default ''
25 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
26 QUERY
27 );
28
29 $result &= db_query(
30 <<<QUERY
31 CREATE TABLE {nodetriggers_events} (
32 event_id int NOT NULL,
33 config_id int NOT NULL,
34 event_name varchar(255) NOT NULL default '',
35 active bool NOT NULL default TRUE
36 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
37 QUERY
38 );
39
40 $result &= db_query(
41 <<<QUERY
42 CREATE TABLE {nodetriggers_actions} (
43 event_id int NOT NULL,
44 action_id varchar(255) NOT NULL,
45 action_order int NOT NULL
46 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
47 QUERY
48 );
49
50 if ($result) {
51 drupal_set_message(t('The node triggers module has successfully added tables to the MySQL database.'));
52 }
53 else {
54 drupal_set_message(t('Drupal was unable to install the database tables for the triggers module.'));
55 }
56 break;
57
58 case 'pgsql':
59 // @TODO: create pgsql tables
60 break;
61 }
62 }
63
64 /**
65 * Implementation of hook_uninstall().
66 */
67 function nodetriggers_uninstall() {
68 db_query('DROP TABLE {nodetriggers_configs}');
69 db_query('DROP TABLE {nodetriggers_nodes}');
70 db_query('DROP TABLE {nodetriggers_events}');
71 db_query('DROP TABLE {nodetriggers_actions}');
72 }

  ViewVC Help
Powered by ViewVC 1.1.2