uc_usps.install 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the uc_usps module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function uc_usps_schema() {
  10. $schema = array();
  11. $schema['uc_usps_products'] = array(
  12. 'description' => 'Stores product information for USPS 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. 'container' => array(
  29. 'description' => 'The package type in which the product will be shipped.',
  30. 'type' => 'varchar',
  31. 'length' => '255',
  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_usps_uninstall() {
  53. variable_del('uc_usps_user_id');
  54. variable_del('uc_usps_services');
  55. variable_del('uc_usps_env_services');
  56. variable_del('uc_usps_intl_services');
  57. variable_del('uc_usps_intl_env_services');
  58. variable_del('uc_usps_rate_markup');
  59. variable_del('uc_usps_rate_markup_type');
  60. variable_del('uc_usps_weight_markup');
  61. variable_del('uc_usps_weight_markup_type');
  62. variable_del('uc_usps_all_in_one');
  63. variable_del('uc_usps_insurance');
  64. variable_del('uc_usps_delivery_confirmation');
  65. variable_del('uc_usps_signature_confirmation');
  66. variable_del('uc_usps_online_rates');
  67. }
  68. /**
  69. * Separates markup variables into rate_markup and weight_markup.
  70. */
  71. function uc_usps_update_7300() {
  72. // Rename variables while preserving previous setting values
  73. variable_set('uc_usps_rate_markup', variable_get('uc_usps_markup', ''));
  74. variable_set('uc_usps_rate_markup_type', variable_get('uc_usps_markup_type', ''));
  75. // Remove old variables
  76. variable_del('uc_usps_markup');
  77. variable_del('uc_usps_markup_type');
  78. }