function _auditfiles_used_not_referenced_batch_display_get_operations in Audit Files 7.3
Same name and namespace in other branches
- 7.4 auditfiles.usednotreferenced.inc \_auditfiles_used_not_referenced_batch_display_get_operations()
Configures the operations for the batch process.
Return value
array The operations to execute.
1 call to _auditfiles_used_not_referenced_batch_display_get_operations()
- _auditfiles_used_not_referenced_batch_display_create_batch in ./
auditfiles.usednotreferenced.inc - Prepares the definition for the page display batch.
File
- ./
auditfiles.usednotreferenced.inc, line 241 - Generates report showing files in file_usage, but not referenced by content.
Code
function _auditfiles_used_not_referenced_batch_display_get_operations() {
// Get and save the field data, so this is only done once for the entire batch
// process.
$file_fields = '';
// Get a list of all fields on the site.
$fields = field_info_fields();
foreach ($fields as $field_name => $field) {
// @todo
// Consider adding a setting to allow the administrator the ability for
// spcifying the field types.
if (!empty($field['type']) && ($field['type'] == 'file' || $field['type'] == 'image')) {
// Get the database table name for the field.
$table = key($field['storage']['details']['sql'][FIELD_LOAD_CURRENT]);
$field['table'] = $table;
// Get the column name in the database table for the field.
$column = $field['storage']['details']['sql'][FIELD_LOAD_CURRENT][$table]['fid'];
$field['column'] = $column;
$query = "SELECT t.{$column} FROM {{$table}} AS t INNER JOIN {file_usage} AS f ON f.fid = t.{$column}";
$results = db_query($query)
->fetchAll();
$field['results'] = $results;
// Save the data for use in the operation.
$file_fields[$field_name] = $field;
}
}
$operations = array();
$operations[] = array(
'_auditfiles_used_not_referenced_batch_display_get_files',
array(
$file_fields,
),
);
$operations[] = array(
'_auditfiles_used_not_referenced_batch_display_process_files',
array(),
);
return $operations;
}