You are here

function workbench_moderation_permission in Workbench Moderation 7.2

Same name and namespace in other branches
  1. 7.3 workbench_moderation.module \workbench_moderation_permission()
  2. 7 workbench_moderation.module \workbench_moderation_permission()

Implements hook_permission().

Provides permissions for each state to state change.

File

./workbench_moderation.module, line 147
workbench_moderation.module

Code

function workbench_moderation_permission() {
  $permissions = array();
  $permissions['view moderation messages'] = array(
    'title' => t('View the moderation messages on a node'),
  );
  $permissions['view all unpublished content'] = array(
    'title' => t('View all unpublished content'),
  );
  $permissions['bypass workbench moderation'] = array(
    'title' => t('Bypass moderation restrictions'),
    'restrict access' => TRUE,
  );
  $permissions['use workbench_moderation my drafts tab'] = array(
    'title' => t('Use "My Drafts" workbench tab'),
  );
  $permissions['use workbench_moderation needs review tab'] = array(
    'title' => t('Use "Needs Review" workbench tab'),
  );

  // Add permissions for every state.
  $states = workbench_workflows_load_all();
  foreach ($states as $state => $info) {
    $permission = 'view all content in state ' . $state;
    $permissions[$permission] = array(
      'title' => t('View all content in state "!state"', array(
        '!state' => $info->title,
      )),
    );
    if ($info->entity_state_change < 1) {
      $permissions[$permission]['warning'] = t('This permission will give users access to probably unpublished content.');
    }
  }
  return $permissions;
}