You are here

protected function Workflow::rebuildRoles in Workflow 7.2

2 calls to Workflow::rebuildRoles()
Workflow::preRebuild in includes/Entity/Workflow.php
Rebuild things that get saved with this entity.
Workflow::rebuildInternals in includes/Entity/Workflow.php
Rebuild internals that get saved separately.

File

includes/Entity/Workflow.php, line 701
Contains workflow\includes\Entity\Workflow. Contains workflow\includes\Entity\WorkflowController.

Class

Workflow

Code

protected function rebuildRoles(array $roles) {
  $new_roles = array();

  // @todo: importing Roles is incomplete when user language is not English.
  // function user_roles() translates DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID
  $role_map = workflow_get_roles(NULL, FALSE);

  // See also https://drupal.org/node/1702626 .
  foreach ($roles as $key => $rid) {
    if ($rid == WORKFLOW_ROLE_AUTHOR_RID) {
      $new_roles[$rid] = $rid;
    }
    else {
      if ($role = user_role_load_by_name($role_map[$rid])) {
        $new_roles[$role->rid] = (int) $role->rid;
      }
    }
  }
  return $new_roles;
}