? .svn
? comment_notify.patch
? translations/.svn
Index: comment_notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/comment_notify.module,v
retrieving revision 1.54
diff -u -p -r1.54 comment_notify.module
--- comment_notify.module	7 Mar 2009 19:22:51 -0000	1.54
+++ comment_notify.module	20 May 2009 14:19:16 -0000
@@ -48,6 +48,33 @@ Webmaster of !site
 !mission
 !uri');
 
+define('DEFAULT_AUTHORTEXT',
+'Hi !name,
+
+You have commented on: "!node_title"
+
+The post is about
+----
+!node_teaser
+----
+
+You can view the comment at the following url
+!comment_url
+
+You can stop receiving emails when someone replies to this post,
+by going to !link1
+
+If you have auto-following enabled in your account, you will receive emails like this for all replies to a blog post you commented on. You can disable this by logging in and going to your account settings or unchecking the flag at the time you post the comment.
+
+You can set up auto-following feature for all future posts
+by creating your own user with a few clicks here !uri/user/register
+
+Thanks for your feedback,
+
+Webmaster of !site
+!mission
+!uri');
+
 define('COMMENT_NOTIFY_DISABLED', 0);
 define('COMMENT_NOTIFY_NODE', 1);
 define('COMMENT_NOTIFY_COMMENT', 2);
@@ -391,12 +418,26 @@ function _comment_notify_mailalert($comm
 
   // Send to a subscribed author if they are not the current commenter
   $author = user_load(array('uid' => $node->uid));
-  if (!empty($author->node_notify_mailalert) && $author->node_notify_mailalert == 1 && $user->mail != $author->mail) {
+  if (!empty($author->node_notify_mailalert) && $author->node_notify_mailalert == 1) {
+    // Notify user of their own comment and their notification options.
+    if ($user->mail == $author->mail) {
+      // Add something to message here or break.
+      if (!(variable_get('comment_notify_author', 0))) {
+        break 3;
+      }
+      else {
+        $text = variable_get('comment_notify_default_author_text', '');
+      }
+    }
+    else {
+      $text = variable_get('node_notify_default_mailtext', AUTHOR_MAILTEXT);
+    }
+    
     // Get the author's language.
     $language = user_preferred_language($author);
     $message['subject'] = t('!site :: new comment for your post.', array('!site' => variable_get('site_name', 'drupal')));
     $message['body'] = t(
-      variable_get('node_notify_default_mailtext', AUTHOR_MAILTEXT),
+      $text,
       array(
         '!commname' => $comment->name,
         '!commtext' => $comment->comment,
@@ -433,7 +474,21 @@ function _comment_notify_mailalert($comm
     if ($alert->notify == COMMENT_NOTIFY_COMMENT && $alert->cid != $comment->pid) {
       continue;
     }
-    if ($mail != $comment_mail && !in_array($mail, $sent_to) && $alert->uid != $comment->uid) {
+    if (!in_array($mail, $sent_to)) {
+      
+      // Notify user of their own comment and their notification options.
+      if ($mail == $comment_mail && $alert->uid == $comment->uid) {
+        if (!(variable_get('comment_notify_author', 0))) {
+          break 3;
+        }
+        else {
+          $text = variable_get('comment_notify_default_author_text', '');
+        }
+      }
+      else {
+        $text = variable_get('comment_notify_default_mailtext', DEFAULT_MAILTEXT);
+      }
+          
       $message = array();
       if (!empty($alert->uid)) {
         $recipient_user = user_load(array('uid' => $alert->uid));
@@ -445,7 +500,7 @@ function _comment_notify_mailalert($comm
 
       $message['subject'] = t('!site :: new comment for your post.', array('!site' => variable_get('site_name', 'drupal')));
       $message['body'] = t(
-        variable_get('comment_notify_default_mailtext', DEFAULT_MAILTEXT),
+        $text,
         array(
           '!commname' => $comment->name,
           '!commtext' => $comment->comment,
@@ -611,32 +666,10 @@ function comment_notify_settings() {
     '#description' => t('This flag presets the flag for the follow-up notification on the form that anon users will see when posting a comment'),
     '#options' => $available_options,
   );
-
-
+      
   $form['comment_notify_settings']['comment_notify_default_mailtext'] = array(
     '#type' => 'textarea',
     '#title' => t('Default mail text for sending out notifications to commenters'),
-    '#description' => t(
-      'You can use the following variables to be replaced:
-      <ul>
-      <li>!commname = the username who posted the comment
-      <li>!commtext = the text of the posted comment
-      <li>!commsubj = the subject of the posted comment
-      <li>!comment_url = the full url of the post and comment - note: if you have paging enabled, this does not work correct - set your max comments per page so that all fit on one page or reverse order them
-      <li>!node_title = the title of the node that was commented on
-      <li>!node_teaser = the teaser of the node that was commented on
-      <li>!node_body = the body of the node that was commented on
-      <li>!mission = site_mission text
-      <li>!name = username receiving the alert
-      <li>!site = your site
-      <li>!uri = base_url of site
-      <li>!uri_brief = base_url of site w/o http
-      <li>!date = the current time
-      <li>!login_uri  uri to login the user
-      <li>!edit_uri = uri to edit user profile
-      <li>!link1 the QUICKLINK to disable future follow-up otifications for the user
-      </ul>'
-    ),
     '#default_value' => variable_get('comment_notify_default_mailtext', t(DEFAULT_MAILTEXT)),
     '#return_value' => 1,
     '#cols' => 80,
@@ -646,7 +679,31 @@ function comment_notify_settings() {
   $form['comment_notify_settings']['node_notify_default_mailtext'] = array(
     '#type' => 'textarea',
     '#title' => t('Default mail text for sending out the notifications to node authors'),
-    '#description' => t(
+    '#default_value' => variable_get('node_notify_default_mailtext', t(AUTHOR_MAILTEXT)),
+     '#return_value' => 1,
+     '#cols' => 80,
+     '#rows' => 15
+  );
+
+
+  $form['comment_notify_settings']['comment_notify_author'] = array(
+    '#type' => 'select',
+    '#title' => t('Mail comment author'),
+    '#description' => t('Choose this option to send an email to the comment author when they create a new comment. This will provide immediate feedback and allow them to opt out.'),
+    '#options' => array(0 => t('No'), 1 => t('Yes')),
+    '#default_value' => variable_get('comment_notify_author', 0),
+    );
+  
+  $form['comment_notify_settings']['comment_notify_default_author_text'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Default mail text for sending out notifications to commenters'),
+    '#default_value' => variable_get('comment_notify_default_author_text', t(DEFAULT_AUTHORTEXT)),
+    '#return_value' => 1,
+    '#cols' => 80,
+    '#rows' => 15
+  );
+    
+  $form['#suffix'] =  t(
       'You can use the following variables to be replaced:
       <ul>
       <li>!commname = the username who posted the comment
@@ -664,14 +721,9 @@ function comment_notify_settings() {
       <li>!date = the current time
       <li>!login_uri  uri to login the user
       <li>!edit_uri = uri to edit user profile
-      </ul>'
-    ),
-    '#default_value' => variable_get('node_notify_default_mailtext', t(AUTHOR_MAILTEXT)),
-     '#return_value' => 1,
-     '#cols' => 80,
-     '#rows' => 15
-  );
-
+      <li>!link1 the QUICKLINK to disable future follow-up otifications for the user
+      </ul>');
+      
   $form['#validate'] = array('comment_notify_settings_validate');
 
   return system_settings_form($form);
