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