You are here

function file_entity_type_delete_confirm in File Entity (fieldable files) 7.3

Same name and namespace in other branches
  1. 7.2 file_entity.admin.inc \file_entity_type_delete_confirm()

Menu callback; delete a single file type.

1 string reference to 'file_entity_type_delete_confirm'
file_entity_menu in ./file_entity.module
Implements hook_menu().

File

./file_entity.admin.inc, line 1047

Code

function file_entity_type_delete_confirm($form, &$form_state, $type) {
  $form['type'] = array(
    '#type' => 'value',
    '#value' => $type->type,
  );
  $form['label'] = array(
    '#type' => 'value',
    '#value' => $type->label,
  );
  $message = t('Are you sure you want to delete the file type %type?', array(
    '%type' => $type->label,
  ));
  $caption = '';
  $num_files = db_query("SELECT COUNT(*) FROM {file_managed} WHERE type = :type", array(
    ':type' => $type->type,
  ))
    ->fetchField();
  if ($num_files) {
    $caption .= '<p>' . format_plural($num_files, '%type is used by 1 file on your site. If you remove this file type, you will not be able to edit the %type file and it may not display correctly.', '%type is used by @count pieces of file on your site. If you remove %type, you will not be able to edit the %type file and it may not display correctly.', array(
      '%type' => $type->label,
    )) . '</p>';
  }
  $caption .= '<p>' . t('This action cannot be undone.') . '</p>';
  return confirm_form($form, $message, 'admin/structure/file-types', $caption, t('Delete'));
}