You are here

function _auditfiles_used_not_managed_confirm_operation in Audit Files 7.4

Same name and namespace in other branches
  1. 7.3 auditfiles.usednotmanaged.inc \_auditfiles_used_not_managed_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_used_not_managed_confirm_operation()
auditfiles_used_not_managed_form in ./auditfiles.usednotmanaged.inc
Generates the report.

File

./auditfiles.usednotmanaged.inc, line 369
Generates a report showing files in file_usage, but not in file_managed.

Code

function _auditfiles_used_not_managed_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 $file_id) {
      if (!empty($file_id)) {
        $file = file_load($file_id);
        if (!empty($file)) {
          $form['changelist'][$file_id] = array(
            '#type' => 'hidden',
            '#value' => $file_id,
            '#prefix' => '<li><strong>' . $file->filename . '</strong> ' . t('will be deleted from the file_usage table.'),
            '#suffix' => "</li>\n",
          );
        }
      }
      else {

        // Unsetting the unprocessed files prevents confirm_submit from dealing
        // with them.
        unset($form_state['values']['files'][$file_id]);
      }
    }
  }
  $form['operation'] = array(
    '#type' => 'hidden',
    '#value' => 'delete',
  );

  // 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/usednotmanaged',
  );
  return confirm_form($form, t('Delete these items from the file_usage table?'), 'admin/reports/auditfiles/usednotmanaged', '<strong>' . t('This action cannot be undone.') . '</strong>', t('Yes'), t('No'));
}