You are here

function _auditfiles_referenced_not_used_batch_delete_process_file in Audit Files 7.3

Same name and namespace in other branches
  1. 7.4 auditfiles.referencednotused.inc \_auditfiles_referenced_not_used_batch_delete_process_file()

Deletes the specified file from the database.

Parameters

string $reference_id: The ID for keeping track of the reference.

1 call to _auditfiles_referenced_not_used_batch_delete_process_file()
_auditfiles_referenced_not_used_batch_delete_process_batch in ./auditfiles.referencednotused.inc
The batch process for deleting the file.

File

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

Code

function _auditfiles_referenced_not_used_batch_delete_process_file($reference_id) {
  $reference_id_parts = explode('.', $reference_id);
  $num_rows = db_delete($reference_id_parts[0])
    ->condition($reference_id_parts[1], $reference_id_parts[4])
    ->execute();
  if (empty($num_rows)) {
    drupal_set_message(t('There was a problem deleting the reference to file ID %fid in the %entity_type with ID %eid. Check the logs for more information.', array(
      '%fid' => $reference_id_parts[4],
      '%entity_type' => $reference_id_parts[3],
      '%eid' => $reference_id_parts[2],
    )), 'warning');
  }
  else {

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