You are here

function subscriptions_content_node_insert in Subscriptions 2.0.x

Same name and namespace in other branches
  1. 7 subscriptions_content.module \subscriptions_content_node_insert()

Implements hook_node_insert().

Auto-subscribes and queues notifications for newly-created nodes.

Parameters

object $node:

bool $inserted:

1 call to subscriptions_content_node_insert()
subscriptions_content_node_update in subscriptions_content/subscriptions_content.module
Implements hook_node_update().

File

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

Code

function subscriptions_content_node_insert($node, $inserted = TRUE) {
  $event = [
    'module' => 'node',
    'uid' => $node->uid,
    'load_function' => 'subscriptions_content_load_node',
    'load_args' => $node->nid,
    'type' => 'node',
    'action' => $inserted ? 'insert' : 'update',
    'is_new' => $inserted,
    'node' => $node,
  ];
  if ($node->uid > 0) {
    _subscriptions_content_autosubscribe($node->type, 'node', 'nid', $node->nid, $inserted ? 'on_post' : 'on_update');
  }
  if ((!isset($node->subscriptions_notify) || $node->subscriptions_notify) && !subscriptions_content_suppress_notifications()) {
    subscriptions_queue($event);
  }
}