function auditfiles_notindb_form in Audit Files 6.3
Same name and namespace in other branches
- 5 auditfiles.module \auditfiles_notindb_form()
- 6.2 notindb.admin.inc \auditfiles_notindb_form()
Form definition for audit files not in database
1 call to auditfiles_notindb_form()
- auditfiles_notindb in ./
notindb.admin.inc - Menu callback: audit files not in the database.
File
- ./
notindb.admin.inc, line 30 - Callback and functions to generate files not in database report
Code
function auditfiles_notindb_form() {
// Get the list of files that aren't in the database
$filesnotindb = _auditfiles_filesnotindb();
// Output count of files not in the database
if ($filesnotindb) {
$form['count'] = array(
'#value' => format_plural(count($filesnotindb), '1 file found.', '@count files found.'),
);
}
else {
$form['count'] = array(
'#value' => t('No files found.'),
);
}
// Action button
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Action'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$options = array(
'donothing' => t('Do nothing'),
'delete' => t('Delete checked files'),
);
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'donothing',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
// Process each result in turn and build check box list
$files_dir = file_directory_path();
$files = array();
foreach ($filesnotindb as $file) {
$files[$file] = '';
// Can't use file_create_url as the links fail if the site uses private transfers
// Force a public url instead
$form['file'][$file] = array(
'#value' => l($file, $GLOBALS['base_url'] . '/' . file_directory_path() . '/' . str_replace('\\', '/', $file)),
);
}
// Add list of files to checkboxes
$form['files'] = array(
'#type' => 'checkboxes',
'#options' => $files,
);
// Specify theme for form
$form['#theme'] = 'auditfiles_notindb_form';
// Return form
return $form;
}