workflow_access.install 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * @file
  4. * Workflow access installation.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function workflow_access_schema() {
  10. $schema['workflow_access'] = array(
  11. 'description' => 'Workflow access tables',
  12. 'fields' => array(
  13. 'sid' => array(
  14. 'type' => 'int',
  15. 'description' => 'The Workflow state ID.',
  16. 'not null' => TRUE,
  17. ),
  18. 'rid' => array(
  19. 'type' => 'int',
  20. 'not null' => TRUE,
  21. ),
  22. 'grant_view' => array(
  23. 'type' => 'int',
  24. 'unsigned' => TRUE,
  25. 'size' => 'tiny',
  26. 'not null' => TRUE,
  27. 'default' => 0,
  28. ),
  29. 'grant_update' => array(
  30. 'type' => 'int',
  31. 'unsigned' => TRUE,
  32. 'size' => 'tiny',
  33. 'not null' => TRUE,
  34. 'default' => 0,
  35. ),
  36. 'grant_delete' => array(
  37. 'type' => 'int',
  38. 'unsigned' => TRUE,
  39. 'size' => 'tiny',
  40. 'not null' => TRUE,
  41. 'default' => 0,
  42. ),
  43. ),
  44. 'primary key' => array('sid', 'rid'),
  45. 'indexes' => array(
  46. 'rid' => array('rid'),
  47. ),
  48. );
  49. return $schema;
  50. }
  51. /**
  52. * Force rebuild of node access.
  53. */
  54. function workflow_access_disable() {
  55. node_access_needs_rebuild(TRUE);
  56. }
  57. /**
  58. * Correct field type of field 'sid' in workflow_access table.
  59. */
  60. function workflow_access_update_7001() {
  61. db_drop_primary_key('workflow_access');
  62. db_add_primary_key('workflow_access', array('sid', 'rid'));
  63. db_drop_index('workflow_access', 'sid');
  64. db_drop_index('workflow_access', 'rid');
  65. db_change_field('workflow_access', 'sid', 'sid', array(
  66. 'type' => 'int',
  67. 'not null' => TRUE,
  68. ));
  69. db_drop_primary_key('workflow_access');
  70. db_add_primary_key('workflow_access', array('sid', 'rid'));
  71. db_add_index('workflow_access', 'rid', array('rid'));
  72. }
  73. /**
  74. * Force rebuild of node access.
  75. */
  76. function workflow_access_update_7002() {
  77. node_access_needs_rebuild(TRUE);
  78. }