You are here

function file_entity_multiple_delete_confirm in File Entity (fieldable files) 7.3

Same name and namespace in other branches
  1. 7 file_entity.pages.inc \file_entity_multiple_delete_confirm()
  2. 7.2 file_entity.admin.inc \file_entity_multiple_delete_confirm()

File entity delete confirmation.

1 call to file_entity_multiple_delete_confirm()
file_entity_admin_file in ./file_entity.admin.inc
Menu callback: file administration.

File

./file_entity.admin.inc, line 527

Code

function file_entity_multiple_delete_confirm($form, &$form_state, $files) {
  $form['files'] = array(
    '#prefix' => '<ul>',
    '#suffix' => '</ul>',
    '#tree' => TRUE,
  );

  // array_filter returns only elements with TRUE values.
  foreach ($files as $fid => $value) {
    $filename = db_query('SELECT filename FROM {file_managed} WHERE fid = :fid', array(
      ':fid' => $fid,
    ))
      ->fetchField();
    $form['files'][$fid] = array(
      '#type' => 'hidden',
      '#value' => $fid,
      '#prefix' => '<li>',
      '#suffix' => check_plain($filename) . "</li>\n",
    );
  }
  $form['operation'] = array(
    '#type' => 'hidden',
    '#value' => 'delete',
  );
  $form['#submit'][] = 'file_entity_multiple_delete_confirm_submit';
  $confirm_question = format_plural(count($files), 'Are you sure you want to delete this item?', 'Are you sure you want to delete these items?');
  return confirm_form($form, $confirm_question, 'admin/content/file', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}