You are here

function oa_access_get_permissions in Open Atrium Core 7.2

Get all permissions defined by implementing modules.

Parameters

boolean $reset: (Optional) If set to TRUE, it will reset the static cache.

Return value

array Associative array keyed with the permission name containing associative arrays with the following keys:

  • title: Human readable name of the permission.
  • description: Human readable description of the permission.
  • module: The machine name of the module which defines it.
  • type: Flags specifying if can be used for Groups or Teams or both.
8 calls to oa_access_get_permissions()
oa_access in modules/oa_access/oa_access.module
Determines if the user has a permission.
oa_access_cleanup_permissions in modules/oa_access/oa_access.module
Removes left over permissions that are no longer valid.
oa_access_initialize_permissions in modules/oa_access/oa_access.module
Initializes new permissions that were added after module install.
oa_access_modules_installed in modules/oa_access/oa_access.module
Implements hook_modules_installed().
oa_access_node_insert in modules/oa_access/oa_access.module
Implements hook_node_insert().

... See full list

1 string reference to 'oa_access_get_permissions'
OpenAtriumAccessTestCase::testCleanupPermissions in modules/oa_access/tests/oa_access.test

File

modules/oa_access/oa_access.module, line 282
Code for the Open Atrium Access module.

Code

function oa_access_get_permissions($reset = FALSE) {
  if ($reset) {
    drupal_static_reset(__FUNCTION__);
  }
  $perms =& drupal_static(__FUNCTION__, NULL);
  if (is_null($perms)) {
    $perms = array();
    foreach (module_implements('oa_access_permission') as $module) {
      if ($result = module_invoke($module, 'oa_access_permission')) {
        foreach ($result as $key => $perm) {
          $perms[$key] = array_merge($perm, array(
            'module' => $module,
          ));

          // Set the default 'type' if not set.
          if (empty($perms[$key]['type'])) {
            $perms[$key]['type'] = OA_ACCESS_DEFAULT_PERMISSION;
          }
          elseif (!($perms[$key]['type'] & OA_ACCESS_GROUP_PERMISSION) && !($perms[$key]['type'] & OA_ACCESS_TEAM_PERMISSION)) {
            $perms[$key]['type'] |= OA_ACCESS_DEFAULT_PERMISSION;
          }

          // Set the default 'combine' if not set.
          if (empty($perms[$key]['combine'])) {
            $perms[$key]['combine'] = OA_ACCESS_COMBINE_UNION;
          }
        }
      }
    }
    drupal_alter('oa_access_permission', $perms);
  }
  return $perms;
}