rules_test.test.inc
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* @file Include file for testing file inclusion.
*/
/**
* Extender for the node data type.
*/
function rules_test_custom_node_save($object) {
throw new RulesEvaluationException('Custom save method invoked.');
}
/**
* Custom help callback for the rules_node_publish_action
*/
function rules_test_custom_help() {
return 'custom';
}
/**
* Action callback
*/
function rules_action_test_reference($data) {
$data['changed'] = TRUE;
return array('arg' => $data);
}
/**
* Condition: Check for selected content types
*/
function rules_condition_content_is_type($node, $type) {
return in_array($node->type, $type);
}
/**
* Condition: Check if the node is published
*/
function rules_condition_content_is_published($node, $settings) {
return $node->status == 1;
}
/**
* Loads a node
*/
function rules_action_load_node($nid, $vid = NULL) {
return array('node_loaded' => node_load($nid, $vid ? $vid : NULL));
}
/**
* Action "Delete a node".
*/
function rules_action_delete_node($node) {
node_delete($node->nid);
}
/**
* An action making use of named parameters.
*/
function rules_action_node_set_title($arguments) {
// Make sure the data is unwrapped.
if ($arguments['node'] instanceof EntityMetadataWrapper) {
throw new Exception('Argument has not been correctly unwrapped.');
}
$arguments['node']->title = $arguments['title'];
return $arguments;
}
/**
* Action: Test saving - nothing to do here.
*/
function rules_test_type_save($node) {
}