function subscriptions_content_comment in Subscriptions 6
Same name and namespace in other branches
- 5.2 subscriptions_content.module \subscriptions_content_comment()
Implementation of hook_comment().
Catch comment inserts and updates and send them to the subscriptions queue.
File
- ./
subscriptions_content.module, line 244 - Subscriptions to content events
Code
function subscriptions_content_comment($comment, $op) {
global $user;
static $is_unpublished;
static $inserted_cid = 0;
$comment = (array) $comment;
// $comment can be an object or an array.
if (!isset($comment['nomail']) && ($op == 'insert' || $op == 'update' || $op == 'publish' && $comment['cid'] != $inserted_cid)) {
$node = node_load($comment['nid']);
if (!isset($comment['subscriptions_notify']) || $comment['subscriptions_notify']) {
$event = array(
'module' => 'node',
'load_function' => 'subscriptions_content_comment_load',
'load_args' => $comment['cid'],
'uid' => $comment['uid'],
'type' => 'comment',
'action' => $op,
'is_new' => $op != 'update' || $is_unpublished && $comment['status'] == COMMENT_PUBLISHED,
'node' => $node,
'comment' => (object) $comment,
);
subscriptions_queue($event);
$inserted_cid = $comment['cid'];
}
_subscriptions_content_autosubscribe($node->type, 'node', 'nid', $comment['nid'], 'on_comment');
}
}