Index: comment_notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/comment_notify.module,v
retrieving revision 1.73.2.3
diff -u -r1.73.2.3 comment_notify.module
--- comment_notify.module	10 Mar 2010 22:29:40 -0000	1.73.2.3
+++ comment_notify.module	18 May 2010 16:29:41 -0000
@@ -407,29 +432,30 @@
 
     // Get the author's language.
     $language = user_preferred_language($author);
+    // Build the substitution array.
+    $my_tokens = array(
+      '!cid' => $cid,
+      '!commname' => $comment->name,
+      '!commtext' => drupal_html_to_text($comment_text),
+      '!commsubj' => $comment->subject,
+      '!comment_url' => url('node/'. $nid, array('absolute' => TRUE, 'fragment' => 'comment-'. $cid)),
+      '!node_title' => $node->title,
+      '!node_teaser' => drupal_html_to_text($node_teaser),
+      '!node_truncated' => drupal_html_to_text($node_truncated),
+      '!mission' => variable_get('site_mission', ''),
+      '!nid' =>  $nid,
+      '!node_body' => drupal_html_to_text($node_body),
+      '!name' => (isset($author->realname) ? $author->realname: $author->name),
+      '!site' => variable_get('site_name', 'drupal'),
+      '!uri' => $base_url,
+      '!uri_brief' => preg_replace('!^https?://!', '', $base_url),
+      '!date' => format_date(time()),
+      '!login_uri' => url('user', array('absolute' => TRUE)),
+      '!edit_uri' => url('user/'. $author->uid .'/edit', array('absolute' => TRUE))
+      );
+    // Build the message.
     $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),
-      array(
-        '!cid' => $cid,
-        '!commname' => $comment->name,
-        '!commtext' => drupal_html_to_text($comment_text),
-        '!commsubj' => $comment->subject,
-        '!comment_url' => url('node/'. $nid, array('absolute' => TRUE, 'fragment' => 'comment-'. $cid)),
-        '!node_title' =>  $node->title,
-        '!node_teaser' => drupal_html_to_text($node_teaser),
-        '!mission' => variable_get('site_mission', ''),
-        '!nid' =>  $nid,
-        '!node_body' =>  drupal_html_to_text($node_body),
-        '!name' => $author->name,
-        '!site' => variable_get('site_name', 'drupal'),
-        '!uri' => $base_url,
-        '!uri_brief' => preg_replace('!^https?://!', '', $base_url),
-        '!date' => format_date(time()),
-        '!login_uri' => url('user', array('absolute' => TRUE)),
-        '!edit_uri' => url('user/'. $author->uid .'/edit', array('absolute' => TRUE))
-      )
-    );
+    $message['body'] = t(variable_get('node_notify_default_mailtext', AUTHOR_MAILTEXT), $my_tokens);
     drupal_mail('comment_notify', 'comment_notify_mail', $author->mail, $language, $message);
     $sent_to[] = $author->mail;
   }
@@ -468,29 +497,14 @@
       }
 
       $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),
-        array(
-          '!cid' => $cid,
-          '!commname' => $comment->name,
-          '!commtext' => drupal_html_to_text($comment_text),
-          '!commsubj' => $comment->subject,
-          '!comment_url' => url('node/'. $nid, array('absolute' => TRUE, 'fragment' => 'comment-'. $cid)),
-          '!node_title' =>  $node->title,
-          '!node_teaser' => drupal_html_to_text($node_teaser),
-          '!mission' => variable_get('site_mission', ''),
-          '!nid' =>  $nid,
-          '!node_body' =>  drupal_html_to_text($node_body),
-          '!name' => $alert->name,
-          '!site' => variable_get('site_name', 'drupal'),
-          '!uri' => $base_url,
-          '!uri_brief' => preg_replace('!^https?://!', '', $base_url),
-          '!date' => format_date(time()),
-          '!login_uri' => url('user', array('absolute' => TRUE)),
-          '!edit_uri' => url('user/'. $alert->uid .'/edit', array('absolute' => TRUE)),
-          '!link1' => url('comment_notify/disable/'. $alert->notify_hash, array('absolute' => TRUE))
-        )
-      );
+      // Mail text template depends on whether user is anonymous or authenticated.
+      $mailtext = $user->uid ? variable_get('comment_notify_default_mailtext', DEFAULT_MAILTEXT) : variable_get('comment_notify_default_mailtext_anonymous', ANONYMOUS_MAILTEXT);
+
+      // Add registration and unsubscribe tokens.
+      $my_tokens['!uri_register'] = url('user/register', array('absolute' => TRUE));
+      $my_tokens['!link1'] = url('comment_notify/disable/'. $alert->notify_hash, array('absolute' => TRUE));
+
+      $message['body'] = t($mailtext, $my_tokens);
       drupal_mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);
       $sent_to[] = $mail;
 
@@ -643,68 +657,57 @@
     '#description' => t('If this is checked, new users will receive e-mail notifications for follow-ups on their nodes by default until they individually disable the feature.'),
   );
 
-
+  $token_items = array(
+    '!cid = the comment id for the comment',
+    '!commname = the username who posted the comment',
+    '!commtext = the text of the posted comment',
+    '!commsubj = the subject of the posted comment',
+    '!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',
+    '!nid = the node id the comment was posted on',
+    '!node_title = the title of the node that was commented on',
+    '!node_teaser = the teaser of the node that was commented on',
+    '!node_body = the body of the node that was commented on',
+    '!node_truncated = the shortened version of the node that was commented on, with trailing dots',
+    '!mission = site_mission text',
+    '!name = username receiving the alert',
+    '!site = your site',
+    '!uri = base_url of site',
+    '!uri_brief = base_url of site w/o http',
+    '!date = the current time',
+    '!login_uri  uri to login the user',
+    '!edit_uri = uri to edit user profile',
+    '!link1 the QUICKLINK to disable future follow-up notifications for the user',
+    );
   $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>!cid = the comment id for the comment</li>
-      <li>!commname = the username who posted the comment</li>
-      <li>!commtext = the text of the posted comment</li>
-      <li>!commsubj = the subject of the posted comment</li>
-      <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>
-      <li>!nid = the node id the comment was posted on</li>
-      <li>!node_title = the title of the node that was commented on</li>
-      <li>!node_teaser = the teaser of the node that was commented on</li>
-      <li>!node_body = the body of the node that was commented on</li>
-      <li>!mission = site_mission text</li>
-      <li>!name = username receiving the alert</li>
-      <li>!site = your site</li>
-      <li>!uri = base_url of site</li>
-      <li>!uri_brief = base_url of site w/o http</li>
-      <li>!date = the current time</li>
-      <li>!login_uri  uri to login the user</li>
-      <li>!edit_uri = uri to edit user profile</li>
-      <li>!link1 the QUICKLINK to disable future follow-up notifications for the user</li>
-      </ul>'
-    ),
+    '#title' => t('Default mail text for sending out notifications to authenicated commenters'),
+    '#description' => t('You can use the following variables to be replaced:' . theme('item_list', $token_items)),
     '#default_value' => variable_get('comment_notify_default_mailtext', t(DEFAULT_MAILTEXT)),
     '#return_value' => 1,
     '#cols' => 80,
     '#rows' => 15
   );
 
+  $token_items[] = '!uri_register = uri to register a new user account';
+
+  $form['comment_notify_settings']['comment_notify_default_mailtext_anonymous'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Default mail text for sending out notifications to anonymous commenters'),
+    '#description' => t('You can use the following variables to be replaced:' . theme('item_list', $token_items)),
+    '#default_value' => variable_get('comment_notify_default_mailtext_anonymous', t(ANONYMOUS_MAILTEXT)),
+    '#return_value' => 1,
+    '#cols' => 80,
+    '#rows' => 15
+  );
+
   $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(
-      'You can use the following variables to be replaced:
-      <ul>
-      <li>!cid = the comment id for the comment</li>
-      <li>!commname = the username who posted the comment</li>
-      <li>!commtext = the text of the posted comment</li>
-      <li>!commsubj = the subject of the posted comment</li>
-      <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>
-      <li>!nid = the node id the comment was posted on</li>
-      <li>!node_title = the title of the node that was commented on</li>
-      <li>!node_teaser = the teaser of the node that was commented on</li>
-      <li>!node_body = the body of the node that was commented on</li>
-      <li>!mission = site_mission text</li>
-      <li>!name = username receiving the alert</li>
-      <li>!site = your site</li>
-      <li>!uri = base_url of site</li>
-      <li>!uri_brief = base_url of site w/o http</li>
-      <li>!date = the current time</li>
-      <li>!login_uri  uri to login the user</li>
-      <li>!edit_uri = uri to edit user profile</li>
-      </ul>'
-    ),
+    '#description' => t('You can use the following variables to be replaced:' . theme('item_list', $token_items)),
     '#default_value' => variable_get('node_notify_default_mailtext', t(AUTHOR_MAILTEXT)),
-     '#return_value' => 1,
-     '#cols' => 80,
-     '#rows' => 15
+    '#return_value' => 1,
+    '#cols' => 80,
+    '#rows' => 15
   );
 
   $form['#validate'] = array('comment_notify_settings_validate');

