taxonomy.rules.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * @file rules integration for the taxonomy_term module
  4. *
  5. * @addtogroup rules
  6. * @{
  7. */
  8. /**
  9. * Implements hook_rules_event_info().
  10. */
  11. function rules_taxonomy_event_info() {
  12. $defaults_term = array(
  13. 'group' => t('Taxonomy'),
  14. 'access callback' => 'rules_taxonomy_term_integration_access',
  15. 'module' => 'taxonomy',
  16. );
  17. $defaults_vocab = array(
  18. 'group' => t('Taxonomy'),
  19. 'access callback' => 'rules_taxonomy_vocabulary_integration_access',
  20. 'module' => 'taxonomy',
  21. );
  22. return array(
  23. 'taxonomy_term_insert' => $defaults_term + array(
  24. 'label' => t('After saving a new term'),
  25. 'variables' => array(
  26. 'term' => array('type' => 'taxonomy_term', 'label' => t('created term')),
  27. ),
  28. ),
  29. 'taxonomy_term_update' => $defaults_term + array(
  30. 'label' => t('After updating an existing term'),
  31. 'variables' => array(
  32. 'term' => array('type' => 'taxonomy_term', 'label' => t('updated term')),
  33. 'term_unchanged' => array('type' => 'taxonomy_term', 'label' => t('unchanged term'), 'handler' => 'rules_events_entity_unchanged'),
  34. ),
  35. ),
  36. 'taxonomy_term_presave' => $defaults_term + array(
  37. 'label' => t('Before saving a taxonomy term'),
  38. 'variables' => array(
  39. 'term' => array('type' => 'taxonomy_term', 'label' => t('saved term'), 'skip save' => TRUE),
  40. 'term_unchanged' => array('type' => 'taxonomy_term', 'label' => t('unchanged term'), 'handler' => 'rules_events_entity_unchanged'),
  41. ),
  42. ),
  43. 'taxonomy_term_delete' => $defaults_term + array(
  44. 'label' => t('After deleting a term'),
  45. 'variables' => array(
  46. 'term' => array('type' => 'taxonomy_term', 'label' => t('deleted term')),
  47. ),
  48. ),
  49. 'taxonomy_vocabulary_insert' => $defaults_vocab + array(
  50. 'label' => t('After saving a new vocabulary'),
  51. 'variables' => array(
  52. 'vocabulary' => array('type' => 'taxonomy_vocabulary', 'label' => t('created vocabulary')),
  53. ),
  54. ),
  55. 'taxonomy_vocabulary_update' => $defaults_vocab + array(
  56. 'label' => t('After updating an existing vocabulary'),
  57. 'variables' => array(
  58. 'vocabulary' => array('type' => 'taxonomy_vocabulary', 'label' => t('updated vocabulary')),
  59. 'vocabulary_unchanged' => array('type' => 'taxonomy_vocabulary', 'label' => t('unchanged vocabulary'), 'handler' => 'rules_events_entity_unchanged'),
  60. ),
  61. ),
  62. 'taxonomy_vocabulary_presave' => $defaults_vocab + array(
  63. 'label' => t('Before saving a vocabulary'),
  64. 'variables' => array(
  65. 'vocabulary' => array('type' => 'taxonomy_vocabulary', 'label' => t('saved vocabulary'), 'skip save' => TRUE),
  66. 'vocabulary_unchanged' => array('type' => 'taxonomy_vocabulary', 'label' => t('unchanged vocabulary'), 'handler' => 'rules_events_entity_unchanged'),
  67. ),
  68. ),
  69. 'taxonomy_vocabulary_delete' => $defaults_vocab + array(
  70. 'label' => t('After deleting a vocabulary'),
  71. 'variables' => array(
  72. 'vocabulary' => array('type' => 'taxonomy_vocabulary', 'label' => t('deleted vocabulary')),
  73. ),
  74. ),
  75. );
  76. }
  77. /**
  78. * Taxonomy term integration access callback.
  79. */
  80. function rules_taxonomy_term_integration_access($type, $name) {
  81. if ($type == 'event' || $type == 'condition') {
  82. return entity_access('view', 'taxonomy_term');
  83. }
  84. }
  85. /**
  86. * Taxonomy vocabulary integration access callback.
  87. */
  88. function rules_taxonomy_vocabulary_integration_access($type, $name) {
  89. if ($type == 'event' || $type == 'condition') {
  90. return entity_access('view', 'taxonomy_vocabulary');
  91. }
  92. }
  93. /**
  94. * @}
  95. */