You are here

function countries_configuration in Countries 8

Same name and namespace in other branches
  1. 7.2 modules/countries_configuration/countries_configuration.module \countries_configuration()

Helper function to load country configuration options.

3 calls to countries_configuration()
countries_configuration_options_form in modules/countries_configuration/countries_configuration.admin.inc
Menu callback for generating a countries settings admin form.
countries_load_configuration_options in modules/countries_configuration/countries_configuration.module
Depreciated. Use countries_configuration() instead.
example_address_country_configuration_usage in modules/countries_configuration/countries_configuration.api.php
An example implementing how you would use the data saved.

File

modules/countries_configuration/countries_configuration.module, line 56
Provides the base framework for integration for storing country specific data on behalf of other modules.

Code

function countries_configuration($country, $name, $load_defaults = 1) {
  $config = array();
  $iso2 = is_object($country) ? $country->iso2 : $country;
  $is_new = TRUE;
  if ($data = db_query("SELECT a.data FROM {countries_data} a WHERE iso2 = :iso2 AND name = :name", array(
    ':iso2' => $iso2,
    ':name' => $name,
  ))
    ->fetchField()) {
    $config = unserialize($data);
    $is_new = FALSE;
  }

  // Load any defaults.
  if ($load_defaults) {
    $config_options = countries_configuration_options();
    if (isset($config_options[$name]['default values'])) {
      $config += $config_options[$name]['default values'];
    }
  }
  $info = array(
    'country' => $country,
    'is_new' => $is_new,
    'load_defaults' => $load_defaults,
  );
  drupal_alter('countries_configuration_options', $config, $name, $info);
  return $config;
}