You are here

function hook_workbench_access_configuration in Workbench Access 7

Defines configuration options for your access scheme.

This function is fun, because it uses Drupal 7's new JavaScript $states properties to control the settings form.

Your module is responsible for defining how it interacts with the main form. If the 'workbench_access' value is equal to the name of your access scheme, your options will be presented.

Essentially, this is a custom hook_form_FORM_ID_alter() convenience function.

Note that your form should normally return checkboxes within a fieldset. Do not make the checkboxes required, as this may be confusing if they are in the 'hidden' state.

Parameters

&$form: The base form, passed by reference.

&$form_state: The form state, passed by reference.

Return value

No return value. Modify $form by reference.

See also

drupal_process_states()

2 functions implement hook_workbench_access_configuration()

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_configuration in modules/menu.workbench_access.inc
Defines configuration options for the default access scheme.
taxonomy_workbench_access_configuration in modules/taxonomy.workbench_access.inc
Defines configuration options for the default access scheme.

File

./workbench_access.api.php, line 315
API documentation file for Workbench Access.

Code

function hook_workbench_access_configuration(&$form, &$form_state) {
  $options = array();
  $vocabularies = taxonomy_get_vocabularies();
  foreach ($vocabularies as $vid => $vocabulary) {
    $options[$vocabulary->machine_name] = $vocabulary->name;
  }
  $form['taxonomy_workbench_access_info'] = array(
    '#type' => 'fieldset',
    '#title' => t('Taxonomy scheme settings'),
    '#states' => array(
      'visible' => array(
        ':input[name=workbench_access]' => array(
          'value' => 'taxonomy',
        ),
      ),
    ),
  );
  $form['taxonomy_workbench_access_info']['workbench_access_taxonomy'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Editorial vocabulary'),
    '#description' => t('Select the vocabulary to be used for access control. <strong>Warning: Changing this value in production may disrupt your workflow.</strong>'),
    '#options' => $options,
    '#default_value' => variable_get('workbench_access_taxonomy', array()),
    '#states' => array(
      'visible' => array(
        ':input[name=workbench_access]' => array(
          'value' => 'taxonomy',
        ),
      ),
    ),
  );
}