/[drupal]/contributions/modules/openresort/business.install
ViewVC logotype

Contents of /contributions/modules/openresort/business.install

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


Revision 1.13 - (show annotations) (download) (as text)
Wed Jan 2 22:14:25 2008 UTC (22 months, 3 weeks ago) by marcingy
Branch: MAIN
CVS Tags: DRUPAL-5--1-15-1, DRUPAL-5--1-15-2, DRUPAL-5--1-16-6, DRUPAL-5--1-16-4, DRUPAL-5--1-16-5, DRUPAL-5--1-16-2, DRUPAL-5--1-16-3, DRUPAL-5--1-16-1, DRUPAL-5--1-15, DRUPAL-5--1-16, HEAD
Changes since 1.12: +0 -0 lines
File MIME type: text/x-php
*** empty log message ***
1 <?php
2 // $Id: $
3 function business_install() {
4
5 switch ($GLOBALS['db_type']) {
6 case 'pgsql':
7 case 'mysql':
8 case 'mysqli':
9 db_query("CREATE TABLE {business} (
10 nid int(10) unsigned NOT NULL default '0',
11 vid int(10) unsigned NOT NULL default '0',
12 sid int(10) unsigned NOT NULL default '0',
13 ptype varchar(75) NOT NULL default '',
14 phone varchar(20) NOT NULL default '',
15 altphone varchar(20) NOT NULL default '',
16 fax varchar(20) NOT NULL default '',
17 www varchar(200) NOT NULL default '',
18 email varchar(150) NOT NULL default '',
19 chambermember tinyint(2) NOT NULL default '0',
20 ecommerce tinyint(2) NOT NULL default '0',
21 inventory_mgmt tinyint(2) NOT NULL default '0',
22 virtual_units tinyint(2) NOT NULL default '0',
23 UNIQUE KEY nid (nid),
24 KEY sid (sid),
25 KEY bookable (ecommerce),
26 KEY vid (vid),
27 KEY ptype (ptype)
28 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
29 db_query("CREATE TABLE {business_ammenities} (
30 aid int(10) unsigned NOT NULL default NULL AUTO_INCREMENT,
31 description varchar(150) NOT NULL default '',
32 weight int(2) NOT NULL default '0',
33 helptext varchar(150) NOT NULL default '',
34 PRIMARY KEY (aid)
35 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
36 db_query("CREATE TABLE {business_ammenities_ptype} (
37 aid int(10) unsigned NOT NULL default '0',
38 ptype varchar(75) NOT NULL default '',
39 PRIMARY KEY (aid,ptype)
40 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
41 db_query("CREATE TABLE {business_ammenities_node} (
42 aid int(10) unsigned NOT NULL default '0',
43 nid int(10) unsigned NOT NULL default '0',
44 PRIMARY KEY (aid,nid)
45 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
46
47 db_query("INSERT INTO {business_ammenities} (description,helptext) VALUES
48 ('Hot Tub','Is there a hot tub?'),('Pool','Is there a pool?'),
49 ('Resturant','Is there a resturant?'),('Bar','Is there a bar?'),
50 ('Ski in','can you ski back to the property?'),
51 ('Ski out','Can you ski from the property?'),
52 ('Sauana','Is there a sauana?'), ('Steam Room','Is there a steam room?'),
53 ('Pet Friendly','Are pets welcome?'), ('Indoor Parking','Is there indoor parking?'),
54 ('Internet','Is there interent?')");
55 db_query("INSERT INTO {business_ammenities_ptype} (aid,ptype) VALUES
56 (1,'hotel'),(2,'hotel'),(3,'hotel'),(4,'hotel'),(5,'hotel'),
57 (6,'hotel'),(7,'hotel'),(8,'hotel'),(9,'hotel'),(10,'hotel'),(11,'hotel')");
58 db_query("INSERT INTO {business_ammenities} (description,helptext) VALUES
59 ('Kitchen','Is there a kitchen?'),('Fire Place','Is there a fire place?'),
60 ('Laundry','Is there a Laundry?'),('DVD','Is there a DVD?'),
61 ('VCR','Is there a VCR?'), ('Air Con','Is there aircon?'),
62 ('Non-smoking','Is it non-smoking?'), ('BBQ','Is there a BBQ?'),
63 ('Fridge','Is there a fridge?')");
64 db_query("INSERT INTO {business_ammenities_ptype} (aid,ptype) VALUES
65 (1,'unit'),(11,'unit'),(12,'unit'),(13,'unit'),(14,'unit'),(15,'unit')
66 ,(16,'unit'),(17,'unit'),(18,'unit'),(19,'unit'),(20,'unit')");
67 break;
68 }
69
70 // Notify of changes
71 if(function_exists('taxonomy_save_vocabulary')){
72 $vid = variable_get('business_nav_vocabulary', '');
73 if (empty($vid)) {
74 // Check to see if an business vocabulary exists
75 $edit = array('name' => t('Business Directory'), 'multiple' => 1, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'business', 'weight' => -10, 'nodes' => array('business' => 1));
76 taxonomy_save_vocabulary($edit);
77 $vid = $edit['vid'];
78 variable_set('business_nav_vocabulary', $vid);
79 }
80 }
81 drupal_set_message(t('Business module was successfully installed with default options'));
82 }
83
84 function business_update_3(){
85 $items = array();
86 $items[] = update_sql("UPDATE {business} SET ptype = 'hotel' WHERE ptype ='hostel'");
87 $items[] = update_sql("UPDATE {business} SET ptype = 'hotel' WHERE ptype ='condo'");
88 $items[] = update_sql("UPDATE {business} SET ptype = 'hotel' WHERE ptype ='chalet'");
89 $items[] = update_sql("UPDATE {business} SET ptype = 'hotel' WHERE ptype ='bandb'");
90 $items[] = update_sql("UPDATE {business} SET ptype = 'generic' WHERE ptype =''");
91 return $items;
92 }
93
94 function business_update_4(){
95 $items = array();
96 $vid = variable_get('business_nav_vocabulary', '');
97 if (empty($vid)) {
98 // Check to see if an business vocabulary exists
99 drupal_set_message(t('Created business directory'));
100 $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE name='%s'", 'Business Directory'));
101 if (!$vid) {
102 $vocabulary = array('name' => t('Business Directory'), 'multiple' => '0', 'required' => '0', 'hierarchy' => '1', 'relations' => '0', 'module' => 'business', 'nodes' => array('business'));
103 taxonomy_save_vocabulary($vocabulary);
104 $vid = $vocabulary['vid'];
105 }
106 variable_set('business_nav_vocabulary', $vid);
107 return $items;
108 }
109 }
110
111 function business_update_5(){
112 $items = array();
113 $items[] = update_sql("CREATE TABLE {business_ammenities} (
114 aid int(10) unsigned NOT NULL default NULL AUTO_INCREMENT,
115 description varchar(150) NOT NULL default '',
116 weight int(2) NOT NULL default '0',
117 helptext varchar(150) NOT NULL default '',
118 PRIMARY KEY (aid)
119 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
120 $items[] = update_sql("CREATE TABLE {business_ammenities_ptype} (
121 aid int(10) unsigned NOT NULL default '0',
122 ptype varchar(75) NOT NULL default '',
123 PRIMARY KEY (aid,ptype)
124 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
125 $items[] = update_sql("CREATE TABLE {business_ammenities_node} (
126 aid int(10) unsigned NOT NULL default '0',
127 nid int(10) unsigned NOT NULL default '0',
128 PRIMARY KEY (aid,nid)
129 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
130 return $items;
131 }
132
133 function business_update_6(){
134 $items = array();
135 $items[] = update_sql("INSERT INTO {business_ammenities} (description,helptext) VALUES ('Hot Tub','Is there a hot tub?'),('Pool','Is there a pool?'),('Resturant','Is there a resturant?'),('Bar','Is there a bar?'), ('Ski in','can you ski back to the property?'), ('Ski out','Can you ski from the property?'), ('Sauana','Is there a sauana?'), ('Steam Room','Is there a steam room?'), ('Pet Friendly','Are pets welcome?'), ('Indoor Parking','Is there indoor parking?'), ('Internet','Is there interent?')");
136 $items[] = update_sql("INSERT INTO {business_ammenities_ptype} (aid,ptype) VALUES (1,'hotel'),(2,'hotel'),(3,'hotel'),(4,'hotel'),(5,'hotel'),(6,'hotel'),(7,'hotel'),(8,'hotel'),(9,'hotel'),(10,'hotel'),(11,'hotel')");
137 $items[] = update_sql("INSERT INTO {business_ammenities} (description,helptext) VALUES ('Kitchen','Is there a kitchen?'),('Fire Place','Is there a fire place?'),('Laundry','Is there a Laundry?'),('DVD','Is there a DVD?'), ('VCR','Is there a VCR?'), ('Air Con','Is there aircon?'), ('Non-smoking','Is it non-smoking?'), ('BBQ','Is there a BBQ?'), ('Fridge','Is there a fridge?')");
138 $items[] = update_sql("INSERT INTO {business_ammenities_ptype} (aid,ptype) VALUES (1,'unit'),(11,'unit'),(12,'unit'),(13,'unit'),(14,'unit'),(15,'unit')
139 ,(16,'unit'),(17,'unit'),(18,'unit'),(19,'unit'),(20,'unit')");
140 return $items;
141 }
142
143 function business_update_7(){
144 $items = array();
145 $facilities = array();
146 $result = db_query('SELECT * FROM {business_hotel}');
147 while ($hotel = db_fetch_object($result)){
148 if($hotel->hottub){
149 $facilities[] = '(1,'.$hotel->nid.')';
150 }
151 if($hotel->pool){
152 $facilities[] = '(2,'.$hotel->nid.')';
153 }
154 if($hotel->restaurant){
155 $facilities[] = '(3,'.$hotel->nid.')';
156 }
157 if($hotel->bar){
158 $facilities[] = '(4,'.$hotel->nid.')';
159 }
160 if($hotel->skiin){
161 $facilities[] = '(5,'.$hotel->nid.')';
162 }
163 if($hotel->skiout){
164 $facilities[] = '(6,'.$hotel->nid.')';
165 }
166 if($hotel->sauana){
167 $facilities[] = '(7,'.$hotel->nid.')';
168 }
169 if($hotel->steamroom){
170 $facilities[] = '(8,'.$hotel->nid.')';
171 }
172 if($hotel->petfriendly){
173 $facilities[] = '(9,'.$hotel->nid.')';
174 }
175 if($hotel->indoorparking){
176 $facilities[] = '(10,'.$hotel->nid.')';
177 }
178 if($hotel->internet){
179 $facilities[] = '(11,'.$hotel->nid.')';
180 }
181 }
182 if(sizeof($facilities) > 0){
183 $update = implode(',',$facilities);
184 $items[] = update_sql("INSERT INTO {business_ammenities_node} (aid,nid) VALUES ".$update);
185 }
186 return $items;
187 }
188
189 function business_update_8(){
190 $items = array();
191 $facilities = array();
192 $result = db_query('SELECT * FROM {accommodation_units}');
193 while ($unit = db_fetch_object($result)){
194 if($unit->hottub){
195 $facilities[] = '(1,'.$unit->nid.')';
196 }
197 if($unit->unitinternet){
198 $facilities[] = '(11,'.$unit->nid.')';
199 }
200 if($unit->kitchen){
201 $facilities[] = '(12,'.$unit->nid.')';
202 }
203 if($unit->fireplace){
204 $facilities[] = '(13,'.$unit->nid.')';
205 }
206 if($unit->nonsmoking){
207 $facilities[] = '(14,'.$unit->nid.')';
208 }
209 if($unit->laundry){
210 $facilities[] = '(15,'.$unit->nid.')';
211 }
212 if($unit->DVD){
213 $facilities[] = '(16,'.$unit->nid.')';
214 }
215 if($unit->VCR){
216 $facilities[] = '(17,'.$unit->nid.')';
217 }
218 if($unit->aircon){
219 $facilities[] = '(18,'.$unit->nid.')';
220 }
221 if($unit->bbq){
222 $facilities[] = '(19,'.$unit->nid.')';
223 }
224 if($unit->fridge){
225 $facilities[] = '(20,'.$unit->nid.')';
226 }
227 }
228 if(sizeof($facilities) > 0){
229 $update = implode(',',$facilities);
230 $items[] = update_sql("INSERT INTO {business_ammenities_node} (aid,nid) VALUES ".$update);
231 }
232 return $items;
233 }
234
235 function business_update_9(){
236 $items = array();
237 $items[] = update_sql("ALTER TABLE {accommodation_units} DROP COLUMN kitchen, DROP COLUMN qty
238 ,DROP COLUMN hottub,DROP COLUMN fireplace,DROP COLUMN nonsmoking,DROP COLUMN laundry,DROP COLUMN DVD,DROP COLUMN VCR,
239 DROP COLUMN aircon,DROP COLUMN bbq,DROP COLUMN fridge,DROP COLUMN updater,DROP COLUMN unitinternet");
240 $items[] = update_sql("DROP TABLE {business_hotel}");
241 return $items;
242 }
243
244 function business_update_10(){
245 $items = array();
246 $items[] = update_sql("DELETE FROM {business_ammenities_ptype} WHERE aid = 0");
247 return $items;
248 }

  ViewVC Help
Powered by ViewVC 1.1.2