From 2d06475b0af4800e772ac5011b7bd65a11bf2026 Mon Sep 17 00:00:00 2001 From: Fabio Varesano Date: Thu, 22 Jun 2006 20:18:33 +0000 Subject: Added nodeapi called fuction to delete the uploaded file when video node is deleted. --- plugins/video_upload/video_upload.module | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'plugins/video_upload') diff --git a/plugins/video_upload/video_upload.module b/plugins/video_upload/video_upload.module index b06389b..e85e334 100644 --- a/plugins/video_upload/video_upload.module +++ b/plugins/video_upload/video_upload.module @@ -94,7 +94,7 @@ function video_upload_nodeapi(&$node, $op, $teaser) { break; case 'delete': - ; + _video_upload_delete($node); break; case 'delete revision': @@ -209,13 +209,26 @@ function _video_upload_store(&$node) { unset($_SESSION['video_upload_file']); } else { - print 'error'; + drupal_set_message(t('An error occurred during file saving. Your video file has not been stored.'), 'error'); } - } } +/** + * Delete files associated to this video node + */ +function _video_upload_delete(&$node) { + + // delete file + file_delete($node->video_upload_file->path); + + // delete file information from database + db_query('DELETE FROM {file_revisions} WHERE fid = %d', $node->video_upload_file->fid); + db_query('DELETE FROM {files} WHERE fid = %d', $node->video_upload_file->fid); +} + + /** * Create video upload specific form fields */ -- cgit v1.2.3