You are here

function views_bulk_operations_views_bulk_operations_object_info in Views Bulk Operations (VBO) 6

Same name and namespace in other branches
  1. 6.3 views_bulk_operations.module \views_bulk_operations_views_bulk_operations_object_info()

Implementation of hook_views_bulk_operations_object_info()

Hook used by VBO to be able to handle different objects as does Views 2 and the Drupal core action system.

The array returned for each object type contains: 'type' (required) => the object type name, should be the same as 'type' field in hook_action_info(). 'context' (optional) => the context name that should receive the object, defaults to the value of 'type' above. 'base_table' (required) => the Views 2 table name corresponding to that object type, should be the same as the $view->base_table attribute. 'oid' (currently unused) => an attribute on the object that returns the unique object identifier (should be the same as $view->base_field). 'load' (required) => a function($oid) that returns the corresponding object. 'title' (required) => an attribute on the object that returns a human-friendly identifier of the object. 'access' (optional) => a function($op, $node, $account = NULL) that behaves like node_access().

The following attributes allow VBO to show actions on view types different than the action's type: 'hook' (optional) => the name of the hook supported by this object type, as defined in the 'hooks' attribute of hook_action_info(). 'normalize' (optional) => a function($type, $object) that takes an object type and the object instance, returning additional context information for cross-type

e.g., an action declaring hooks => array('user') while of type 'system' will be shown on user views, and VBO will call the user's 'normalize' function to prepare the action to fit the user context.

File

./views_bulk_operations.module, line 926
Allows operations to be performed on items selected in a view.

Code

function views_bulk_operations_views_bulk_operations_object_info() {
  $object_info = array(
    'node' => array(
      'type' => 'node',
      'base_table' => 'node',
      'load' => '_views_bulk_operations_node_load',
      'oid' => 'nid',
      'title' => 'title',
      'access' => 'node_access',
      'hook' => 'nodeapi',
      'normalize' => '_views_bulk_operations_normalize_node_context',
    ),
    'user' => array(
      'type' => 'user',
      'base_table' => 'users',
      'load' => 'user_load',
      'oid' => 'uid',
      'title' => 'name',
      'context' => 'account',
      'access' => '_views_bulk_operations_user_access',
      'hook' => 'user',
      'normalize' => '_views_bulk_operations_normalize_user_context',
    ),
    'comment' => array(
      'type' => 'comment',
      'base_table' => 'comments',
      'load' => '_comment_load',
      'oid' => 'cid',
      'title' => 'subject',
      'access' => '_views_bulk_operations_comment_access',
      'hook' => 'comment',
      'normalize' => '_views_bulk_operations_normalize_comment_context',
    ),
    'term' => array(
      'type' => 'term',
      'base_table' => 'term_data',
      'load' => 'taxonomy_get_term',
      'oid' => 'tid',
      'title' => 'name',
      'hook' => 'taxonomy',
    ),
    'node_revision' => array(
      'type' => 'node_revision',
      'base_table' => 'node_revisions',
      'load' => '_views_bulk_operations_node_revision_load',
      'title' => 'name',
    ),
    'file' => array(
      'type' => 'file',
      'base_table' => 'files',
      'load' => '_views_bulk_operations_file_load',
      'oid' => 'fid',
      'title' => 'filename',
    ),
  );
  return $object_info;
}