australia_36_2.cif 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function australia_install() {
  7. // Make the entry in the country table.
  8. // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  9. db_insert('uc_countries')
  10. ->fields(array(
  11. 'country_id' => 36,
  12. 'country_name' => 'Australia',
  13. 'country_iso_code_2' => 'AU',
  14. 'country_iso_code_3' => 'AUS',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(36, 'NSW', 'New South Wales'),
  21. array(36, 'QLD', 'Queensland'),
  22. array(36, 'SA', 'South Australia'),
  23. array(36, 'TAS', 'Tasmania'),
  24. array(36, 'VIC', 'Victoria'),
  25. array(36, 'WA', 'Western Australia'),
  26. array(36, 'NT', 'Northern Territory'),
  27. array(36, 'ACT', 'Australian Capital Territory'),
  28. );
  29. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  30. foreach ($zones as $zone) {
  31. $query->values($zone);
  32. }
  33. $query->execute();
  34. // Set address format
  35. uc_set_address_format(
  36. 36,
  37. "!company\r\n" .
  38. "!first_name !last_name\r\n" .
  39. "!street1\r\n" .
  40. "!street2\r\n" .
  41. "!city !zone_code !postal_code\r\n" .
  42. "!country_name_if"
  43. );
  44. }
  45. /**
  46. * Implements hook_update() with $version being the only argument.
  47. * Add a new case for each version update, and be sure to always include the
  48. * latest changes in the install function.
  49. */
  50. function australia_update($version) {
  51. switch ($version){
  52. case 2:
  53. db_update('uc_countries')
  54. ->fields(array('country_iso_code_3' => 'AUS'))
  55. ->condition('country_id', 36)
  56. ->execute();
  57. break;
  58. }
  59. }