function views_bulk_operations_drush_execute in Views Bulk Operations (VBO) 6.3
Same name and namespace in other branches
- 7.3 views_bulk_operations.drush.inc \views_bulk_operations_drush_execute()
Implementation of 'vbo execute' command.
1 string reference to 'views_bulk_operations_drush_execute'
- views_bulk_operations_drush_command in ./
views_bulk_operations.drush.inc - Implementation of hook_drush_command().
File
- ./
views_bulk_operations.drush.inc, line 81
Code
function views_bulk_operations_drush_execute($vid = NULL, $operation = NULL) {
// Parse arguments.
if (is_null($vid)) {
drush_set_error('VIEWS_BULK_OPERATIONS_MISSING_VID', dt('Please specify a view ID to execute.'));
return;
}
if (is_null($operation)) {
drush_set_error('VIEWS_BULK_OPERATIONS_MISSING_OPERATION', dt('Please specify an operation to execute.'));
return;
}
$args = func_get_args();
$view_exposed_input = array();
$operation_arguments = array();
$view_arguments = array();
if (count($args) > 2) {
for ($i = 2; $i < count($args); $i++) {
$parts = array();
if (FALSE === preg_match('/^(?<type>\\w+):(?:(?<name>\\w+)=)?(?<value>(.*?))$/', $args[$i], $parts)) {
drush_set_error('VIEWS_BULK_OPERATIONS_INVALID_PARAMETER', dt('The parameter %arg should be of the form type:[name=]value where type in {input, argument, operation}.', array(
'%arg' => $args[$i],
)));
return;
}
switch ($parts['type']) {
case 'input':
$view_exposed_input[$parts['name']] = $parts['value'];
break;
case 'operation':
$operation_arguments[$parts['name']] = $parts['value'];
break;
case 'argument':
$view_arguments[] = $parts['value'];
break;
default:
drush_set_error('VIEWS_BULK_OPERATIONS_UNKNOWN_PARAMETER', dt('The parameter type %type is unknown. Please specify either input, argument or operation.', array(
'%type' => $parts['type'],
)));
return;
}
}
}
// Impersonate admin.
global $user;
$user = user_load(array(
'uid' => '1',
));
session_save_session(FALSE);
// Execute the VBO.
views_bulk_operations_execute($vid, $operation, $operation_arguments, $view_exposed_input, $view_arguments);
}