function auditfiles_referenced_not_used_form_submit in Audit Files 7.4
Same name and namespace in other branches
- 7.3 auditfiles.referencednotused.inc \auditfiles_referenced_not_used_form_submit()
Submit handler for the auditfiles_referenced_not_used_form form.
File
- ./
auditfiles.referencednotused.inc, line 181 - Generates report showing files referenced by content, but not in file_usage.
Code
function auditfiles_referenced_not_used_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_referenced_not_used_record_selection', 'batch_sets');
}
else {
// Set appropriate variables for this operation.
variable_set('auditfiles_referenced_not_used_record_selection', 'batched');
}
// Prepare and set the batch.
batch_set(_auditfiles_referenced_not_used_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_referenced_not_used_batch_offset', 0);
variable_set('auditfiles_referenced_not_used_batch_offset', $batch_offset - $batch_size);
variable_set('auditfiles_referenced_not_used_record_selection', 'batch_sets');
// Prepare and set the batch.
batch_set(_auditfiles_referenced_not_used_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_referenced_not_used_batch_offset', 0);
variable_set('auditfiles_referenced_not_used_batch_offset', $batch_offset + $batch_size);
variable_set('auditfiles_referenced_not_used_record_selection', 'batch_sets');
// Prepare and set the batch.
batch_set(_auditfiles_referenced_not_used_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_referenced_not_used_record_selection', 'normal');
variable_del('auditfiles_referenced_not_used_batch_offset');
}
elseif (($form_state['values']['op'] == 'Add selected items to the file_usage table' || $form_state['values']['op'] == 'Delete selected references') && !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'] == 'add') {
// Prepare and set the batch.
batch_set(_auditfiles_referenced_not_used_batch_add_create_batch($form_state['values']['changelist']));
}
elseif ($form_state['values']['operation'] == 'delete') {
// Prepare and set the batch.
batch_set(_auditfiles_referenced_not_used_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'];
}
}