Adding a custom views bulk operation VBO Reference: https://drupal.org/node/459070
/**
* Implementation of hook_views_api().
*/
function maestro_views_api() {
return array(
'api' => 2.0,
'path' => drupal_get_path('module', 'maestro')
);
}
/**
* Implements hook_action_info()
*/
function maestro_action_info() {
return array(
'maestro_vbo_task_delete_action' => array(
'type' => 'maestro',
'label' => t('Maestro - Delete Task'),
'description' => t('Delete task'),
'configurable' => FALSE,
'hooks' => array(),
),
'maestro_vbo_task_reminder_action' => array(
'type' => 'maestro',
'label' => t('Maestro - Send Task Reminder'),
'description' => t('Task Reminder'),
'configurable' => FALSE,
'hooks' => array(),
),
);
}
/**
* Implementation of hook_views_bulk_operations_object_info().
*/
function maestro_views_bulk_operations_object_info() {
$object_info = array(
'maestro' => array(
'type' => 'maestro',
'base_table' => 'maestro_queue',
'load' => 'maestro_task_vbo_load',
'oid' => 'id',
'title' => 'name',
),
);
return $object_info;
}
function maestro_task_vbo_load($type, $queueId) {
$query = db_select('maestro_queue', 'a');
$query->join('maestro_template_data','b','b.id = a.template_data_id');
$query->join('maestro_template','c','c.id = b.template_id');
$query->fields('a', array('id','template_data_id', 'process_id'));
$query->fields('b', array('taskname'));
$query->fields('c', array('template_name'));
$query->condition('a.id', $queueId, '=');
$rec = $query->execute()->fetchObject();
$retval = new stdClass();
$retval->name = "{$rec->template_name} => Task: {$rec->taskname}";
return $retval;
}
function maestro_vbo_task_delete_action(&$workflow, $context) {
$maestro = Maestro::createMaestroObject(1);
$maestro->engine()->deleteTask($context['row']->id);
}
function maestro_vbo_task_reminder_action(&$workflow, $context) {
$maestro = Maestro::createMaestroObject(1);
$maestro->engine()->sendTaskAssignmentNotifications($context['row']->id);
}