1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * Documentation of hooks. |
---|
6 | */ |
---|
7 | |
---|
8 | /** |
---|
9 | * Hook used by VBO to be able to handle different objects as does Views 2+ and the Drupal core action system. |
---|
10 | * |
---|
11 | * The array returned for each object type contains: |
---|
12 | * 'type' (required) => the object type name, should be the same as 'type' field in hook_action_info(). |
---|
13 | * 'context' (optional) => the context name that should receive the object, defaults to the value of 'type' above. |
---|
14 | * 'base_table' (required) => the Views 2 table name corresponding to that object type, should be the same as the $view->base_table attribute. |
---|
15 | * 'oid' (currently unused) => an attribute on the object that returns the unique object identifier (should be the same as $view->base_field). |
---|
16 | * 'load' (required) => a function($oid) that returns the corresponding object. |
---|
17 | * 'title' (required) => an attribute on the object that returns a human-friendly identifier of the object. |
---|
18 | * 'access' (optional) => a function($op, $node, $account = NULL) that behaves like node_access(). |
---|
19 | * |
---|
20 | * The following attributes allow VBO to show actions on view types different than the action's type: |
---|
21 | * 'hook' (optional) => the name of the hook supported by this object type, as defined in the 'hooks' attribute of hook_action_info(). |
---|
22 | * 'normalize' (optional) => a function($type, $object) that takes an object type and the object instance, returning additional context information for cross-type |
---|
23 | * |
---|
24 | * e.g., an action declaring hook => array('user') while of type 'system' will be shown on user views, and VBO will call the user's 'normalize' function to |
---|
25 | * prepare the action to fit the user context. |
---|
26 | */ |
---|
27 | function hook_views_bulk_operations_object_info() { |
---|
28 | $object_info = array( |
---|
29 | 'node' => array( |
---|
30 | 'type' => 'node', |
---|
31 | 'base_table' => 'node', |
---|
32 | 'load' => '_views_bulk_operations_node_load', |
---|
33 | 'oid' => 'nid', |
---|
34 | 'title' => 'title', |
---|
35 | 'access' => 'node_access', |
---|
36 | 'hook' => 'nodeapi', |
---|
37 | 'normalize' => '_views_bulk_operations_normalize_node_context', |
---|
38 | ), |
---|
39 | ); |
---|
40 | return $object_info; |
---|
41 | } |
---|
42 | |
---|
43 | /** |
---|
44 | * Hook used by VBO to allow altering the object_info structure returned by other modules. |
---|
45 | */ |
---|
46 | function hook_views_bulk_operations_object_info_alter(&$object_info) { |
---|
47 | $object_info['node']['load'] = '_my_special_node_load_callback'; |
---|
48 | } |
---|
49 | |
---|
50 | /** |
---|
51 | * Hook used by VBO to alter the way views results are indexed. |
---|
52 | * |
---|
53 | * Indexing is essential to remember the selected objects between the server and the browser. |
---|
54 | * This hook is useful for situations where the view query can return multiple rows with the same |
---|
55 | * object primary id, as in the case of multiple-valued node reference fields returned separately. |
---|
56 | */ |
---|
57 | function hook_views_bulk_operations_object_hash_alter(&$hash, $object, $view) { |
---|
58 | if ($view->name == 'my_view_name') { |
---|
59 | $hash = md5($object->nid . $object->field_node_reference_nid); |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|