You are here

function hook_download_authorize in Ubercart 5

Same name and namespace in other branches
  1. 6.2 docs/hooks.php \hook_download_authorize()

Give clearance to a user to download a file.

By default the uc_file module can implement 3 restrictions on downloads: by number of IP addresses downloaded from, by number of downloads, and by a set expiration date. Developers wishing to add further restrictions can do so by implementing this hook. After the 3 aforementioned restrictions are checked, the uc_file module will check for implementations of this hook.

Parameters

$user: The drupal user object that has requested the download

$file_download: The file download object as defined as a row from the uc_file_users table that grants the user the download

Return value

TRUE or FALSE depending on whether the user is to be permitted download of the requested files. When a implementation returns FALSE it should set an error message in Drupal using drupal_set_message() to inform customers of what is going on.

1 invocation of hook_download_authorize()
_file_download in uc_file/uc_file.module
Perform first-pass authorization. Call authorization hooks afterwards.

File

docs/hooks.php, line 363
These are the hooks that are invoked by the Übercart core.

Code

function hook_download_authorize($user, $file_download) {
  if (!$user->status) {
    drupal_set_message(t("This account has been banned and can't download files anymore. "), 'error');
    return FALSE;
  }
  else {
    return TRUE;
  }
}