function filefield_field_delete_file in FileField 6.3
Check that FileField controls a file before attempting to deleting it.
3 calls to filefield_field_delete_file()
- filefield_field_delete in ./
filefield_field.inc - Implementation of CCK's hook_field($op = 'delete').
- filefield_field_delete_revision in ./
filefield_field.inc - Implementation of CCK's hook_field($op = 'delete_revision').
- filefield_field_update in ./
filefield_field.inc - Implementation of CCK's hook_field($op = 'update').
File
- ./
filefield_field.inc, line 251 - FileField CCK field hooks and callbacks.
Code
function filefield_field_delete_file($file, $field) {
$file = (object) $file;
// Remove the field_name and delete_nid properties so that references can be
// counted including the files to be deleted.
$field_name = isset($file->field_name) ? $file->field_name : NULL;
$delete_nid = isset($file->delete_nid) ? $file->delete_nid : NULL;
unset($file->field_name, $file->delete_nid);
// To prevent FileField from deleting files it doesn't know about, check the
// FileField reference count. Temporary files can be deleted because they
// are not yet associated with any content at all.
if ($file->status == 0 || filefield_get_file_reference_count($file, $field) > 0) {
$file->field_name = $field_name;
$file->delete_nid = $delete_nid;
return field_file_delete($file);
}
// Even if the file is not deleted, return TRUE to indicate the FileField
// record can be removed from the FileField database tables.
return TRUE;
}