You are here

function scald_compute_role_actions in Scald: Media Management made easy 7

Computes actions bitsting for a single role.

Return value

int Computed action bistring.

2 calls to scald_compute_role_actions()
scald_permissions_submit in ./scald.module
Handles the permissions form submission.
_scald_user_combine_actions in ./scald.module
Fetch action bitstring components for a user.

File

./scald.module, line 2592
The Scald Core, which handles all Scald Registries and dispatch.

Code

function scald_compute_role_actions($role) {

  // Get permissions for the specified role.
  $permissions = user_role_permissions($role);

  // Get all Scald actions.
  $scald_actions = scald_actions();

  // Extract the role id.
  $rid = key($role);

  // Prepare empty bit strings.
  $role_actions = array(
    'own' => 0,
    'any' => 0,
  );

  // Get enabled permissions for this role.
  $role_permissions = $permissions[$rid];

  // For each action, check the role permissions, and add the action bitmask
  // to our counter if the permission is granted.
  foreach ($scald_actions as $key => $action) {
    if (!empty($role_permissions[$key . ' own atom'])) {
      $role_actions['own'] |= $action['bitmask'];
    }
    if (!empty($role_permissions[$key . ' any atom'])) {
      $role_actions['any'] |= $action['bitmask'];
    }
  }
  cache_set('scald_actions_bitstring_for_rid_' . $rid, $role_actions, 'cache_scald', CACHE_TEMPORARY);
  return $role_actions;
}