? 417542_comment_notify_no_node_setting_for_underprivileged_users.patch
? 486752_users_defaults_not_respected_for_no_mails.patch
? cleanup-comment-notify_0.patch
? comment_notify-array-warning-476526-7.patch
? comment_notify_6x_private.patch
? refactor_to_use_merlins_function.patch
Index: comment_notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/comment_notify.module,v
retrieving revision 1.66
diff -u -p -r1.66 comment_notify.module
--- comment_notify.module	14 Jun 2009 14:55:02 -0000	1.66
+++ comment_notify.module	14 Jun 2009 19:32:50 -0000
@@ -284,13 +284,28 @@ function comment_notify_user($type, &$ed
           '#weight' => 4,
           '#collapsible' => TRUE
         );
-
-        $form['comment_notify_settings']['node_notify_mailalert'] = array(
-          '#type' => 'checkbox',
-          '#title' => t('Receive node follow-up notification e-mails'),
-          '#default_value' => isset($edit['node_notify_mailalert']) ? $edit['node_notify_mailalert'] : FALSE,
-          '#description' => t('Check this box to receive an e-mail notification for follow-ups on your nodes (pages, forum topics, etc). You can not disable notifications for individual threads.')
-        );
+        // Only show the node followup UI if the user has permission to create nodes.
+        $nodes = FALSE;
+        foreach (node_get_types() as $type) {
+          if (user_access('create '. $type->type .' content')) {
+            $nodes = TRUE;
+            break;
+          }
+        }
+        if (user_access('administer nodes') || $nodes) {
+          $form['comment_notify_settings']['node_notify_mailalert'] = array(
+            '#type' => 'checkbox',
+            '#title' => t('Receive node follow-up notification e-mails'),
+            '#default_value' => isset($edit['node_notify_mailalert']) ? $edit['node_notify_mailalert'] : FALSE,
+            '#description' => t('Check this box to receive an e-mail notification for follow-ups on your nodes (pages, forum topics, etc). You can not disable notifications for individual threads.')
+          );
+        }
+        else {
+          $form['comment_notify_settings']['node_notify_mailalert'] = array(
+            '#type' => 'hidden',
+            '#value' => COMMENT_NOTIFY_DISABLED,
+          );
+        }
 
         $available_options[COMMENT_NOTIFY_DISABLED] = t('No notifications');
         $available_options += _comment_notify_options();
@@ -308,10 +323,8 @@ function comment_notify_user($type, &$ed
     case 'submit':
       // Save the values of node_notify_mailalert and comment_notify_mailalert
       // to {comment_notify_user_settings}.
-      if (db_result(db_query('SELECT uid FROM {comment_notify_user_settings} WHERE uid = %d', $user->uid))) {
-        db_query('UPDATE {comment_notify_user_settings} SET node_notify = %d, comment_notify = %d WHERE uid = %d', $edit['node_notify_mailalert'], $edit['comment_notify_mailalert'], $user->uid);
-      }
-      else {
+      db_query('UPDATE {comment_notify_user_settings} SET node_notify = %d, comment_notify = %d WHERE uid = %d', $edit['node_notify_mailalert'], $edit['comment_notify_mailalert'], $user->uid);
+      if (!db_affected_rows()) {
         db_query('INSERT INTO {comment_notify_user_settings} (uid, node_notify, comment_notify) VALUES (%d, %d, %d)', $user->uid, $edit['node_notify_mailalert'], $edit['comment_notify_mailalert']);
       }
 
