You are here

function comment_notify_unsubscribe_by_email in Comment Notify 7

Same name and namespace in other branches
  1. 8 comment_notify.inc \comment_notify_unsubscribe_by_email()

Unsubscribe all comment notification requests associated with an email.

If the email belongs to a user, it will unsubscribe all of their Comment Notify records. If not it will unsubscribe all anonymous users.

Parameters

string $mail: An email address to unsubscribe.

Return value

bool TRUE on success, otherwise false.

1 call to comment_notify_unsubscribe_by_email()
comment_notify_unsubscribe_submit in ./comment_notify.module
Based on admin submit, do the actual unsubscribe from notifications.

File

./comment_notify.inc, line 247
Contains functions which utilize the database and other internal helpers.

Code

function comment_notify_unsubscribe_by_email($mail) {
  $update_query = db_update('comment_notify');
  $update_query
    ->fields(array(
    'notify' => 0,
  ));
  $comment_query = db_select('comment', 'c');
  $comment_query
    ->fields('c', array(
    'cid',
  ));
  $uid = db_select('users', 'u')
    ->fields('u', array(
    'uid',
  ))
    ->condition('mail', $mail)
    ->execute()
    ->fetchField();
  if ($uid) {
    $comment_query
      ->condition('uid', $uid);
  }
  else {
    $comment_query
      ->condition('mail', $mail);
  }
  $update_query
    ->condition('cid', $comment_query, 'IN');
  return (bool) $update_query
    ->execute();
}