canada_124_2.cif 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. function canada_install() {
  3. // Make the entry in the country table.
  4. // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  5. db_insert('uc_countries')
  6. ->fields(array(
  7. 'country_id' => 124,
  8. 'country_name' => 'Canada',
  9. 'country_iso_code_2' => 'CA',
  10. 'country_iso_code_3' => 'CAN',
  11. 'version' => 2,
  12. ))
  13. ->execute();
  14. // Make the entries in the zones table.
  15. $zones = array(
  16. array(124, 'AB', 'Alberta'),
  17. array(124, 'BC', 'British Columbia'),
  18. array(124, 'MB', 'Manitoba'),
  19. array(124, 'NL', 'Newfoundland and Labrador'),
  20. array(124, 'NB', 'New Brunswick'),
  21. array(124, 'NS', 'Nova Scotia'),
  22. array(124, 'NT', 'Northwest Territories'),
  23. array(124, 'NU', 'Nunavut'),
  24. array(124, 'ON', 'Ontario'),
  25. array(124, 'PE', 'Prince Edward Island'),
  26. array(124, 'QC', 'Quebec'),
  27. array(124, 'SK', 'Saskatchewan'),
  28. array(124, 'YT', 'Yukon Territory'),
  29. );
  30. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  31. foreach ($zones as $zone) {
  32. $query->values($zone);
  33. }
  34. $query->execute();
  35. // Set address format
  36. // Have to call variable_set() instead of uc_set_address_format()
  37. // because the Canada .cif file is loaded during the installation
  38. // of the uc_store module, before uc_set_address_format() is available
  39. // to use.
  40. variable_set(
  41. 'uc_address_format_124',
  42. "!company\r\n".
  43. "!first_name !last_name\r\n".
  44. "!street1\r\n".
  45. "!street2\r\n".
  46. "!city !zone_code !postal_code\r\n".
  47. "!country_name_if"
  48. );
  49. }
  50. function canada_update($version) {
  51. switch ($version) {
  52. case 2:
  53. // Rename zone
  54. db_update('uc_zones')
  55. ->fields(array('zone_name' => 'Newfoundland and Labrador', 'zone_code' => 'NL'))
  56. ->condition('zone_country_id', 124)
  57. ->condition('zone_code', 'NF')
  58. ->execute();
  59. break;
  60. }
  61. }