Commit 37be47c6 authored by greggles's avatar greggles

Issue #539214 by burgs, greggles: Subscribe/Unsubscribe should be by node, not...

Issue #539214 by burgs, greggles: Subscribe/Unsubscribe should be by node, not by comment if the subscription is to all comments
parent 1e08a8ea
......@@ -251,7 +251,7 @@ function comment_notify_unsubscribe_by_email($mail) {
}
/**
* Unsubscribe all comment notification requests associated with a hash.
* Unsubscribe comment notification requests associated with a hash.
*
* This is used in the unsubscribe link.
*
......@@ -259,12 +259,43 @@ function comment_notify_unsubscribe_by_email($mail) {
* @return boolean
*/
function comment_notify_unsubscribe_by_hash($hash) {
return (bool)db_update('comment_notify')
->fields(array(
'notify' => 0,
))
$notification = db_select('comment_notify')
->fields('comment_notify')
->condition('notify_hash', $hash)
->execute()->fetchAll();
// If this notification is at the node level, delete all notifications for this node.
if (COMMENT_NOTIFY_NODE == $notification[0]->notify) {
// Get all this user's comments for this node.
$result = db_query("SELECT c.cid
FROM {comment} c, (
SELECT oc.nid, oc.uid
FROM {comment} AS oc, comment_notify AS ocn
WHERE oc.cid = ocn.cid
AND ocn.notify_hash = :hash
) AS o
WHERE o.nid = c.nid
AND o.uid = c.uid", array(':hash' => $hash));
$cids = $result->fetchCol();
// Update all comment notifications to be disabled.
return (bool)db_update('comment_notify')
->fields(array(
'notify' => 0,
))
->condition('cid', $cids, 'IN')
->execute();
}
else {
// Update this notification to be disabled.
return (bool)db_update('comment_notify')
->fields(array(
'notify' => 0,
))
->condition('notify_hash', $hash)
->execute();
}
}
/**
......
......@@ -211,12 +211,11 @@ function comment_notify_menu() {
function comment_notify_disable_page($hash) {
module_load_include('inc', 'comment_notify', 'comment_notify');
if (comment_notify_unsubscribe_by_hash($hash)) {
drupal_set_message(t('Your comment follow-up notification for this post was disabled. Thanks.'));
return(t('Your comment follow-up notification for this post was disabled. Thanks.'));
}
else {
drupal_set_message(t('Sorry, there was a problem unsubscribing from notifications.'));
return(t('Sorry, there was a problem unsubscribing from notifications.'));
}
return ' ';
}
function comment_notify_comment_validate($comment) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment