function comment_notify_unsubscribe_by_email in Comment Notify 8
Same name and namespace in other branches
- 7 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 it does not, then it will unsubscribe all anonymous users.
Parameters
string $mail: The mail that is going to be unsubscribed.
Return value
bool TRUE if the comment was unsubscribed correctly.
1 call to comment_notify_unsubscribe_by_email()
- CommentNotifyUnsubscribe::submitForm in src/
Form/ CommentNotifyUnsubscribe.php - Form submission handler.
File
- ./
comment_notify.inc, line 165 - Contains functions which utilize the database and other internal helpers.
Code
function comment_notify_unsubscribe_by_email($mail) {
$comment_query = \Drupal::entityQuery('comment');
if ($user = user_load_by_mail($mail)) {
$comment_query
->condition('uid', $user
->id());
}
else {
$comment_query
->condition('mail', $mail);
}
$comments = $comment_query
->execute();
if (empty($comments)) {
return FALSE;
}
$update_query = \Drupal::database()
->update('comment_notify');
$update_query
->fields([
'notify' => 0,
]);
$update_query
->condition('cid', $comment_query
->execute(), 'IN');
return (bool) $update_query
->execute();
}