You are here

function _revision_scheduler_operation_access in Revision scheduler 7

1 call to _revision_scheduler_operation_access()
revision_scheduler_entity_revision_operation_get_options in ./revision_scheduler.module
Fetch the list of available entity revision operation that the user can add.

File

./revision_scheduler.module, line 597

Code

function _revision_scheduler_operation_access($operation, $entity_type, $entity = NULL, $account = NULL) {
  $access = FALSE;
  if (isset($operation['access callback']) || isset($operation['access arguments'])) {
    $operation += array(
      'access callback' => 'user_access',
      'access arguments' => array(),
    );
    $access_callback = isset($operation['access callback']) ? $operation['access callback'] : 'user_access';
    if (is_bool($access_callback)) {
      $access = $access_callback;
    }
    else {
      $access_arguments = isset($operation['access arguments']) ? $operation['access arguments'] : array();
      if ($access_callback === 'user_access' && count($access_arguments) === 1) {
        $access_arguments[] = $account;
      }
      $access = call_user_func_array($access_callback, $access_arguments);
    }
  }
  $access_checks = module_invoke_all('entity_revision_operation_access', $operation, $entity_type, $entity, $account);
  if (in_array(FALSE, $access_checks, TRUE)) {
    return FALSE;
  }
  elseif (in_array(TRUE, $access_checks, TRUE)) {
    return TRUE;
  }
  return $access;
}