hook_download_authorize

Function hook_download_authorize() in uc_file.module:

<?php
  hook_download_authorize
($user, $file_download)
?>


Description:

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(t($message_text),'error')) to inform customers of what is going on.


Example:

<?php
function module_name_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;
  }
}
?>