function workbench_email_determine_valid_roles_per_transition in Workbench Email 7.3
Same name and namespace in other branches
- 7 workbench_email.module \workbench_email_determine_valid_roles_per_transition()
Determines the valid roles for a given transition.
Parameters
string $from_state: The transition from_state
string $to_state: The transition to_state
string $node_type: The node type used to determine valid roles.
Return value
valid_roles Returns the valid roles or an empty array
File
- ./
workbench_email.module, line 385 - Code for the Workbench Email Module.
Code
function workbench_email_determine_valid_roles_per_transition($from_state, $to_state, $node_type = NULL) {
$roles = user_roles();
$valid_roles = array();
if ($node_type == NULL) {
$transition = "moderate content from " . $from_state . " to " . $to_state;
}
foreach ($roles as $rid => $role) {
if ($role == "administrator") {
continue;
}
// Get a full list of this role's permissions.
$actual_permissions = user_role_permissions(array_filter(array(
$rid => TRUE,
DRUPAL_AUTHENTICATED_RID => $rid != DRUPAL_ANONYMOUS_RID,
)));
foreach ($actual_permissions as $permissions) {
if (isset($permissions[$transition])) {
$valid_roles[$rid] = $role;
}
}
}
return $valid_roles;
}