You are here

function entity_metadata_file_access in Entity API 7

Access callback for file entities.

1 string reference to 'entity_metadata_file_access'
_entity_info_add_metadata in ./entity.module
Adds metadata and callbacks for core entities to the entity info.

File

modules/callbacks.inc, line 856
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_file_access($op, $file, $account, $entity_type) {

  // We can only check access for the current user, so return FALSE on other accounts.
  global $user;
  if ($op == 'view' && isset($file) && (!isset($account) || $user->uid == $account->uid)) {

    // Invoke hook_file_download() to obtain access information.
    foreach (module_implements('file_download') as $module) {
      $result = module_invoke($module, 'file_download', $file->uri);
      if ($result == -1) {
        return FALSE;
      }
    }
    return TRUE;
  }
  return FALSE;
}