function _auditfiles_merge_file_references_pre_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_pre_confirm_operation()
- auditfiles_merge_file_references_form in ./
auditfiles.mergefilereferences.inc - Generates the report.
File
- ./
auditfiles.mergefilereferences.inc, line 480 - Generates a report showing & allowing for merging potential duplicate files.
Code
function _auditfiles_merge_file_references_pre_confirm_operation(array $form, array &$form_state) {
// Prepare the list of items to present to the user.
if (!empty($form_state['values']['files'])) {
$header = array(
'filename' => 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'] as $file_name) {
if (!empty($file_name)) {
$query = 'SELECT fid
FROM {file_managed}
WHERE filename = :file_name
ORDER BY uri ASC';
$results = db_query($query, array(
':file_name' => $file_name,
))
->fetchAll();
if (!empty($results)) {
foreach ($results as $result) {
$file = file_load($result->fid);
if (!empty($file)) {
$files[$result->fid] = array(
'filename' => $file_name,
'fileid' => $result->fid,
'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' => $result->fid,
)));
}
}
}
}
else {
// Unsetting the unprocessed files prevents confirm_submit from dealing
// with them.
unset($form_state['values']['files'][$file_name]);
}
}
}
$form['files_being_merged'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $files,
'#empty' => t('No items found.'),
);
if (!empty($files)) {
$form['actions'] = array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
'#value' => t('Next step'),
),
);
}
return $form;
}