singapore_702_2.cif 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function singapore_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' => 702,
  12. 'country_name' => 'Singapore',
  13. 'country_iso_code_2' => 'SG',
  14. 'country_iso_code_3' => 'SGP',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(702, 'SG-01', 'Central Singapore'),
  21. array(702, 'SG-02', 'North East'),
  22. array(702, 'SG-03', 'North West'),
  23. array(702, 'SG-04', 'South East'),
  24. array(702, 'SG-05', 'South West'),
  25. );
  26. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  27. foreach ($zones as $zone) {
  28. $query->values($zone);
  29. }
  30. $query->execute();
  31. // Set address format
  32. uc_set_address_format(
  33. 702,
  34. "!company\r\n" .
  35. "!first_name !last_name\r\n" .
  36. "!street1\r\n" .
  37. "!street2\r\n" .
  38. "!country_name, !postal_code"
  39. );
  40. }
  41. /**
  42. * Implements hook_update() with $version being the only argument.
  43. * Add a new case for each version update, and be sure to always include the
  44. * latest changes in the install function.
  45. */
  46. function singapore_update($version) {
  47. switch ($version) {
  48. case 2:
  49. $zones = array(
  50. array(702, 'SG-01', 'Central Singapore'),
  51. array(702, 'SG-02', 'North East'),
  52. array(702, 'SG-03', 'North West'),
  53. array(702, 'SG-04', 'South East'),
  54. array(702, 'SG-05', 'South West'),
  55. );
  56. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  57. foreach ($zones as $zone) {
  58. $query->values($zone);
  59. }
  60. $query->execute();
  61. break;
  62. }
  63. }