| 1 |
<?php
|
| 2 |
/* $Id: weather.install,v 1.41 2009/09/03 21:24:19 toddy Exp $
|
| 3 |
*
|
| 4 |
* Copyright © 2006-2009 Tobias Quathamer <t.quathamer@gmx.net>
|
| 5 |
*
|
| 6 |
* This file is part of the Drupal Weather module.
|
| 7 |
*
|
| 8 |
* Weather is free software; you can redistribute it and/or modify
|
| 9 |
* it under the terms of the GNU General Public License as published by
|
| 10 |
* the Free Software Foundation; either version 2 of the License, or
|
| 11 |
* (at your option) any later version.
|
| 12 |
*
|
| 13 |
* Weather is distributed in the hope that it will be useful,
|
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
* GNU General Public License for more details.
|
| 17 |
*
|
| 18 |
* You should have received a copy of the GNU General Public License
|
| 19 |
* along with Weather; if not, write to the Free Software
|
| 20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
| 21 |
*/
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
/**
|
| 26 |
* @file
|
| 27 |
* Database installation of weather module.
|
| 28 |
*/
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Implementation of hook_install().
|
| 34 |
*/
|
| 35 |
function weather_install() {
|
| 36 |
// Install the database schema
|
| 37 |
drupal_install_schema('weather');
|
| 38 |
|
| 39 |
// Insert ICAO data into table
|
| 40 |
require_once drupal_get_path('module', 'weather') .'/weather_data.inc';
|
| 41 |
_weather_fill_icao_table();
|
| 42 |
}
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
/**
|
| 47 |
* Implementation of hook_uninstall().
|
| 48 |
*/
|
| 49 |
function weather_uninstall() {
|
| 50 |
variable_del('weather_fetch');
|
| 51 |
variable_del('weather_use_cron');
|
| 52 |
|
| 53 |
// Remove the database schema
|
| 54 |
drupal_uninstall_schema('weather');
|
| 55 |
}
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
/**
|
| 60 |
* Implementation of hook_schema().
|
| 61 |
*/
|
| 62 |
function weather_schema() {
|
| 63 |
$schema['weather_metar'] = array(
|
| 64 |
'description' => 'Stores the raw METAR data for each ICAO code, together with the time of the next scheduled update',
|
| 65 |
'fields' => array(
|
| 66 |
'icao' => array(
|
| 67 |
'description' => 'ICAO code of the METAR station',
|
| 68 |
'type' => 'varchar', 'length' => 4, 'not null' => TRUE, 'default' => ''
|
| 69 |
),
|
| 70 |
'next_update_on' => array(
|
| 71 |
'description' => 'UNIX timestamp of next possible update',
|
| 72 |
'type' => 'int', 'not null' => TRUE, 'default' => 0
|
| 73 |
),
|
| 74 |
'metar_raw' => array(
|
| 75 |
'description' => 'Raw METAR data, not parsed',
|
| 76 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 77 |
),
|
| 78 |
),
|
| 79 |
'primary key' => array(
|
| 80 |
'icao'
|
| 81 |
),
|
| 82 |
);
|
| 83 |
|
| 84 |
$schema['weather_locations'] = array(
|
| 85 |
'description' => 'Stores the configuration of one weather location',
|
| 86 |
'fields' => array(
|
| 87 |
'block_type' => array(
|
| 88 |
'description' => 'Type of block, e.g. system, user, default',
|
| 89 |
'type' => 'varchar', 'length' => 10, 'not null' => TRUE, 'default' => ''
|
| 90 |
),
|
| 91 |
'block_id' => array(
|
| 92 |
'description' => 'Block ID for system blocks, user ID for custom weather blocks',
|
| 93 |
'type' => 'int', 'not null' => TRUE, 'default' => 0
|
| 94 |
),
|
| 95 |
'location_id' => array(
|
| 96 |
'description' => 'Location ID, to enable multiple locations in one block',
|
| 97 |
'type' => 'int', 'not null' => TRUE, 'default' => 0
|
| 98 |
),
|
| 99 |
'icao' => array(
|
| 100 |
'description' => 'ICAO code of the METAR station',
|
| 101 |
'type' => 'varchar', 'length' => 4, 'not null' => TRUE, 'default' => ''
|
| 102 |
),
|
| 103 |
'real_name' => array(
|
| 104 |
'description' => 'The name to display for the ICAO code',
|
| 105 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 106 |
),
|
| 107 |
'units' => array(
|
| 108 |
'description' => 'Units for display (Celsius/Fahrenheit, mmHg/hPa etc.)',
|
| 109 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 110 |
),
|
| 111 |
'settings' => array(
|
| 112 |
'description' => 'Settings for display (Show raw METAR, abbrev. wind directions etc.)',
|
| 113 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 114 |
),
|
| 115 |
'weight' => array(
|
| 116 |
'description' => 'Weight of the location',
|
| 117 |
'type' => 'int', 'not null' => TRUE, 'default' => 0
|
| 118 |
),
|
| 119 |
),
|
| 120 |
'primary key' => array(
|
| 121 |
'block_id', 'location_id'
|
| 122 |
),
|
| 123 |
);
|
| 124 |
|
| 125 |
$schema['weather_block_settings'] = array(
|
| 126 |
'description' => 'Stores the configuration of weather blocks',
|
| 127 |
'fields' => array(
|
| 128 |
'block_type' => array(
|
| 129 |
'description' => 'Type of block, e.g. system, user, default',
|
| 130 |
'type' => 'varchar', 'length' => 10, 'not null' => TRUE, 'default' => ''
|
| 131 |
),
|
| 132 |
'block_id' => array(
|
| 133 |
'description' => 'Block ID for system blocks, user ID for custom weather blocks',
|
| 134 |
'type' => 'int', 'not null' => TRUE, 'default' => 0
|
| 135 |
),
|
| 136 |
'units' => array(
|
| 137 |
'description' => 'Units for display (Celsius/Fahrenheit, mmHg/hPa etc.)',
|
| 138 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 139 |
),
|
| 140 |
'settings' => array(
|
| 141 |
'description' => 'Settings for display (Show raw METAR, abbrev. wind directions etc.)',
|
| 142 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 143 |
),
|
| 144 |
),
|
| 145 |
'primary key' => array(
|
| 146 |
'block_id'
|
| 147 |
),
|
| 148 |
);
|
| 149 |
|
| 150 |
$schema['weather_icao'] = array(
|
| 151 |
'description' => 'Contains all known ICAO codes with further information. The countries are not decoupled, but that is probably not worth the effort.',
|
| 152 |
'fields' => array(
|
| 153 |
'icao' => array(
|
| 154 |
'description' => 'ICAO code of the METAR station',
|
| 155 |
'type' => 'varchar', 'length' => 4, 'not null' => TRUE, 'default' => ''
|
| 156 |
),
|
| 157 |
'country' => array(
|
| 158 |
'description' => 'Name of the country',
|
| 159 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 160 |
),
|
| 161 |
'name' => array(
|
| 162 |
'description' => 'Name of the METAR station',
|
| 163 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 164 |
),
|
| 165 |
'latitude' => array(
|
| 166 |
'description' => 'Location of METAR station, latitude',
|
| 167 |
'type' => 'float', 'size' => 'big', 'not null' => TRUE, 'default' => 0.0
|
| 168 |
),
|
| 169 |
'longitude' => array(
|
| 170 |
'description' => 'Location of METAR station, longitude',
|
| 171 |
'type' => 'float', 'size' => 'big', 'not null' => TRUE, 'default' => 0.0
|
| 172 |
),
|
| 173 |
),
|
| 174 |
'primary key' => array(
|
| 175 |
'icao'
|
| 176 |
),
|
| 177 |
);
|
| 178 |
|
| 179 |
return $schema;
|
| 180 |
}
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
/**
|
| 185 |
* Implementation of hook_update_last_removed().
|
| 186 |
*
|
| 187 |
* The updates 1-3 were for Drupal 4.7.x, which is no longer supported.
|
| 188 |
*
|
| 189 |
* Drupal 5.x (will be removed after Drupal 7.x is out):
|
| 190 |
* Update 4, 5, 6, 7, 8, 9
|
| 191 |
*
|
| 192 |
* Drupal 6.x:
|
| 193 |
* Update 6100, 6101, 6200
|
| 194 |
*/
|
| 195 |
function weather_update_last_removed() {
|
| 196 |
return 3;
|
| 197 |
}
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
/**
|
| 202 |
* Implementation of hook_update_N().
|
| 203 |
*
|
| 204 |
* Expand the units column and add a config column
|
| 205 |
*/
|
| 206 |
function weather_update_4() {
|
| 207 |
$ret = array();
|
| 208 |
|
| 209 |
switch ($GLOBALS['db_type']) {
|
| 210 |
case 'mysql':
|
| 211 |
case 'mysqli':
|
| 212 |
// expand the VARCHAR for units from 8 to 255
|
| 213 |
$sql = "ALTER TABLE {weather_config} CHANGE units units VARCHAR(255) NOT NULL DEFAULT '%s'";
|
| 214 |
// we cannot use update_sql() because of the brackets {} issue
|
| 215 |
$result = db_query($sql, 'a:4:{s:11:"temperature";s:7:"celsius";s:9:"windspeed";s:3:"kmh";s:8:"pressure";s:3:"hpa";s:10:"visibility";s:10:"kilometers";}');
|
| 216 |
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
|
| 217 |
|
| 218 |
// add another column for configuration
|
| 219 |
$sql = "ALTER TABLE {weather_config} ADD config VARCHAR(255) NOT NULL DEFAULT '%s' AFTER units";
|
| 220 |
// we cannot use update_sql() because of the brackets {} issue
|
| 221 |
$result = db_query($sql, 'a:1:{s:22:"show_unconverted_metar";i:0;}');
|
| 222 |
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
|
| 223 |
break;
|
| 224 |
case 'pgsql':
|
| 225 |
// expand the VARCHAR for units from 8 to 255
|
| 226 |
$ret[] = update_sql("ALTER TABLE {weather_config} RENAME units TO units_old");
|
| 227 |
$ret[] = update_sql("ALTER TABLE {weather_config} ADD units VARCHAR(255)");
|
| 228 |
$ret[] = update_sql("UPDATE {weather_config} SET units = units_old");
|
| 229 |
$ret[] = update_sql("ALTER TABLE {weather_config} ALTER units SET NOT NULL");
|
| 230 |
|
| 231 |
// we cannot use update_sql() because of the brackets {} issue
|
| 232 |
$sql = "ALTER TABLE {weather_config} ALTER units SET DEFAULT '%s'";
|
| 233 |
$result = db_query($sql, 'a:4:{s:11:"temperature";s:7:"celsius";s:9:"windspeed";s:3:"kmh";s:8:"pressure";s:3:"hpa";s:10:"visibility";s:10:"kilometers";}');
|
| 234 |
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
|
| 235 |
|
| 236 |
$ret[] = update_sql("ALTER TABLE {weather_config} DROP units_old");
|
| 237 |
|
| 238 |
// add another column for configuration
|
| 239 |
$ret[] = update_sql("ALTER TABLE {weather_config} ADD config VARCHAR(255)");
|
| 240 |
$ret[] = update_sql("ALTER TABLE {weather_config} ALTER config SET NOT NULL");
|
| 241 |
|
| 242 |
// we cannot use update_sql() because of the brackets {} issue
|
| 243 |
$sql = "ALTER TABLE {weather_config} ALTER config SET DEFAULT '%s'";
|
| 244 |
$result = db_query($sql, 'a:1:{s:22:"show_unconverted_metar";i:0;}');
|
| 245 |
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
|
| 246 |
|
| 247 |
// this is a null-op, but restores the original order of columns.
|
| 248 |
// yes, I'm a pedantic. ;-)
|
| 249 |
$ret[] = update_sql("ALTER TABLE {weather_config} RENAME weight TO weight_old");
|
| 250 |
$ret[] = update_sql("ALTER TABLE {weather_config} ADD weight INTEGER");
|
| 251 |
$ret[] = update_sql("UPDATE {weather_config} SET weight = weight_old");
|
| 252 |
$ret[] = update_sql("ALTER TABLE {weather_config} ALTER weight SET NOT NULL");
|
| 253 |
$ret[] = update_sql("ALTER TABLE {weather_config} ALTER weight SET DEFAULT 0");
|
| 254 |
$ret[] = update_sql("ALTER TABLE {weather_config} DROP weight_old");
|
| 255 |
break;
|
| 256 |
}
|
| 257 |
|
| 258 |
// convert the 'metric' and 'imperial' entries
|
| 259 |
// we cannot use update_sql() because of the brackets {} issue
|
| 260 |
$sql = "UPDATE {weather_config} SET units='%s' WHERE units='metric'";
|
| 261 |
$result = db_query($sql, 'a:4:{s:11:"temperature";s:7:"celsius";s:9:"windspeed";s:3:"kmh";s:8:"pressure";s:3:"hpa";s:10:"visibility";s:10:"kilometers";}');
|
| 262 |
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
|
| 263 |
|
| 264 |
$sql = "UPDATE {weather_config} SET units='%s' WHERE units='imperial'";
|
| 265 |
$result = db_query($sql, 'a:4:{s:11:"temperature";s:10:"fahrenheit";s:9:"windspeed";s:3:"mph";s:8:"pressure";s:4:"inhg";s:10:"visibility";s:5:"miles";}');
|
| 266 |
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
|
| 267 |
|
| 268 |
return $ret;
|
| 269 |
}
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
/**
|
| 274 |
* Implementation of hook_update_N().
|
| 275 |
*
|
| 276 |
* Add show_abbreviated_directions and show_directions_degree to
|
| 277 |
* default of config column
|
| 278 |
*/
|
| 279 |
function weather_update_5() {
|
| 280 |
$ret = array();
|
| 281 |
|
| 282 |
switch ($GLOBALS['db_type']) {
|
| 283 |
case 'mysql':
|
| 284 |
case 'mysqli':
|
| 285 |
$sql = "ALTER TABLE {weather_config} CHANGE config settings VARCHAR(255) NOT NULL DEFAULT '%s'";
|
| 286 |
// we cannot use update_sql() because of the brackets {} issue
|
| 287 |
$result = db_query($sql, 'a:3:{s:22:"show_unconverted_metar";i:0;s:27:"show_abbreviated_directions";i:0;s:22:"show_directions_degree";i:0;}');
|
| 288 |
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
|
| 289 |
break;
|
| 290 |
case 'pgsql':
|
| 291 |
$sql = "ALTER TABLE {weather_config} RENAME COLUMN config TO settings";
|
| 292 |
$ret[] = update_sql($sql);
|
| 293 |
|
| 294 |
$sql = "ALTER TABLE {weather_config} ALTER settings SET DEFAULT '%s'";
|
| 295 |
// we cannot use update_sql() because of the brackets {} issue
|
| 296 |
$result = db_query($sql, 'a:3:{s:22:"show_unconverted_metar";i:0;s:27:"show_abbreviated_directions";i:0;s:22:"show_directions_degree";i:0;}');
|
| 297 |
$ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
|
| 298 |
break;
|
| 299 |
}
|
| 300 |
|
| 301 |
return $ret;
|
| 302 |
}
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
/**
|
| 307 |
* Implementation of hook_update_N().
|
| 308 |
*
|
| 309 |
* Import ICAO data into dedicated table
|
| 310 |
*/
|
| 311 |
function weather_update_6() {
|
| 312 |
$ret = array();
|
| 313 |
|
| 314 |
// the table holds all known ICAO codes with further information
|
| 315 |
// it's not decoupled, but that's probably not worth the effort.
|
| 316 |
// icao: ICAO code of the METAR station
|
| 317 |
// country: name of the country
|
| 318 |
// name: the METAR station's name
|
| 319 |
// latitude: degree of the station
|
| 320 |
// longitude: degree of the station
|
| 321 |
$sql = "CREATE TABLE {weather_icao} (
|
| 322 |
icao VARCHAR(4) DEFAULT '' NOT NULL,
|
| 323 |
country VARCHAR(255) DEFAULT '' NOT NULL,
|
| 324 |
name VARCHAR(255) DEFAULT '' NOT NULL,
|
| 325 |
latitude DOUBLE PRECISION DEFAULT 0 NOT NULL,
|
| 326 |
longitude DOUBLE PRECISION DEFAULT 0 NOT NULL,
|
| 327 |
PRIMARY KEY (icao)
|
| 328 |
)";
|
| 329 |
// ensure the utf8 character set on MySQL (syntax for 4.1 and above)
|
| 330 |
if ($GLOBALS['db_type'] == 'mysql' or $GLOBALS['db_type'] == 'mysqli') {
|
| 331 |
$sql .= " /*!40100 DEFAULT CHARACTER SET utf8 */";
|
| 332 |
}
|
| 333 |
$ret[] = update_sql($sql);
|
| 334 |
|
| 335 |
require_once drupal_get_path('module', 'weather') .'/weather_data.inc';
|
| 336 |
_weather_fill_icao_table();
|
| 337 |
|
| 338 |
return $ret;
|
| 339 |
}
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
/**
|
| 344 |
* Implementation of hook_update_N().
|
| 345 |
*
|
| 346 |
* Change UID of the system weather block from 0 to -1 and add
|
| 347 |
* Melbourne to ICAO codes
|
| 348 |
*/
|
| 349 |
function weather_update_7() {
|
| 350 |
$ret = array();
|
| 351 |
|
| 352 |
// Change UID of the system weather block from 0 to -1
|
| 353 |
$sql = "UPDATE {weather_config} SET uid = -1 WHERE uid = 0";
|
| 354 |
$ret[] = update_sql($sql);
|
| 355 |
|
| 356 |
// Add Melbourne to ICAO codes
|
| 357 |
require_once drupal_get_path('module', 'weather') .'/weather_data.inc';
|
| 358 |
_weather_fill_icao_table();
|
| 359 |
|
| 360 |
return $ret;
|
| 361 |
}
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
/**
|
| 366 |
* Implementation of hook_update_N().
|
| 367 |
*
|
| 368 |
* Add Denpasar / Ngurah-Rai, Indonesia to ICAO codes
|
| 369 |
*/
|
| 370 |
function weather_update_8() {
|
| 371 |
$ret = array();
|
| 372 |
|
| 373 |
// Add Denpasar / Ngurah-Rai, Indonesia to ICAO codes
|
| 374 |
require_once drupal_get_path('module', 'weather') .'/weather_data.inc';
|
| 375 |
_weather_fill_icao_table();
|
| 376 |
|
| 377 |
return $ret;
|
| 378 |
}
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
/**
|
| 383 |
* Implementation of hook_update_N().
|
| 384 |
*
|
| 385 |
* Add Gyumri and Yerevan (both Armenia) to ICAO codes
|
| 386 |
*/
|
| 387 |
function weather_update_9() {
|
| 388 |
$ret = array();
|
| 389 |
|
| 390 |
// Add Gyumri and Yerevan (both Armenia) to ICAO codes
|
| 391 |
require_once drupal_get_path('module', 'weather') .'/weather_data.inc';
|
| 392 |
_weather_fill_icao_table();
|
| 393 |
|
| 394 |
return $ret;
|
| 395 |
}
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
/**
|
| 400 |
* Implementation of hook_update_N().
|
| 401 |
*
|
| 402 |
* Unset the default value for 'units' and 'settings' in 'weather_config'.
|
| 403 |
*/
|
| 404 |
function weather_update_6100() {
|
| 405 |
$ret = array();
|
| 406 |
db_field_set_default($ret, 'weather_config', 'units', '');
|
| 407 |
db_field_set_default($ret, 'weather_config', 'settings', '');
|
| 408 |
return $ret;
|
| 409 |
}
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
/**
|
| 414 |
* Implementation of hook_update_N().
|
| 415 |
*
|
| 416 |
* Add Gyumri and Yerevan (both Armenia) to ICAO codes.
|
| 417 |
*/
|
| 418 |
function weather_update_6101() {
|
| 419 |
$ret = array();
|
| 420 |
require_once drupal_get_path('module', 'weather') .'/weather_data.inc';
|
| 421 |
_weather_fill_icao_table();
|
| 422 |
return $ret;
|
| 423 |
}
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
/**
|
| 428 |
* Implementation of hook_update_N().
|
| 429 |
*
|
| 430 |
* Adjust block deltas for multiple system-wide weather blocks.
|
| 431 |
*/
|
| 432 |
function weather_update_6200() {
|
| 433 |
$ret = array();
|
| 434 |
|
| 435 |
// Change default weather configuration from UID -2 to UID 0
|
| 436 |
$sql = "UPDATE {weather_config} SET uid = 0 WHERE uid = -2";
|
| 437 |
$ret[] = update_sql($sql);
|
| 438 |
|
| 439 |
// Temporarily adjust the block delta of system-wide block
|
| 440 |
$sql = "UPDATE {blocks} SET delta = '10' WHERE delta = '0' AND module = 'weather'";
|
| 441 |
$ret[] = update_sql($sql);
|
| 442 |
|
| 443 |
// Adjust the block delta of custom user block
|
| 444 |
$sql = "UPDATE {blocks} SET delta = '0' WHERE delta = '1' AND module = 'weather'";
|
| 445 |
$ret[] = update_sql($sql);
|
| 446 |
|
| 447 |
// Adjust the block delta of location block
|
| 448 |
$sql = "UPDATE {blocks} SET delta = '1' WHERE delta = '2' AND module = 'weather'";
|
| 449 |
$ret[] = update_sql($sql);
|
| 450 |
|
| 451 |
// Adjust the block delta of system-wide block
|
| 452 |
$sql = "UPDATE {blocks} SET delta = '2' WHERE delta = '10' AND module = 'weather'";
|
| 453 |
$ret[] = update_sql($sql);
|
| 454 |
|
| 455 |
return $ret;
|
| 456 |
}
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
/**
|
| 461 |
* Implementation of hook_update_N().
|
| 462 |
*
|
| 463 |
* Insert Kathmandu, Nepal.
|
| 464 |
*/
|
| 465 |
function weather_update_6500() {
|
| 466 |
$ret = array();
|
| 467 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 468 |
VALUES ('VNKT', 'Nepal', 'Kathmandu', 27.696389, 85.358889)";
|
| 469 |
$ret[] = update_sql($sql);
|
| 470 |
return $ret;
|
| 471 |
}
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
/**
|
| 476 |
* Implementation of hook_update_N().
|
| 477 |
*
|
| 478 |
* Insert Messina, Sicily, Italy.
|
| 479 |
*/
|
| 480 |
function weather_update_6501() {
|
| 481 |
$ret = array();
|
| 482 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 483 |
VALUES ('LICF', 'Italy', 'Messina', 38.200000, 15.550000)";
|
| 484 |
$ret[] = update_sql($sql);
|
| 485 |
return $ret;
|
| 486 |
}
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
/**
|
| 491 |
* Implementation of hook_update_N().
|
| 492 |
*
|
| 493 |
* Update some spellings of cities in Romania and Poland.
|
| 494 |
* Also insert new cities.
|
| 495 |
*/
|
| 496 |
function weather_update_6502() {
|
| 497 |
$ret = array();
|
| 498 |
// Update spellings
|
| 499 |
$sql = "UPDATE {weather_icao} SET name='Bucureşti \'Aurel Vlaicu\' International Airport'
|
| 500 |
WHERE icao='LRBS'";
|
| 501 |
$ret[] = update_sql($sql);
|
| 502 |
$sql = "UPDATE {weather_icao} SET name='Bucureşti \'Henri Coandǎ\' International Airport'
|
| 503 |
WHERE icao='LROP'";
|
| 504 |
$ret[] = update_sql($sql);
|
| 505 |
$sql = "UPDATE {weather_icao} SET name='Constanţa' WHERE icao='LRCK'";
|
| 506 |
$ret[] = update_sql($sql);
|
| 507 |
$sql = "UPDATE {weather_icao} SET name='Timişoara' WHERE icao='LRTR'";
|
| 508 |
$ret[] = update_sql($sql);
|
| 509 |
$sql = "UPDATE {weather_icao} SET name='Târgu Mureş' WHERE icao='LRTM'";
|
| 510 |
$ret[] = update_sql($sql);
|
| 511 |
|
| 512 |
// Insert new cities
|
| 513 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 514 |
VALUES ('LRBC', 'Romania', 'Bacău', 46.521946, 26.910278)";
|
| 515 |
$ret[] = update_sql($sql);
|
| 516 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 517 |
VALUES ('LRBM', 'Romania', 'Baia Mare', 47.658389, 23.470022)";
|
| 518 |
$ret[] = update_sql($sql);
|
| 519 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 520 |
VALUES ('LRCS', 'Romania', 'Caransebeş Airport, Reşiţa', 45.420000, 22.253333)";
|
| 521 |
$ret[] = update_sql($sql);
|
| 522 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 523 |
VALUES ('LRCL', 'Romania', 'Cluj-Napoca', 46.766667, 23.583333)";
|
| 524 |
$ret[] = update_sql($sql);
|
| 525 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 526 |
VALUES ('LRCV', 'Romania', 'Craiova', 44.318139, 23.888611)";
|
| 527 |
$ret[] = update_sql($sql);
|
| 528 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 529 |
VALUES ('LRIA', 'Romania', 'Iaşi', 47.178492, 27.620631)";
|
| 530 |
$ret[] = update_sql($sql);
|
| 531 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 532 |
VALUES ('LROD', 'Romania', 'Oradea', 47.025278, 21.902500)";
|
| 533 |
$ret[] = update_sql($sql);
|
| 534 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 535 |
VALUES ('LRSM', 'Romania', 'Satu Mare', 47.703275, 22.885700)";
|
| 536 |
$ret[] = update_sql($sql);
|
| 537 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 538 |
VALUES ('LRSB', 'Romania', 'Sibiu', 45.785597, 24.091342)";
|
| 539 |
$ret[] = update_sql($sql);
|
| 540 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 541 |
VALUES ('LRSV', 'Romania', 'Suceava', 47.687500, 26.354056)";
|
| 542 |
$ret[] = update_sql($sql);
|
| 543 |
|
| 544 |
// Insert new city
|
| 545 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 546 |
VALUES ('LIRI', 'Italy', 'Salerno', 40.620400, 14.911294)";
|
| 547 |
$ret[] = update_sql($sql);
|
| 548 |
|
| 549 |
// Insert new city
|
| 550 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 551 |
VALUES ('DNAA', 'Nigeria', 'Abuja', 9.006792, 7.263172)";
|
| 552 |
$ret[] = update_sql($sql);
|
| 553 |
|
| 554 |
// Insert new city
|
| 555 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 556 |
VALUES ('EPLL', 'Poland', 'Łódź-Lublinek', 51.721944, 19.398056)";
|
| 557 |
$ret[] = update_sql($sql);
|
| 558 |
|
| 559 |
// Update spellings
|
| 560 |
$sql = "UPDATE {weather_icao} SET name='Gdańsk-Rębiechowo' WHERE icao='EPGD'";
|
| 561 |
$ret[] = update_sql($sql);
|
| 562 |
$sql = "UPDATE {weather_icao} SET name='Katowice-Pyrzowice' WHERE icao='EPKT'";
|
| 563 |
$ret[] = update_sql($sql);
|
| 564 |
$sql = "UPDATE {weather_icao} SET name='Kraków-Balice' WHERE icao='EPKK'";
|
| 565 |
$ret[] = update_sql($sql);
|
| 566 |
$sql = "UPDATE {weather_icao} SET name='Poznań-Ławica' WHERE icao='EPPO'";
|
| 567 |
$ret[] = update_sql($sql);
|
| 568 |
$sql = "UPDATE {weather_icao} SET name='Rzeszów-Jasionka' WHERE icao='EPRZ'";
|
| 569 |
$ret[] = update_sql($sql);
|
| 570 |
$sql = "UPDATE {weather_icao} SET name='Szczecin-Goleniów' WHERE icao='EPSC'";
|
| 571 |
$ret[] = update_sql($sql);
|
| 572 |
$sql = "UPDATE {weather_icao} SET name='Warszawa-Okęcie' WHERE icao='EPWA'";
|
| 573 |
$ret[] = update_sql($sql);
|
| 574 |
$sql = "UPDATE {weather_icao} SET name='Wrocław-Strachowice' WHERE icao='EPWR'";
|
| 575 |
$ret[] = update_sql($sql);
|
| 576 |
|
| 577 |
// Insert new cities
|
| 578 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 579 |
VALUES ('HTAR', 'Tanzania', 'Arusha', -3.367794, 36.633333)";
|
| 580 |
$ret[] = update_sql($sql);
|
| 581 |
$sql = "INSERT INTO {weather_icao} (icao, country, name, latitude, longitude)
|
| 582 |
VALUES ('HTDA', 'Tanzania', 'Dar es Salaam', -6.878111, 39.202625)";
|
| 583 |
$ret[] = update_sql($sql);
|
| 584 |
return $ret;
|
| 585 |
}
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
/**
|
| 590 |
* Implementation of hook_update_N().
|
| 591 |
*
|
| 592 |
* Change ICAO code of Bangalore, India from VOBG to VOBL,
|
| 593 |
* which is updated more often.
|
| 594 |
*/
|
| 595 |
function weather_update_6503() {
|
| 596 |
$ret = array();
|
| 597 |
// Update spellings
|
| 598 |
$sql = "UPDATE {weather_icao} SET icao='VOBL' WHERE icao='VOBG'";
|
| 599 |
$ret[] = update_sql($sql);
|
| 600 |
return $ret;
|
| 601 |
}
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
/**
|
| 606 |
* Implementation of hook_update_N().
|
| 607 |
*
|
| 608 |
* Rename table "weather" to "weather_metar" and restructure table
|
| 609 |
* "weather_config"
|
| 610 |
*/
|
| 611 |
function weather_update_6504() {
|
| 612 |
$ret = array();
|
| 613 |
db_rename_table($ret, 'weather', 'weather_metar');
|
| 614 |
db_rename_table($ret, 'weather_config', 'weather_locations');
|
| 615 |
db_add_field($ret, 'weather_locations', 'block_type', array(
|
| 616 |
'description' => 'Type of block, e.g. system, user, default',
|
| 617 |
'type' => 'varchar', 'length' => 10, 'not null' => TRUE, 'default' => ''
|
| 618 |
));
|
| 619 |
db_drop_primary_key($ret, 'weather_locations');
|
| 620 |
db_change_field($ret, 'weather_locations', 'uid', 'block_id', array(
|
| 621 |
'description' => 'Block ID for system blocks, user ID for custom weather blocks',
|
| 622 |
'type' => 'int', 'not null' => TRUE, 'default' => 0
|
| 623 |
));
|
| 624 |
db_change_field($ret, 'weather_locations', 'cid', 'location_id', array(
|
| 625 |
'description' => 'Location ID, to enable multiple locations in one block',
|
| 626 |
'type' => 'int', 'not null' => TRUE, 'default' => 0),
|
| 627 |
array('primary key' => array('block_id', 'location_id'))
|
| 628 |
);
|
| 629 |
$sql = "UPDATE {weather_locations} SET block_type='system' WHERE block_id<0";
|
| 630 |
$ret[] = update_sql($sql);
|
| 631 |
$sql = "UPDATE {weather_locations} SET block_type='user' WHERE block_id>0";
|
| 632 |
$ret[] = update_sql($sql);
|
| 633 |
$sql = "UPDATE {weather_locations} SET block_type='default' WHERE block_id=0";
|
| 634 |
$ret[] = update_sql($sql);
|
| 635 |
$sql = "UPDATE {weather_locations} SET block_id=(-1 * block_id) WHERE block_type='system'";
|
| 636 |
$ret[] = update_sql($sql);
|
| 637 |
return $ret;
|
| 638 |
}
|
| 639 |
|
| 640 |
/**
|
| 641 |
* Implementation of hook_update_N().
|
| 642 |
*
|
| 643 |
* Create table "weather_block_settings"
|
| 644 |
*/
|
| 645 |
function weather_update_6508() {
|
| 646 |
$ret = array();
|
| 647 |
$schema['weather_block_settings'] = array(
|
| 648 |
'description' => 'Stores the configuration of weather blocks',
|
| 649 |
'fields' => array(
|
| 650 |
'block_type' => array(
|
| 651 |
'description' => 'Type of block, e.g. system, user, default',
|
| 652 |
'type' => 'varchar', 'length' => 10, 'not null' => TRUE, 'default' => ''
|
| 653 |
),
|
| 654 |
'block_id' => array(
|
| 655 |
'description' => 'Block ID for system blocks, user ID for custom weather blocks',
|
| 656 |
'type' => 'int', 'not null' => TRUE, 'default' => 0
|
| 657 |
),
|
| 658 |
'units' => array(
|
| 659 |
'description' => 'Units for display (Celsius/Fahrenheit, mmHg/hPa etc.)',
|
| 660 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 661 |
),
|
| 662 |
'settings' => array(
|
| 663 |
'description' => 'Settings for display (Show raw METAR, abbrev. wind directions etc.)',
|
| 664 |
'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''
|
| 665 |
),
|
| 666 |
),
|
| 667 |
'primary key' => array(
|
| 668 |
'block_id'
|
| 669 |
),
|
| 670 |
);
|
| 671 |
db_create_table($ret, 'weather_block_settings', $schema['weather_block_settings']);
|
| 672 |
return $ret;
|
| 673 |
}
|