summaryrefslogtreecommitdiffstats
path: root/views.install
blob: f1c854939086535d6799821b6d895e2ab90a19c7 (plain)
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<?php
  // $Id$

  function views_install() {
    drupal_set_message('Installing views');
    switch ($GLOBALS['db_type']) {
      case 'mysqli':
      case 'mysql':
      db_query("CREATE TABLE if not exists {view_view} (
        vid int(10) unsigned NOT NULL default '0',
        name varchar(32) NOT NULL UNIQUE,
        description varchar(255),
        access varchar(255),
        -- page fields
        page int(1),
        page_title varchar(255),
        page_header longtext,
        page_header_format int(4) NOT NULL,
        page_empty longtext,
        page_empty_format int(4) NOT NULL,
        page_footer longtext,
        page_footer_format int(4) NOT NULL,
        page_type varchar(20),
        use_pager int(1),
        nodes_per_page int(5),
        url varchar(255),
        -- menu fields
        menu int(1),
        menu_tab int(1),
        menu_tab_default int(1),
        menu_tab_weight int(4),
        menu_title varchar(255),
        -- block fields
        block int(1),
        block_title varchar(255),
        block_use_page_header int(1),
        block_header longtext,
        block_header_format int(4) NOT NULL,
        block_use_page_footer int(1),
        block_footer longtext,
        block_footer_format int(4) NOT NULL,
        block_use_page_empty int(1),
        block_empty longtext,
        block_empty_format int(4) NOT NULL,
        block_type varchar(20),
        nodes_per_block int(5),
        block_more int(1),
        -- breadcrumb
        breadcrumb_no_home int(1), -- true means start breadcrumb trail from 'Home'.
        -- other
        changed int(11),
        query longtext,
        countquery longtext,
        view_args_php longtext,
        PRIMARY KEY (vid),
        KEY (name)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");

      db_query("CREATE TABLE if not exists {view_sort} (
        vid int(10) unsigned NOT NULL default '0',
        position int(2),
        field varchar(255),
        sortorder varchar(5),
        options varchar(255),
        tablename varchar(255),
        KEY (vid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");

      db_query("CREATE TABLE if not exists {view_argument} (
        vid int(10) unsigned NOT NULL default '0',
        type varchar(255),
        argdefault varchar(255),
        title varchar(255),
        options varchar(255),
        position int(2),
        wildcard varchar(32),
        wildcard_substitution varchar(32),
        KEY (vid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");

      db_query("CREATE TABLE if not exists {view_tablefield} (
        vid int(10) unsigned NOT NULL default '0',
        tablename varchar(255),
        field varchar(255),
        label varchar(255),
        handler varchar(255),
        sortable int(1),
        defaultsort varchar(5),
        options varchar(255),
        position int(2),
        KEY (vid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");

      db_query("CREATE TABLE if not exists {view_filter} (
        vid int(10) unsigned NOT NULL default '0',
        tablename varchar(255),
        field varchar(255),
        value longtext,
        operator varchar(20),
        options varchar(255),
        position int(2),
        KEY (vid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");

      db_query("CREATE TABLE if not exists {view_exposed_filter} (
        vid int(10) unsigned NOT NULL default '0',
        field varchar(255),
        label varchar(255),
        optional int(1),
        is_default int(1),
        operator int(1),
        single int(1),
        position int(2),
        KEY (vid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");

      $success = TRUE;
      break;
    case 'pgsql':
      db_query("CREATE TABLE {view_view} (
        vid SERIAL,
        name varchar(32) NOT NULL UNIQUE,
        description varchar(255),
        access varchar(255),
        -- page fields
        page smallint,
        page_title varchar(255),
        page_header text,
        page_header_format smallint NOT NULL,
        page_empty text,
        page_empty_format smallint NOT NULL,
        page_footer text,
        page_footer_format smallint NOT NULL,
        page_type varchar(20),
        use_pager smallint,
        nodes_per_page smallint, 
        url varchar(255),
        -- menu fields
        menu smallint,
        menu_tab smallint,
        menu_tab_default smallint,
        menu_tab_weight smallint,
        menu_title varchar(255),
        -- block fields
        block smallint,
        block_title varchar(255),
        block_use_page_header smallint,
        block_header text,
        block_header_format smallint NOT NULL,
        block_use_page_footer smallint,
        block_footer text,
        block_footer_format smallint NOT NULL,
        block_use_page_empty smallint,
        block_empty text,
        block_empty_format smallint NOT NULL,
        block_type varchar(20),
        nodes_per_block smallint,
        block_more smallint,
        -- breadcrumb
        breadcrumb_no_home smallint, -- true means start breadcrumb trail from 'Home'.
        -- other
        changed integer,
        query text,
        countquery text,
        view_args_php text,
        PRIMARY KEY (vid)
      )");
      db_query("CREATE INDEX {view_view}_name_idx ON {view_view} (name)");

      db_query("CREATE TABLE {view_sort} (
        vid integer NOT NULL default '0',
        position smallint,
        field varchar(255),
        sortorder varchar(5),
        options varchar(255),
        tablename varchar(255)
      )");
      db_query("CREATE INDEX {view_sort}_vid_idx ON {view_sort} (vid)");

      db_query("CREATE TABLE {view_argument} (
        vid integer NOT NULL default '0',
        type varchar(255),
        argdefault varchar(255),
        title varchar(255),
        options varchar(255),
        position smallint,
        wildcard varchar(32),
        wildcard_substitution varchar(32)
      )");
      db_query("CREATE INDEX {view_argument}_vid_idx ON {view_argument} (vid)");

      db_query("CREATE TABLE {view_tablefield} (
        vid integer NOT NULL default '0',
        tablename varchar(255),
        field varchar(255),
        label varchar(255),
        handler varchar(255),
        sortable smallint,
        defaultsort varchar(5),
        options varchar(255),
        position smallint
      )");
      db_query("CREATE INDEX {view_tablefield}_vid_idx ON {view_tablefield} (vid)");

      db_query("CREATE TABLE {view_filter} (
        vid integer NOT NULL default '0',
        tablename varchar(255),
        field varchar(255),
        value text,
        operator varchar(20),
        options varchar(255),
        position smallint
      )");
      db_query("CREATE INDEX {view_filter}_vid_idx ON {view_filter} (vid)");
      db_query("CREATE TABLE {view_exposed_filter} (
        vid integer NOT NULL default '0',
        field varchar(255),
        label varchar(255),
        optional smallint,
        is_default smallint,
        operator smallint,
        single smallint,
        position smallint
      )");
      db_query("CREATE INDEX {view_exposed_filter}_vid_idx ON {view_exposed_filter} (vid)");

      $success = TRUE;
      break;
  } // End case

  if ($success) {
    drupal_set_message(t('Views module installed tables successfully.'));
  }
  else {
    drupal_set_message(t('The installation of views module was unsuccessful.'), 'error');
  }
}

/*
 * update module for UTF.
 */
function views_update_1() {
  return _system_update_utf8(array('view_view', 'view_tablefield', 'view_filter', 'view_sort', 'view_argument'));
}

/**
 * Dummy function cause we're apparently not to skip update #s.
 */
function views_update_2() {
// dummy function
  return array();
}
/*
 * update module for exposed filters.
 */
function views_update_3() {
  $ret = array();
//  db_add_column($ret, 'view_view', 'page_empty', 'longtext');
//  db_add_column($ret, 'view_view', 'page_empty_format', 'int(4)', array('not null' => TRUE));
//  db_add_column($ret, 'view_view', 'block_use_page_empty', 'int(1)');
//  db_add_column($ret, 'view_view', 'block_empty', 'longtext');
//  db_add_column($ret, 'view_view', 'block_empty_format', 'int(4)', array('not null' => TRUE));
  switch($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
    $ret[] = update_sql("CREATE TABLE if not exists {view_exposed_filter} (
        vid int(10) unsigned NOT NULL default '0',
        field varchar(255),
        label varchar(255),
        optional int(1),
        is_default int(1),
        operator int(1),
        single int(1),
        position int(2),
        KEY (vid)
      ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE TABLE {view_exposed_filter} (
        vid numeric(10) unsigned NOT NULL default '0',
        field varchar(255),
        label varchar(255),
        optional numeric(1),
        is_default numeric(1),
        operator numeric(1),
        single numeric(1),
        position numeric(2),
      )");
      $ret[] = update_sql("CREATE INDEX {view_exposed_filter}_vid_idx ON {view_exposed_filter} (vid)");
      break;
  }
  return $ret;
}

function views_update_4() {
  $ret = array();
  db_add_column($ret, 'view_view', 'page_footer', 'longtext');
  db_add_column($ret, 'view_view', 'page_footer_format', 'int(4)', array('default' => 0));
  db_add_column($ret, 'view_view', 'block_use_page_footer', 'int(1)');
  db_add_column($ret, 'view_view', 'block_footer', 'longtext');
  db_add_column($ret, 'view_view', 'block_footer_format', 'int(4)', array('default' => 0));
  db_add_column($ret, 'view_view', 'page_empty', 'longtext');
  db_add_column($ret, 'view_view', 'page_empty_format', 'int(4)', array('default' => 0));
  db_add_column($ret, 'view_view', 'block_use_page_empty', 'int(1)');
  db_add_column($ret, 'view_view', 'block_empty', 'longtext');
  db_add_column($ret, 'view_view', 'block_empty_format', 'int(4)', array('default' => 0));
  return $ret;
}

function views_update_5() {
  $ret = array();
  db_add_column($ret, 'view_view', 'view_args_php', 'longtext');
  return $ret;
}

function views_update_6() {
  $ret = array();
  db_add_column($ret, 'view_tablefield', 'options', 'varchar(255)');
  return $ret;
}

function views_update_7() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE {view_argument} MODIFY type varchar(255)");
  return $ret;
}

function views_update_8() {
  $ret = array();
  $ret[] = update_sql("ALTER TABLE {view_view} MODIFY nodes_per_page int(5)");
  return $ret;
}

function views_update_9() {
  $ret = array();
  db_add_column($ret, 'view_argument', 'wildcard', 'varchar(32)');
  db_add_column($ret, 'view_argument', 'wildcard_substitution', 'varchar(32)');
  return $ret;
}