You are here

function notifications_content_nodeapi in Notifications 5

Same name and namespace in other branches
  1. 6.4 notifications_content/notifications_content.module \notifications_content_nodeapi()
  2. 6 notifications_content/notifications_content.module \notifications_content_nodeapi()
  3. 6.2 notifications_content/notifications_content.module \notifications_content_nodeapi()
  4. 6.3 notifications_content/notifications_content.module \notifications_content_nodeapi()

Implementation of hook_nodeapi()

File

notifications_content/notifications_content.module, line 442
Subscriptions to content events

Code

function notifications_content_nodeapi(&$node, $op, $arg = 0) {
  global $user;
  switch ($op) {
    case 'update':

      // If inmediate sending is active, need to reset the node cache so we don't send old versions of the node
      if ($node->status && variable_get('notifications_send_immediate', 0)) {
        node_load(0, NULL, TRUE);
      }

    // else, fall through
    case 'insert':
      if ($node->status) {
        $event = array(
          'module' => 'node',
          'oid' => $node->nid,
          'type' => 'node',
          'action' => $op,
          'node' => $node,
          'params' => array(
            'nid' => $node->nid,
          ),
        );
        notifications_event($event);
      }
      break;
    case 'delete':

      // Remove all subscriptions for this node
      notifications_delete_subscriptions(array(
        'event_type' => 'node',
      ), array(
        'nid' => $node->nid,
      ));
  }
}