function _weather_get_config in Weather 6.5
Same name and namespace in other branches
- 5.6 weather.module \_weather_get_config()
- 5 weather.module \_weather_get_config()
Return the configuration for the given user id.
If there is no configuration yet, get the default configuration instead.
3 calls to _weather_get_config()
- weather_block in ./
weather.module - Generate HTML for the weather block
- weather_custom_block in ./
weather.module - Show a configuration page for a custom weather block
- weather_search_location in ./
weather.module - Searches for the specified location, whether it is a place name or an ICAO code. For example, weather/fuhlsbüttel will display the weather for Hamburg-Fuhlsbüttel.
File
- ./
weather.module, line 1226 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function _weather_get_config($uid, $cid) {
$sql = "SELECT * FROM {weather_config} WHERE uid=%d AND cid=%d";
$result = db_query($sql, $uid, $cid);
$config = db_fetch_array($result);
if (!isset($config['icao'])) {
// There was no configuration found. See if there is a custom
// default configuration.
$sql = "SELECT * FROM {weather_config} WHERE uid=%d AND cid=%d";
$result = db_query($sql, 0, 1);
$config = db_fetch_array($result);
if (!isset($config['icao'])) {
// There is no custom default configuration, provide the
// module's default
$config['icao'] = 'EDDH';
$config['real_name'] = 'Hamburg-Fuhlsbüttel';
$config['units'] = array(
'temperature' => 'celsius',
'windspeed' => 'kmh',
'pressure' => 'hpa',
'humidity' => 'display',
'visibility' => 'kilometers',
);
$config['settings'] = array(
'show_windchill' => FALSE,
'show_unconverted_metar' => FALSE,
'show_abbreviated_directions' => FALSE,
'show_directions_degree' => FALSE,
'show_sunrise_sunset' => FALSE,
'sunrise_sunset_timezone' => 'gmt',
'show_compact_block' => FALSE,
);
$config['weight'] = 0;
}
else {
// get the custom default configuration
$config['units'] = unserialize($config['units']);
$config['settings'] = unserialize($config['settings']);
}
}
else {
// get the user's configuration
$config['units'] = unserialize($config['units']);
$config['settings'] = unserialize($config['settings']);
}
return $config;
}