? notify-unpublished-content-and-only-new-content.patch
? notify-unpublished-content.patch
Index: notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/notify/notify.module,v
retrieving revision 2.78
diff -u -p -r2.78 notify.module
--- notify.module	23 Jun 2009 23:38:12 -0000	2.78
+++ notify.module	3 Apr 2010 02:47:51 -0000
@@ -22,6 +22,8 @@ function notify_help($section) {
  */
 function notify_admin_settings() {
   $period = array(
+    300         => format_interval(300),
+    600         => format_interval(600),
     900         => format_interval(900),
     1800        => format_interval(1800),
     3600        => format_interval(3600),
@@ -84,6 +86,19 @@ function notify_admin_settings() {
     '#collapsed' => false,
     '#description' => 'Having nothing checked defaults to sending notifications about all node types.'
   );
+    $form['notify_settings']['notify_process_unpublished_content'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Process unpublish content'),
+    '#default_value' =>  variable_get('notify_process_unpublished_content',0),
+    '#description' => t('Enable to process unpublished content to notify.')
+  );
+  
+  $form['notify_settings']['notify_process_only_new_content'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Process only new content'),
+    '#default_value' =>  variable_get('notify_process_only_new_content',0),
+    '#description' => t('Enable to process only new content, changes in content will be ignored.')
+  );
   
   foreach (node_get_types('types', array()) as $type => $object) {
     $form[$set][NOTIFY_NODE_TYPE . $type] = array(
@@ -444,9 +459,22 @@ function _notify_send() {
   while ($user = db_fetch_object($uresult)) {
     // Switch current user to this account to use node_access functions, etc.
     _notify_switch_user($user->uid);
-
+	if(variable_get('notify_process_unpublished_content',0)){
+		$WhereClauseNodes=" (1=1) ";// see that $reqntype  could have and AND so it can't be empty/
+		$WhereClauseComments=" c.status = ". COMMENT_PUBLISHED. ' OR c.status = '.COMMENT_NOT_PUBLISHED .' ' ;
+	}else{
+		$WhereClauseNodes=" (n.status = 1 OR n.moderate = 1) ";//use precaution spaces
+		$WhereClauseComments=" c.status = ". COMMENT_PUBLISHED. ' ';
+	}
+	
+	//Check only new content variable
+    if(variable_get('notify_process_only_new_content',0)){
+		$WhereClauseNodes=" (n.created = n.changed) ";
+	}	
+	
     // 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) '. $reqntype . ' AND ((n.created > %d AND n.created <= %d) OR (n.changed > %d AND n.changed <= %d)) ORDER BY n.created'), $period, time(), $period, time());
+   $cbtime=time();
+    $nresult = db_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE '. $WhereClauseNodes . $reqntype . ' AND ((n.created > %d AND n.created <= %d) OR (n.changed > %d AND n.changed <= %d)) ORDER BY n.created'), $period, $cbtime, $period, $cbtime);
     $nodes = array();
     while ($node = db_fetch_object($nresult)) {
       $nodes[$node->nid] = node_load($node->nid);
@@ -455,7 +483,7 @@ function _notify_send() {
     // Fetch new comments.
     $comments = array();
     if (module_exists('comment')) {
-        $cresult = db_query(db_rewrite_sql('SELECT c.nid, c.cid, c.subject, c.name FROM {comments} c INNER JOIN {node} n ON c.nid = n.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());
+    $cresult = db_query(db_rewrite_sql('SELECT c.nid, c.cid, c.subject, c.name FROM {comments} c INNER JOIN {node} n ON c.nid = n.nid WHERE '.$WhereClauseComments.' AND c.timestamp > %d AND c.timestamp <= %d '. $reqntype . ' ORDER BY c.nid, c.timestamp', 'c'), $period, time());
         while ($comment = db_fetch_object($cresult)) {
           $comments[$comment->nid][] = $comment;
         }

