feedback.install 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * @file
  4. * Installation functions for Feedback module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function feedback_schema() {
  10. $schema['feedback'] = array(
  11. 'description' => 'Stores all feedback messages.',
  12. 'fields' => array(
  13. 'fid' => array(
  14. 'description' => 'Feedback message ID.',
  15. 'type' => 'serial',
  16. 'unsigned' => TRUE,
  17. 'not null' => TRUE,
  18. ),
  19. 'uid' => array(
  20. 'description' => 'User ID of the feedback message author.',
  21. 'type' => 'int',
  22. 'unsigned' => TRUE,
  23. 'not null' => TRUE,
  24. 'default' => 0,
  25. ),
  26. 'status' => array(
  27. 'description' => 'Feedback status (0 = new, 1 = processed).',
  28. 'type' => 'int',
  29. 'size' => 'tiny',
  30. 'unsigned' => TRUE,
  31. 'not null' => TRUE,
  32. 'default' => 0,
  33. ),
  34. 'message' => array(
  35. 'description' => 'The feedback message.',
  36. 'type' => 'text',
  37. 'size' => 'big',
  38. 'not null' => TRUE,
  39. ),
  40. 'location' => array(
  41. 'description' => 'System path of the originating page.',
  42. 'type' => 'text',
  43. 'not null' => TRUE,
  44. ),
  45. 'location_masked' => array(
  46. 'description' => 'Untranslated system path of the originating page.',
  47. 'type' => 'text',
  48. 'not null' => TRUE,
  49. ),
  50. 'url' => array(
  51. 'description' => 'Absolute URL of the originating page.',
  52. 'type' => 'text',
  53. 'not null' => TRUE,
  54. ),
  55. 'useragent' => array(
  56. 'description' => 'User agent of the feedback message author.',
  57. 'type' => 'varchar',
  58. 'length' => 255,
  59. 'not null' => TRUE,
  60. ),
  61. // @todo Rename to created. Also add 'changed'.
  62. 'timestamp' => array(
  63. 'description' => 'UNIX timestamp of the feedback message creation date.',
  64. 'type' => 'int',
  65. 'not null' => TRUE,
  66. 'default' => 0,
  67. ),
  68. ),
  69. 'primary key' => array('fid'),
  70. 'indexes' => array(
  71. 'location' => array(array('location', 32)),
  72. 'location_masked' => array(array('location_masked', 32)),
  73. ),
  74. );
  75. return $schema;
  76. }
  77. /**
  78. * Implements hook_uninstall().
  79. */
  80. function feedback_uninstall() {
  81. db_delete('variable')
  82. ->condition('name', 'feedback_%', 'LIKE')
  83. ->execute();
  84. }
  85. /**
  86. * Change fid into type serial field.
  87. */
  88. function feedback_update_6100() {
  89. db_drop_primary_key('feedback');
  90. db_change_field('feedback', 'fid', 'fid', array(
  91. 'type' => 'serial',
  92. 'unsigned' => TRUE,
  93. 'not null' => TRUE,
  94. ), array(
  95. 'primary key' => array('fid'),
  96. ));
  97. }
  98. /**
  99. * Add column for absolute URL.
  100. */
  101. function feedback_update_6101() {
  102. db_add_field('feedback', 'url', array(
  103. 'type' => 'text',
  104. 'not null' => TRUE,
  105. ));
  106. // Set 'url' to the value of 'location' for all existing entries.
  107. db_update('feedback')
  108. ->expression('url', 'location')
  109. ->execute();
  110. }