From e2acedde1f6fc76ec79dad2a96e263a7b856486d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 8 Nov 2006 04:35:47 +0000 Subject: [PATCH] r1274: We can now remove attachments from the database permanently --- attachment.php | 51 ++++++++++++++++++++++++++-------------- docs/changes.txt | 1 + templates/editattach.tpl | 1 + 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/attachment.php b/attachment.php index 017141b..f4d05ee 100755 --- a/attachment.php +++ b/attachment.php @@ -198,27 +198,42 @@ if ($_POST['do'] == 'update') $message->error_permission(); } - $log = new Logging; - $log->set_bugid($bug['bugid']); - $log->set_attachmentid($bugsys->in['attachmentid']); - $attachapi = new AttachmentAPI($bugsys); $attachapi->set('attachmentid', $bugsys->in['attachmentid']); - $attachapi->set_condition(); $attachapi->dorelations = array(); - $attachapi->fetch(); - - $log->add_data(true, $attachapi->objdata, array('attachment'), true, 'attachment'); - - $attachapi->set('description', $bugsys->in['description']); - $attachapi->set('obsolete', $bugsys->in['obsolete']); - $attachapi->update(); - - $log->add_data(false, $attachapi->values, array('attachment'), true, 'attachment'); - - $log->update_history(); + $attachapi->set_condition(); - $message->redirect(_('The attachment was successfully modified.'), "showreport.php?bugid=$bug[bugid]"); + if ($bugsys->in['__delete__'] != '') + { + if (!(can_perform('caneditattach', $bug['product']) AND can_perform('candeletedata', $bug['productid']))) + { + $message->error_permission(); + } + + $attachapi->delete(); + + $message->redirect(_('The attachment was successfully deleted.'), "showreport.php?bugid=$bug[bugid]"); + } + else + { + $log = new Logging; + $log->set_bugid($bug['bugid']); + $log->set_attachmentid($bugsys->in['attachmentid']); + + $attachapi->fetch(); + + $log->add_data(true, $attachapi->objdata, array('attachment'), true, 'attachment'); + + $attachapi->set('description', $bugsys->in['description']); + $attachapi->set('obsolete', $bugsys->in['obsolete']); + $attachapi->update(); + + $log->add_data(false, $attachapi->values, array('attachment'), true, 'attachment'); + + $log->update_history(); + + $message->redirect(_('The attachment was successfully modified.'), "showreport.php?bugid=$bug[bugid]"); + } } // ################################################################### @@ -230,7 +245,7 @@ if ($_REQUEST['do'] == 'edit') $message->error_permission(); } - $show['delete'] = ((can_perform('caneditattach', $bug['product'])) ? true : false); + $show['delete'] = (can_perform('caneditattach', $bug['product']) AND can_perform('candeletedata', $bug['productid'])); eval('$template->flush("' . $template->fetch('editattach') . '");'); } diff --git a/docs/changes.txt b/docs/changes.txt index 5991581..2cb72cd 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -7,6 +7,7 @@ - When $bugsys->options['pagelinks'] is set to 0, it now actually does its advertised behavior (http://www.bluestatic.org/bugs/showreport.php?bugid=45) - Foreign langauge users cannot use the product/component editing system beacause localized strings are used to create the do actions instead of english variable ones (http://www.bluestatic.org/bugs/showreport.php?bugid=42) - Fixed a SQL error that would occur when editing a report with no emails linked to it (http://www.bluestatic.org/bugs/showreport.php?bugid=46) +- Added the ability to delete attachments from the database (http://www.bluestatic.org/bugs/showreport.php?bugid=47) 1.1.3 =============================== diff --git a/templates/editattach.tpl b/templates/editattach.tpl index b3689b0..67a9aa7 100644 --- a/templates/editattach.tpl +++ b/templates/editattach.tpl @@ -34,6 +34,7 @@ $header
+
-- 2.43.5