You are here

function file_entity_delete_form_submit in File Entity (fieldable files) 7.3

Same name and namespace in other branches
  1. 7.2 file_entity.pages.inc \file_entity_delete_form_submit()

Form submission handler for file_entity_delete_form().

File

./file_entity.pages.inc, line 1133
Supports file operations including View, Edit, and Delete.

Code

function file_entity_delete_form_submit($form, &$form_state) {
  if ($form_state['values']['confirm'] && ($file = file_load($form_state['values']['fid']))) {

    // Use file_delete_multiple() rather than file_delete() since we want to
    // avoid unwanted validation and usage checking.
    file_delete_multiple(array(
      $file->fid,
    ));
    $args = array(
      '@type' => file_entity_type_get_name($file),
      '%title' => entity_label('file', $file),
    );
    watchdog('file', '@type: deleted %title.', $args);
    drupal_set_message(t('@type %title has been deleted.', $args));
  }
  $form_state['redirect'] = '<front>';

  // Clear the page and block caches.
  cache_clear_all();
}