Index: INSTALL.TXT
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/INSTALL.TXT,v
retrieving revision 1.1.4.1
diff -u -F^f -r1.1.4.1 INSTALL.TXT
--- INSTALL.TXT	19 Aug 2007 21:35:41 -0000	1.1.4.1
+++ INSTALL.TXT	12 Nov 2007 04:28:53 -0000
@@ -1,16 +1,11 @@
-
-
-Installation for drupal 5.x 
+Installation for drupal 5.x
 
 - replace the comment.module with the file comment.module.dp5
   (and please VOTE here http://drupal.org/node/156475
    for getting the comment.module fixed in Drupal 6 or 7 finally)
-  
+
 - enable module in Drupal
 
-- configure the settings for comments, 
-  especially
-  
+- configure the settings for comments, especially
   - comment moderation on/off
   - if users must leave their contact info (set to yet, or how shall we mail them?)
-  
\ No newline at end of file
Index: comment_notify.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/Attic/comment_notify.info,v
retrieving revision 1.1.2.1
diff -u -F^f -r1.1.2.1 comment_notify.info
--- comment_notify.info	19 Aug 2007 21:35:41 -0000	1.1.2.1
+++ comment_notify.info	12 Nov 2007 04:28:53 -0000
@@ -1,7 +1,5 @@
 ; $Id: comment_notify.info,v 1.1.2.1 2007/08/19 21:35:41 christophccemper Exp $
-name = comment Notify
-description = "Comment follup e-mail notification for anonymous as well as reg'ed users. sponsored by <a href=http://www.cemper.com>CEMPER.COM</a> - see it live at <a href=http://www.marketingfan.com>Marketingfan</a> "
+name = Comment Notify
+description = "Comment follow-up e-mail notification for anonymous as well as registered users."
 version = "5.1"
-package = Core - optional
 dependencies = comment
-
Index: comment_notify.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/comment_notify.install,v
retrieving revision 1.1.4.1
diff -u -F^f -r1.1.4.1 comment_notify.install
--- comment_notify.install	19 Aug 2007 21:35:41 -0000	1.1.4.1
+++ comment_notify.install	12 Nov 2007 04:28:53 -0000
@@ -1,6 +1,5 @@
 <?php
 // $Id: comment_notify.install,v 1.1.4.1 2007/08/19 21:35:41 christophccemper Exp $
- 
 
 /**
  * Implementation of hook_install().
@@ -9,15 +8,15 @@ function comment_notify_install() {
   switch ($GLOBALS['db_type']) {
     case 'mysql':
     case 'mysqli':
-     $status[] = db_query("
+      $status[] = db_query("
         ALTER TABLE {comments}
-	      ADD COLUMN `notify` tinyint(1) NOT NULL DEFAULT '1'");
+        ADD COLUMN `notify` tinyint(1) NOT NULL DEFAULT '1'");
       break;
 
     case 'pgsql':
-     $status[] = db_query("
+      $status[] = db_query("
         ALTER TABLE {comments}
-	      ADD COLUMN `notify` tinyint(1) NOT NULL DEFAULT '1'");
+        ADD COLUMN `notify` tinyint(1) NOT NULL DEFAULT '1'");
       break;
   }
   
@@ -31,23 +30,20 @@ function comment_notify_install() {
   else {
     drupal_set_message(t('comment_notify module installed successfully.'));
   }
- 
-   
 }
 
 // Table creation called in update_1 to allow for the case
 // where a user is upgrading from a previous version of
 // the comment_notify module that did not use tables.
 function comment_notify_update_1() {
-    comment_notify_install();
+  comment_notify_install();
 }
 
 // Table creation called in update_1 to allow for the case
 function comment_notify_update_2() {
-
   // Set module weight for my module
   $result  = db_query("UPDATE {system} SET weight = 10 WHERE name = 'comment_notify'");
-  drupal_set_message( $results );
+  drupal_set_message($results);
 
   if ($result) {
     drupal_set_message(t('comment_notify module weight config update successfully.'));
@@ -56,16 +52,15 @@ function comment_notify_update_2() {
     drupal_set_message(t('comment_notify module weight config update unsuccessful.'), 'error');
   }
   
-  $ret[]=$result;
+  $ret[] = $result;
   return $ret;
 }
 
 // modify default mailtext to contain ! instead of % for placeholders
 function comment_notify_update_3() {
-
   // Set module weight for my module
   $result  = db_query("UPDATE {variable} SET value = replace(value, '%', '!') WHERE name = 'comment_notify_default_mailtext'");
-  drupal_set_message( $results );
+  drupal_set_message($results);
 
   if ($result) {
     drupal_set_message(t('comment_notify mail text migration successful.'));
@@ -77,7 +72,3 @@ function comment_notify_update_3() {
   $ret[]=$result;
   return $ret;
 }
-
-
-
-?>
\ No newline at end of file
Index: comment_notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/comment_notify.module,v
retrieving revision 1.1.4.3
diff -u -F^f -r1.1.4.3 comment_notify.module
--- comment_notify.module	3 Nov 2007 12:39:02 -0000	1.1.4.3
+++ comment_notify.module	12 Nov 2007 04:28:54 -0000
@@ -3,73 +3,12 @@
 
 /**
  * @file
- * 
- * This module provides comment follup e-mail notification for anonymous as well as reg'ed users.
- 
- 
-other folks needing this
-
-http://urlgreyhot.com/personal/weblog/anonymous_commenting_in_drupal_4_5_whats_missing
-    no updates since may
-
-http://www.brentrasmussen.com/log/anonymous_user_comments
-
-http://drupal.org/node/64920
-    make signup easier
-        
-http://drupal.org/node/76711
-    => send to subscriptions module
-
-performance for commenting
-    
- http://drupal.org/node/50827
-
-useful threads:
------------------
-
-understanding hooks 
-    http://drupal.org/node/55243
-    for clean plugin-implementation
- 
-The discussion in this thread reflects an opinion that I've held for quite some time now: the hooks system has (almost) no documentation, and it desperately needs more. It is one of the key concepts that any Drupal module developer needs to understand, and it is also quite a unique aspect of Drupal's architecture.
- 
-
-the "comment" hook 
-    http://api.drupal.org/api/4.7/function/hook_comment
-
-
-other related modules that don't do the job
-
-
-commentmail
-    This module is for sending emails to registered users.  It includes a 
-    custom "mail" content type, but can also be used to add emailing to any
-    existing content type. 
-
-
-
-Wishlist:
------------
-
-    asyn mailing
-    
-    for big sites and even nodes with 50+ comment the in-sync mail sending can lead to 
-    a massive delay... so these mails should be put into a notification mail queue table 
-    and sent a bit later via cron... 
-
-
-    move settings to "comments -> configure" instead of modules->comment_notify
-      (more intuitive)
-      
-
-    use of alternative mailer
-    
-        is it required? why for a single notification mail?
-        
+ *
+ * This module provides comment follow-up e-mail notification for anonymous and registered users.
  */
 
-define('DEFAULT_MAILTEXT','
-Hi !name,
+define('DEFAULT_MAILTEXT',
+'Hi !name,
 
 !commname has commented on: "!node_title"
 
@@ -81,24 +20,19 @@
 You can view the comment at the following url
 !comment_url
 
-You can stop receiving emails when someone replies to this blog post, 
+You can stop receiving emails when someone replies to this blog post,
 by going to !link1
 
 If you have auto-blog-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 blog-following feature for all future posts 
+You can set up blog-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 
+Webmaster of !site
 !mission
-!uri 
-
-
----
-This notification is sponsored by http://www.cemper.com
-');
+!uri');
 
 /**
  * Implementation of hook_help().
@@ -106,98 +40,60 @@
 function comment_notify_help($section) {
   switch ($section) {
     case 'admin/modules#description':
-      return t('Comment follup e-mail notification for anonymous as well as reg\'ed users.
-      sponsored by <a href=http://www.cemper.com>CEMPER.COM</a> - see it live at <a href=http://www.marketingfan.com>Marketingfan</a> ');
+      return t('Comment follow-up e-mail notification for anonymous and registered users.');
       break;
   }
 }
 
-/** 
+/**
  * Insert our checkbox, and populate fields.
  * set validation hook.
  */
-function comment_notify_form_alter($form_id, &$form) { 
-
+function comment_notify_form_alter($form_id, &$form) {
   global $user;
-  if ( ($form_id != 'comment_form')) {
-  return;
-  }
 
+  if (($form_id != 'comment_form')) {
+    return;
+  }
 
   $op = isset($_POST['op']) ? $_POST['op'] : '';
 
-  /*
-      if ( $user->comment_notify_mailalert ) {
-  
-      }
-  */
-  
-
   if ($op == t('Preview comment')) {
-      drupal_set_message(
-        t('ATTENTION: your comment is NOT YET posted - please click the post button to confirm your post' )
-        );
-
+    drupal_set_message(t('ATTENTION: Your comment is NOT YET posted - please click the post button to confirm your post'));
 
-/*      $form['submitextra']['privatemsg_allow'] = array(
-          '#type' => 'checkbox',
-          '#title' => t('Allow private messages'),
-          '#default_value' => isset($edit['privatemsg_allow']) ? $edit['privatemsg_allow'] : 1,
-          '#description' => t('Check this box to allow users to send you private messages.')
-          );
-*/
-    #$form['submitextra']['preview'] = array('#type' => 'button', '#value' => t('Preview comment'), '#weight' => -19);
-  
     //extra submit button on top
     if (!form_get_errors() && ((variable_get('comment_preview', COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) || ($op == t('Preview comment')) || ($op == t('Post comment')))) {
       $form['submitextra'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Comment is not posted yet - please click post button to confirm your post'),
-          '#weight' => -99,
-          '#collapsible' => FALSE
-          );
+        '#type' => 'fieldset',
+        '#title' => t('Comment is not posted yet - please click post button to confirm your post'),
+        '#weight' => -99,
+        '#collapsible' => FALSE
+      );
 
       $form['submitextra']['submit'] = array('#type' => 'submit', '#value' => t('Post comment'), '#weight' => -20);
-
     }
-
   }
 
-    
-#  drupal_set_message(' user:'. $user->uid .' setting: '.$user->comment_notify_mailalert );
-#  print_r($user);
-
- //print_r($form);
- 
-
-
-  if ( ($user->uid == 0) || ( variable_get("comment_notify_regged_checkbox", TRUE) ) ) {
+  if (($user->uid == 0) || (variable_get('comment_notify_regged_checkbox', TRUE))) {
     $form['notify'] = array(
       '#type' => 'checkbox',
-      '#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)
-      );
-  } else
-  {
+      '#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)
+    );
+  }
+  else {
     $form['notify'] = array(
-    '#type' => 'hidden',
-    '#title' => t('Mail me updates to this comment.'), 
-    '#default_value' =>
-        $user->comment_notify_mailalert
-     //need user-settings from profile, not global default yes/no 
-     //variable_get("comment_notify_default_anon_mailalert", FALSE)
+      '#type' => 'hidden',
+      '#title' => t('Mail me updates to this comment.'),
+      '#default_value' => $user->comment_notify_mailalert
     );
   }
 
-  if( $form['cid']['#value'] != '' )
-  {
-	 $form['notify']['#default_value'] = $form['#parameters'][1]['notify'];
+  if ($form['cid']['#value'] != '') {
+    $form['notify']['#default_value'] = $form['#parameters'][1]['notify'];
   }
-
 }
 
-
-
 /**
  * Implementation of hook_menu().
  */
@@ -207,34 +103,35 @@ function comment_notify_menu($may_cache)
 
   if ($may_cache) {
     $items[] = array(
-		'path' => 'admin/settings/comment_notify',
-        'title' => t('Comment Notify'),
-        'callback' => 'drupal_get_form',
-		'callback arguments' => array('comment_notify_settings'),
-		'access' => user_access('administer comment_notify'),
-		'type' => MENU_NORMAL_ITEM,
-	);
+      'path' => 'admin/settings/comment_notify',
+      'title' => t('Comment Notify'),
+      'callback' => 'drupal_get_form',
+      'description' => t('Configure settings for e-mails about new comment.'),
+      'callback arguments' => array('comment_notify_settings'),
+      'access' => user_access('administer comment_notify'),
+      'type' => MENU_NORMAL_ITEM,
+    );
   }
   else {
-    $items[] = array('path' => 'comment_notify',
-                     'title' => t('comment notify') ,
-                     'callback' => 'comment_notify_page',
-                     'access'=>1,
-                     'type' => MENU_CALLBACK);
+    $items[] = array(
+      'path' => 'comment_notify',
+      'title' => t('comment notify') ,
+      'callback' => 'comment_notify_page',
+      'access' => 1,
+      'type' => MENU_CALLBACK
+    );
   }
   return $items;
 }
 
-
-
 function comment_notify_page() {
   global $user;
 
   $breadcrumb = NULL;
-  $op = $_POST["op"];
-  $edit = $_POST["edit"];
+  $op = $_POST['op'];
+  $edit = $_POST['edit'];
 
- $page_content=" ";
+  $page_content = ' ';
   if (empty($op)) {
     $op = arg(1);
   }
@@ -242,66 +139,62 @@ function comment_notify_page() {
 
   switch ($op) {
     case 'disable':
-      $key=$arg;
-      db_query("UPDATE {comments} c , users u
-                 SET c.notify = 0 
-               WHERE u.uid=c.uid
-                 AND md5( concat( c.mail,ifnull(u.mail,u.init),c.uid,c.name,c.nid ) ) = '%s'",$arg);
-
+      $key = $arg;
+      db_query("UPDATE {comments} c, users u
+          SET c.notify = 0
+        WHERE u.uid=c.uid
+        AND md5(concat(c.mail, ifnull(u.mail, u.init), c.uid, c.name, c.nid)) = '%s'",
+        $arg
+      );
 
-      drupal_set_message(t("Your comment follow up notification for this post was disabled. Thanks"));
-      $title = t('Disabled comment follow up notification feature for this node');
-      
+      drupal_set_message(t('Your comment follow-up notification for this post was disabled. Thanks.'));
+      $title = t('Disabled comment follow-up notification feature for this post.');
       break;
     default;
       $title = t('Comment Notify');
       break;
   }
+
   drupal_set_title($title);
   drupal_set_breadcrumb($breadcrumb);
-  print theme("page", $page_content);
-    
+  print theme('page', $page_content);
 }
 
-/** 
+/**
  * save our data.
  */
-function comment_notify_validate($form_id, $form_values) { 
+function comment_notify_validate($form_id, $form_values) {
 
   if ($form_values['optin']) {
     foreach (array('optin') as $field) {
       $_SESSION['comment_notify'][$field] = $form_values[$field];
     }
-  } else {
+  }
+  else {
     foreach (array('optin') as $field) {
       unset($_SESSION['comment_notify'][$field]);
     }
   }
 }
 
-/** 
+/**
  * implement comment hook and check the publish status
  */
 function comment_notify_comment($comment, $op) {
   global $user;
 
-  switch($op) {
+  switch ($op) {
 
     case 'publish':
-#      drupal_set_message(t('THE publish hook called').$mail.' '.$name  );
-#      drupal_set_message(t('222Comment is ').$comment->status .' ###'.$comment[cid] .' ###'.$comment[nid].' ##notify me#'.$comment['notify'] );
-     
-      _comment_notify_mailalert2( $comment );
+      _comment_notify_mailalert2($comment);
       break;
-	case 'update':
+  case 'update':
     case 'insert':
-		$sql = "update {comments} set notify = %d where cid = %d";		
-		db_query($sql, $comment['notify'], $comment['cid']);
+    $sql = 'UPDATE {comments} set notify = %d where cid = %d';
+    db_query($sql, $comment['notify'], $comment['cid']);
   }
 }
 
-
-
 /**
  * Implementation of hook_user().
  */
@@ -309,24 +202,24 @@ function comment_notify_user($type, &$ed
   switch ($type) {
 
     case 'form':
-//      if (user_access('access private messages') && $category == 'account') {
-      if ( $category == 'account' ) {
+      if ($category == 'account') {
         $form = array();
         $form['comment_notify_settings'] = array(
-            '#type' => 'fieldset',
-            '#title' => t('Comment follow up notification settings'),
-            '#weight' => 4,
-            '#collapsible' => TRUE
-            );
+          '#type' => 'fieldset',
+          '#title' => t('Comment follow-up notification settings'),
+          '#weight' => 4,
+          '#collapsible' => TRUE
+        );
         $form['comment_notify_settings']['comment_notify_mailalert'] = array(
-            '#type' => 'checkbox',
-            '#title' => t('Receive comment follow-up notification e-mails'),
-            '#default_value' => isset($edit['comment_notify_mailalert']) ? $edit['comment_notify_mailalert'] : 1,
-            '#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.')
-            );
+          '#type' => 'checkbox',
+          '#title' => t('Receive comment follow-up notification e-mails'),
+          '#default_value' => isset($edit['comment_notify_mailalert']) ? $edit['comment_notify_mailalert'] : 1,
+          '#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;
       }
+
       break;
   }
 }
@@ -336,156 +229,126 @@ function _comment_notify_mailalert2($com
   global $base_url;
 
   $initial_locale = $locale;
+
   if (function_exists('locale')) {
     $languages = locale_supported_languages();
     $languages = $languages['name'];
   }
-    $nid = $comment->nid;
-    $cid = $comment->cid;
-    $commname= $comment->name;
-    $commtext= $comment->comment;
-    $commsubj= $comment->subject;
-   
-    
-
-    $node = node_load($nid);
-#    print_r($node);
-
-    $from = variable_get('site_mail', ini_get('sendmail_from'));
-
-
-#   drupal_set_message ("send 1 for $nid");
-
-        
-    $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
-    );
 
-  #      drupal_set_message ("send 2");
-    
-    $count=0;
-    
-    while ($alert = db_fetch_object($result)) 
-	{
-		if( $commname != $alert->name )
-		{
-			if (function_exists('locale') && $languages[$user->language]) 
-			{
-				$locale = $user->language;
-			}
-		
-			$subject = t('!site :: new comment for your post.', array('!site' => variable_get('site_name', 'drupal')));
-			$message = t((variable_get('comment_notify_default_mailtext',DEFAULT_MAILTEXT)),
-		array(
-			'!commname' => $commname,
-			'!commtext' => $commtext,
-			'!commsubj' => $commsubj,
-			'!comment_url' => url('node/'.$nid,NULL,NULL,1)."#comment-".$cid,
-			'!node_title' =>  $node->title,
-			'!node_teaser' => $node->teaser, 
-			'!mission' => variable_get('site_mission', ''), 
-			'!node_body' =>  $node->body, 
-			'!name' => $alert->name, 
-			'!site' => variable_get('site_name', 'drupal'), 
-			'!uri' => $base_url, 
-			'!uri_brief' => substr($base_url, strlen('http://')), 
-			'!date' => format_date(time()), 
-			'!login_uri' => url('user', NULL, NULL, 1), 
-			'!edit_uri' => url('user/'. $alert->uid .'/edit', NULL, NULL, 1),
-			'!link1' => url('comment_notify/disable/'.$alert->mymd5, NULL, NULL, 1)
-			)
-			);
-
-		 
-			$headers = array();
-			
-			drupal_mail('comment_notify_mail',$alert->mail, $subject, $message, $from, $headers);
-			$count++;
-
-			if ( ($alert->uid)!=0 ) 
-			  $mylink =l( $alert->mail , 'user/'. $alert->uid .'/edit') ;
-			else
-			  $mylink =$alert->mail;
-			
-
-			// Add an entry to the watchdog log.
-			watchdog('comment_notify', t('Notify ') . $mylink, 
-			WATCHDOG_NOTICE, l(t('source comment'), 'node/'. $nid, NULL, NULL, 'comment-'. $alert->cid));
-
-			
-			// revert to previous (site default) locale
-			$locale = $initial_locale;
-		}
-   
-  }
-  
-  if( $count > 0 )
-	  drupal_set_message ("Thanks for your comment! I just sent out $count follow-up mail notifications!");
-  
-}
+  $nid = $comment['nid'];
+  $cid = $comment['cid'];
+  $commname = $comment['name'];
+  $commtext = $comment['comment'];
+  $commsubj = $comment['subject'];
+  $node = node_load($nid);
+
+  $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
+  );
+
+  $count = 0;
+  while ($alert = db_fetch_object($result)) {
+    if ($commname != $alert->name) {
+      if (function_exists('locale') && $languages[$user->language]) {
+        $locale = $user->language;
+      }
 
+      $subject = t('!site :: new comment for your post.', array('!site' => variable_get('site_name', 'drupal')));
+      $message = t((variable_get('comment_notify_default_mailtext', DEFAULT_MAILTEXT)),
+                    array(
+                      '!commname' => $commname,
+                      '!commtext' => $commtext,
+                      '!commsubj' => $commsubj,
+                      '!comment_url' => url('node/'. $nid, NULL, NULL, 1) .'#comment-'. $cid,
+                      '!node_title' =>  $node->title,
+                      '!node_teaser' => $node->teaser,
+                      '!mission' => variable_get('site_mission', ''),
+                      '!node_body' =>  $node->body,
+                      '!name' => $alert->name,
+                      '!site' => variable_get('site_name', 'drupal'),
+                      '!uri' => $base_url,
+                      '!uri_brief' => substr($base_url, strlen('http://')),
+                      '!date' => format_date(time()),
+                      '!login_uri' => url('user', NULL, NULL, 1),
+                      '!edit_uri' => url('user/'. $alert->uid .'/edit', NULL, NULL, 1),
+                      '!link1' => url('comment_notify/disable/'. $alert->mymd5, NULL, NULL, 1)
+                    )
+      );
 
+      drupal_mail('comment_notify_mail', $alert->mail, $subject, $message, $from, array());
+      $count++;
 
-function comment_notify_settings() {
-  $form['comment_notify_settings'] = array();
+      if (($alert->uid) != 0) {
+        $mylink =l($alert->mail , 'user/'. $alert->uid .'/edit');
+      }
+      else {
+        $mylink =$alert->mail;
+      }
 
-  $form['comment_notify_settings']['comment_notify_background_mail'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Send notification mails in background (yet to be implemented/future use)'),
-      '#return_value' => 1,
-      '#default_value' => variable_get('comment_notify_background_mail', 0),
-      '#description' => t('for big sites and even nodes with 50+ comment the in-sync mail sending can lead to 
-    a massive delay... so these mails will be put into a notification queue and sent a bit later via cron.')
-      );
+      // Add an entry to the watchdog log.
+      watchdog('comment_notify', t('Notify ') . $mylink,
+      WATCHDOG_NOTICE, l(t('source comment'), 'node/'. $nid, NULL, NULL, 'comment-'. $alert->cid));
 
+      // revert to previous (site default) locale
+      $locale = $initial_locale;
+    }
+  }
+}
+
+function comment_notify_settings() {
+  $form['comment_notify_settings'] = array();
   $form['comment_notify_settings']['comment_notify_regged_checkbox'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Let registered users select notification on a node basis'),
-      '#return_value' => 1,
-      '#default_value' => variable_get('comment_notify_regged_checkbox', TRUE),
-      '#description' => t('letting registered users select/unselect if they want to be notified. If this is disabled, this setting is propagated from their user profile, hence reducing and clutter and confusion')
-      );
+    '#type' => 'checkbox',
+    '#title' => t('Let registered users select notification on a node basis'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('comment_notify_regged_checkbox', TRUE),
+    '#description' => t('letting registered users select/unselect if they want to be notified. If this is disabled, this setting is propagated from their user profile, hence reducing and clutter and confusion')
+  );
 
   $form['comment_notify_settings']['comment_notify_default_anon_mailalert'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Fill checkbox for followup 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'),
-      '#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')
-      );
+    '#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'),
+    '#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_default_mailtext'] = array(
-      '#type' => 'textarea',
-      '#title' => t('Default mail text for sending out the notifications.'),
-      '#description' => t("You can use the following variables to be replaced 
+    '#type' => 'textarea',
+    '#title' => t('Default mail text for sending out the notifications.'),
+    '#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,
-      '#rows' => 15
-      );
+      <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,
+    '#rows' => 15
+  );
 
   return system_settings_form($form);
 }
-
