Fix comment::delete() to take $bSilent as an input parameter and use
comment::SendNotificationEmail(). Update version::delete() to pass false into comment::delete() so we don't send an email for each comment we are deleting for a given version. Fixes bug 8473.
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
* - iCommentId, comment identifier
|
* - iCommentId, comment identifier
|
||||||
*
|
*
|
||||||
* Optional parameters:
|
* Optional parameters:
|
||||||
* - sWhy, reason for deleting the comment
|
* - sReplyText, reason for deleting the comment
|
||||||
* - iDeleteIt, 1 if the deletion has been confirmed
|
* - 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), "<br /><br />\n";
|
echo htmlify_urls($oComment->sBody), "<br /><br />\n";
|
||||||
echo html_frame_end();
|
echo html_frame_end();
|
||||||
echo '<table width="100%" border=0 cellpadding=0 cellspacing=1>',"\n";
|
echo '<table width="100%" border=0 cellpadding=0 cellspacing=1>',"\n";
|
||||||
echo "<tr class=color1><td colspan=2><textarea name=\"sWhy\" cols=\"70\" rows=\"15\" wrap=\"virtual\"></textarea></td></tr>\n";
|
echo "<tr class=color1><td colspan=2><textarea name=\"sReplyText\" cols=\"70\" rows=\"15\" wrap=\"virtual\"></textarea></td></tr>\n";
|
||||||
echo "<tr class=color1><td colspan=2 align=center>\n";
|
echo "<tr class=color1><td colspan=2 align=center>\n";
|
||||||
echo " <input type=\"submit\" value=\"Delete Comment\" class=\"button\" />\n";
|
echo " <input type=\"submit\" value=\"Delete Comment\" class=\"button\" />\n";
|
||||||
echo "</td></tr>\n";
|
echo "</td></tr>\n";
|
||||||
@@ -54,7 +54,7 @@ if($_SESSION['current']->getPref("confirm_comment_deletion") != "no" && !isset($
|
|||||||
// otherwise, just delete the comment
|
// otherwise, just delete the comment
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
$oComment->delete($aClean['sWhy']);
|
$oComment->delete(true);
|
||||||
$oVersion = new version($oComment->iVersionId);
|
$oVersion = new version($oComment->iVersionId);
|
||||||
util_redirect_and_exit($oVersion->objectMakeUrl());
|
util_redirect_and_exit($oVersion->objectMakeUrl());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class Comment {
|
|||||||
* Informs interested people about the deletion.
|
* Informs interested people about the deletion.
|
||||||
* Returns true on success and false on failure.
|
* 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);
|
$hResult = query_parameters("DELETE FROM appComments WHERE commentId = '?'", $this->iCommentId);
|
||||||
if ($hResult)
|
if ($hResult)
|
||||||
@@ -170,33 +170,60 @@ class Comment {
|
|||||||
/* fixup the child comments so the parentId points to a valid parent comment */
|
/* fixup the child comments so the parentId points to a valid parent comment */
|
||||||
$hResult = query_parameters("UPDATE appComments set parentId = '?' WHERE parentId = '?'",
|
$hResult = query_parameters("UPDATE appComments set parentId = '?' WHERE parentId = '?'",
|
||||||
$this->iParentId, $this->iCommentId);
|
$this->iParentId, $this->iCommentId);
|
||||||
$sEmail = User::get_notify_email_address_list($this->iAppId, $this->iVersionId);
|
|
||||||
$sEmail .= $this->oOwner->sEmail;
|
if(!$bSilent)
|
||||||
if($sEmail)
|
|
||||||
{
|
{
|
||||||
$sSubject = "Comment for '".version::fullName($this->iVersionId)."' deleted by ".$_SESSION['current']->sRealname;
|
$this->SendNotificationMail("delete");
|
||||||
$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");
|
|
||||||
return true;
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
addmsg("Error removing the deleted comment!", "red");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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)
|
function get_comment_count_for_versionid($iVersionId)
|
||||||
{
|
{
|
||||||
$sQuery = "SELECT count(*) as cnt from appComments where versionId = '?'";
|
$sQuery = "SELECT count(*) as cnt from appComments where versionId = '?'";
|
||||||
|
|||||||
@@ -256,7 +256,10 @@ class version {
|
|||||||
foreach($aCommentsIds as $iCommentId)
|
foreach($aCommentsIds as $iCommentId)
|
||||||
{
|
{
|
||||||
$oComment = new Comment($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 */
|
/* fetch Test Results Ids */
|
||||||
$aTestingIds = array();
|
$aTestingIds = array();
|
||||||
$sQuery = "SELECT *
|
$sQuery = "SELECT *
|
||||||
|
|||||||
Reference in New Issue
Block a user