You are here

function fillpdf_file_usage_delete in FillPDF 7

Wrapper function for file_usage_delete().

Call file_usage_delete() directly if you want to delete a specific amount of references. You will have to clean up {fillpdf_file_context} yourself.

Parameters

object $file: The file object.

See also

file_usage_delete()

File

./fillpdf.module, line 2206

Code

function fillpdf_file_usage_delete(stdClass $file) {

  // Remove all {file_usage} references for the file.
  file_usage_delete($file, 'fillpdf', 'fillpdf_file', NULL, 0);
  $subquery = db_select('file_usage', 'fu');

  // $fcid is the same as the $id argument to file_usage_delete().
  $subquery
    ->addField('fu', 'id', 'fcid');
  $subquery = $subquery
    ->condition('type', 'fillpdf_file')
    ->condition('module', 'fillpdf');

  // Remove {fillpdf_file_context} record if it's no longer referred to.
  db_delete('fillpdf_file_context')
    ->condition('fcid', $subquery, 'NOT IN')
    ->execute();
}