function subscriptions_content_nodeapi in Subscriptions 6
Same name and namespace in other branches
- 5.2 subscriptions_content.module \subscriptions_content_nodeapi()
Implementation of hook_nodeapi().
Catch node inserts and updates and send them to the subscriptions queue; catch node deletes and remove any associated thread subscriptions.
1 call to subscriptions_content_nodeapi()
- subscriptions_content_node_admin_nodes_submit in ./
subscriptions_content.module - Handle bulk publishing.
File
- ./
subscriptions_content.module, line 188 - Subscriptions to content events
Code
function subscriptions_content_nodeapi(&$node, $op, $arg = 0) {
global $user;
static $unpublished_nid;
switch ($op) {
case 'load':
case 'prepare':
$unpublished_nid = $node->status ? NULL : $node->nid;
$node->subscriptions_notify = in_array(isset($node->nid) ? $node->status ? 'n_pub' : 'n_unpub' : 'n_new', subscriptions_content_get_default_workflow($node->type));
break;
case 'update':
if ($unpublished_nid == $node->nid && $node->status) {
// An unpublished node just became published -- treat this as an 'insert'!
$op = 'insert';
}
// fall through
case 'insert':
$event = array(
'module' => 'node',
'uid' => $node->uid,
'load_function' => 'subscriptions_content_node_load',
'load_args' => $node->nid,
'type' => 'node',
'action' => $op,
'is_new' => $op == 'insert',
'node' => $node,
);
$unpublished_nid = NULL;
// Check direct subscription and auto subscription
//if (isset($node->subscriptions_subscribe)) {
// if ($node->subscriptions_subscribe) {
// subscriptions_write_subscription('node', 'nid', $node->nid, -1, $user->uid);
// }
//} else
if ($node->uid > 0 && !$arg) {
_subscriptions_content_autosubscribe($node->type, 'node', 'nid', $node->nid, $op == 'insert' ? 'on_post' : 'on_update');
}
if ((!isset($node->subscriptions_notify) || $node->subscriptions_notify) && !subscriptions_content_suppress_notifications()) {
subscriptions_queue($event);
}
break;
case 'delete':
db_query("DELETE FROM {subscriptions} WHERE module = 'node' AND field = 'nid' AND value = '%s'", $node->nid);
break;
}
}