You are here

function comment_notify_comment_load in Comment Notify 8

Same name and namespace in other branches
  1. 7 comment_notify.module \comment_notify_comment_load()

Implements hook_comment_load().

File

./comment_notify.module, line 346
This module provides comment follow-up e-mail notifications.

Code

function comment_notify_comment_load($comments) {

  // Load some comment_notify specific information into the comment object.
  $query = \Drupal::database()
    ->select('comment_notify', 'cn');
  $query
    ->join('comment_field_data', 'c', 'c.cid = cn.cid');
  $query
    ->leftJoin('users_field_data', 'u', 'c.uid = u.uid');
  $query
    ->condition('c.cid', array_keys($comments), 'IN');
  $query
    ->fields('cn', [
    'cid',
    'notify',
    'notify_hash',
    'notified',
  ]);
  $query
    ->addField('c', 'mail', 'cmail');
  $query
    ->addField('u', 'init', 'uinit');
  $query
    ->addField('u', 'mail', 'umail');
  $records = $query
    ->execute()
    ->fetchAllAssoc('cid');
  foreach ($records as $cid => $record) {
    $comments[$cid]->notify = $record->notify;
    $comments[$cid]->notify_type = $record->notify;
    $comments[$cid]->notify_hash = $record->notify_hash;
    $comments[$cid]->notified = $record->notified;
    $comments[$cid]->cmail = $record->cmail;
    $comments[$cid]->uinit = $record->uinit;
    $comments[$cid]->umail = $record->umail;
  }
}