--- notify.5.x-1.3.module	2009-03-20 12:07:11.000000000 -0700
+++ notify.5.x-1.3-patch.module	2009-06-02 08:57:46.389940400 -0700
@@ -1,5 +1,5 @@
 <?php
-// $Id: notify.module,v 2.67.2.5 2009/03/20 19:07:11 matt2000 Exp $
+// $Id: notify.module,v 2.x 2009/02/30 22:20:00 waddink Exp $
 
 /**
  * Implementation of hook_help().
@@ -20,6 +20,8 @@ function notify_help($section) {
  */
 function notify_admin_settings() {
   $period = array(
+    60          => format_interval(60), 
+    300          => format_interval(300),
     900         => format_interval(900),
     1800        => format_interval(1800),
     3600        => format_interval(3600),
@@ -95,7 +97,7 @@ function notify_user($type, &$edit, &$us
  * Implementation of hook_perm().
  */
 function notify_perm() {
-  return array('access notify', 'administer notify');
+  return array('access notify', 'administer notify','notify unpublished nodes','notify published nodes','notify unpublished comments','notify published comments');
 }
 
 /**
@@ -153,7 +155,7 @@ function notify_menu($may_cache) {
  */
 function notify_user_settings_form($uid = 0) {
   global $user;
-  if ($user->uid != $uid && !user_access('administer notify')) {
+  if ($user->uid != $uid && $user->uid != 1) {
     drupal_access_denied();
     return;
   }
@@ -368,19 +370,35 @@ function _notify_send() {
     _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());
-    $nodes = array();
-    while ($node = db_fetch_object($nresult)) {
-      $nodes[$node->nid] = node_load($node->nid);
+     $nodes = array();
+    if(user_access('notify published nodes')){
+        $pubresult = 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());
+        while ($node = db_fetch_object($pubresult)) {
+          $nodes[$node->nid] = node_load($node->nid);
+        }  
+    }
+    if(user_access('notify unpublished nodes')){
+        $unpubresult = db_query(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.status <> 1 AND n.moderate <> 1 AND n.created > %d AND n.created <= %d ORDER BY n.created'), $period, time());
+         while ($node = db_fetch_object($unpubresult)) {
+           $nodes[$node->nid] = node_load($node->nid);
+         }
     }
+    //$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());
 
     // 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());
-    $comments = array();
-    while ($comment = db_fetch_object($cresult)) {
+ $comments = array();
+ if(user_access('notify published comments')){
+   $pbresult = 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());
+    while ($comment = db_fetch_object($pbresult)) {
       $comments[$comment->nid][] = $comment;
     }
-
+ }
+ if(user_access('notify unpublished comments')){
+   $unpresult = 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'), $period, time());
+    while ($comment = db_fetch_object($unpresult)) {
+      $comments[$comment->nid][] = $comment;
+    } 
+ }
     $node_body = '';
     $comment_body = '';
 
