r1274: We can now remove attachments from the database permanently
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 8 Nov 2006 04:35:47 +0000 (04:35 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 8 Nov 2006 04:35:47 +0000 (04:35 +0000)
attachment.php
docs/changes.txt
templates/editattach.tpl

index 017141b075d93d7ebabb51a8788073d8d26b82c7..f4d05ee527e51ad21eded6113f812e6823fcad8d 100755 (executable)
@@ -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') . '");');
 }
index 5991581dcda6b886b6593821ae300f4b8f408efb..2cb72cd21ee421c7abf3e547c31ac4f5032d313f 100644 (file)
@@ -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
 ===============================
index b3689b045226f26fddefb3199cd2a5aa76349bee..67a9aa74fe48ac99d354fe006522e3d270ef517b 100644 (file)
@@ -34,6 +34,7 @@ $header
 
 <div id="submitrow">
        <input name="submit" type="submit" value="  {@"Submit"}  " accesskey="s" />
+       <if condition="$show['delete']"><input name="__delete__" type="submit" value="  {@"Delete"}  " /></if>
        <input name="reset" type="reset" value="  {@"Reset"}  " accesskey="r" />
        <script type="text/javascript"> draw_cancel("showreport.php?bugid=$bug[bugid]"); </script>
 </div>