You are here

function eck__multiple_access_check in Entity Construction Kit (ECK) 7.3

Same name and namespace in other branches
  1. 7.2 eck.module \eck__multiple_access_check()

Callback for checking multiple permissions.

Parameters

array $perms: An array of permissions to be checked against.

bool $b_own: (optional) Flag to indicate if we should also check ownership permissions which are the same as the usual permissions, but will be postfixed with ' own'. Defaults to FALSE.

object $account: (optional) The account to check permissions against. Defaults to the current user.

File

./eck.module, line 525

Code

function eck__multiple_access_check($perms, $b_own = FALSE, $account = NULL) {
  if (!isset($account)) {
    $account = $GLOBALS['user'];
  }
  foreach ($perms as $perm) {
    if (user_access($perm, $account)) {
      return TRUE;
    }
  }
  if (!$b_own) {
    return FALSE;
  }

  // Check for entity author field and user ownership permissions.
  foreach ($perms as $perm) {
    if (user_access($perm . ' own', $account)) {
      return TRUE;
    }
  }

  // The user does not have any of the supplied permissions.
  return FALSE;
}