You are here

function _auditfiles_used_not_referenced_batch_delete_process_file in Audit Files 7.3

Same name and namespace in other branches
  1. 7.4 auditfiles.usednotreferenced.inc \_auditfiles_used_not_referenced_batch_delete_process_file()

Deletes the specified file from the file_usage table.

Parameters

int $file_id: The ID of the file to delete from the database.

1 call to _auditfiles_used_not_referenced_batch_delete_process_file()
_auditfiles_used_not_referenced_batch_delete_process_batch in ./auditfiles.usednotreferenced.inc
The batch process for deleting the file.

File

./auditfiles.usednotreferenced.inc, line 529
Generates report showing files in file_usage, but not referenced by content.

Code

function _auditfiles_used_not_referenced_batch_delete_process_file($file_id) {
  $num_rows = db_delete('file_usage')
    ->condition('fid', $file_id)
    ->execute();
  if (empty($num_rows)) {
    drupal_set_message(t('There was a problem deleting the record with file ID %fid from the file_usage table. Check the logs for more information.', array(
      '%fid' => $file_id,
    )), 'warning');
  }
  else {

    // Remove the deleted files from the list of files to display.
    $rows = variable_get('auditfiles_used_not_referenced_files_to_display', array());
    unset($rows[$file_id]);
    variable_set('auditfiles_used_not_referenced_files_to_display', $rows);
  }
}