singapore_702_2.cif 1.8 KB

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