You are here

function file_entity_type_disable_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_disable_confirm()

Menu callback; disable a single file type.

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

File

./file_entity.admin.inc, line 990

Code

function file_entity_type_disable_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 disable 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 disable this file type, you will not be able to edit
      the %type file and it may not display correctly.', '%type is used by
      @count files 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>';
  }
  return confirm_form($form, $message, 'admin/structure/file-types', $caption, t('Disable'));
}