You are here

function uc_file_get_by_uid in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 uc_file/uc_file.module \uc_file_get_by_uid()

Retrieves a file by user ID.

Parameters

$uid: A user ID.

$fid: A file ID.

Return value

A uc_file object.

1 call to uc_file_get_by_uid()
_uc_file_download in uc_file/uc_file.pages.inc
Handles file downloading and error states.

File

uc_file/uc_file.module, line 1562
Allows products to be associated with downloadable files.

Code

function &uc_file_get_by_uid($uid, $fid) {
  $cache = _uc_file_get_cache();
  if (!isset($cache[$uid][$fid])) {
    $cache[$uid][$fid] = db_query("SELECT * FROM {uc_file_users} ufu " . "LEFT JOIN {uc_files} uf ON uf.fid = ufu.fid " . "WHERE ufu.fid = :fid AND ufu.uid = :uid", array(
      ':uid' => $uid,
      ':fid' => $fid,
    ))
      ->fetchObject();
    if ($cache[$uid][$fid]) {
      $cache[$uid][$fid]->addresses = unserialize($cache[$uid][$fid]->addresses);
    }
  }
  return $cache[$uid][$fid];
}