uc_ups.install 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the uc_ups module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function uc_ups_schema() {
  10. $schema = array();
  11. $schema['uc_ups_products'] = array(
  12. 'description' => 'Stores product information for UPS shipping quotes.',
  13. 'fields' => array(
  14. 'vid' => array(
  15. 'description' => 'The {uc_products}.vid.',
  16. 'type' => 'int',
  17. 'unsigned' => TRUE,
  18. 'not null' => TRUE,
  19. 'default' => 0,
  20. ),
  21. 'nid' => array(
  22. 'description' => 'The {uc_products}.nid.',
  23. 'type' => 'int',
  24. 'unsigned' => TRUE,
  25. 'not null' => TRUE,
  26. 'default' => 0,
  27. ),
  28. 'pkg_type' => array(
  29. 'description' => 'The type of package in which the product will be shipped.',
  30. 'type' => 'varchar',
  31. 'length' => 2,
  32. 'not null' => TRUE,
  33. 'default' => '',
  34. ),
  35. ),
  36. 'primary key' => array('vid'),
  37. 'foreign keys' => array(
  38. 'uc_products' => array(
  39. 'table' => 'uc_products',
  40. 'columns' => array(
  41. 'nid' => 'nid',
  42. 'vid' => 'vid',
  43. ),
  44. ),
  45. ),
  46. );
  47. return $schema;
  48. }
  49. /**
  50. * Implements hook_uninstall().
  51. */
  52. function uc_ups_uninstall() {
  53. variable_del('uc_ups_access_license');
  54. variable_del('uc_ups_shipper_number');
  55. variable_del('uc_ups_user_id');
  56. variable_del('uc_ups_password');
  57. variable_del('uc_ups_connection_address');
  58. variable_del('uc_ups_services');
  59. variable_del('uc_ups_pickup_type');
  60. variable_del('uc_ups_pkg_type');
  61. variable_del('uc_ups_classification');
  62. variable_del('uc_ups_negotiated_rates');
  63. variable_del('uc_ups_all_in_one');
  64. variable_del('uc_ups_unit_system');
  65. variable_del('uc_ups_insurance');
  66. variable_del('uc_ups_rate_markup');
  67. variable_del('uc_ups_rate_markup_type');
  68. variable_del('uc_ups_weight_markup');
  69. variable_del('uc_ups_weight_markup_type');
  70. }
  71. /**
  72. * Separates markup variables into rate_markup and weight_markup.
  73. */
  74. function uc_ups_update_7300() {
  75. // Rename variables while preserving previous setting values
  76. variable_set('uc_ups_rate_markup', variable_get('uc_ups_markup', ''));
  77. variable_set('uc_ups_rate_markup_type', variable_get('uc_ups_markup_type', ''));
  78. // Remove old variables
  79. variable_del('uc_ups_markup');
  80. variable_del('uc_ups_markup_type');
  81. }
  82. /**
  83. * Updates UPS Production URL.
  84. */
  85. function uc_ups_update_7301() {
  86. $current = variable_get('uc_ups_connection_address', '');
  87. // If currently using production URL, update variable to new value.
  88. if ($current == 'https://www.ups.com/ups.app/xml/') {
  89. variable_set('uc_ups_connection_address',
  90. 'https://onlinetools.ups.com/ups.app/xml/');
  91. }
  92. }