1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file Includes any rules integration provided by the module.
|
5
|
*/
|
6
|
|
7
|
|
8
|
/**
|
9
|
* Implements hook_default_rules_configuration().
|
10
|
*/
|
11
|
function rules_test_default_rules_configuration() {
|
12
|
$rule = rules_reaction_rule();
|
13
|
$rule->label = 'example default rule';
|
14
|
$rule->active = FALSE;
|
15
|
$rule->event('node_update')
|
16
|
->condition(rules_condition('data_is', array('data:select' => 'node:status', 'value' => TRUE))->negate())
|
17
|
->condition('data_is', array('data:select' => 'node:type', 'value' => 'page'))
|
18
|
->action('drupal_message', array('message' => 'A node has been updated.'));
|
19
|
|
20
|
$configs['rules_test_default_1'] = $rule;
|
21
|
|
22
|
$action_set = rules_action_set(array('node' => array('type' => 'node', 'label' => 'Content')));
|
23
|
$action_set->action('node_publish');
|
24
|
$configs['rules_test_action_set'] = $action_set;
|
25
|
|
26
|
// Test providing a rule using an export.
|
27
|
$configs['rules_export_test'] = rules_import(_rules_export_get_test_export());
|
28
|
|
29
|
// An action set used to test merging term parents.
|
30
|
$configs['rules_retrieve_term_parents'] = rules_import('{ "rules_retrieve_term_parents" : {
|
31
|
"LABEL" : "Retrieve term parents",
|
32
|
"PLUGIN" : "action set",
|
33
|
"REQUIRES" : [ "rules" ],
|
34
|
"USES VARIABLES" : {
|
35
|
"terms" : { "label" : "Terms", "type" : "list\u003ctaxonomy_term\u003e" },
|
36
|
"term_parents" : {
|
37
|
"label" : "Term parents",
|
38
|
"type" : "list\u003ctaxonomy_term\u003e",
|
39
|
"parameter" : false
|
40
|
}
|
41
|
},
|
42
|
"ACTION SET" : [
|
43
|
{ "LOOP" : {
|
44
|
"USING" : { "list" : [ "terms" ] },
|
45
|
"ITEM" : { "current_term" : "Current term" },
|
46
|
"DO" : [
|
47
|
{ "LOOP" : {
|
48
|
"USING" : { "list" : [ "current-term:parent" ] },
|
49
|
"ITEM" : { "current_parent" : "Current parent" },
|
50
|
"DO" : [
|
51
|
{ "list_add" : {
|
52
|
"list" : [ "term-parents" ],
|
53
|
"item" : [ "current-parent" ],
|
54
|
"unique" : 1
|
55
|
}
|
56
|
}
|
57
|
]
|
58
|
}
|
59
|
}
|
60
|
]
|
61
|
}
|
62
|
}
|
63
|
],
|
64
|
"PROVIDES VARIABLES" : [ "term_parents" ]
|
65
|
}
|
66
|
}');
|
67
|
|
68
|
return $configs;
|
69
|
}
|
70
|
|
71
|
/**
|
72
|
* Defines the export of rule for testing import/export.
|
73
|
*/
|
74
|
function _rules_export_get_test_export() {
|
75
|
return '{ "rules_export_test" : {
|
76
|
"LABEL" : "Test import rule2",
|
77
|
"PLUGIN" : "reaction rule",
|
78
|
"WEIGHT" : "-1",
|
79
|
"ACTIVE" : false,
|
80
|
"OWNER" : "rules",
|
81
|
"TAGS" : [ "bar", "baz", "foo" ],
|
82
|
"REQUIRES" : [ "rules", "comment" ],
|
83
|
"ON" : { "comment_insert" : [] },
|
84
|
"IF" : [
|
85
|
{ "OR" : [
|
86
|
{ "NOT node_is_sticky" : { "node" : [ "comment:node" ] } },
|
87
|
{ "node_is_of_type" : {
|
88
|
"node" : [ "comment:node" ],
|
89
|
"type" : { "value" : { "page" : "page" } }
|
90
|
}
|
91
|
},
|
92
|
{ "NOT AND" : [ { "OR" : [] } ] }
|
93
|
]
|
94
|
}
|
95
|
],
|
96
|
"DO" : [
|
97
|
{ "data_set" : {
|
98
|
"data" : [ "comment:node:created" ],
|
99
|
"value" : { "select" : "site:current-date", "date_offset" : { "value" : -604800 } }
|
100
|
}
|
101
|
},
|
102
|
{ "node_make_sticky" : { "node" : [ "comment:node" ] } },
|
103
|
{ "variable_add" : {
|
104
|
"USING" : { "type" : "token", "value" : "error" },
|
105
|
"PROVIDE" : { "variable_added" : { "level" : "Error level" } }
|
106
|
}
|
107
|
},
|
108
|
{ "drupal_message" : {
|
109
|
"message" : "fein, [comment:node:title] has been made sticky!",
|
110
|
"type" : [ "level" ]
|
111
|
}
|
112
|
},
|
113
|
{ "LOOP" : {
|
114
|
"USING" : { "list" : [ "site:current-user:roles" ] },
|
115
|
"ITEM" : { "current_role" : "Current role" },
|
116
|
"DO" : [ { "drupal_message" : { "message" : [ "current-role" ] } } ]
|
117
|
}
|
118
|
}
|
119
|
]
|
120
|
}
|
121
|
}';
|
122
|
}
|