Index: banner.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/banner/banner.module,v retrieving revision 1.66 diff -u -r1.66 banner.module --- banner.module 15 Aug 2006 20:53:38 -0000 1.66 +++ banner.module 5 Sep 2006 23:20:15 -0000 @@ -260,6 +260,27 @@ // hide 'published' checkbox, status is set in hook_validate $form['options']['status']['#type'] = 'hidden'; } + + // Catch the banner form on submission & delete old uploads. + if ($form_id == 'banner_node_form' && $_POST['op'] == t('Submit')) { + // Reverse keys since they will be ordered $fid, then upload_x + $tmp = array_reverse(element_children($form['attachments']['wrapper']['files'])); + + // Don't delete the first file since it will be the most recent upload. + $delete = FALSE; + foreach($tmp as $key) { + // Check the delete flag. + if ($delete) { + // Mark older uploads for deletion. + $form['attachments']['wrapper']['files'][$key]['remove']['#value'] = 1; + } + // If the first file is a new upload && it isn't marked for deletion. + if ((strpos($key, 'upload') === 0) && !$form['attachments']['wrapper']['files'][$key]['remove']['#value']) { + // Set the delete flag to TRUE so remaining attachments will be removed by upload.module. + $delete = TRUE; + } + } + } } /**