You are here

function weather_get_location_settings in Weather 7

Same name and namespace in other branches
  1. 7.3 weather.forms.inc \weather_get_location_settings()
  2. 7.2 weather.forms.inc \weather_get_location_settings()

Return location settings for a specific id.

If there are no settings yet, get the default settings instead.

Parameters

int $location_id: Location id.

Return value

Location configuration.

2 calls to weather_get_location_settings()
weather_block_view in ./weather.module
Implement hook_block_view().
weather_location_settings_form in ./weather.forms.inc
Create a settings form for a weather location.

File

./weather.module, line 505
Display current weather data from many places in the world.

Code

function weather_get_location_settings($location_id) {
  $settings = db_query('SELECT * FROM {weather_location} WHERE id=:id', array(
    ':id' => $location_id,
  ))
    ->fetchObject();
  if (empty($settings)) {

    // There are no settings. Get module's default settings.
    $settings = new stdClass();
    $settings->icao = 'EDDH';
    $settings->real_name = 'Hamburg-Fuhlsbüttel';
    $settings->weight = 0;
    $settings->country = 'Germany';
  }
  else {
    $settings->country = weather_get_country_from_icao($settings->icao);
  }
  return $settings;
}