function _weather_get_config in Weather 5.6
Same name and namespace in other branches
- 5 weather.module \_weather_get_config()
- 6.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.
2 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
File
- ./
weather.module, line 882 - 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);
if (db_num_rows($result) != 1) {
// 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, WEATHER_DEFAULT_BLOCK, 1);
if (db_num_rows($result) != 1) {
// 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',
'visibility' => 'kilometers',
);
$config['settings'] = array(
'show_unconverted_metar' => FALSE,
'show_abbreviated_directions' => FALSE,
'show_directions_degree' => FALSE,
'show_sunrise_sunset' => FALSE,
'show_compact_block' => FALSE,
);
$config['weight'] = 0;
}
else {
// get the custom default configuration
$config = db_fetch_array($result);
$config['units'] = unserialize($config['units']);
$config['settings'] = unserialize($config['settings']);
}
}
else {
// get the user's configuration
$config = db_fetch_array($result);
$config['units'] = unserialize($config['units']);
$config['settings'] = unserialize($config['settings']);
}
return $config;
}