-
Notifications
You must be signed in to change notification settings - Fork 2
/
openadstream.install
255 lines (236 loc) · 6.08 KB
/
openadstream.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<?php
// $Id: openadstream.install,v 1.1.2.6 2009/12/17 04:31:46 damienmckenna Exp $
/**
* @file
* Install, update and uninstall functions for the Open AdStream module.
*/
/**
* Implements hook_schema().
*/
function openadstream_schema() {
$schema = array();
$schema['openadstream_tags'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'tags' => array(
'type' => 'varchar',
'length' => 100,
'default' => '',
),
),
'primary key' => array('vid'),
);
$schema['openadstream_positions'] = array(
'fields' => array(
'position_id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => 75,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('position_id'),
'indexes' => array('name' => array('name')),
);
$schema['openadstream_node_pagenames'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'pagename' => array(
'type' => 'varchar',
'length' => 75,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('nid'),
'indexes' => array('pagename' => array('pagename')),
);
$schema['openadstream_pagenames'] = array(
'fields' => array(
'pagename_id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'path' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'pagename' => array(
'type' => 'varchar',
'length' => 75,
'not null' => TRUE,
'default' => '',
),
'weight' => array(
'type' => 'int',
'unsigned' => FALSE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('pagename_id'),
);
$schema['openadstream_gutters'] = array(
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'path' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'date_from' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'date_to' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'is_include' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'default' => 1,
),
'bgcolor' => array(
'type' => 'char',
'length' => 6,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('id'),
'indexes' => array(
'dates' => array('id', 'date_from', 'date_to', 'is_include'),
),
);
return $schema;
}
/**
* Implements hook_enable().
*/
function openadstream_enable() {
// Check whether the defaults have been installed before.
if (!variable_get('openadstream_defaults_installed', FALSE)) {
// Add the default gutters.
openadstream_default_gutters();
variable_set('openadstream_defaults_installed', TRUE);
}
}
/**
* Implements hook_uninstall().
*/
function openadstream_uninstall() {
_block_rehash();
variable_del('openadstream_defaults_installed');
}
/**
* Add the new description field
*/
function openadstream_update_6301() {
// Add the new description field.
$spec = array(
'type' => 'varchar',
'length' => 100,
'not null' => TRUE,
'default' => '',
);
db_add_field('openadstream_positions', 'description', $spec);
return t('Updated Open AdStream positions table.');
}
/**
* Add the new gutters table and the default gutters
*/
function openadstream_update_6302() {
// Add the new gutters table.
$schema = openadstream_schema();
db_create_table('openadstream_gutters', $schema['openadstream_gutters']);
// Add the default gutters.
openadstream_default_gutters();
$ret[] = array('success' => TRUE, 'query' => "Added some default gutter ad settings to get you started.");
return t('Updated Open AdStream adding gutters table.');
}
/**
* Add the new background color field
*/
function openadstream_update_6303() {
// Add the new background color field.
$spec = array(
'type' => 'char',
'length' => 7,
'not null' => TRUE,
'default' => '',
);
db_add_field('openadstream_gutters', 'bgcolor', $spec);
return t('Updated Open AdStream gutters table.');
}
/**
* Check if default gutters were installed, installing if they were not
* and then marking a new variable setting indicating defaults installed.
*/
function openadstream_update_6304() {
// Check whether the defaults have been installed before.
if (!variable_get('openadstream_defaults_installed', FALSE)) {
// Add the default gutters.
openadstream_default_gutters();
variable_set('openadstream_defaults_installed', TRUE);
return t('Added some default gutter ad settings to get you started.');
}
else {
return t('Default gutter ad settings already loaded.');
}
}
/**
* Add default gutters.
*/
function openadstream_default_gutters() {
// Add a default include gutter.
$obj = new stdClass;
$obj->path = '*';
$obj->is_include = TRUE;
drupal_write_record('openadstream_gutters', $obj);
// Add a default exclude gutter.
$obj = new stdClass;
$obj->path = "admin\nadmin/*\nnode/add\nnode/add/*\nnode/*/edit";
$obj->is_include = FALSE;
drupal_write_record('openadstream_gutters', $obj);
}