-
Notifications
You must be signed in to change notification settings - Fork 0
/
processclone.rules.inc
62 lines (58 loc) · 1.45 KB
/
processclone.rules.inc
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
<?php
/**
* @file Node clone rules functions
*/
/**
* Implementation of hook_rules_event_info.
*/
function processclone_rules_event_info() {
// Let rules know about the node clone event.
$items = array(
'processclone_node' => array(
'label' => t('After cloning a node'),
'group' => t('Node'),
'variables' => array(
'cloned_node' => array('type' => 'node', 'label' => t('The cloned node')),
'original_node' => array('type' => 'node', 'label' => t('The original node')),
),
),
);
return $items;
}
/**
* Implements hook_rules_action_info().
*/
function processclone_rules_action_info() {
$actions = array(
'processclone_action_node_processclone' => array(
'label' => t('Clone a node'),
'group' => t('Node'),
'parameter' => array(
'node' => array(
'type' => 'node',
'label' => t('Node to clone'),
),
),
'provides' => array(
'clone' => array(
'type' => 'node',
'label' => t('Cloned node'),
),
),
),
);
return $actions;
}
/**
* Action callback for cloning a node.
* @param $node
* The node to clone.
*/
function processclone_action_node_processclone($node) {
include_once drupal_get_path('module', 'processclone') . '/processclone.pages.inc';
$new_nid = processclone_node_save($node->nid);
$new_node = entity_load_single('node', $new_nid);
return array(
'clone' => $new_node,
);
}