-
Notifications
You must be signed in to change notification settings - Fork 1
/
node_convert.rules.inc
72 lines (67 loc) · 1.84 KB
/
node_convert.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
63
64
65
66
67
68
69
70
71
72
<?php
/**
* @file
* rules integration for the node_convert module
*/
/**
* Implements hook_rules_event_info().
* @ingroup rules
*/
function node_convert_rules_event_info() {
return array(
'node_convert_converted_node' => array(
'label' => t('Content has been converted'),
'module' => 'node',
'group' => t('Node'),
'variables' => rules_events_node_variables(t('Converted node')),
),
);
}
/**
* Implements hook_rules_action_info().
* @ingroup rules
*/
function node_convert_rules_action_info() {
$actions = array();
$actions['node_convert_convert_nodes_using_template_rules_callback'] = array(
'label' => t('Convert content'),
'group' => t('Node'),
'parameter' => array(
'template' => array(
'type' => 'text',
'label' => t('Select the Convert Template you wish to use.'),
'options list' => 'node_convert_rules_template_list',
),
'node' => array(
'type' => 'node',
'label' => t('Content to convert'),
),
),
);
return $actions;
}
/**
* Takes rules action parameters and passes them to the convert function.
*
* @param $template
* The template id to use for conversion.
* @param $node
* Full node object
* @return bool FALSE if conversion fails, this is return of convert function.
*/
function node_convert_convert_nodes_using_template_rules_callback($template, $node) {
return node_convert_convert_nodes_using_template(array($node->nid), $template);
}
/**
* Helper - Gets a list of templates and id's.
*
* @return array A associated array of template id's and names.
*/
function node_convert_rules_template_list() {
$template_objects = node_convert_load_all_templates();
$templates = array();
foreach ($template_objects as $template) {
$templates[$template->machine_name] = $template->name;
}
return $templates;
}