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

Contents of /contributions/modules/banner/banner.install

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


Revision 1.10 - (show annotations) (download) (as text)
Tue Jan 30 23:19:30 2007 UTC (2 years, 9 months ago) by wulff
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +17 -3 lines
File MIME type: text/x-php
#102677 - rename content field - thanks heine
#105334 - some fixes for remote banners - thanks bdragon
1 <?php
2 // $Id: banner.install,v 1.9 2006/12/10 20:59:30 wulff Exp $
3 // FIXME: fix pgsql support
4 function banner_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysql':
7 case 'mysqli':
8 db_query("
9 CREATE TABLE {banner} (
10 vid INT(10) UNSIGNED NOT NULL DEFAULT '0',
11 nid INT(10) UNSIGNED NOT NULL DEFAULT '0',
12
13 -- basic information
14 url VARCHAR(255) NOT NULL DEFAULT '',
15 target VARCHAR(8) NOT NULL DEFAULT '',
16 workflow TINYINT UNSIGNED NOT NULL DEFAULT '0',
17 mode TINYINT UNSIGNED NOT NULL DEFAULT '0',
18 banner_content TEXT,
19 cache TEXT,
20
21 -- notifications
22 notify_day TINYINT UNSIGNED NOT NULL DEFAULT '0',
23 notify_week TINYINT UNSIGNED NOT NULL DEFAULT '0',
24 notify_failed INT(3) UNSIGNED NOT NULL DEFAULT '0',
25 notify_send TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
26 notify_sent TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
27
28 -- limits
29 chance INT UNSIGNED NOT NULL DEFAULT '1',
30 clicks_max INT UNSIGNED NOT NULL DEFAULT '0',
31 views_max INT UNSIGNED NOT NULL DEFAULT '0',
32 views_week_max INT UNSIGNED NOT NULL DEFAULT '0',
33 views_day_max INT UNSIGNED NOT NULL DEFAULT '0',
34
35 -- statistics
36 views INT UNSIGNED NOT NULL DEFAULT '0',
37 views_week INT UNSIGNED NOT NULL DEFAULT '0',
38 views_day INT UNSIGNED NOT NULL DEFAULT '0',
39 clicks INT UNSIGNED NOT NULL DEFAULT '0',
40 clicks_week INT UNSIGNED NOT NULL DEFAULT '0',
41 clicks_day INT UNSIGNED NOT NULL DEFAULT '0',
42
43 -- file information
44 width INT UNSIGNED NOT NULL DEFAULT '0',
45 height INT UNSIGNED NOT NULL DEFAULT '0',
46
47 PRIMARY KEY (vid),
48 KEY (nid),
49 KEY (workflow)
50 ) /*!40100 DEFAULT CHARACTER SET utf8 */;
51 ");
52 break;
53 case 'pgsql':
54 db_query("
55 CREATE TABLE {banner} (
56 nid integer NOT NULL DEFAULT '0',
57 vid integer NOT NULL DEFAULT '0',
58
59 url varchar(255) NOT NULL DEFAULT '',
60 target varchar(8) NOT NULL DEFAULT '',
61 workflow smallint NOT NULL DEFAULT '0',
62 mode smallint NOT NULL DEFAULT '0',
63 banner_content text NOT NULL DEFAULT '',
64 cache text NOT NULL DEFAULT '',
65
66 notify_day smallint NOT NULL DEFAULT '0',
67 notify_week smallint NOT NULL DEFAULT '0',
68 notify_failed smallint NOT NULL DEFAULT '0',
69 notify_send smallint NOT NULL DEFAULT '0',
70 notify_sent smallint NOT NULL DEFAULT '0',
71
72 chance smallint NOT NULL DEFAULT '1',
73 clicks_max integer NOT NULL DEFAULT '0',
74 views_max integer NOT NULL DEFAULT '0',
75 views_week_max integer NOT NULL DEFAULT '0',
76 views_day_max integer NOT NULL DEFAULT '0',
77
78 views integer NOT NULL DEFAULT '0',
79 views_week integer NOT NULL DEFAULT '0',
80 views_day integer NOT NULL DEFAULT '0',
81 clicks integer NOT NULL DEFAULT '0',
82 clicks_week integer NOT NULL DEFAULT '0',
83 clicks_day integer NOT NULL DEFAULT '0',
84
85 width integer NOT NULL DEFAULT '0',
86 height integer NOT NULL DEFAULT '0',
87
88 PRIMARY KEY (vid)
89 );
90 ");
91
92 break;
93 }
94
95 // create vocabulary for banner groups
96 $edit = array(
97 'name' => t('Banner groups'),
98 'description' => t('This vocabulary is a container for banner groups.'),
99 'help' => t('Choose the banner groups you want to add this banner to.'),
100 'required' => 1,
101 'multiple' => 1,
102 'weight' => -10,
103 'module' => 'banner',
104 'nodes' => array(
105 'banner' => 1,
106 ),
107 );
108 taxonomy_save_vocabulary($edit);
109
110 // get the vid of the vocabulary
111 $vocabularies = taxonomy_get_vocabularies('banner');
112 foreach ($vocabularies as $vid => $voc) {
113 variable_set('banner_vocabulary', $vid);
114 }
115
116 // create default banner groups
117 for ($i = 1; $i <= 3; $i++) {
118 $edit = array(
119 'name' => 'Banner group '. $i,
120 'description' => '',
121 'weight' => 0,
122 'vid' => variable_get('banner_vocabulary', ''),
123 );
124 taxonomy_save_term($edit);
125 }
126 }
127
128 function banner_update_1() {
129 $ret = array();
130 switch ($GLOBALS['db_type']) {
131 case 'mysql':
132 case 'mysqli':
133 $ret[] = update_sql("ALTER TABLE {banner} CHANGE content banner_content TEXT");
134 break;
135 case 'pgsql':
136 $ret[] = update_sql("ALTER TABLE {banner} RENAME content TO banner_content");
137 break;
138 }
139 return $ret;
140 }
141
142 function banner_uninstall() {
143 db_query('DROP TABLE {banner}');
144 variable_del('banner_cache_todo');
145 variable_del('banner_vocabulary');
146 variable_del('banner_cache');
147 variable_del('banner_cache_max');
148 variable_del('banner_daily_notification');
149 variable_del('banner_weekly_notification');
150 variable_del('banner_failed_notify');
151 variable_del('banner_renewal');
152 variable_del('banner_renewal_time');
153 variable_del('banner_renewal_message');
154 variable_del('banner_notify_failed');
155 }

  ViewVC Help
Powered by ViewVC 1.1.2