united_kingdom_826_2.cif 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. /**
  3. * Implements hook_install() using the name of the country as the base of
  4. * the function name.
  5. */
  6. function united_kingdom_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' => 826,
  12. 'country_name' => 'United Kingdom',
  13. 'country_iso_code_2' => 'GB',
  14. 'country_iso_code_3' => 'GBR',
  15. 'version' => 2,
  16. ))
  17. ->execute();
  18. // Make the entries in the zones table.
  19. $zones = array(
  20. array(826, 'ABN', 'Aberdeen'),
  21. array(826, 'ABNS', 'Aberdeenshire'),
  22. array(826, 'ANG', 'Anglesey'),
  23. array(826, 'AGS', 'Angus'),
  24. array(826, 'ARY', 'Argyll and Bute'),
  25. array(826, 'AVON', 'Avon'),
  26. array(826, 'BEDS', 'Bedfordshire'),
  27. array(826, 'BERKS', 'Berkshire'),
  28. array(826, 'BLA', 'Blaenau Gwent'),
  29. array(826, 'BRI', 'Bridgend'),
  30. array(826, 'BSTL', 'Bristol'),
  31. array(826, 'BUCKS', 'Buckinghamshire'),
  32. array(826, 'CAE', 'Caerphilly'),
  33. array(826, 'CAMBS', 'Cambridgeshire'),
  34. array(826, 'CDF', 'Cardiff'),
  35. array(826, 'CARM', 'Carmarthenshire'),
  36. array(826, 'CDGN', 'Ceredigion'),
  37. array(826, 'CHES', 'Cheshire'),
  38. array(826, 'CLACK', 'Clackmannanshire'),
  39. array(826, 'CLVD', 'Cleveland'),
  40. array(826, 'CON', 'Conwy'),
  41. array(826, 'CORN', 'Cornwall'),
  42. array(826, 'COAN', 'County Antrim'),
  43. array(826, 'COAR', 'County Armagh'),
  44. array(826, 'CODN', 'County Down'),
  45. array(826, 'COFE', 'County Fermanagh'),
  46. array(826, 'COLO', 'County Londonderry'),
  47. array(826, 'COTY', 'County Tyrone'),
  48. array(826, 'CMA', 'Cumbria'),
  49. array(826, 'DNBG', 'Denbighshire'),
  50. array(826, 'DERBY', 'Derbyshire'),
  51. array(826, 'DVN', 'Devon'),
  52. array(826, 'DOR', 'Dorset'),
  53. array(826, 'DGL', 'Dumfries and Galloway'),
  54. array(826, 'DUND', 'Dundee'),
  55. array(826, 'DHM', 'Durham'),
  56. array(826, 'ARYE', 'East Ayrshire'),
  57. array(826, 'DUNBE', 'East Dunbartonshire'),
  58. array(826, 'LOTE', 'East Lothian'),
  59. array(826, 'RENE', 'East Renfrewshire'),
  60. array(826, 'ERYS', 'East Riding of Yorkshire'),
  61. array(826, 'SXE', 'East Sussex'),
  62. array(826, 'EDIN', 'Edinburgh'),
  63. array(826, 'ESX', 'Essex'),
  64. array(826, 'FALK', 'Falkirk'),
  65. array(826, 'FFE', 'Fife'),
  66. array(826, 'FLINT', 'Flintshire'),
  67. array(826, 'GLAS', 'Glasgow'),
  68. array(826, 'GLOS', 'Gloucestershire'),
  69. array(826, 'MAN', 'Greater Manchester'),
  70. array(826, 'GDD', 'Gwynedd'),
  71. array(826, 'HANTS', 'Hampshire'),
  72. array(826, 'HWR', 'Herefordshire'),
  73. array(826, 'HERTS', 'Hertfordshire'),
  74. array(826, 'HLD', 'Highlands'),
  75. array(826, 'IVER', 'Inverclyde'),
  76. array(826, 'IOW', 'Isle of Wight'),
  77. array(826, 'IOS', 'Isles of Scilly'),
  78. array(826, 'KNT', 'Kent'),
  79. array(826, 'LANCS', 'Lancashire'),
  80. array(826, 'LEICS', 'Leicestershire'),
  81. array(826, 'LINCS', 'Lincolnshire'),
  82. array(826, 'LDN', 'London'),
  83. array(826, 'MSY', 'Merseyside'),
  84. array(826, 'MERT', 'Merthyr Tydfil'),
  85. array(826, 'MIDDX', 'Middlesex'),
  86. array(826, 'MLOT', 'Midlothian'),
  87. array(826, 'MMOUTH', 'Monmouthshire'),
  88. array(826, 'MORAY', 'Moray'),
  89. array(826, 'NPRTAL', 'Neath Port Talbot'),
  90. array(826, 'NEWPT', 'Newport'),
  91. array(826, 'NOR', 'Norfolk'),
  92. array(826, 'ARYN', 'North Ayrshire'),
  93. array(826, 'LANN', 'North Lanarkshire'),
  94. array(826, 'YSN', 'North Yorkshire'),
  95. array(826, 'NHM', 'Northamptonshire'),
  96. array(826, 'NLD', 'Northumberland'),
  97. array(826, 'NOT', 'Nottinghamshire'),
  98. array(826, 'ORK', 'Orkney Islands'),
  99. array(826, 'OFE', 'Oxfordshire'),
  100. array(826, 'PEM', 'Pembrokeshire'),
  101. array(826, 'PERTH', 'Perth and Kinross'),
  102. array(826, 'PWS', 'Powys'),
  103. array(826, 'REN', 'Renfrewshire'),
  104. array(826, 'RHON', 'Rhondda Cynon Taff'),
  105. array(826, 'RUT', 'Rutland'),
  106. array(826, 'BOR', 'Scottish Borders'),
  107. array(826, 'SHET', 'Shetland Islands'),
  108. array(826, 'SPE', 'Shropshire'),
  109. array(826, 'SOM', 'Somerset'),
  110. array(826, 'ARYS', 'South Ayrshire'),
  111. array(826, 'LANS', 'South Lanarkshire'),
  112. array(826, 'YSS', 'South Yorkshire'),
  113. array(826, 'SFD', 'Staffordshire'),
  114. array(826, 'STIR', 'Stirling'),
  115. array(826, 'SFK', 'Suffolk'),
  116. array(826, 'SRY', 'Surrey'),
  117. array(826, 'SWAN', 'Swansea'),
  118. array(826, 'TORF', 'Torfaen'),
  119. array(826, 'TWR', 'Tyne and Wear'),
  120. array(826, 'VGLAM', 'Vale of Glamorgan'),
  121. array(826, 'WARKS', 'Warwickshire'),
  122. array(826, 'WDUN', 'West Dunbartonshire'),
  123. array(826, 'WLOT', 'West Lothian'),
  124. array(826, 'WMD', 'West Midlands'),
  125. array(826, 'SXW', 'West Sussex'),
  126. array(826, 'YSW', 'West Yorkshire'),
  127. array(826, 'WIL', 'Western Isles'),
  128. array(826, 'WLT', 'Wiltshire'),
  129. array(826, 'WORCS', 'Worcestershire'),
  130. array(826, 'WRX', 'Wrexham')
  131. );
  132. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  133. foreach ($zones as $zone) {
  134. $query->values($zone);
  135. }
  136. $query->execute();
  137. // Set address format
  138. uc_set_address_format(
  139. 826,
  140. "!first_name !last_name\r\n".
  141. "!company\r\n".
  142. "!street1\r\n".
  143. "!street2\r\n".
  144. "!city\r\n".
  145. "!postal_code\r\n".
  146. "!country_name_if"
  147. );
  148. }
  149. /**
  150. * Implements hook_update() with $version being the only argument.
  151. * Add a new case for each version update, and be sure to always include the
  152. * latest changes in the install function.
  153. */
  154. function united_kingdom_update($version) {
  155. switch ($version) {
  156. case 2:
  157. $zones = array(
  158. array(826, 'AVON', 'Avon'),
  159. array(826, 'COAN', 'County Antrim'),
  160. array(826, 'COAR', 'County Armagh'),
  161. array(826, 'CODN', 'County Down'),
  162. array(826, 'COFE', 'County Fermanagh'),
  163. array(826, 'COLO', 'County Londonderry'),
  164. array(826, 'COTY', 'County Tyrone'),
  165. array(826, 'CLVD', 'Cleveland'),
  166. array(826, 'IOS', 'Isles of Scilly'),
  167. array(826, 'MIDDX', 'Middlesex'),
  168. );
  169. $query = db_insert('uc_zones')->fields(array('zone_country_id', 'zone_code', 'zone_name'));
  170. foreach ($zones as $zone) {
  171. $query->values($zone);
  172. }
  173. $query->execute();
  174. db_update('uc_zones')
  175. ->fields(array('zone_name' => 'Greater Manchester'))
  176. ->condition('zone_country_id', 826)
  177. ->condition('zone_name', 'Manchester')
  178. ->execute();
  179. uc_set_address_format(
  180. 826,
  181. "!first_name !last_name\r\n".
  182. "!company\r\n".
  183. "!street1\r\n".
  184. "!street2\r\n".
  185. "!city\r\n".
  186. "!postal_code\r\n".
  187. "!country_name_if"
  188. );
  189. break;
  190. }
  191. }