? 221196_node_owner_notify.patch
? 280502_all_comments_my_replies.patch
Index: comment_notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/comment_notify.module,v
retrieving revision 1.8.2.10
diff -u -p -r1.8.2.10 comment_notify.module
--- comment_notify.module	30 Sep 2008 22:20:04 -0000	1.8.2.10
+++ comment_notify.module	3 Oct 2008 18:49:07 -0000
@@ -34,6 +34,10 @@ Webmaster of !site
 !mission
 !uri');
 
+define('COMMENT_NOTIFY_DISABLED', 0);
+define('COMMENT_NOTIFY_NODE', 1);
+define('COMMENT_NOTIFY_COMMENT', 2);
+
 /**
  * Implementation of hook_help().
  */
@@ -93,19 +97,30 @@ function comment_notify_form_alter($form
       return;
     }
     $form['notify'] = array(
-      '#type' => 'checkbox',
+      '#type' => 'select',
       '#title' => t('Notify me of follow-up comments posted here.'),
       '#default_value' => ($user->uid != 0) ? $user->comment_notify_mailalert : variable_get('comment_notify_default_anon_mailalert', TRUE),
+      '#options' => array(
+        COMMENT_NOTIFY_DISABLED => t('No notifications'),
+        COMMENT_NOTIFY_NODE     => t('For all comments on this post'),
+        COMMENT_NOTIFY_COMMENT  => t('Just for replies to my comment')
+      )
     );
   }
   // For registered users and the admin wants them to see the checkbox.
   elseif (variable_get('comment_notify_regged_checkbox', TRUE)) {
     $form['notify'] = array(
-      '#type' => 'checkbox',
+      '#type' => 'select',
       '#title' => t('Notify me of follow-up comments posted here.'),
-      '#default_value' => ($user->uid != 0) ? $user->comment_notify_mailalert : variable_get('comment_notify_default_anon_mailalert', TRUE),
+      '#default_value' => empty($user->comment_notify_mailalert) ? $user->comment_notify_mailalert : variable_get('comment_notify_default_anon_mailalert', TRUE),
+      '#options' => array(
+        COMMENT_NOTIFY_DISABLED => t('No notifications'),
+        COMMENT_NOTIFY_NODE     => t('For all comments on this post'),
+        COMMENT_NOTIFY_COMMENT  => t('Just for replies to my comment')
+      ),
       '#description' => t('You can change the default for this field in "Comment follow-up notification settings" on <a href="!uri">your account edit page</a>', array('!uri' => url('user/'. $user->uid .'/edit'))),
     );
+
   }
   // For the registered users where the admin wants the checkbox hidden.
   else {
@@ -260,10 +275,16 @@ function comment_notify_user($type, &$ed
           '#collapsible' => TRUE
         );
 
+        // TODO make this a select
         $form['comment_notify_settings']['comment_notify_mailalert'] = array(
-          '#type' => 'checkbox',
+          '#type' => 'select',
           '#title' => t('Receive comment follow-up notification e-mails'),
           '#default_value' => isset($edit['comment_notify_mailalert']) ? $edit['comment_notify_mailalert'] : 0,
+          '#options' => array(
+            COMMENT_NOTIFY_DISABLED => t('No notifications'),
+            COMMENT_NOTIFY_NODE     => t('For all comments on this post'),
+            COMMENT_NOTIFY_COMMENT  => t('Just for replies to my comment')
+          ),
           '#description' => t("Check this box to receive e-mail notification for follow-up comments to comments you posted. You can later disable this on a post-by-post basis... so if you leave this to YES, you can still disable follow-up notifications for comments you don't want follow-up mails anymore - i.e. for very popular posts.")
         );
         return $form;
@@ -303,9 +324,9 @@ function _comment_notify_mailalert($comm
   }
 
   $from = variable_get('site_mail', ini_get('sendmail_from'));
-  $result = db_query("SELECT DISTINCT c.cid, u.init, c.uid, c.name, c.nid, c.mail cmail, u.mail AS umail, u.init AS uinit, c.uid, c.name, cn.notify_hash mymd5
+  $result = db_query("SELECT DISTINCT c.cid, u.init, c.uid, c.name, c.nid, c.mail cmail, u.mail AS umail, u.init AS uinit, c.uid, c.name, cn.notify, cn.notify_hash mymd5
     FROM {comments} c INNER JOIN {comment_notify} cn on c.cid = cn.cid LEFT OUTER JOIN {users} u ON c.uid = u.uid
-    WHERE nid = %d  AND cn.notify = 1 AND c.status = 0 AND (u.status = 1 OR u.status = '')", $nid
+    WHERE nid = %d  AND cn.notify > 0 AND c.status = 0 AND (u.status = 1 OR u.status = '')", $nid
   );
   // TODO? the original big query had stuff making sure the mail was populated and contained .+@.+ Perhaps check for that here and set notify = 0 if that is the case for this cid
 
@@ -316,6 +337,10 @@ function _comment_notify_mailalert($comm
     $umail = empty($alert->umail) ? $alert->uinit : $alert->umail;
     $mail = empty($alert->cmail) ? $umail : $alert->cmail;
 
+    if ($alert->notify == COMMENT_NOTIFY_COMMENT && $alert->cid != $comment->pid) {
+      break;
+    }
+
     if ($mail != $comment_mail && !in_array($mail, $sent_to) && $alert->uid != $comment->uid) {
 
       if (function_exists('locale') && $languages[$user->language]) {
@@ -391,11 +416,11 @@ function comment_notify_unsubscribe_subm
   // If they have a uid, use that, otherwise update comments directly
   $result = db_result(db_query_range("SELECT uid FROM {users} WHERE mail = '%s'", $email, 0, 1));
   if ($result > 0) {
-    $comments = db_result(db_query("SELECT COUNT(1) FROM {comments} c INNER JOIN {comment_notify} cn ON c.cid = cn.cid WHERE c.uid = %d AND cn.notify = 1", $result));
+    $comments = db_result(db_query("SELECT COUNT(1) FROM {comments} c INNER JOIN {comment_notify} cn ON c.cid = cn.cid WHERE c.uid = %d AND cn.notify > 0", $result));
     db_query("UPDATE {comment_notify} cn INNER JOIN {comments} c ON cn.cid = c.cid SET cn.notify = 0 WHERE c.uid = %d", $result);
   }
   else {
-    $comments = db_result(db_query("SELECT COUNT(1) FROM {comments} c INNER JOIN {comment_notify} cn ON c.cid = cn.cid WHERE c.mail = '%s' AND cn.notify = 1", $email));
+    $comments = db_result(db_query("SELECT COUNT(1) FROM {comments} c INNER JOIN {comment_notify} cn ON c.cid = cn.cid WHERE c.mail = '%s' AND cn.notify > 0", $email));
     db_query("UPDATE {comment_notify} cn INNER JOIN {comments} c ON cn.cid = c.cid SET cn.notify = 0 WHERE c.mail = '%s'", $email);
   }
   // Update the admin about the state of this comment notification subscription.
@@ -444,8 +469,8 @@ function comment_notify_settings() {
   );
 
   $form['comment_notify_settings']['comment_notify_default_anon_mailalert'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Fill checkbox for follow-up with YES by default for anonymous users, so they will get an email alert for follow-up comments if they do not uncheck it then'),
+    '#type' => 'select',
+    '#title' => t('Default state for the notification selection box for anonymous users.'),
     '#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')
