<?php

function brunei_darussalam_install() {
  db_query("INSERT INTO {uc_countries} (country_id, country_name, country_iso_code_2, country_iso_code_3, version) VALUES (96, 'Brunei Darussalam', 'BN', 'BRN', 3)");

  $zones = array(
    array(96, 'BN-BE', 'Belait'),
    array(96, 'BN-BM', 'Brunei-Muara'),
    array(96, 'BN-TE', 'Temburong'),
    array(96, 'BN-TU', 'Tutong'),
  );

  foreach ($zones as $zone) {
    db_query("INSERT INTO {uc_zones} (zone_country_id, zone_code, zone_name) VALUES (%d, '%s', '%s')", $zone);
  }

  uc_set_address_format(
    96,
    "!company\r\n".
    "!first_name !last_name\r\n".
    "!street1\r\n".
    "!street2\r\n".
    "!city !postal_code\r\n".
    "!zone_name\r\n".
    "!country_name_if"
  );
}

function brunei_darussalam_update($version) {
  switch ($version) {
    case 3:
      // Correct ISO-3166-1 country name
      db_query("UPDATE {uc_countries} SET country_name = 'Brunei Darussalam' WHERE country_id = 96");
      break;
  }
}
