function auditfiles_used_not_managed_form_submit in Audit Files 7.4
Same name and namespace in other branches
- 7.3 auditfiles.usednotmanaged.inc \auditfiles_used_not_managed_form_submit()
Submit handler for the auditfiles_used_not_managed_form form.
File
- ./
auditfiles.usednotmanaged.inc, line 178 - Generates a report showing files in file_usage, but not in file_managed.
Code
function auditfiles_used_not_managed_form_submit($form, &$form_state) {
// Check if an operation was performed.
if (!empty($form_state['values']['op'])) {
// Check which operation was performed and start the batch process.
if ($form_state['values']['op'] == 'Load all records' || $form_state['values']['op'] == 'Load first batch set') {
// Clear the variable, so subsequent pages will load the correct data.
variable_del('auditfiles_files_to_display');
$batch_size = variable_get('auditfiles_report_options_batch_size', 0);
if ($batch_size > 0) {
// Set appropriate variables for this operation.
variable_set('auditfiles_used_not_managed_record_selection', 'batch_sets');
}
else {
// Set appropriate variables for this operation.
variable_set('auditfiles_used_not_managed_record_selection', 'batched');
}
// Prepare and set the batch.
batch_set(_auditfiles_used_not_managed_batch_display_create_batch());
}
elseif ($form_state['values']['op'] == 'Load previous batch set') {
// Clear the variable, so subsequent pages will load the correct data.
variable_del('auditfiles_files_to_display');
// Set appropriate variables for this operation.
$batch_size = variable_get('auditfiles_report_options_batch_size', 0);
$batch_offset = variable_get('auditfiles_used_not_managed_batch_offset', 0);
variable_set('auditfiles_used_not_managed_batch_offset', $batch_offset - $batch_size);
variable_set('auditfiles_used_not_managed_record_selection', 'batch_sets');
// Prepare and set the batch.
batch_set(_auditfiles_used_not_managed_batch_display_create_batch());
}
elseif ($form_state['values']['op'] == 'Load next batch set') {
// Clear the variable, so subsequent pages will load the correct data.
variable_del('auditfiles_files_to_display');
// Set appropriate variables for this operation.
$batch_size = variable_get('auditfiles_report_options_batch_size', 0);
$batch_offset = variable_get('auditfiles_used_not_managed_batch_offset', 0);
variable_set('auditfiles_used_not_managed_batch_offset', $batch_offset + $batch_size);
variable_set('auditfiles_used_not_managed_record_selection', 'batch_sets');
// Prepare and set the batch.
batch_set(_auditfiles_used_not_managed_batch_display_create_batch());
}
elseif ($form_state['values']['op'] == 'Reset record selection') {
// Clear the variable, so subsequent pages will load the correct data.
variable_del('auditfiles_files_to_display');
// Set appropriate variables for this operation.
unset($form_state['values']['saved_rows']);
variable_set('auditfiles_used_not_managed_record_selection', 'normal');
variable_del('auditfiles_used_not_managed_batch_offset');
}
elseif ($form_state['values']['op'] == 'Delete selected items from the file_usage table' && !empty($form_state['values']['files'])) {
foreach ($form_state['values']['files'] as $file_id) {
if (!empty($file_id)) {
// At least one file was selected, and the operation has not been
// confirmed, so modify the data to display the confirmation form.
$form_state['storage']['files'] = $form_state['values']['files'];
$form_state['storage']['op'] = $form_state['values']['op'];
$form_state['storage']['confirm'] = TRUE;
$form_state['rebuild'] = TRUE;
return TRUE;
}
}
drupal_set_message(t('No items were selected to operate on.'));
}
elseif ($form_state['values']['op'] == 'Yes') {
if ($form_state['values']['operation'] == 'delete') {
// Prepare and set the batch.
batch_set(_auditfiles_used_not_managed_batch_delete_create_batch($form_state['values']['changelist']));
}
}
}
if (!empty($form_state['values']['saved_rows'])) {
$form_state['storage']['saved_rows'] = $form_state['values']['saved_rows'];
}
}