You are here

function hook_commerce_file_download_unlicensed_access in Commerce File 7

Control unlicensed download access to Commerce files.

The hook is typically implemented to allow access to a restricted file for users that do not have any valid license for that file.

Parameters

$file: A file object.

$account: A user object attempting to download the file.

$licenses: An array of licenses associated with the user that currently do not allow access to the file.

Return value

TRUE is access should be allowed or FALSE if denied. Note that denial may be overridden by module which makes this grant permissive rather than restrictive.

File

./commerce_file.api.php, line 216
Hooks provided by the Commerce File module.

Code

function hook_commerce_file_download_unlicensed_access($file, $account = NULL, $licenses = array()) {

  // Grant access to the file if the user has a special permission and
  // has a pending license.
  if (user_access('mymodules special permission', $account)) {
    foreach ($licenses as $license) {
      if ($license->status == 'pending') {
        return TRUE;
      }
    }
  }
}