canada_124_2.cif 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function canada_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' => 124,
  12. 'country_name' => 'Canada',
  13. 'country_iso_code_2' => 'CA',
  14. 'country_iso_code_3' => 'CAN',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(124, 'AB', 'Alberta'),
  21. array(124, 'BC', 'British Columbia'),
  22. array(124, 'MB', 'Manitoba'),
  23. array(124, 'NL', 'Newfoundland and Labrador'),
  24. array(124, 'NB', 'New Brunswick'),
  25. array(124, 'NS', 'Nova Scotia'),
  26. array(124, 'NT', 'Northwest Territories'),
  27. array(124, 'NU', 'Nunavut'),
  28. array(124, 'ON', 'Ontario'),
  29. array(124, 'PE', 'Prince Edward Island'),
  30. array(124, 'QC', 'Quebec'),
  31. array(124, 'SK', 'Saskatchewan'),
  32. array(124, 'YT', 'Yukon Territory'),
  33. );
  34. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  35. foreach ($zones as $zone) {
  36. $query->values($zone);
  37. }
  38. $query->execute();
  39. // Set address format
  40. // Have to call variable_set() instead of uc_set_address_format()
  41. // because the Canada .cif file is loaded during the installation
  42. // of the uc_store module, before uc_set_address_format() is available
  43. // to use.
  44. variable_set(
  45. 'uc_address_format_124',
  46. "!company\r\n" .
  47. "!first_name !last_name\r\n" .
  48. "!street1\r\n" .
  49. "!street2\r\n" .
  50. "!city !zone_code !postal_code\r\n" .
  51. "!country_name_if"
  52. );
  53. }
  54. /**
  55. * Implements hook_update() with $version being the only argument.
  56. * Add a new case for each version update, and be sure to always include the
  57. * latest changes in the install function.
  58. */
  59. function canada_update($version) {
  60. switch ($version) {
  61. case 2:
  62. // Rename zone
  63. db_update('uc_zones')
  64. ->fields(array('zone_name' => 'Newfoundland and Labrador', 'zone_code' => 'NL'))
  65. ->condition('zone_country_id', 124)
  66. ->condition('zone_code', 'NF')
  67. ->execute();
  68. break;
  69. }
  70. }