From 12df639261e24856e9874fec6b17a4d1d93098e2 Mon Sep 17 00:00:00 2001
From: codeforkjeff <jeff@codefork.com>
Date: Thu, 17 Mar 2011 13:31:49 -0400
Subject: [PATCH] issue #952072 by codeforkjeff: fix hash in unsubscribe-url token replacement to refer to watching comment

---
 comment_notify.module     |    2 +-
 comment_notify.tokens.inc |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/comment_notify.module b/comment_notify.module
index 87f2cb7..dd25911 100644
--- a/comment_notify.module
+++ b/comment_notify.module
@@ -483,7 +483,7 @@ function _comment_notify_mailalert($comment) {
       );
 
       foreach ($raw_values as $k => $v) {
-        $message[$k] = token_replace(t($v), array('comment' => $comment, 'node' => $node, 'user' => $user));
+        $message[$k] = token_replace(t($v), array('comment' => $comment, 'watcher' => $alert, 'node' => $node, 'user' => $user));
       }
 
       drupal_mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);
diff --git a/comment_notify.tokens.inc b/comment_notify.tokens.inc
index 2f1dab7..7c4f07f 100644
--- a/comment_notify.tokens.inc
+++ b/comment_notify.tokens.inc
@@ -34,12 +34,13 @@ function comment_notify_tokens($type, $tokens, array $data = array(), array $opt
 
   if ($type == 'comment' && !empty($data['comment'])) {
     $comment = $data['comment'];
+    $watcher = $data['watcher'];
 
     foreach ($tokens as $name => $original) {
       switch ($name) {
         case 'unsubscribe-url':
           module_load_include('inc', 'comment_notify', 'comment_notify');
-          if ($hash = comment_notify_get_notify_hash($comment->cid)) {
+          if ($hash = comment_notify_get_notify_hash($watcher->cid)) {
             $replacements[$original] = url('comment_notify/disable/' . $hash, $url_options);
           }
           break;
-- 
1.7.3.5

