You are here

function subscriptions_content_load_comment in Subscriptions 7

Same name and namespace in other branches
  1. 2.0.x subscriptions_content/subscriptions_content.module \subscriptions_content_load_comment()

Callback function for loading comments.

Function name stored in {subscriptions_queue}.load_func and called by subscriptions_mail().

Parameters

array $subs: The {subscriptions_queue} item.

Return value

bool

4 string references to 'subscriptions_content_load_comment'
subscriptions_content_comment_insert in ./subscriptions_content.module
Implements hook_comment_insert().
subscriptions_content_comment_update in ./subscriptions_content.module
Implements hook_comment_update().
_subscriptions_content_access in ./subscriptions_content.module
Implements _hook_access(), subhook of hook_subscriptions().
_subscriptions_content_load in ./subscriptions_content.notify.inc
Returns a node if published, including any comments that are still queued, but limited by the given subscriptions queue ID.

File

./subscriptions_content.module, line 739
Subscriptions to content events

Code

function subscriptions_content_load_comment(array &$subs) {
  if (module_exists('comment')) {
    $cid = $subs['load_args'];
    $sqid = $subs['sqid'];

    /** @var $nid int */
    if ($nid = db_query('SELECT nid FROM {comment} WHERE cid = :cid', array(
      ':cid' => $cid,
    ))
      ->fetchField()) {
      if ($subs['module'] != 'node' || $subs['field'] != 'nid') {

        // Only if we're processing a node/nid queue item should we cut off
        // the comments at an update item, otherwise not.
        $sqid = NULL;
      }
      _subscriptions_module_load_include('subscriptions_content', 'notify.inc');
      if (($node = _subscriptions_content_load($nid, $sqid)) && !empty($node->_subscriptions_comments)) {
        $subs['object'] = $node;
        return TRUE;
      }
    }
  }
  return FALSE;
}