comparison channel/ad_channel.install @ 8:32c1a7d9e1fa ad tip

maj module ad en 2.1
author sly
date Fri, 11 Sep 2009 11:10:20 +0000
parents 6aeff3329e01
children
comparison
equal deleted inserted replaced
7:6aeff3329e01 8:32c1a7d9e1fa
1 <?php 1 <?php
2 // $Id: ad_channel.install,v 1.1.4.8 2009/07/11 16:39:21 jeremy Exp $ 2 // $Id: ad_channel.install,v 1.1.4.9 2009/07/28 17:39:35 jeremy Exp $
3 3
4 /** 4 /**
5 * 5 *
6 * Ad channel database schema. 6 * Ad channel database schema.
7 * Copyright (c) 2008-2009 Jeremy Andrews <jeremy@tag1consulting.com>. 7 * Copyright (c) 2008-2009 Jeremy Andrews <jeremy@tag1consulting.com>.
8 */ 8 */
9 9
10 /** 10 /**
11 * Create the ad_channel schema. 11 * Create the ad_channel schema.
12 */ 12 */
13 function ad_channel_schema() {
14 $schema['ad_channel'] = array(
15 'description' => 'The ad_channel table allows advertisements to be organized into channels against which rules can be applied.',
16 'fields' => array(
17 'chid' => array(
18 'type' => 'serial',
19 'not null' => TRUE,
20 'unsigned' => TRUE,
21 'description' => 'Unique channel ID.',
22 ),
23 'name' => array(
24 'type' => 'varchar',
25 'length' => 64,
26 'not null' => TRUE,
27 'default' => '',
28 'description' => 'The name of the channel.',
29 ),
30 'description' => array(
31 'type' => 'text',
32 'size' => 'big',
33 'not null' => FALSE,
34 'description' => 'A description of the channel.',
35 ),
36 'conid' => array(
37 'type' => 'int',
38 'not null' => TRUE,
39 'unsigned' => TRUE,
40 'default' => 0,
41 'description' => 'ID of the container the channel is in.',
42 ),
43 'weight' => array(
44 'type' => 'int',
45 'size' => 'medium',
46 'not null' => TRUE,
47 'unsigned' => TRUE,
48 'default' => 0,
49 'description' => 'Used when displaying channels to admins, heavier weights sink to the bottom.',
50 ),
51 'display' => array(
52 'type' => 'int',
53 'size' => 'tiny',
54 'not null' => TRUE,
55 'unsigned' => TRUE,
56 'default' => 0,
57 ),
58 'no_channel_percent' => array(
59 'type' => 'int',
60 'size' => 'medium',
61 'not null' => TRUE,
62 'unsigned' => TRUE,
63 'default' => 0,
64 ),
65 'inventory' => array(
66 'type' => 'int',
67 'not null' => TRUE,
68 'unsigned' => TRUE,
69 'default' => 0,
70 ),
71 'urls' => array(
72 'type' => 'text',
73 ),
74 'groups' => array(
75 'type' => 'text',
76 ),
77 ),
78 'primary key' => array('chid'),
79 'indexes' => array(
80 'name' => array('name'),
81 ),
82 );
83 $schema['ad_channel_remnant'] = array(
84 'fields' => array(
85 'aid' => array(
86 'type' => 'int',
87 'not null' => TRUE,
88 'unsigned' => TRUE,
89 'default' => 0,
90 ),
91 'remnant' => array(
92 'type' => 'int',
93 'size' => 'tiny',
94 'not null' => TRUE,
95 'unsigned' => TRUE,
96 'default' => 0,
97 ),
98 ),
99 'primary key' => array('aid', 'remnant'),
100 );
101 $schema['ad_channel_container'] = array(
102 'description' => 'The ad_channel_container table stores channel container definitions.',
103 'fields' => array(
104 'conid' => array(
105 'type' => 'serial',
106 'not null' => TRUE,
107 'unsigned' => TRUE,
108 'description' => 'Unique container ID.',
109 ),
110 'name' => array(
111 'type' => 'varchar',
112 'length' => 64,
113 'not null' => TRUE,
114 'default' => '',
115 'description' => 'The name of the container.',
116 ),
117 'description' => array(
118 'type' => 'text',
119 'size' => 'big',
120 'not null' => FALSE,
121 'description' => 'A description of the container.',
122 ),
123 'weight' => array(
124 'type' => 'int',
125 'size' => 'medium',
126 'not null' => TRUE,
127 'unsigned' => TRUE,
128 'default' => 0,
129 'description' => 'Used when displaying channels to admins, heavier weights sink to the bottom.',
130 ),
131 ),
132 'primary key' => array('conid'),
133 );
134 $schema['ad_channel_node'] = array(
135 'description' => 'The ad_channel_node table stores per node channel information.',
136 'fields' => array(
137 'chid' => array(
138 'type' => 'int',
139 'not null' => TRUE,
140 'unsigned' => TRUE,
141 'default' => 0,
142 ),
143 'nid' => array(
144 'type' => 'int',
145 'not null' => TRUE,
146 'unsigned' => TRUE,
147 'default' => 0,
148 ),
149 ),
150 'primary key' => array('chid', 'nid'),
151 'indexes' => array(
152 'nid_chid' => array('nid', 'chid'),
153 ),
154 );
155 $schema['ad_priority'] = array(
156 'fields' => array(
157 'aid' => array(
158 'type' => 'int',
159 'not null' => TRUE,
160 'unsigned' => TRUE,
161 'default' => 0,
162 ),
163 'priority' => array(
164 'type' => 'int',
165 'size' => 'tiny',
166 'not null' => TRUE,
167 'unsigned' => TRUE,
168 'default' => 0,
169 ),
170 ),
171 'primary key' => array('aid', 'priority'),
172 );
173 return $schema;
174 }
175
13 function ad_channel_install() { 176 function ad_channel_install() {
14 switch ($GLOBALS['db_type']) { 177 // Create tables
15 case 'mysql': 178 drupal_install_schema('ad_channel');
16 case 'mysqli':
17 default:
18 // TODO: PostgreSQL support. Patches welcome.
19 /* The ad_channel table stores channel definitions and rules.
20 */
21 db_query("CREATE TABLE {ad_channel} (
22 chid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
23 name VARCHAR(64) NOT NULL DEFAULT '',
24 description LONGTEXT NULL,
25 conid INT(11) UNSIGNED NOT NULL DEFAULT '0',
26 weight TINYINT(4) SIGNED NOT NULL DEFAULT '0',
27 display TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
28 no_channel_percent INT(3) NOT NULL DEFAULT '0',
29 urls TEXT NULL,
30 groups TEXT NULL,
31 PRIMARY KEY (chid),
32 KEY (name)
33 );");
34 /* The ad_channel_container table stores channel container definitions.
35 */
36 db_query("CREATE TABLE {ad_channel_container} (
37 conid INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
38 name VARCHAR(64) NOT NULL DEFAULT '',
39 description LONGTEXT NULL,
40 weight TINYINT(4) SIGNED NOT NULL DEFAULT '0',
41 PRIMARY KEY (conid)
42 );");
43 /* The ad_channel_node table stores per node channel information.
44 */
45 db_query("CREATE TABLE {ad_channel_node} (
46 chid INT(11) UNSIGNED NOT NULL DEFAULT '0',
47 nid INT(11) UNSIGNED NOT NULL DEFAULT '0',
48 PRIMARY KEY (chid, nid),
49 KEY (nid, chid)
50 );");
51 /* The ad_channel_node table stores per node channel information.
52 */
53 db_query("CREATE TABLE {ad_priority} (
54 aid INT(11) UNSIGNED NOT NULL DEFAULT '0',
55 priority TINYINT UNSIGNED NOT NULL DEFAULT '0',
56 PRIMARY KEY (aid, priority)
57 );");
58 }
59 } 179 }
60 180
61 /** 181 /**
62 * Completely uninstall the ad channel module. 182 * Completely uninstall the ad channel module.
63 */ 183 */
64 function ad_channel_uninstall() { 184 function ad_channel_uninstall() {
65 switch ($GLOBALS['db_type']) { 185 // Drop tables
66 case 'mysql': 186 drupal_uninstall_schema('ad_channel');
67 case 'mysqli':
68 default:
69 // TODO: PostgreSQL support. Patches welcome.
70 db_query('DROP TABLE {ad_channel}');
71 db_query('DROP TABLE {ad_channel_container}');
72 db_query('DROP TABLE {ad_channel_node}');
73 }
74 } 187 }
75 188
76 /** 189 /**
77 * Populate the ad_priority table. 190 * Populate the ad_priority table.
78 */ 191 */