--- F:/WebServers/home/dd/www/modules/comment_notify/comment_notify_old.module	Wed Jul 09 21:51:18 2008
+++ F:/WebServers/home/dd/www/modules/comment_notify/comment_notify.module	Wed Jul 09 21:50:40 2008
@@ -281,15 +281,27 @@
 
   $from = variable_get('site_mail', ini_get('sendmail_from'));
 
-  $result = db_query('SELECT DISTINCT c.cid, u.init, c.uid, c.name, c.nid, IF(length(c.mail) < 1, ifnull(u.mail, u.init), c.mail) mail, c.uid, c.name, max(cid) cid, md5(concat(c.mail, ifnull(u.mail, u.init), c.uid, c.name, c.nid)) mymd5
-    FROM {comments} c LEFT OUTER JOIN {users} u ON u.uid = c.uid
-    WHERE nid = %d  AND notify = 1 AND c.status = 0
-      AND LENGTH(IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail)) > 1
-      AND IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail) like \'%@%.%\'
-    GROUP BY IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail), c.name',
-    $nid
-  );
-
+  if (variable_get('comment_notify_only_replies_for_comments', FALSE)) {
+    $result = db_query('SELECT DISTINCT c.cid, u.init, c.uid, c.name, c.nid, IF(length(c.mail) < 1, ifnull(u.mail, u.init), c.mail) mail, c.uid, c.name, max(cid) cid, md5(concat(c.mail, ifnull(u.mail, u.init), c.uid, c.name, c.nid)) mymd5
+      FROM {comments} c LEFT OUTER JOIN {users} u ON u.uid = c.uid
+      WHERE nid = %d  AND notify = 1 AND c.status = 0 AND c.cid = %d
+        AND LENGTH(IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail)) > 1
+        AND IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail) like \'%@%.%\'
+      GROUP BY IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail), c.name',
+      $nid, $comment->pid
+    );
+  }
+  else {
+    $result = db_query('SELECT DISTINCT c.cid, u.init, c.uid, c.name, c.nid, IF(length(c.mail) < 1, ifnull(u.mail, u.init), c.mail) mail, c.uid, c.name, max(cid) cid, md5(concat(c.mail, ifnull(u.mail, u.init), c.uid, c.name, c.nid)) mymd5
+      FROM {comments} c LEFT OUTER JOIN {users} u ON u.uid = c.uid
+      WHERE nid = %d  AND notify = 1 AND c.status = 0
+        AND LENGTH(IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail)) > 1
+        AND IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail) like \'%@%.%\'
+      GROUP BY IF(LENGTH(c.mail) < 1, ifnull(u.mail, u.init), c.mail), c.name',
+      $nid
+    );
+  }
+  
   $count = 0;
   $sent_to = array();
 
@@ -325,11 +337,11 @@
 
       drupal_mail('comment_notify_mail', $alert->mail, $subject, $message, $from, array());
       $count++;
+      $sent_to[] = $alert->mail;
 
       if ($alert->uid != 0) {
         $watchdog_message = t('Notified: <a href="!url">@user_mail</a>', 
           array('!url' => url('user/'. $alert->uid .'/edit'), '@user_mail' => $alert->mail)) ;
-
       }
       else {
         $watchdog_message = t('Notified @user_mail', array('@user_mail' => $alert->mail));
@@ -403,6 +415,13 @@
     '#return_value' => 1,
     '#default_value' => variable_get('comment_notify_default_anon_mailalert', TRUE),
     '#description' => t('This flag presets the flag for the follow-up notification on the form that anon users will see when posting a comment')
+  );
+  
+  $form['comment_notify_settings']['comment_notify_only_replies_for_comments'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Send notifications only to people, who got responces to their comments'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('comment_notify_only_replies_for_comments', FALSE),
   );
 
   $form['comment_notify_settings']['comment_notify_default_mailtext'] = array(
