From d4f09b78218e7ee8bcbbce28255847622c0567f0 Mon Sep 17 00:00:00 2001
From: xoxys <robert.kaussow@rknet.org>
Date: Tue, 9 Feb 2016 10:49:50 +0100
Subject: [PATCH] check session variable to detect a reply from author

---
 include/functions_comments.inc.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/functions_comments.inc.php b/include/functions_comments.inc.php
index 66750e6f..7a7d0977 100644
--- a/include/functions_comments.inc.php
+++ b/include/functions_comments.inc.php
@@ -789,6 +789,11 @@ function serendipity_insertComment($id, $commentInfo, $type = 'NORMAL', $source
     if (!empty($ca['status'])) {
         $commentInfo['status'] = $ca['status'];
     }
+    
+    if ($serendipity['serendipityAuthedUser']) {
+		$authorReply = true;
+		$authorEmail = $serendipity['serendipityEmail'];
+	}
 
     $title         = serendipity_db_escape_string(isset($commentInfo['title']) ? $commentInfo['title'] : '');
     $comments      = $commentInfo['comment'];
@@ -801,7 +806,6 @@ function serendipity_insertComment($id, $commentInfo, $type = 'NORMAL', $source
     $status        = serendipity_db_escape_string(isset($commentInfo['status']) ? $commentInfo['status'] : (serendipity_db_bool($ca['moderate_comments']) ? 'pending' : 'approved'));
     $t             = serendipity_db_escape_string(isset($commentInfo['time']) ? $commentInfo['time'] : time());
     $referer       = substr((isset($_SESSION['HTTP_REFERER']) ? serendipity_db_escape_string($_SESSION['HTTP_REFERER']) : ''), 0, 200);
-    $backend       = $commentInfo['backend'];
 
     $query = "SELECT a.email, e.title, a.mail_comments, a.mail_trackbacks
                 FROM {$serendipity['dbPrefix']}entries AS e
@@ -874,7 +878,7 @@ function serendipity_insertComment($id, $commentInfo, $type = 'NORMAL', $source
     if ($status != 'confirm' && (serendipity_db_bool($ca['moderate_comments'])
         || ($type == 'NORMAL' && serendipity_db_bool($row['mail_comments']))
         || (($type == 'TRACKBACK' || $type == 'PINGBACK') && serendipity_db_bool($row['mail_trackbacks'])))) {
-            if (! ($backend && $email == $row['email'])) {
+            if (! ($authorReply && $authorEmail == $row['email'])) {
                 serendipity_sendComment($cid, $row['email'], $name, $email, $url, $id, $row['title'], $comments, $type, serendipity_db_bool($ca['moderate_comments']), $referer);
             }
     }