1 file.entity.inc | public static File::createAccess($bundle = NULL, $account = NULL) |
Overrides Entity::createAccess().
Overrides Entity::createAccess
File
- core/
modules/ file/ file.entity.inc, line 147 - Entity controller and class for files.
Class
- File
- Defines the file entity class.
Code
public static function createAccess($bundle = NULL, $account = NULL) {
$rights = &backdrop_static('file_access', array());
// If no user object is supplied, the access check is for the current user.
if (empty($account)) {
$account = $GLOBALS['user'];
}
// If we've already checked access for this file, user and op, return from
// cache.
if (isset($rights[$account->uid][$bundle])) {
return $rights[$account->uid][$bundle];
}
if (user_access('bypass file access', $account)) {
$rights[$account->uid][$bundle] = TRUE;
return $rights[$account->uid][$bundle];
}
if (user_access('create files', $account)) {
$rights[$account->uid][$bundle] = TRUE;
return $rights[$account->uid][$bundle];
}
// We grant access to the file if both of the following conditions are met:
// - No modules say to deny access.
// - At least one module says to grant access.
$access = module_invoke_all('file_access', $bundle, 'create', $account);
if (in_array(FILE_ACCESS_DENY, $access, TRUE)) {
$rights[$account->uid][$bundle] = FALSE;
return $rights[$account->uid][$bundle];
}
elseif (in_array(FILE_ACCESS_ALLOW, $access, TRUE)) {
$rights[$account->uid][$bundle] = TRUE;
return $rights[$account->uid][$bundle];
}
$rights[$account->uid][$bundle] = FALSE;
return $rights[$account->uid][$bundle];
}