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