You are here

function weather_get_location_settings in Weather 7.2

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

Return location settings for a specific id.

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

Parameters

int $id: ID of table weather_displays_places.

Return value

Location configuration.

1 call to weather_get_location_settings()
weather_location_settings_form in ./weather.forms.inc
Create a form for a weather place.

File

./weather.forms.inc, line 509
Provide forms for configuration of weather displays.

Code

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

    // There are no settings. Get module's default settings.
    $settings = new stdClass();
    $settings->place_geoid = 'geonames_2911298';
    $settings->displayed_name = 'Hamburg';
    $settings->weight = 0;
    $settings->country = 'Germany';
  }
  else {
    module_load_include('inc', 'weather', 'weather.common');
    $info = weather_get_information_about_geoid($settings->place_geoid);
    $settings->country = $info->country;
  }
  return $settings;
}