Index: subscriptions.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/subscriptions/subscriptions.module,v
retrieving revision 1.62.2.45
diff -u -r1.62.2.45 subscriptions.module
--- subscriptions.module	18 Apr 2007 14:40:44 -0000	1.62.2.45
+++ subscriptions.module	28 Jun 2007 06:36:42 -0000
@@ -763,30 +763,37 @@
  * Implementation of hook_comment().
  */
 function subscriptions_comment($comment, $op) {
-  global $user;
-  $strsent = '!';
-  // $comment can be an object or an array.
-  $comment = (array)$comment;
-  if ($op == 'insert' || ($op == 'update' && $comment['status'] == 0)) { // ignore deactivated comments
+
+  // notification are possible when comment is either created or updated or published
+  if ($op == 'insert' || $op == 'update' || $op == 'publish' ) {
+    
+    // $comment can be an object or an array.
+    // send notification only if the comment is already SAVED and published in the database
+    // comment could be moderated or killed by spam filters
+    $comment = (array)$comment;
+    $comment = db_fetch_array(db_query('SELECT * FROM {comments} WHERE cid = %d', $comment['cid']));
+    if ($comment['status'] != COMMENT_PUBLISHED) return;
+    $strsent = '!';
+
     // if use_cron is set, insert node actions into holding table
     if (variable_get('subscriptions_usecron', 0)) {
-      subscriptions_hold($comment, 'comment', $op, $user->uid);
+      subscriptions_hold($comment, 'comment', $op, $comment['uid']);
     }
     else {  // if cron is not used
       $nid = $comment['nid'];
       $nobj = node_load($nid);
       // send node subscriptions
-      $strsent .= subscriptions_mailvars($nid, $comment['cid'], $user->uid, 'node', $strsent);
+      $strsent .= subscriptions_mailvars($nid, $comment['cid'], $comment['uid'], 'node', $strsent);
       // get subscription->node->taxonomy
       $taxa = subscriptions_comment_taxa($comment);
       // send to taxonomy subscribers
       foreach ($taxa as $tid) {
-        $strsent .= subscriptions_mailvars($tid, $nid, $user->uid, 'taxa', $strsent);
+        $strsent .= subscriptions_mailvars($tid, $nid, $comment['uid'], 'taxa', $strsent);
       }
       // send content type subscriptions
-      $strsent .= subscriptions_mailvars($nobj->type, $nobj->nid, $user->uid, 'type', $strsent);
+      $strsent .= subscriptions_mailvars($nobj->type, $nobj->nid, $comment['uid'], 'type', $strsent);
     } // end cron test
-    subscriptions_autosubscribe($user->uid, $nid);
+    subscriptions_autosubscribe($comment['uid'], $nid);
   }
 }
 
