function _auditfiles_used_not_referenced_get_file_data in Audit Files 7.4
Same name and namespace in other branches
- 7.3 auditfiles.usednotreferenced.inc \_auditfiles_used_not_referenced_get_file_data()
Retrieves information about an individual file from the database.
Parameters
int $file_id: The ID of the file to prepare for display.
Return value
array The row for the table on the report, with the file's information formatted for display.
2 calls to _auditfiles_used_not_referenced_get_file_data()
- auditfiles_used_not_referenced_form in ./
auditfiles.usednotreferenced.inc - Generates the report.
- _auditfiles_used_not_referenced_batch_display_process_operation in ./
auditfiles.usednotreferenced.inc - The batch process for displaying the files.
File
- ./
auditfiles.usednotreferenced.inc, line 586 - Generates report showing files in file_usage, but not referenced by content.
Code
function _auditfiles_used_not_referenced_get_file_data($file_id) {
// Get the file's information from the file_managed table.
$file_managed = db_query("SELECT * FROM {file_managed} fm WHERE fid = {$file_id}")
->fetchObject();
if (empty($file_managed)) {
// The file is not listed in the file_managed table. Display an error
// message, instead of the file information.
$row = array(
'fid' => t('This file is not listed in the file_managed table. See the ":usednotmanaged" report.', array(
':usednotmanaged' => l(t('Used not managed'), 'admin/reports/auditfiles/usednotmanaged'),
)),
'uri' => '',
'usage' => '',
);
}
else {
$usage = '<ul>';
$results = db_query("SELECT * FROM {file_usage} WHERE fid = {$file_id}");
foreach ($results as $file_usage) {
// Create the usages list.
$used_by = $file_usage->module . ' ' . t('module');
$used_in = l($file_usage->type . '/' . $file_usage->id, $file_usage->type . '/' . $file_usage->id);
$times_used = $file_usage->count;
$usage .= '<li>' . t('Used by: %used_by; Used in: %used_in; Times used: %times_used', array(
'%used_by' => $used_by,
'%used_in' => $used_in,
'%times_used' => $times_used,
)) . '</li>';
}
$usage .= '</ul>';
// Create the data for displaying in the table.
$row = array(
'fid' => $file_id,
'uri' => $file_managed->uri,
'usage' => $usage,
);
}
return $row;
}