diff --git location/location.admin.inc location/location.admin.inc
index 37200bc..5a707f2 100644
--- location/location.admin.inc
+++ location/location.admin.inc
@@ -27,6 +27,14 @@ function location_admin_settings() {
'#options' => $iso_list_sorted,
'#description' => t('This will be the country that is automatically selected when a location form is served for a new location.')
);
+ $form['location_enabled_countries'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Enabled countries'),
+ '#size' => 50,
+ '#maxlength' => 800,
+ '#default_value' => variable_get('location_enabled_countries', ''),
+ '#description' => t('Space delimited list of countries codes, which should be included in countries list. Special code: xx means NOT LISTED. Leave field empty if all countries (and xx - NOT LISTED) should be included. Example: xx us ca mx')
+ );
$form['location_display_location'] = array(
'#type' => 'radios',
'#title' => t('Toggle location display'),
diff --git location/location.install location/location.install
index 8f8978d..dbe27a3 100644
--- location/location.install
+++ location/location.install
@@ -23,6 +23,7 @@ function location_uninstall() {
variable_del('location_display_location');
variable_del('location_usegmap');
variable_del('location_locpick_macro');
+ variable_del('location_enabled_countries');
// Delete geocoder settings.
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'location_geocode_%'");
diff --git location/location.module location/location.module
index a24d026..f6a898b 100644
--- location/location.module
+++ location/location.module
@@ -676,7 +676,7 @@ function location_locationapi(&$obj, $op, $a3 = NULL, $a4 = NULL, $a5 = NULL) {
);
}
else {
- $options = array_merge(array('' => t('Please select'), 'xx' => t('NOT LISTED')), location_get_iso3166_list());
+ $options = array_merge(array('' => t('Please select')), location_get_enabled_countries_list());
return array(
'#type' => 'select',
'#title' => t('Country'),
@@ -1501,7 +1501,7 @@ function template_preprocess_location(&$variables) {
// Map link.
$variables['map_link'] = '';
if (!empty($location['map_link'])) {
- // Do not use $location for generating the map link, since it will
+ // Do not use $location for generating the map link, since it will
// not contain the country if that field is hidden.
$variables['map_link'] = location_map_link($variables['location']);
}
@@ -1780,3 +1780,25 @@ function location_google_geocode_accuracy_codes() {
9 => t('Premise (building name, property name, shopping center, etc.) level accuracy'),
);
}
+
+/**
+ * Returns a list of enabled countries, which will be used in select lists.
+ * Enabled countries can be set on admin/settings/location page
+ */
+function location_get_enabled_countries_list() {
+ $list = location_get_iso3166_list();
+ $enabled_countries = variable_get('location_enabled_countries', '');
+ if (!empty($enabled_countries)) {
+ $enabled = array_flip(explode(' ', $enabled_countries));
+ foreach ($list as $code => $name) {
+ if (!isset($enabled[$code])) {
+ unset($list[$code]);
+ }
+ }
+ // Add special option: xx - NOT LISTED
+ if (isset($enabled['xx'])) {
+ $list = array_merge(array('xx' => t('NOT LISTED')), $list);
+ }
+ }
+ return $list;
+}