You are here

function uc_country_disable in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_store/uc_store.module \uc_country_disable()
  2. 7.3 uc_store/uc_store.countries.inc \uc_country_disable()

Disables a country so it remains installed but is no longer selectable.

1 string reference to 'uc_country_disable'
uc_store_menu in uc_store/uc_store.module
Implements hook_menu().

File

uc_store/uc_store.admin.inc, line 1033
Store administration menu items.

Code

function uc_country_disable($country_id) {
  $result = db_query("SELECT * FROM {uc_countries} WHERE country_id = %d", $country_id);
  if ($country = db_fetch_object($result)) {

    // Version is positive if the country is enabled.
    // Version is negative if the country is disabled.
    if ($country->version > 0) {
      db_query("UPDATE {uc_countries} SET version = %d WHERE country_id = %d", 0 - $country->version, $country_id);
      drupal_set_message(t('!country disabled.', array(
        '!country' => t($country->country_name),
      )));
    }
    else {
      drupal_set_message(t('!country is already disabled.', array(
        '!country' => t($country->country_name),
      )), 'error');
    }
  }
  else {
    drupal_set_message(t('Attempted to disable an invalid country.'), 'error');
  }
  drupal_goto('admin/store/settings/countries/edit');
}