You are here

function comment_notify_comment_load in Comment Notify 7

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

Implements hook_comment_load().

File

./comment_notify.module, line 405
This module provides comment follow-up e-mail notification for anonymous and registered users.

Code

function comment_notify_comment_load($comments) {

  // Load some comment_notify specific information into the comment object.
  $query = db_select('comment_notify', 'cn');
  $query
    ->join('comment', 'c', 'c.cid = cn.cid');
  $query
    ->leftJoin('users', 'u', 'c.uid = u.uid');
  $query
    ->condition('c.cid', array_keys($comments));
  $query
    ->fields('cn', array(
    '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;
  }
}