function _auditfiles_merge_file_references_confirm_operation in Audit Files 7.3
Presents a confirmation form to verify the user wants to complete the action.
Parameters
array $form: The form definition.
array $form_state: The current state of the form.
Return value
array A form array for a confirmation form.
1 call to _auditfiles_merge_file_references_confirm_operation()
- auditfiles_merge_file_references_form in ./
auditfiles.mergefilereferences.inc - Generates the report.
File
- ./
auditfiles.mergefilereferences.inc, line 568 - Generates a report showing & allowing for merging potential duplicate files.
Code
function _auditfiles_merge_file_references_confirm_operation(array $form, array &$form_state) {
// Prepare the list of items to present to the user.
if (!empty($form_state['values']['files_being_merged'])) {
$header = array(
'origname' => array(
'data' => t('Filename'),
),
'fileid' => array(
'data' => t('File ID'),
),
'fileuri' => array(
'data' => t('URI'),
),
'filesize' => array(
'data' => t('Size'),
),
'timestamp' => array(
'data' => t('Time uploaded'),
),
);
$date_format = variable_get('auditfiles_report_options_date_format', 'long');
$files = array();
foreach ($form_state['values']['files_being_merged'] as $file_id) {
if (!empty($file_id)) {
$file = file_load($file_id);
if (!empty($file)) {
$files[$file_id] = array(
'origname' => $file->filename,
'fileid' => $file_id,
'fileuri' => $file->uri,
'filesize' => number_format($file->filesize),
'timestamp' => format_date($file->timestamp, $date_format),
);
}
else {
drupal_set_message(t('A file object was not found for file ID @fid.', array(
'@fid' => $file_id,
)));
}
}
else {
// Remove files that were not selected.
unset($form_state['values']['files_being_merged'][$file_id]);
}
}
// Save the selected items for later use.
$form_state['storage']['files_being_merged'] = $files;
}
$form['operation'] = array(
'#type' => 'hidden',
'#value' => 'merge',
);
// Tell the submit handler to process the confirmation.
$form['process'] = array(
'#type' => 'hidden',
'#value' => 'TRUE',
);
// Go back to the main form, when done with this one.
$form['destination'] = array(
'#type' => 'hidden',
'#value' => 'admin/reports/auditfiles/mergefilereferences',
);
$form['file_being_kept'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $files,
'#default_value' => key($files),
'#empty' => t('No items found.'),
'#multiple' => FALSE,
);
return confirm_form($form, t('Which file will be the one the others are merged into?'), 'admin/reports/auditfiles/mergefilereferences', '<div><strong>' . t('This action cannot be undone.') . '</strong></div>', t('Confirm'), t('Cancel'));
}