| 1 actions.inc | actions_access($action_name, ? UserInterface $account = NULL) |
Checks if the current user account has access to a single action.
Parameters
string $action_name: The name of the action to check access.
UserInterface|null $account: The user account to check access action against. Defaults to the currently logged-in user.
File
- core/
includes/ actions.inc, line 86 - This is the actions engine for executing stored actions.
Code
function actions_access($action_name, ? UserInterface $account = NULL) {
global $user;
if (!isset($account)) {
$account = $user;
}
$action_info = actions_get_info($action_name);
if (!$action_info) {
trigger_error(t('The action "@action" could not be found.', array('@action' => $action_name)), E_USER_ERROR);
}
// Check if access is allowed to this action.
$access_callback = $action_info['access callback'];
$access_arguments = $action_info['access arguments'];
$access_arguments[] = $account;
$access = ($access_callback === TRUE);
if (!$access) {
$access = call_user_func_array($access_callback, $access_arguments);
}
return $access;
}