--- notify_orig.module	2007-01-05 02:53:43.000000000 -0500
+++ notify.module	2007-03-27 15:50:03.000000000 -0400
@@ -53,6 +53,34 @@ function notify_admin_settings() {
     '#options' => array(t('Disabled'), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20),
   );
 
+  $form['notify_page_master'] = array('#type' => 'fieldset', '#title' => t('Master switch'));
+  $form['notify_page_master']['notify_default_receive'] = array('#type' => 'radios',
+    '#title' => t('Notify status'),
+    '#default_value' => variable_get('notify_default_receive', 'Enabled'),
+    '#options' =>  array(t('Disabled'), t('Enabled')),
+    '#description' => t('Have new users receive notifications by default?'),
+  );
+
+  $form['notify_page_detailed'] = array('#type' => 'fieldset', '#title' => t('Detailed settings'));
+  $form['notify_page_detailed']['notify_default_node'] = array('#type' => 'radios',
+    '#title' => t('Notify new content'),
+    '#default_value' => variable_get('notify_default_node', t('Enabled')),
+    '#options' => array(t('Disabled'), t('Enabled')),
+    '#description' => t('Include new content in the notification mail.'),
+  );
+  $form['notify_page_detailed']['notify_default_teasers'] = array('#type' => 'radios',
+    '#title' => t('Content'),
+    '#default_value' => variable_get('notify_default_teasers', 'Title + Teaser'),
+    '#options' => array(t('Title only'), t('Title + Teaser'), t('Title + Body')),
+    '#description' => t('Select the amount of each post that you would like to see in the notification e-mails.'),
+  );
+  $form['notify_page_detailed']['notify_default_comments'] = array('#type' => 'radios',
+    '#title' => t('Notify new comments'),
+    '#default_value' => variable_get('notify_default_comments', 'Disabled'),
+    '#options' => array(t('Disabled'), t('Enabled')),
+    '#description' => t('Include new comments in the notification mail.'),
+  );
+
   return system_settings_form($form);
 }
 
@@ -74,6 +102,20 @@ function notify_user($type, &$edit, &$us
     case 'delete':
       db_query('DELETE FROM {notify} WHERE uid = %d', $user->uid);
       break;
+    case 'register':
+	  $form['notify_page_master'] = array('#type' => 'fieldset', '#title' => t('Content Email Notifications'));
+	  $form['notify_page_master']['status'] = array('#type' => 'checkboxes',
+		'#title' => t('Notify status'),
+		'#default_value' => variable_get('notify_receive', 'Enabled'),
+		'#options' =>  array(1 => t('Keep me information of new content on this site')),
+		'#description' => t('Do you wish to receive periodic e-mails when new content is posted?'),
+	  );
+      return $form;
+      break;
+    case 'insert':
+	  db_query('INSERT INTO {notify} (uid, status) VALUES (%d, %d)', $edit['uid'], $edit['notify_receive']);
+	  drupal_set_message(t('Notify settings saved.'));
+      break;
   }
 }
 
@@ -81,7 +123,7 @@ function notify_user($type, &$edit, &$us
  * Implementation of hook_perm().
  */
 function notify_perm() {
-  return array('access notify', 'administer notify');
+  return array('access notify', 'configure own notifications', 'administer notify');
 }
 
 /**
@@ -157,26 +199,29 @@ function notify_user_settings_form($uid 
       '#options' =>  array(t('Disabled'), t('Enabled')),
       '#description' => t('Do you wish to receive periodic e-mails when new content is posted?'),
     );
+    
+    if (user_access('configure own notifications')) {
 
-    $form['notify_page_detailed'] = array('#type' => 'fieldset', '#title' => t('Detailed settings'));
-    $form['notify_page_detailed']['node'] = array('#type' => 'radios',
-      '#title' => t('Notify new content'),
-      '#default_value' => $notify->node,
-      '#options' => array(t('Disabled'), t('Enabled')),
-      '#description' => t('Include new content in the notification mail.'),
-    );
-    $form['notify_page_detailed']['teasers'] = array('#type' => 'radios',
-      '#title' => t('Content'),
-      '#default_value' => $notify->teasers,
-      '#options' => array(t('Title only'), t('Title + Teaser'), t('Title + Body')),
-      '#description' => t('Select the amount of each post that you would like to see in your notification e-mails.'),
-    );
-    $form['notify_page_detailed']['comment'] = array('#type' => 'radios',
-      '#title' => t('Notify new comments'),
-      '#default_value' => $notify->comment,
-      '#options' => array(t('Disabled'), t('Enabled')),
-      '#description' => t('Include new comments in the notification mail.'),
-    );
+	  $form['notify_page_detailed'] = array('#type' => 'fieldset', '#title' => t('Detailed settings'));
+	  $form['notify_page_detailed']['node'] = array('#type' => 'radios',
+		'#title' => t('Notify new content'),
+		'#default_value' => $notify->node,
+		'#options' => array(t('Disabled'), t('Enabled')),
+		'#description' => t('Include new content in the notification mail.'),
+	  );
+	  $form['notify_page_detailed']['teasers'] = array('#type' => 'radios',
+		'#title' => t('Content'),
+		'#default_value' => $notify->teasers,
+		'#options' => array(t('Title only'), t('Title + Teaser'), t('Title + Body')),
+		'#description' => t('Select the amount of each post that you would like to see in your notification e-mails.'),
+	  );
+	  $form['notify_page_detailed']['comment'] = array('#type' => 'radios',
+		'#title' => t('Notify new comments'),
+		'#default_value' => $notify->comment,
+		'#options' => array(t('Disabled'), t('Enabled')),
+		'#description' => t('Include new comments in the notification mail.'),
+	  );
+    }
     $form['uid'] = array('#type' => 'value', '#value' => $account->uid);
     $form['submit'] = array('#type' => 'submit', '#value' => t('Save settings'));
   }
@@ -327,8 +372,19 @@ function _notify_send() {
 
   // 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));
+  $notify_defaults = array(
+    'node' => variable_get('notify_default_node', 'Enabled'),
+    'teasers' => variable_get('notify_default_teasers', 'Title + Teaser'),
+    'comment' => variable_get('notify_default_comments', 'Disabled'),
+  );
 
   while ($user = db_fetch_object($uresult)) {
+    foreach ($notify_defaults as $default_key => $default_val) {
+      if (empty($user->$default_key)) {
+        $user->$default_key = $default_val;
+      }
+    }
+    
     // Switch current user to this account to use node_access functions, etc.
     _notify_switch_user($user->uid);
 
