From 46c590981f51548e39023c9ccf6ce4338a128431 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 22 Jul 2006 04:33:24 +0000 Subject: [PATCH] r932: Added protection into the Comment API against deleting initialreport's --- editcomment.php | 5 +++++ includes/api_comment.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/editcomment.php b/editcomment.php index 0907b45..5138e96 100644 --- a/editcomment.php +++ b/editcomment.php @@ -77,6 +77,11 @@ if ($_REQUEST['do'] == 'delete') $message->error_permission(); } + if ($bug['initialreport'] == $comment['commentid']) + { + $messsage->error($lang->string('You cannot delete this comment because it is attached to the bug as the first comment. You have to delete the entire bug instead (which is not recommended unless it is spam).')); + } + $message->confirm($lang->string('Are you sure you want to delete this comment? After you do so, the data will 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'])); } diff --git a/includes/api_comment.php b/includes/api_comment.php index 9218aa4..4b0d91d 100644 --- a/includes/api_comment.php +++ b/includes/api_comment.php @@ -100,6 +100,20 @@ class CommentAPI extends API { $this->set_comment_parsed(); } + + // ################################################################### + /** + * Pre-delete + * + * @access private + */ + function pre_delete() + { + if ($this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE initialreport = " . $this->values['commentid'])) + { + $this->error($this->registry->lang->string('You cannot delete this comment because it is attached to the bug as the first comment. You have to delete the entire bug instead (which is not recommended unless it is spam).')); + } + } } /*=====================================================================*\ -- 2.22.5