Index: notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/notify/notify.module,v
retrieving revision 2.67
diff -u -r2.67 notify.module
--- notify.module	5 Jan 2007 07:53:43 -0000	2.67
+++ notify.module	10 Feb 2007 11:30:08 -0000
@@ -1,6 +1,8 @@
 <?php
 // $Id: notify.module,v 2.67 2007/01/05 07:53:43 robroy Exp $
 
+define('NOTIFY_NODE_TYPE', 'notify_node_type_');
+ 
 /**
  * Implementation of hook_help().
  */
@@ -38,7 +40,15 @@
 
   $form = array();
 
-  $form['notify_send'] = array(
+  $set = 'global';
+  $form[$set] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Global notification settings'),
+    '#collapsible' => true,
+    '#collapsed' => true,
+  );
+    
+  $form[$set]['notify_send'] = array(
     '#type' => 'select',
     '#title' => t('Send notifications every'),
     '#default_value' => variable_get('notify_send', 86400),
@@ -46,13 +56,28 @@
     '#description' => t('How often should new content notifications be sent? Requires cron to be running.'),
   );
 
-  $form['notify_attempts'] = array(
+  $form[$set]['notify_attempts'] = array(
     '#type' => 'select',
     '#title' => t('Number of failed sends after which notifications are disabled'),
     '#default_value' => variable_get('notify_attempts', 5),
     '#options' => array(t('Disabled'), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20),
   );
 
+  $set = 'ntype';
+  $form[$set] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Notification by node type'),
+    '#collapsible' => true,
+    '#collapsed' => false,
+  );
+  foreach(node_get_types() as $type) {
+    $form[$set][NOTIFY_NODE_TYPE . $type->type] = array(
+      '#type' => 'checkbox',
+      '#title' => $type->name,
+      '#return_value' => 1,
+      '#default_value' => variable_get(NOTIFY_NODE_TYPE . $type->type, 0),
+    );
+  }
   return system_settings_form($form);
 }
 
@@ -328,19 +353,32 @@
   // Fetch users with notify enabled
   $uresult = db_query('SELECT u.uid, u.name, u.mail, n.status, n.node, n.teasers, n.comment FROM {notify} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.status = 1 AND u.status = 1 AND n.attempts <= %d', variable_get('notify_attempts', 5));
 
+    // Fetch all node type authorized by notify settings
+    $ntype = array();
+      foreach(node_get_types() as $type) {
+    	if ( variable_get(NOTIFY_NODE_TYPE . $type->type, 0) ) {
+    		$ntype[] = $type->type;
+          }
+          if (count($ntype) >= 1){
+      	    $reqntype = "AND (n.type = '".implode("' OR n.type = '", $ntype)."') ";
+          }else{
+          	$reqntype = "";
+          }
+  	}
+  
   while ($user = db_fetch_object($uresult)) {
     // Switch current user to this account to use node_access functions, etc.
     _notify_switch_user($user->uid);
 
     // Fetch all new nodes and 'load' it to get proper body, etc.
-    $nresult = db_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE (n.status = 1 OR n.moderate = 1) AND n.created > %d AND n.created <= %d ORDER BY n.created'), $period, time());
+    $nresult = db_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE (n.status = 1 OR n.moderate = 1) '.$reqntype.' AND n.created > %d AND n.created <= %d ORDER BY n.created'), $period, time());
     $nodes = array();
     while ($node = db_fetch_object($nresult)) {
       $nodes[$node->nid] = node_load($node->nid);
     }
 
     // Fetch new comments.
-    $cresult = db_query(db_rewrite_sql('SELECT c.nid, c.cid, c.subject, c.name FROM {comments} c WHERE c.status = %d AND c.timestamp > %d AND c.timestamp <= %d ORDER BY c.nid, c.timestamp', 'c'), COMMENT_PUBLISHED, $period, time());
+      $cresult = db_query(db_rewrite_sql('SELECT c.nid, c.cid, c.subject, c.name, n.type FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.status = %d AND c.timestamp > %d AND c.timestamp <= %d '.$reqntype.' ORDER BY c.nid, c.timestamp', 'c'), COMMENT_PUBLISHED, $period, time());
     $comments = array();
     while ($comment = db_fetch_object($cresult)) {
       $comments[$comment->nid][] = $comment;
