You are here

function auditfiles_merge_files_form in Audit Files 7.3

Same name and namespace in other branches
  1. 7.4 auditfiles.module \auditfiles_merge_files_form()

The form definition for allowing the user to choose which file to keep.

File

./auditfiles.module, line 266
Implements various Drupal hooks.

Code

function auditfiles_merge_files_form($settings, &$form_state) {
  $form = array();
  foreach ($form_state['selection'] as $file_id) {
    $file = file_load($file_id);

    // Create the options array for display in the form.
    $files[$file_id] = t('File ID: !fileid; Name: !filename; URI: !fileuri; MIME: !filemime; Size: !filesize; Time uploaded: !timestamp (!formatted)', array(
      '!fileid' => $file_id,
      '!filename' => $file->filename,
      '!fileuri' => $file->uri,
      '!filemime' => $file->filemime,
      '!filesize' => $file->filesize,
      '!timestamp' => $file->timestamp,
      '!formatted' => date('r', $file->timestamp),
    ));
  }

  // Default to sorting by file ID.
  natsort($files);
  $form['file_being_kept'] = array(
    '#type' => 'radios',
    '#title' => t('Which file will be the one the others are merged into'),
    '#default_value' => key($files),
    '#options' => $files,
  );
  return $form;
}