new_zealand_554_3.cif 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function new_zealand_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' => 554,
  12. 'country_name' => 'New Zealand',
  13. 'country_iso_code_2' => 'NZ',
  14. 'country_iso_code_3' => 'NZL',
  15. 'version' => 3,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(554, 'AUK', 'Auckland'),
  21. array(554, 'BOP', 'Bay of Plenty'),
  22. array(554, 'CAN', 'Canterbury'),
  23. array(554, 'COR', 'Coromandel'),
  24. array(554, 'GIS', 'Gisborne'),
  25. array(554, 'FIO', 'Fiordland'),
  26. array(554, 'HKB', "Hawke's Bay"),
  27. array(554, 'MBH', 'Marlborough'),
  28. array(554, 'MWT', 'Manawatu-Wanganui'),
  29. array(554, 'MCM', 'Mt Cook-Mackenzie'),
  30. array(554, 'NSN', 'Nelson'),
  31. array(554, 'NTL', 'Northland'),
  32. array(554, 'OTA', 'Otago'),
  33. array(554, 'STL', 'Southland'),
  34. array(554, 'TKI', 'Taranaki'),
  35. array(554, 'WGN', 'Wellington'),
  36. array(554, 'WKO', 'Waikato'),
  37. array(554, 'WAI', 'Wairarapa'),
  38. array(554, 'WTC', 'West Coast'),
  39. );
  40. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  41. foreach ($zones as $zone) {
  42. $query->values($zone);
  43. }
  44. $query->execute();
  45. // Set address format
  46. uc_set_address_format(
  47. 554,
  48. "!first_name !last_name\r\n" .
  49. "!company\r\n" .
  50. "!street1\r\n" .
  51. "!street2\r\n" .
  52. "!city !postal_code\r\n" .
  53. "!country_name_if"
  54. );
  55. }
  56. /**
  57. * Implements hook_update() with $version being the only argument.
  58. * Add a new case for each version update, and be sure to always include the
  59. * latest changes in the install function.
  60. */
  61. function new_zealand_update($version) {
  62. switch ($version) {
  63. case 2:
  64. $zones = array(
  65. array(554, 'AUK', 'Auckland'),
  66. array(554, 'BOP', 'Bay of Plenty'),
  67. array(554, 'CAN', 'Canterbury'),
  68. array(554, 'COR', 'Coromandel'),
  69. array(554, 'GIS', 'Gisborne'),
  70. array(554, 'FIO', 'Fiordland'),
  71. array(554, 'HKB', "Hawke's Bay"),
  72. array(554, 'MBH', 'Marlborough'),
  73. array(554, 'MWT', 'Manawatu-Wanganui'),
  74. array(554, 'MCM', 'Mt Cook-Mackenzie'),
  75. array(554, 'NSN', 'Nelson'),
  76. array(554, 'NTL', 'Northland'),
  77. array(554, 'OTA', 'Otago'),
  78. array(554, 'STL', 'Southland'),
  79. array(554, 'TKI', 'Taranaki'),
  80. array(554, 'WGN', 'Wellington'),
  81. array(554, 'WKO', 'Waikato'),
  82. array(554, 'WAI', 'Wairarapa'),
  83. array(554, 'WTC', 'West Coast'),
  84. );
  85. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  86. foreach ($zones as $zone) {
  87. $query->values($zone);
  88. }
  89. $query->execute();
  90. break;
  91. case 3:
  92. db_update('uc_zones')
  93. ->fields(array('zone_name' => 'Wairarapa'))
  94. ->condition('zone_name', 'Wairprarapa')
  95. ->execute();
  96. break;
  97. }
  98. }