You are here

function uc_file_remove_user_file_by_id in Ubercart 7.3

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

Removes a user's downloadable file by hash key.

Parameters

$uid: A Drupal user ID.

$key: The unique hash associated with the file.

1 call to uc_file_remove_user_file_by_id()
uc_file_user_form_submit in uc_file/uc_file.module
Submit handler for per-user file download administration.

File

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

Code

function uc_file_remove_user_file_by_id($user, $fid) {
  $file = uc_file_get_by_id($fid);
  $query = db_delete('uc_file_users')
    ->condition('uid', $user->uid)
    ->condition('fid', $fid);

  // Echo the deletion only if something was actually deleted.
  if ($query
    ->execute()) {
    drupal_set_message(t('!user has had %file removed from his/her downloadable file list.', array(
      '!user' => theme('username', array(
        'account' => $user,
        'name' => check_plain($user->name),
        'link_path' => 'user/' . $user->uid,
      )),
      '%file' => $file->filename,
    )));
  }
}