Views Bulk Operations (VBO) development guide

Last modified: July 19, 2009 - 01:16

This guide applies to Drupal 6 only, starting with release 6.x-1.7

Developing operations for VBO

VBO reuses existing Drupal infrastructure to allow new operations to be added. The main method to create a new operation is by writing a Drupal Action. Please read the linked page first. VBO supports a superset of the capabilities of actions, so here are the steps to create an action that fully utilizes VBO.

Implement hook_action_info()

VBO supports a superset of the attributes that describe an action. Here are the added attributes:

  • parameters (optional): keyed array. This attribute gets appended as is to the $context array that is passed to action_function().
  • aggregate (optional): TRUE or FALSE. This attribute causes VBO to call the action just once, instead of once per selected row. The array of all selected object IDs (nid, uid, cid, etc.) is passed to action_function() in the $object argument instead of a reference to the selected object. This is useful for actions that perform aggregate functions such as node export, summation of a certain field, etc.

    It is worth noting that for actions that are marked as aggregate, Batch API and deferred execution modes are disabled and the action executes immediately, because it doesn't make sense to call the action only once in batch mode.

  • behavior (optional): array of flags. This attribute exists in the original Action specification, but is augmented here with additional flags:
    • views_node_property to signify that this action will show the node on-screen.
    • deletes_node_property to signify that this action might delete the node.

    These flags, along with the original changes_node_property, cause VBO to call node_access() on each node that is about to be acted upon, with the $op parameter corresponding to the specified flag(s). If VBO is invoked in direct execution mode or through Batch API, the current user's permissions are checked against the required node access. If a deferred execution mode such as Job Queue is used, then the uid of the user who fired the job is used.

  • permissions (optional): array of permissions. VBO calls user_access on each permission before accepting to execute the selected action.

Implement action_function_form($context)

TODO

Implement action_function_submit($form, $form_state)

TODO

Implement action_function_validate($form, $form_state)

TODO

Implement action_function(&$object, $context)

TODO

 
 

Drupal is a registered trademark of Dries Buytaert.