flag_actions.install 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @file
  4. * Flag actions install file.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function flag_actions_uninstall() {
  10. }
  11. /**
  12. * Implements hook_schema().
  13. */
  14. function flag_actions_schema() {
  15. $schema = array();
  16. $schema['flag_actions'] = array(
  17. 'fields' => array(
  18. 'aid' => array(
  19. 'type' => 'serial',
  20. 'not null' => TRUE,
  21. 'disp-width' => '5',
  22. ),
  23. 'fid' => array(
  24. 'type' => 'int',
  25. 'size' => 'small',
  26. 'not null' => FALSE,
  27. 'disp-width' => '5',
  28. ),
  29. 'event' => array(
  30. 'type' => 'varchar',
  31. 'length' => '255',
  32. 'not null' => FALSE,
  33. ),
  34. 'threshold' => array(
  35. 'type' => 'int',
  36. 'size' => 'small',
  37. 'not null' => TRUE,
  38. 'default' => 0,
  39. 'disp-width' => '5',
  40. ),
  41. 'repeat_threshold' => array(
  42. 'type' => 'int',
  43. 'size' => 'small',
  44. 'not null' => TRUE,
  45. 'default' => 0,
  46. 'disp-width' => '5',
  47. ),
  48. 'callback' => array(
  49. 'type' => 'varchar',
  50. 'length' => '255',
  51. 'not null' => TRUE,
  52. 'default' => '',
  53. ),
  54. 'parameters' => array(
  55. 'type' => 'text',
  56. 'size' => 'big',
  57. 'not null' => TRUE,
  58. ),
  59. ),
  60. 'primary key' => array('aid'),
  61. );
  62. return $schema;
  63. }
  64. /**
  65. * Add a "repeat_threshold" value to all existing Flag actions.
  66. */
  67. function flag_actions_update_6200() {
  68. // Add the new repeat_threshold column.
  69. if (!db_field_exists('flag_actions', 'repeat_threshold')) {
  70. $column = array(
  71. 'type' => 'int',
  72. 'size' => 'small',
  73. 'not null' => TRUE,
  74. 'default' => 0,
  75. 'disp-width' => '5',
  76. );
  77. db_add_field('flag_actions', 'repeat_threshold', $column);
  78. }
  79. // Update the normal threshold column to default to 0.
  80. $column = array(
  81. 'type' => 'int',
  82. 'size' => 'small',
  83. 'not null' => TRUE,
  84. 'default' => 0,
  85. 'disp-width' => '5',
  86. );
  87. db_change_field('flag_actions', 'threshold', 'threshold', $column);
  88. }