r931: - You can now delete bugs and comments
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 22 Jul 2006 04:29:33 +0000 (04:29 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 22 Jul 2006 04:29:33 +0000 (04:29 +0000)
- Added a Message_Reporter::confirm() method
- Addend an extra candeletedata permission to make deletion its own separate bit

admin/permission.php
admin/usergroup.php
docs/changes.txt
editcomment.php
editreport.php
includes/class_message_reporter.php
includes/permissions.php
showreport.php
templates/showreport.tpl
templates/showreport_comment.tpl
templates/std_message.tpl

index 5ed11c02b2cc4cd95ba0cc2a4c9bb7f5094e8431..ccf7327fc022ea9bf1a66aa7a133c765499034d8 100755 (executable)
@@ -58,7 +58,8 @@ $permissions = array(
                'caneditownreply' => $lang->string('Can Edit Own Comments'),
                'caneditotherreply' => $lang->string('Can Edit Others\' Comments'),
                'canassign' => $lang->string('Can Assign Bugs'),
-               'canchangestatus' => $lang->string('Can Change Status')
+               'canchangestatus' => $lang->string('Can Change Status'),
+               'candeletedata' => $lang->string('Can Delete Bugs and Comments')
        )
 );
 
index 68fe658a1b07f08cc9b30a702f0328aeed3e4df7..bdda866d692939c9ea25b648e97c7c67175ef046 100755 (executable)
@@ -60,7 +60,8 @@ $permissions = array(
                'caneditownreply' => $lang->string('Can Edit Own Comments'),
                'caneditotherreply' => $lang->string('Can Edit Others\' Comments'),
                'canassign' => $lang->string('Can Assign Bugs'),
-               'canchangestatus' => $lang->string('Can Change Status')
+               'canchangestatus' => $lang->string('Can Change Status'),
+               'candeletedata' => $lang->string('Can Delete Bugs and Comments')
        ),
        
        $lang->string('Administrator Permissions') => array(
index 3aca7ad4c3164a070b30e1b8ed1cf1db1b3febe7..4b2ab4e44027f543c822d2f29f737c15b1d2cf44 100644 (file)
@@ -26,6 +26,7 @@
        - Usergroup
        - User help
 - Added support for DST observation (http://bugs.iris-studios.com/showreport.php?bugid=22)
+- Data (bugs and comments) can now be removed (http://bugs.iris-studios.com/showreport.php?bugid=16)
 
 1.0.2
 ==================
index 40c41fa2f899b5a6d6611802ebcbb1f2d1c28bbb..0907b45b5d7de4870e8ae3b967c0538da99367da 100644 (file)
@@ -42,11 +42,6 @@ $comment =& $commentapi->objdata;
 
 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = $comment[bugid]");
 
-if (!((can_perform('caneditownreply', $bug['productid']) AND $bugsys->userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['productid']) AND $bugsys->userinfo['userid'] != $comment['userid'])))
-{
-       $message->error_permission();
-}
-
 if ($bug['hidden'] AND !can_perform('canviewhidden', $bug['productid']))
 {
        $message->error_permissison();
@@ -61,8 +56,39 @@ if (empty($_REQUEST['do']))
 
 // ###################################################################
 
+if ($_POST['do'] == 'kill')
+{
+       if (!can_perform('candeletedata', $bug['productid']))
+       {
+               $message->error_permission();
+       }
+       
+       $commentapi->delete();
+       
+       $message->redirect($lang->string('The comment has been deleted. You will be redirected back to the bug.'), 'showreport.php?bugid=' . $bug['bugid']);
+}
+
+// ###################################################################
+
+if ($_REQUEST['do'] == 'delete')
+{
+       if (!can_perform('candeletedata', $bug['productid']))
+       {
+               $message->error_permission();
+       }
+       
+       $message->confirm($lang->string('Are you sure you want to delete this comment? After you do so, the data <strong>will</strong> be lost forever. We recommend only deleting spam comments and nothing else.'), 'editcomment.php', 'kill', $lang->string('Delete Comment'), 'showreport.php?bugid=' . $bug['bugid'], array('commentid' => $comment['commentid']));
+}
+
+// ###################################################################
+
 if ($_POST['do'] == 'update')
 {
+       if (!((can_perform('caneditownreply', $bug['productid']) AND $bugsys->userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['productid']) AND $bugsys->userinfo['userid'] != $comment['userid'])))
+       {
+               $message->error_permission();
+       }
+       
        $commentapi->set('comment',     $bugsys->in['comment']);
        $commentapi->set('hidden',      $bugsys->in['hidden']);
        
@@ -118,6 +144,11 @@ if ($_POST['do'] == 'update')
 
 if ($_REQUEST['do'] == 'edit')
 {
+       if (!((can_perform('caneditownreply', $bug['productid']) AND $bugsys->userinfo['userid'] == $comment['userid']) OR (can_perform('caneditotherreply', $bug['productid']) AND $bugsys->userinfo['userid'] != $comment['userid'])))
+       {
+               $message->error_permission();
+       }
+       
        $comment['posttime'] = $datef->format($bugsys->options['dateformat'], $comment['dateline']);
        $comment['postby'] = construct_user_display($commentapi->relations['userid']->objdata);
        $comment['comment'] = $bugsys->sanitize($comment['comment']);
index 8edee836a119686a7a170489307fec56ca4feef8..4e991be29819e0c4047654b1bc95a8afa7bba169 100644 (file)
@@ -42,11 +42,6 @@ $bug = $db->query_first("
        WHERE bug.bugid = " . $bugsys->input_clean('bugid', TYPE_UINT)
 );
 
-if (!((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['productid']))
-{
-       $message->error_permission();
-}
-
 if (!$bug)
 {
        $message->error($lang->getlex('error_invalid_id'));
@@ -79,15 +74,46 @@ $bugfields = array(
 
 $notif = new NotificationCenter;
 
+$bugapi = new BugAPI($bugsys);
+$bugapi->set('bugid',          $bugsys->in['bugid']);
+$bugapi->set_condition();
+$bugapi->dorelations = array();
+$bugapi->fetch();
+
+// ###################################################################
+
+if ($_POST['do'] == 'kill')
+{
+       if (!can_perform('candeletedata', $bug['productid']))
+       {
+               $message->error_permission();
+       }
+       
+       $bugapi->delete();
+       
+       $message->redirect($lang->string('The entire bug has been deleted.'), 'index.php');
+}
+
+// ###################################################################
+
+if ($_REQUEST['do'] == 'delete')
+{
+       if (!can_perform('candeletedata', $bug['productid']))
+       {
+               $message->error_permission();
+       }
+       
+       $message->confirm($lang->string('Are you sure you want to delete this bug? Doing so will <strong>destroy</strong> all associated data, including comments, attachments, and votes. We strongly recommend only deleting span records and nothing else as users may wish to go back and look at any bug to check its status.'), 'editreport.php', 'kill', $lang->string('Delete Bug Permanently'), 'showreport.php?bugid=' . $bug['bugid'], array('bugid' => $bug['bugid']));
+}
+
 // ###################################################################
 
 if ($_POST['do'] == 'update')
 {
-       $bugapi = new BugAPI($bugsys);
-       $bugapi->set('bugid',           $bugsys->in['bugid']);
-       $bugapi->set_condition();
-       $bugapi->dorelations = array();
-       $bugapi->fetch();
+       if (!((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['productid']))
+       {
+               $message->error_permission();
+       }
        
        $log->add_data(true, $bugapi->objdata, $bugfields);
        
index 7c7c5a31d2b5629f91aaa92af8e6f4085ad02586..c449c0a754eca7887160fd2c043a00e96675b312 100755 (executable)
@@ -153,6 +153,37 @@ class Message_Reporter
                exit;
        }
        
+       // ###################################################################
+       /**
+       * Displays a standard message template with extra confirm data on it
+       *
+       * @access       public
+       *
+       * @param        string  Message to confirm to
+       * @param        string  Form action
+       * @param        string  Do branch
+       * @param        string  Button text
+       * @param        string  Cancel action
+       * @param        array   Extra hidden information
+       */
+       function confirm($message, $action, $do, $button, $cancel, $arrextra)
+       {
+               global $bugsys;
+               global $doctype, $header, $headinclude, $footer, $focus, $show, $stylevar;
+               
+               $show['confirm'] = true;
+               
+               $this->process = $message;
+               
+               foreach ($arrextra AS $name => $value)
+               {
+                       $extra .= '<input type="hidden" name="' . $name . '" value="' . $value . '" />' . "\n";
+               }
+               
+               eval('$bugsys->template->flush("' . $bugsys->template->fetch('std_message') . '");');
+               exit;
+       }
+       
        /**
        * Checks to make sure that there is some text in the processed variable
        */
index 5783485a0f904ba93e5eb1b7d4f39e5e9ff47d7e..dbd17e4e1524214a183f8f5ed6164b72b5a00fac 100644 (file)
@@ -43,7 +43,8 @@ $bugsys->permissions = array(
        'canbeassignedto'       => 1048576, // can be assigned bugs,
        'caneditattach'         => 2097152, // can edit attachments
        'canviewhidden'         => 4194304, // can see hidden bugs
-       'caneditotherreply'     => 8388608 // can edit other peoples' comments
+       'caneditotherreply'     => 8388608, // can edit other peoples' comments
+       'candeletedata'         => 16777216 // can delete data (bugs, comments)
 );
 
 $bugsys->emailoptions = array(
index a4f5ce07c95926cb1d80d5b2b9a03505ad4e74ea..ca59cf98a7e19b04d8288b458c7044e9c653c4b7 100644 (file)
@@ -77,6 +77,7 @@ if (!can_perform('canviewbugs', $bug['productid']))
 }
 
 $show['edit'] = ((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo['userid'] == $bug['userid'] AND $bug['userid'] != 0) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo['userid'] != $bug['userid']));
+$show['delete'] = can_perform('candeletedata', $bug['productid']);
 
 if (!is_array($bug))
 {
index 89857471a281787d867b5d3cd4161937dbe9afc9..af839dfc98e5f0801a1ff7921c25eb7e1c10992e 100644 (file)
@@ -36,6 +36,7 @@ $header
                                
                                / [<a href="showhistory.php?bugid=$bug[bugid]">{@"Show Bug History"}</a>]
                                <if condition="$show['subscribe']">/ [<a href="favourite.php?do=handle&amp;bugid=$bug[bugid]">$favouritetext</a>]</if>
+                               <if condition="$show['delete']">/ [<a href="editreport.php?do=delete&amp;bugid=$bug[bugid]">{@"Delete"}</a>]</if>
                        </div>
                </fieldset>
                <!-- / bug id & hidden -->
index 8b5080a0ae5b97dfa47308ced5f5925fce374b76..57f24571e95627a2a6d1e47269f11114e373d5a4 100644 (file)
@@ -13,6 +13,7 @@
        <if condition="$show['editcomment']">
        <div class="box-foot">
                <span style="float: right">
+                       <if condition="$show['delete']">[<a href="editcomment.php?do=delete&amp;commentid=$comment[commentid]">{@"Delete"}</a>]</if>
                        [<a href="editcomment.php?commentid=$comment[commentid]">{@"Edit Comment"}</a>]
                </span>
                <if condition="$comment['hidden']"><strong>{@"Hidden"}</strong><else />{@"Visible"}</if>
index 4a5bdf8031e0d5eca47460e11b2965e3e7f6c4e6..72232282bdf10d6c38f001982ea22b1b63d65c2c 100644 (file)
@@ -3,21 +3,41 @@ $doctype
 <head>
 $headinclude
        <link rel="stylesheet" href="templates/box.css" media="screen" />
-       <title>{$bugsys->options['trackertitle']} - {@"Notice"}</title>
+       <title>{$bugsys->options['trackertitle']} - <if condition="$show['confirm']">{@"Confirm"}<else />{@"Notice"}</if></title>
 </head>
 
 <body>
 
 $header
 
+<if condition="$show['confirm']">
+<form name="confirm" action="$action" method="post">
+<input type="hidden" name="do" value="$do" />
+$extra
+</if>
+
 <div align="center" style="margin-top: 10px">
        <div class="box" style="width: $stylevar[alternate_width]">
-               <div class="box-head">{@"Notice"}</div>
+               <div class="box-head"><if condition="$show['confirm']">{@"Confirm"}<else />{@"Notice"}</if></div>
                
                <div class="box-mid + box-overpad">
                        {$this->process}
+                       
+                       <if condition="$show['confirm']">
+                               <br />
+                               <br />
+                               
+                               <div id="submitrow">
+                                       <input type="submit" name="submit" value="$button" /> 
+                                       <script type="text/javascript"> draw_cancel("$cancel"); </script>
+                               </div>
+                       </if>
                </div>
        </div>
 </div>
 
+<if condition="$show['confirm']">
+</form>
+</if>
+
 $footer
\ No newline at end of file