function _auditfiles_not_in_database_confirm_operation in Audit Files 7.3
Same name and namespace in other branches
- 7.4 auditfiles.notindatabase.inc \_auditfiles_not_in_database_confirm_operation()
Presents a confimation 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_not_in_database_confirm_operation()
- auditfiles_not_in_database_form in ./
auditfiles.notindatabase.inc - Generates the report.
File
- ./
auditfiles.notindatabase.inc, line 447 - Generates a report showing files on the server, but not in the database.
Code
function _auditfiles_not_in_database_confirm_operation(array $form, array &$form_state) {
$values = $form_state['values'];
$form['changelist'] = array(
'#prefix' => '<ul>',
'#suffix' => '</ul>',
'#tree' => TRUE,
);
// Prepare the list of items to present to the user.
if (!empty($values['files'])) {
foreach ($values['files'] as $filename) {
if (!empty($filename)) {
if ($values['op'] == t('Add selected items to the database')) {
$message = t('will be added to the database.');
}
elseif ($values['op'] == t('Delete selected items from the server')) {
$message = t('will be deleted from the server.');
}
$form['changelist'][$filename] = array(
'#type' => 'hidden',
'#value' => $filename,
'#prefix' => '<li><strong>' . $filename . '</strong> ' . $message,
'#suffix' => "</li>\n",
);
}
else {
// Unsetting the unprocessed files prevents confirm_submit from dealing
// with them.
unset($form_state['values']['files'][$filename]);
}
}
}
$form['operation'] = array(
'#type' => 'hidden',
);
if ($values['op'] == t('Add selected items to the database')) {
$form['operation']['#value'] = 'add';
$confirm_question = t('Add these files to the database?');
$confirm_description = '';
}
elseif ($values['op'] == t('Delete selected items from the server')) {
$form['operation']['#value'] = 'delete';
$confirm_question = t('Delete these files from the server?');
$confirm_description = '<strong>' . t('This action cannot be undone.') . '</strong>';
}
// 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/notindatabase',
);
return confirm_form($form, $confirm_question, 'admin/reports/auditfiles/notindatabase', $confirm_description, t('Yes'), t('No'));
}