function hook_workbench_access_info in Workbench Access 7
Defines your implementation for Workbench Access.
This hook declares your module to Workbench Access.
Return value
An array keyed by the name of your access scheme. (This is generally the module name.)
Array elements:
- 'access_scheme' The name of the scheme, generally the name of your module. Required.
- 'name' The human-readable name of the scheme, wrapped in t(). Required.
- 'access_type' The module that defines core hooks for your access scheme. This can be different from the access_scheme and use one provided by another module. Required.
- 'access_type_id' An array of keys that define the default access items in your structure. This should be a variable_get() from an array of checkboxes. The variable should be named 'workbench_access_ACCESS_SCHEME'. Required.
- 'description' A human-readable description of the access control scheme. Required.
- 'configuration' The configuration callback function. (Will default to hook_workbench_access_configuration() if not supplied.) Optional.
- 'form_field' The name of the default form element, if any, used by this scheme's implementation of hook_node_form_alter(). For FieldAPI-enabled modules, such as Taxonomy, this will be NULL. Optional.
- 'storage_column' The name of the database column used to store the primary key of the element. This value is used with FormAPI and FIeldAPI to ensure that the proper data is saved when using native form elements. Required.
- 'translatable' Boolean value that indicated the value is translatable via FieldAPI. Tells the module how to save language-sensitive data. Required.
The remainder of the elements are used with Views to provide proper query execution. They provide run-time alterations to Views handlers provided by Workbench Access. These elements will likely change as the module matures. These elements are all optional.
- 'query_field' The join field to the node storage table. Always 'access_id'.
- 'field_table' The table where the join field is stored. Always {workbench_access_node}.
- 'adjust_join' An array that defines how to alter the Views join for the table. This value is used to prevent duplicate results. See taxonomy_workbench_access_info() for sample usage.
- 'sort' The table(s) and fields to use for Views sorting.
2 functions implement hook_workbench_access_info()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- menu_workbench_access_info in modules/
menu.workbench_access.inc - Implements hook_workbench_access_info().
- taxonomy_workbench_access_info in modules/
taxonomy.workbench_access.inc - Implements hook_workbench_access_info().
3 invocations of hook_workbench_access_info()
- workbench_access_access_scheme_load in ./
workbench_access.module - Load callback to load information about an access scheme.
- workbench_access_requirements in ./
workbench_access.install - Implements hook_requirements() to check if workbench_access is configured.
- workbench_access_settings_form in ./
workbench_access.admin.inc - Settings form for Workbench Access configuration.
File
- ./
workbench_access.api.php, line 83 - API documentation file for Workbench Access.
Code
function hook_workbench_access_info() {
return array(
'menu' => array(
'access_scheme' => 'menu',
'name' => t('Menu'),
'access_type' => 'menu',
'access_type_id' => array_filter(variable_get('workbench_access_menu', array(
'main-menu',
))),
'description' => t('Uses a menu for assigning hierarchical access control'),
'configuration' => 'menu_workbench_access_configuration',
'form_field' => 'menu',
'storage_column' => 'mlid',
'translatable' => FALSE,
'node_table' => 'workbench_access_node',
'query_field' => 'access_id',
'field_table' => 'workbench_access_node',
'adjust_join' => array(
'menu_links' => array(
'original_table' => 'menu_links',
'original_field' => 'mlid',
'new_table' => 'workbench_access_node',
'new_field' => 'access_id',
),
),
'sort' => array(
array(
'table' => 'menu_links',
'field' => 'plid',
),
array(
'table' => 'menu_links',
'field' => 'weight',
'order' => 'ASC',
),
),
),
);
}