function content_files_user_may_download_file

6.x content.module content_files_user_may_download_file($fid)

Returns TRUE or FALSE if the user has access to download this particular student's file.

File

modules/content/content.module, line 241

Code

function content_files_user_may_download_file($fid) {
  global $user;

  $file = content_get_uploaded_file($fid);

  if ($user->id == 1) {
    return TRUE; // this is the admin user.
  }

  // Get cid of original piece of content this file belonged to.
  $cid = intval($file ['cid']);

  if ($cid === 0) {
    return TRUE; // no CID attached, so we can assume they can view it.
  }

  // Otherwise, see if the user is allowed to "view" this piece of content.  If so, that means they
  // can view any files attached as well.
  return content_user_access('view', $cid);

}