? 308585_comment_notify_pgsql_compliance.patch
? 308585_comment_notify_pgsql_compliance_4.patch
? general.pot
Index: comment_notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_notify/comment_notify.module,v
retrieving revision 1.21
diff -u -p -r1.21 comment_notify.module
--- comment_notify.module 12 Sep 2008 21:46:09 -0000 1.21
+++ comment_notify.module 19 Sep 2008 20:34:12 -0000
@@ -296,69 +296,71 @@ function _comment_notify_mailalert($comm
$comment_mail = $comment->mail;
}
- $result = db_query("SELECT DISTINCT c.cid, u.init, c.uid, c.name, c.nid, c.mail cmail, u.mail umail, u.init uinit, c.uid, c.name, cn.notify_hash mymd5
+ $result = db_query("SELECT DISTINCT c.cid, u.init, c.uid, c.name, c.nid, c.mail AS cmail, u.mail AS umail, u.init uinit, c.uid, c.name, cn.notify_hash mymd5, u.status AS u_status
FROM {comments} c INNER JOIN {comment_notify} cn on c.cid = cn.cid LEFT OUTER JOIN {users} u ON c.uid = u.uid
- WHERE nid = %d AND cn.notify = 1 AND c.status = 0 AND (u.status = 1 or u.status = '')", $nid
+ WHERE nid = %d AND cn.notify = 1 AND c.status = 0", $nid
);
// TODO? the original big query had stuff making sure the mail was populated and contained .+@.+ Perhaps check for that here and set notify = 0 if that is the case for this cid
+ // TODO: this query also used to only allow in users who were active or who were anonymous, but that's moved to php in the loop which may be less efficient but is more cross db compatible...
$count = 0;
$sent_to = array();
while ($alert = db_fetch_object($result)) {
- $umail = empty($alert->umail) ? $alert->uinit : $alert->umail;
- $mail = empty($alert->cmail) ? $umail : $alert->cmail;
+ if (!$alert->u_status === 0) {
+ $umail = empty($alert->umail) ? $alert->uinit : $alert->umail;
+ $mail = empty($alert->cmail) ? $umail : $alert->cmail;
+
+ if ($mail != $comment_mail && !in_array($mail, $sent_to) && $alert->uid != $comment->uid) {
+ $message = array();
+ if (!empty($alert->uid)) {
+ $recipient_user = user_load(array('uid' => $alert->uid));
+ $language = user_preferred_language($recipient_user);
+ }
+ else {
+ $language = language_default();
+ }
+
+ $message['subject'] = t('!site :: new comment for your post.', array('!site' => variable_get('site_name', 'drupal')));
+ $message['body'] = t(
+ variable_get('comment_notify_default_mailtext', DEFAULT_MAILTEXT),
+ array(
+ '!commname' => $comment->name,
+ '!commtext' => $comment->comment,
+ '!commsubj' => $comment->subject,
+ '!comment_url' => url('node/'. $nid, array('absolute' => TRUE)) .'#comment-'. $cid,
+ '!node_title' => $node->title,
+ '!node_teaser' => $node->teaser,
+ '!mission' => variable_get('site_mission', ''),
+ '!node_body' => $node->body,
+ '!name' => $alert->name,
+ '!site' => variable_get('site_name', 'drupal'),
+ '!uri' => $base_url,
+ '!uri_brief' => drupal_substr($base_url, drupal_strlen('http://')),
+ '!date' => format_date(time()),
+ '!login_uri' => url('user', array('absolute' => TRUE)),
+ '!edit_uri' => url('user/'. $alert->uid .'/edit', array('absolute' => TRUE)),
+ '!link1' => url('comment_notify/disable/'. $alert->mymd5, array('absolute' => TRUE))
+ )
+ );
+ drupal_mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);
+ $count++;
+ $sent_to[] = $mail;
+
+ if ($alert->uid != 0) {
+ $watchdog_message = 'Notified: @user_mail';
+ }
+ else {
+ $watchdog_message = 'Notified @user_mail';
+ }
+
+ // Add an entry to the watchdog log.
+ watchdog('comment_notify', $watchdog_message, array('!url' => url('user/'. $alert->uid .'/edit'), '@user_mail' => $mail),
+ WATCHDOG_NOTICE, l(t('source comment'), 'node/'. $nid, array('fragment' => 'comment-'. $alert->cid)));
- if ($mail != $comment_mail && !in_array($mail, $sent_to) && $alert->uid != $comment->uid) {
- $message = array();
- if (!empty($alert->uid)) {
- $recipient_user = user_load(array('uid' => $alert->uid));
- $language = user_preferred_language($recipient_user);
+ // revert to previous (site default) locale
+ $language = $initial_language;
}
- else {
- $language = language_default();
- }
-
- $message['subject'] = t('!site :: new comment for your post.', array('!site' => variable_get('site_name', 'drupal')));
- $message['body'] = t(
- variable_get('comment_notify_default_mailtext', DEFAULT_MAILTEXT),
- array(
- '!commname' => $comment->name,
- '!commtext' => $comment->comment,
- '!commsubj' => $comment->subject,
- '!comment_url' => url('node/'. $nid, array('absolute' => TRUE)) .'#comment-'. $cid,
- '!node_title' => $node->title,
- '!node_teaser' => $node->teaser,
- '!mission' => variable_get('site_mission', ''),
- '!node_body' => $node->body,
- '!name' => $alert->name,
- '!site' => variable_get('site_name', 'drupal'),
- '!uri' => $base_url,
- '!uri_brief' => drupal_substr($base_url, drupal_strlen('http://')),
- '!date' => format_date(time()),
- '!login_uri' => url('user', array('absolute' => TRUE)),
- '!edit_uri' => url('user/'. $alert->uid .'/edit', array('absolute' => TRUE)),
- '!link1' => url('comment_notify/disable/'. $alert->mymd5, array('absolute' => TRUE))
- )
- );
- drupal_mail('comment_notify', 'comment_notify_mail', $mail, $language, $message);
- $count++;
- $sent_to[] = $mail;
-
- if ($alert->uid != 0) {
- $watchdog_message = 'Notified: @user_mail';
- }
- else {
- $watchdog_message = 'Notified @user_mail';
- }
-
- watchdog('comment_notify', $watchdog_message, array('!url' => url('user/'. $alert->uid .'/edit'), '@user_mail' => $mail),
- WATCHDOG_NOTICE, l(t('source comment'), 'node/'. $nid, array('fragment' => 'comment-'. $alert->cid)));
-
- // Add an entry to the watchdog log.
-
- // revert to previous (site default) locale
- $language = $initial_language;
}
}
}