function tripal_delete_file_form_submit
3.x tripal.user.inc | tripal_delete_file_form_submit($form, &$form_state) |
Implements a form submit for deleting a galaxy workflow uploaded file.
File
- tripal/
includes/ tripal.user.inc, line 176
Code
function tripal_delete_file_form_submit($form, &$form_state) {
$fid = $form_state['values']['fid'];
$uid = $form_state['values']['uid'];
$file = file_load($fid);
// Remove the file from the file_usage table for all entries that link
// to the tripal module.
file_usage_delete($file, 'tripal', NULL, NULL, 0);
// Get any remaining usage for other modules
$file_usage = file_usage_list($file);
// If this file is still used by the tripal module then something
// didn't work right.
if (in_array('tripal', $file_usage)) {
drupal_set_message('The file could not be removed. Please contact the site administrator.', 'error');
}
// If there is no other usage of this file from other modules then delete it.
if (count(array_keys($file_usage)) == 0) {
if (file_unmanaged_delete($file->uri)) {
// Also remove the md5 checksum.
if (file_exists(file_unmanaged_delete($file->uri . '.md5'))) {
file_unmanaged_delete($file->uri . '.md5');
}
drupal_set_message('The file has been fully removed.');
}
else {
drupal_set_message('The file has removed from this list and does not count against your quota, but other components of this site rely on this file. Thus it has not been fully removed.');
}
}
drupal_goto('user/' . $file->uid . '/files/');
}