function weather_install in Weather 5
Same name and namespace in other branches
- 8 weather.install \weather_install()
- 5.6 weather.install \weather_install()
- 6.5 weather.install \weather_install()
- 7.3 weather.install \weather_install()
- 7 weather.install \weather_install()
- 7.2 weather.install \weather_install()
- 2.0.x weather.install \weather_install()
Implementation of hook_install().
We use the install hook to clean up the Drupal tables from old variables used by previous versions of this module.
File
- ./
weather.install, line 31
Code
function weather_install() {
// these were used by the official module
variable_del('weather_region');
variable_del('weather_scale');
variable_del('weather_mini_block');
variable_del('weather_extended_forecast');
variable_del('weather_xml_feed');
variable_del('weather_recache_cache');
variable_del('weather_enable_cron');
// these were added by an inofficial module release for Drupal 4.7
variable_del('weather_host');
variable_del('weather_title');
// these were used in version 1.x of this module, they are no longer
// needed in the 2.x series
variable_del('weather_country');
variable_del('weather_icao');
variable_del('weather_icao_name');
variable_del('weather_place');
variable_del('weather_units');
variable_del('weather_use_cron');
// icao: ICAO code of the METAR station
// next_update_on: timestamp of next possible update
// metar_raw: raw METAR data, not parsed
$sql = "CREATE TABLE {weather} (\n icao VARCHAR(4) DEFAULT '' NOT NULL,\n next_update_on INTEGER DEFAULT 0 NOT NULL,\n metar_raw VARCHAR(255) DEFAULT '' NOT NULL,\n PRIMARY KEY (icao)\n )";
// ensure the utf8 character set on MySQL (syntax for 4.1 and above)
if ($GLOBALS['db_type'] == 'mysql' or $GLOBALS['db_type'] == 'mysqli') {
$sql .= " /*!40100 DEFAULT CHARACTER SET utf8 */";
}
db_query($sql);
// the table stores the configuration of a custom user weather block
// uid: user id
// cid: configuration id, to enable multiple locations in one block
// icao: ICAO code of the METAR station
// real_name: the name to display for the ICAO code
// units: units for display (metric, imperial)
// weight: the weight of the location
$sql = "CREATE TABLE {weather_config} (\n uid INTEGER DEFAULT 0 NOT NULL,\n cid INTEGER DEFAULT 0 NOT NULL,\n icao VARCHAR(4) DEFAULT '' NOT NULL,\n real_name VARCHAR(255) DEFAULT '' NOT NULL,\n units VARCHAR(8) DEFAULT 'metric' NOT NULL,\n weight INTEGER DEFAULT 0 NOT NULL,\n PRIMARY KEY (uid, cid)\n )";
// ensure the utf8 character set on MySQL (syntax for 4.1 and above)
if ($GLOBALS['db_type'] == 'mysql' or $GLOBALS['db_type'] == 'mysqli') {
$sql .= " /*!40100 DEFAULT CHARACTER SET utf8 */";
}
db_query($sql);
}