You are here

function _auditfiles_merge_file_references_batch_merge_create_batch in Audit Files 7.3

Creates the batch for merging files.

Parameters

int $file_being_kept: The file ID of the file to merge the others into.

array $files_being_merged: The list of file IDs to be processed.

Return value

array The definition of the batch.

1 call to _auditfiles_merge_file_references_batch_merge_create_batch()
auditfiles_merge_file_references_form_submit in ./auditfiles.mergefilereferences.inc
Submit handler for the auditfiles_merge_file_references_form form.

File

./auditfiles.mergefilereferences.inc, line 664
Generates a report showing & allowing for merging potential duplicate files.

Code

function _auditfiles_merge_file_references_batch_merge_create_batch($file_being_kept, array $files_being_merged) {
  $batch = _auditfiles_merge_file_references_batch_set_common_values();
  $batch['title'] = t('Merging files');
  $operations = array();

  // Remove all the empty values from the array.
  $file_ids = array();
  foreach ($files_being_merged as $file_id => $file_info) {
    if ($file_id != 0) {
      $file_ids[] = $file_id;
    }
  }

  // Fill in the $operations variable.
  foreach ($file_ids as $file_id) {
    if ($file_id != $file_being_kept) {
      $operations[] = array(
        '_auditfiles_merge_file_references_batch_merge_process_batch',
        array(
          $file_being_kept,
          $file_id,
        ),
      );
    }
  }
  $batch['operations'] = $operations;
  return $batch;
}