iran_364_3.cif 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function iran_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' => 364,
  12. 'country_name' => 'Iran, Islamic Republic of',
  13. 'country_iso_code_2' => 'IR',
  14. 'country_iso_code_3' => 'IRN',
  15. 'version' => 3,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(364, 'AS', 'آذربایجان شرقی'),
  21. array(364, 'AG', 'آذربایجان غربی'),
  22. array(364, 'AR', 'اردبیل'),
  23. array(364, 'ES', 'اصفهان'),
  24. array(364, 'AL', 'البرز'),
  25. array(364, 'IL', 'ایلام'),
  26. array(364, 'BU', 'بوشهر'),
  27. array(364, 'TH', 'تهران'),
  28. array(364, 'CB', 'چهار محال بختیاری'),
  29. array(364, 'KH', 'خراسان جنوبی'),
  30. array(364, 'KH', 'خراسان رضوی'),
  31. array(364, 'KH', 'خراسان شمالی'),
  32. array(364, 'KZ', 'خوزستان'),
  33. array(364, 'ZN', 'زنجان'),
  34. array(364, 'SB', 'سیستان و بلوچستان'),
  35. array(364, 'SM', 'سمنان'),
  36. array(364, 'FR', 'فارس'),
  37. array(364, 'QZ', 'قزوین'),
  38. array(364, 'QM', 'قم'),
  39. array(364, 'KD', 'کردستان'),
  40. array(364, 'KR', 'کرمان'),
  41. array(364, 'KS', 'کرمانشاه'),
  42. array(364, 'KB', 'کهگیلویه و بویر احمد'),
  43. array(364, 'GL', 'گیلان'),
  44. array(364, 'GS', 'گلستان'),
  45. array(364, 'LR', 'لرستان'),
  46. array(364, 'MZ', 'مازندران'),
  47. array(364, 'MR', 'مرکزی'),
  48. array(364, 'HR', 'هرمزگان'),
  49. array(364, 'HM', 'همدان'),
  50. array(364, 'YZ', 'یزد'),
  51. );
  52. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  53. foreach ($zones as $zone) {
  54. $query->values($zone);
  55. }
  56. $query->execute();
  57. // Set address format
  58. uc_set_address_format(
  59. 364,
  60. "!first_name !last_name\r\n" .
  61. "!country_name - !zone_name - !city,\r\n" .
  62. "!street1\r\n" .
  63. "!street2\r\n" .
  64. "!postal_code"
  65. );
  66. }
  67. /**
  68. * Implements hook_update() with $version being the only argument.
  69. * Add a new case for each version update, and be sure to always include the
  70. * latest changes in the install function.
  71. */
  72. function iran_update($version) {
  73. switch ($version) {
  74. case 2:
  75. // Correct ISO-3166-1 country name
  76. db_update('uc_countries')
  77. ->fields(array(
  78. 'country_name' => 'Iran, Islamic Republic of',
  79. 'country_iso_code_3' => 'IRN',
  80. ))
  81. ->condition('country_id', 364)
  82. ->execute();
  83. break;
  84. case 3:
  85. // Add the Alborz zone
  86. db_insert('uc_zones')
  87. ->fields(array(
  88. 'zone_country_id' => 364,
  89. 'zone_code' => 'AL',
  90. 'zone_name' => 'البرز',
  91. ))
  92. ->execute();
  93. break;
  94. }
  95. }