function tripal_get_user_usage

3.x tripal.quotas.api.inc tripal_get_user_usage($uid)

Retrieves the current size of all files uploaded by the user.

Parameters

$uid The: User ID.

Return value

The total number of bytes currently used.

2 calls to tripal_get_user_usage()
tripal_file_upload in tripal/includes/tripal.upload.inc
tripal_user_files_page in tripal/includes/tripal.user.inc
Provides the page with a list of files uploaded by the user.

File

tripal/api/tripal.quotas.api.inc, line 70

Code

function tripal_get_user_usage($uid) {
  // Get the user's current file usage
  $sql = "
    SELECT DISTINCT FU.fid
    FROM {file_usage} FU
      INNER JOIN {file_managed} FM ON FM.fid = FU.fid and FU.module = 'tripal'
    WHERE FM.uid = :uid
  ";
  $fids = db_query($sql, [
  ':uid' $uid
  ]);
  $total_size = 0;
  while ($fid = $fids->fetchObject()) {
    $sql = "SELECT filesize FROM {file_managed} WHERE fid = :fid";
    $total_size += db_query($sql, [
    ':fid' $fid->fid
    ])->fetchObject()->filesize;
  }
  return $total_size;
}