function subscriptions_nodeapi in Subscriptions 5
Implementation of hook_nodeapi().
File
- ./
subscriptions.module, line 845
Code
function subscriptions_nodeapi(&$node, $op, $arg = 0) {
global $user;
$strsent = '!';
switch ($op) {
case 'update':
if ($node->status == '0') {
// unpublished
break;
// don't notify
}
// prevent already published edits from sending notifications
// @ TODO send nodes that have been updated could be controlled here
if ($node->status == '1' && $node->subscriptions_currentstatus == '1') {
break;
}
// else, fall through
case 'insert':
if (variable_get('subscriptions_usecron', 0)) {
// using cron to send notifications
subscriptions_hold($node, 'node', $op, $user->uid);
}
else {
// sending notification on submission
if ($node->status) {
if (!empty($node->taxonomy)) {
$omitted_taxa = variable_get('subscriptions_omitted_taxa', array());
foreach ($node->taxonomy as $vid => $taxa) {
// only have unparsed text for tags at this point, not tid values
if ($vid != 'tags' && !in_array($vid, $omitted_taxa)) {
if (!is_array($taxa)) {
$taxa = array(
$taxa,
);
}
// send taxonomy subscriptions
foreach ($taxa as $tid) {
$strsent .= subscriptions_mailvars($tid, $node->nid, $user->uid, 'taxa', $strsent);
}
}
}
}
// send content type subscriptions
$strsent .= subscriptions_mailvars($node->type, $node->nid, $user->uid, 'type', $strsent);
// send node subscriptions
$strsent .= subscriptions_mailvars($node->nid, 0, $user->uid, 'node', $strsent);
if ($node->type == 'blog') {
// send blog subscriptions
$strsent .= subscriptions_mailvars($node->uid, $node->nid, $user->uid, 'blog', $strsent);
}
}
}
// cron test
subscriptions_autosubscribe($user->uid, $node->nid);
if (isset($node->subscriptions_subscribe)) {
if ($node->subscriptions_subscribe) {
subscriptions_add($node->nid, $user->uid, 'node');
}
user_save($user, array(
'subscriptions_subscribe' => $node->subscriptions_subscribe,
));
}
break;
}
}