function workbench_moderation_permission in Workbench Moderation 7
Same name and namespace in other branches
- 7.3 workbench_moderation.module \workbench_moderation_permission()
- 7.2 workbench_moderation.module \workbench_moderation_permission()
Implements hook_permission().
Provides permissions for each state to state change.
File
- ./
workbench_moderation.module, line 386 - Content moderation for Workbench.
Code
function workbench_moderation_permission() {
$permissions = array();
$permissions['view all unpublished content'] = array(
'title' => t('View all unpublished content'),
);
$permissions['administer workbench moderation'] = array(
'title' => t('Administer Workbench Moderation'),
);
$permissions['bypass workbench moderation'] = array(
'title' => t('Bypass moderation restrictions'),
'restrict access' => TRUE,
);
$permissions['view moderation history'] = array(
'title' => t('View moderation history'),
);
$permissions['view moderation messages'] = array(
'title' => t('View the moderation messages on a node'),
);
$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'),
);
// Per-node-type, per-transition permissions. Used by workbench_moderation_state_allowed().
$node_types = workbench_moderation_moderate_node_types();
$transitions = workbench_moderation_transitions();
foreach ($transitions as $transition) {
$from_state = $transition->from_name;
$to_state = $transition->to_name;
// Always set a permission to perform all moderation states.
$permissions["moderate content from {$from_state} to {$to_state}"] = array(
'title' => t('Moderate all content from %from_state to %to_state', array(
'%from_state' => workbench_moderation_state_label($from_state),
'%to_state' => workbench_moderation_state_label($to_state),
)),
);
// Per-node type permissions are very complex, and should only be used if
// absolutely needed. For right now, this is hardcoded to OFF. To enable it,
// Add this line to settings.php and then reset permissions.
// $conf['workbench_moderation_per_node_type'] = TRUE;
if (variable_get('workbench_moderation_per_node_type', FALSE)) {
foreach ($node_types as $node_type) {
$permissions["moderate {$node_type} state from {$from_state} to {$to_state}"] = array(
'title' => t('Moderate %node_type state from %from_state to %to_state', array(
'%node_type' => node_type_get_name($node_type),
'%from_state' => workbench_moderation_state_label($from_state),
'%to_state' => workbench_moderation_state_label($to_state),
)),
);
}
}
}
return $permissions;
}