diff --git a/deletecomment.php b/deletecomment.php index 3cf9aef..468cf4d 100644 --- a/deletecomment.php +++ b/deletecomment.php @@ -6,7 +6,7 @@ * - iCommentId, comment identifier * * Optional parameters: - * - sWhy, reason for deleting the comment + * - sReplyText, reason for deleting the comment * - iDeleteIt, 1 if the deletion has been confirmed */ @@ -40,7 +40,7 @@ if($_SESSION['current']->getPref("confirm_comment_deletion") != "no" && !isset($ echo htmlify_urls($oComment->sBody), "

\n"; echo html_frame_end(); echo '',"\n"; - echo "\n"; + echo "\n"; echo "\n"; @@ -54,7 +54,7 @@ if($_SESSION['current']->getPref("confirm_comment_deletion") != "no" && !isset($ // otherwise, just delete the comment } else { - $oComment->delete($aClean['sWhy']); + $oComment->delete(true); $oVersion = new version($oComment->iVersionId); util_redirect_and_exit($oVersion->objectMakeUrl()); } diff --git a/include/comment.php b/include/comment.php index 4e9ffe5..1de25c7 100644 --- a/include/comment.php +++ b/include/comment.php @@ -162,7 +162,7 @@ class Comment { * Informs interested people about the deletion. * Returns true on success and false on failure. */ - function delete($sReason=null) + function delete($bSilent = false) { $hResult = query_parameters("DELETE FROM appComments WHERE commentId = '?'", $this->iCommentId); if ($hResult) @@ -170,33 +170,60 @@ class Comment { /* fixup the child comments so the parentId points to a valid parent comment */ $hResult = query_parameters("UPDATE appComments set parentId = '?' WHERE parentId = '?'", $this->iParentId, $this->iCommentId); - $sEmail = User::get_notify_email_address_list($this->iAppId, $this->iVersionId); - $sEmail .= $this->oOwner->sEmail; - if($sEmail) + + if(!$bSilent) { - $sSubject = "Comment for '".version::fullName($this->iVersionId)."' deleted by ".$_SESSION['current']->sRealname; - $oVersion = new version($this->iVersionId); - $sMsg = $oVersion->objectMakeUrl()."\n"; - $sMsg .= "\n"; - $sMsg .= "This comment was made on ".substr($this->sDateCreated,0,10)." by ".$this->oOwner->sRealname."\n"; - $sMsg .= "\n"; - $sMsg .= "Subject: ".$this->sSubject."\r\n"; - $sMsg .= "\n"; - $sMsg .= $this->sBody."\r\n"; - $sMsg .= "\n"; - $sMsg .= "Because:\n"; - if($sReason) - $sMsg .= $sReason."\n"; - else - $sMsg .= "No reason given.\n"; - mail_appdb($sEmail, $sSubject ,$sMsg); - } - addmsg("Comment deleted.", "green"); + $this->SendNotificationMail("delete"); + } + return true; + } else + { + addmsg("Error removing the deleted comment!", "red"); } + return false; } + function SendNotificationMail($sAction="add", $sMsg = null) + { + global $aClean; + + // use 'sReplyText' if it is defined, otherwise define the value as an empty string + if(!isset($aClean['sReplyText'])) + $aClean['sReplyText'] = ""; + + $oApp = new Application($this->iAppId); + switch($sAction) + { + case "delete": + $sSubject = "Comment for '".version::fullName($this->iVersionId)."' deleted by ".$_SESSION['current']->sRealname; + $oVersion = new version($this->iVersionId); + $sMsg = $oVersion->objectMakeUrl()."\n"; + $sMsg .= "\n"; + $sMsg .= "This comment was made on ".substr($this->sDateCreated,0,10)." by ".$this->oOwner->sRealname."\n"; + $sMsg .= "\n"; + $sMsg .= "Subject: ".$this->sSubject."\r\n"; + $sMsg .= "\n"; + $sMsg .= $this->sBody."\r\n"; + $sMsg .= "\n"; + $sMsg .= "Because:\n"; + if($sReason) + $sMsg .= $sReason."\n"; + else + $sMsg .= "No reason given.\n"; + + addmsg("Comment deleted.", "green"); + + break; + } + + $sEmail = User::get_notify_email_address_list($this->iAppId, $this->iVersionId); + $sEmail .= $this->oOwner->sEmail; + if($sEmail) + mail_appdb($sEmail, $sSubject, $sMsg); + } + function get_comment_count_for_versionid($iVersionId) { $sQuery = "SELECT count(*) as cnt from appComments where versionId = '?'"; diff --git a/include/version.php b/include/version.php index a4f0042..bbf4f01 100644 --- a/include/version.php +++ b/include/version.php @@ -256,7 +256,10 @@ class version { foreach($aCommentsIds as $iCommentId) { $oComment = new Comment($iCommentId); - $oComment->delete($bSilent); + + // delete the comment silently, we don't want to send out + // any notifications since the version is being deleted + $oComment->delete(false); } @@ -297,8 +300,6 @@ class version { } - - /* fetch Test Results Ids */ $aTestingIds = array(); $sQuery = "SELECT *
\n"; echo " \n"; echo "