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:
Chris Morgan
2007-08-24 02:52:34 +00:00
committed by WineHQ
parent 6b5305d1bf
commit 9e05efb1b6
3 changed files with 56 additions and 28 deletions

View File

@@ -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 = '?'";