You are here

function subscriptions_content_load_comment in Subscriptions 2.0.x

Same name and namespace in other branches
  1. 7 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/subscriptions_content.module
Implements hook_comment_insert().
subscriptions_content_comment_update in subscriptions_content/subscriptions_content.module
Implements hook_comment_update().
_subscriptions_content_access in subscriptions_content/subscriptions_content.module
Implements _hook_access(), subhook of hook_subscriptions().
_subscriptions_content_load in subscriptions_content/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/subscriptions_content.module, line 744
Subscriptions to content events.

Code

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

    /** @var int $nid */
    if ($nid = db_query('SELECT nid FROM {comment} WHERE cid = :cid', [
      ':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;
}