From 00764cd913d123a21f89518339f9612dfe988950 Mon Sep 17 00:00:00 2001
From: valuev <gease@mail.ru>
Date: Sun, 27 Apr 2014 17:48:22 +0400
Subject: [PATCH] Issue #2067651 by gease: fixed only todo.

---
 includes/mail.inc |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/includes/mail.inc b/includes/mail.inc
index ba4d99d..f8fff26 100644
--- a/includes/mail.inc
+++ b/includes/mail.inc
@@ -192,14 +192,9 @@ function _project_issue_mail($key, &$message, $params) {
       );
       // If there are comments, set In-Reply-To and References accordingly.
       if (!empty($comments)) {
-        // TODO: fix this to use $comment_id to know the current comment.
-        foreach ($comments as $comment) {
-          // We need the most recent cid and the next most recent cid for the
-          // message headers. Instead of issuing another query, just keep
-          // track of them here.
-          $previous_cid = isset($cid) ? $cid : '';
-          $cid = isset($comment->cid) ? $comment->cid : 0;
-        }
+        $cids = array_keys($comments);
+        $cid_key = array_search($comment_id, $cids);
+        $previous_cid = isset($cids[$cid_key - 1]) ? $cids[$cid_key - 1] : 0;
         $message['headers']['Message-Id'] = "<type=project&nid=$issue->nid&cid=$cid&host=@$domain>";
         $message['headers']['In-Reply-To'] = "<type=project&nid=$issue->nid&host=@$domain>";
         $message['headers']['References'] = "<type=project&nid=$issue->nid&host=@$domain> <type=project&nid=$issue->nid&cid=$previous_cid&host=@$domain> <type=project&nid=$issue->nid&revcount=1&host=@$domain>";
-- 
1.7.10.msysgit.1

