comment.rules.inc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @file rules integration for the comment module
  4. *
  5. * @addtogroup rules
  6. * @{
  7. */
  8. /**
  9. * Implementation of hook_rules_event_info().
  10. */
  11. function rules_comment_event_info() {
  12. $defaults = array(
  13. 'group' => t('comment'),
  14. 'module' => 'comment',
  15. 'access callback' => 'rules_comment_integration_access',
  16. );
  17. return array(
  18. 'comment_insert' => $defaults + array(
  19. 'label' => t('After saving a new comment'),
  20. 'variables' => array(
  21. 'comment' => array('type' => 'comment', 'label' => t('created comment')),
  22. ),
  23. ),
  24. 'comment_update' => $defaults + array(
  25. 'label' => t('After updating an existing comment'),
  26. 'variables' => array(
  27. 'comment' => array('type' => 'comment', 'label' => t('updated comment')),
  28. 'comment_unchanged' => array('type' => 'comment', 'label' => t('unchanged comment'), 'handler' => 'rules_events_entity_unchanged'),
  29. ),
  30. ),
  31. 'comment_presave' => $defaults + array(
  32. 'label' => t('Before saving a comment'),
  33. 'variables' => array(
  34. 'comment' => array('type' => 'comment', 'label' => t('saved comment'), 'skip save' => TRUE),
  35. 'comment_unchanged' => array('type' => 'comment', 'label' => t('unchanged comment'), 'handler' => 'rules_events_entity_unchanged'),
  36. ),
  37. ),
  38. 'comment_view' => $defaults + array(
  39. 'label' => t('A comment is viewed'),
  40. 'variables' => array(
  41. 'comment' => array('type' => 'comment', 'label' => t('viewed comment')),
  42. ),
  43. 'help' => t("Note that if drupal's page cache is enabled, this event won't be generated for pages served from cache."),
  44. ),
  45. 'comment_delete' => $defaults + array(
  46. 'label' => t('After deleting a comment'),
  47. 'variables' => array(
  48. 'comment' => array('type' => 'comment', 'label' => t('deleted comment')),
  49. ),
  50. ),
  51. );
  52. }
  53. /**
  54. * Comment integration access callback.
  55. */
  56. function rules_comment_integration_access($type, $name) {
  57. if ($type == 'event' || $type == 'condition') {
  58. return entity_access('view', 'comment');
  59. }
  60. }
  61. /**
  62. * @}
  63. */