function _views_bulk_operations_action_do in Views Bulk Operations (VBO) 6
Same name and namespace in other branches
- 5 views_bulk_operations.module \_views_bulk_operations_action_do()
- 6.3 views_bulk_operations.module \_views_bulk_operations_action_do()
Helper function to execute one operation.
3 calls to _views_bulk_operations_action_do()
- _views_bulk_operations_execute_multiple in ./
views_bulk_operations.module - Helper function for multiple execution operations.
- _views_bulk_operations_execute_queue in ./
views_bulk_operations.module - Helper function to handle Drupal Queue operations.
- _views_bulk_operations_execute_single in ./
views_bulk_operations.module - Helper function to handle Batch API operations.
File
- ./
views_bulk_operations.module, line 1827 - Allows operations to be performed on items selected in a view.
Code
function _views_bulk_operations_action_do($operation, $oid, $object, $row, $params, $object_info, $account = NULL) {
_views_bulk_operations_action_permission($operation, $account);
// Add the object to the context.
if (!empty($object_info['context'])) {
$params[$object_info['context']] = $object;
}
else {
$params[$object_info['type']] = $object;
}
// If the operation type is different from the view type, normalize the context first.
$actual_object = $object;
if ($object_info['type'] != $operation['type']) {
if (isset($object_info['normalize']) && function_exists($object_info['normalize'])) {
$actual_object = call_user_func($object_info['normalize'], $operation['type'], $object);
}
$params['hook'] = $object_info['hook'];
}
if (is_null($actual_object)) {
// Normalize function can return NULL: we don't want that
$actual_object = $object;
}
$params['row'] = $row;
// Expose the original view row to the action
if ($operation['source'] == 'action') {
actions_do($operation['callback'], $actual_object, $params);
if ($operation['type'] == 'node' && $operation['access op'] & VBO_ACCESS_OP_UPDATE) {
// Save nodes explicitly if needed
$node_options = variable_get('node_options_' . $actual_object->type, array(
'status',
'promote',
));
if (in_array('revision', $node_options) && !isset($actual_object->revision)) {
$actual_object->revision = TRUE;
$actual_object->log = '';
}
node_save($actual_object);
}
}
else {
// source == 'operation'
$args = array_merge(array(
array(
$oid,
),
), $params);
call_user_func_array($operation['callback'], $args);
}
}