1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Implementation of hook_rules_action_info(). |
---|
5 | */ |
---|
6 | function views_bulk_operations_rules_action_info() { |
---|
7 | $actions = array(); |
---|
8 | |
---|
9 | // Execute VBO programmatically. |
---|
10 | foreach (module_invoke_all('views_bulk_operations_object_info') as $type => $info) { |
---|
11 | $actions['views_bulk_operations_rules_action_' . $type] = array( |
---|
12 | 'label' => t('Use !type object to execute a VBO programmatically', array('!type' => $type)), |
---|
13 | 'arguments' => array( |
---|
14 | 'object' => array( |
---|
15 | 'type' => $type, |
---|
16 | 'label' => t('Object'), |
---|
17 | 'description' => t('The chosen object will be loaded as the <code>$object</code> variable, available below.'), |
---|
18 | ), |
---|
19 | ), |
---|
20 | 'module' => 'Views Bulk Operations', |
---|
21 | 'eval input' => array(), |
---|
22 | 'base' => 'views_bulk_operations_rules_action', |
---|
23 | ); |
---|
24 | } |
---|
25 | |
---|
26 | // Modify node fields. |
---|
27 | $actions['views_bulk_operations_fields_rules_action'] = array( |
---|
28 | 'label' => t('Modify node fields'), |
---|
29 | 'arguments' => array( |
---|
30 | 'node' => array( |
---|
31 | 'type' => 'node', |
---|
32 | 'label' => t('Node'), |
---|
33 | ), |
---|
34 | ), |
---|
35 | 'module' => 'Node', |
---|
36 | ); |
---|
37 | |
---|
38 | return $actions; |
---|
39 | } |
---|
40 | |
---|
41 | function _views_bulk_operations_rules_variables(&$context, $state) { |
---|
42 | if (!empty($state['variables'])) foreach ($state['variables'] as $variable) { |
---|
43 | if (!empty($variable->data)) { |
---|
44 | $context['rules'][$variable->name] = $variable->data->_data; |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | function views_bulk_operations_rules_action($object, $settings, $element, &$state) { |
---|
50 | _views_bulk_operations_rules_variables($settings, $state); |
---|
51 | views_bulk_operations_action($object, $settings); |
---|
52 | return array('object' => $object); |
---|
53 | } |
---|
54 | |
---|
55 | function views_bulk_operations_rules_action_form($settings, &$form, &$form_state) { |
---|
56 | $form += views_bulk_operations_action_form($settings); |
---|
57 | } |
---|
58 | |
---|
59 | function views_bulk_operations_rules_action_validate($form, &$form_state) { |
---|
60 | views_bulk_operations_action_validate($form, $form_state); |
---|
61 | } |
---|
62 | |
---|
63 | function views_bulk_operations_rules_action_submit(&$settings, $form, &$form_state) { |
---|
64 | $submit = views_bulk_operations_action_submit($form, $form_state); |
---|
65 | $settings = array_merge($settings, $submit); |
---|
66 | } |
---|
67 | |
---|
68 | function views_bulk_operations_fields_rules_action($object, $settings, $element, &$state) { |
---|
69 | _views_bulk_operations_rules_variables($settings, $state); |
---|
70 | views_bulk_operations_fields_action($object, $settings); |
---|
71 | return array('node' => $object); |
---|
72 | } |
---|
73 | |
---|
74 | function views_bulk_operations_fields_rules_action_form($settings, &$form, &$form_state) { |
---|
75 | $form += views_bulk_operations_fields_action_form($settings); |
---|
76 | } |
---|
77 | |
---|
78 | function views_bulk_operations_fields_rules_action_validate($form, &$form_state) { |
---|
79 | views_bulk_operations_fields_action_validate($form, $form_state); |
---|
80 | } |
---|
81 | |
---|
82 | function views_bulk_operations_fields_rules_action_submit(&$settings, $form, &$form_state) { |
---|
83 | $submit = views_bulk_operations_fields_action_submit($form, $form_state); |
---|
84 | $settings = array_merge($settings, $submit); |
---|
85 | } |
---|