function activity_nodeapi in Activity 5
Same name and namespace in other branches
- 6.2 activity.module \activity_nodeapi()
Implementation of hook_nodeapi()
File
- includes/
node.inc, line 32
Code
function activity_nodeapi($node, $op, $teaser, $page) {
switch ($op) {
case 'insert':
if (variable_get('activity_nodeapi_' . $node->type, 0) == 1) {
$type = $node->type;
$action = $op;
$tokens = array(
'user-id' => $node->uid,
'user-name' => $node->name,
'node-id' => $node->nid,
'node-title' => $node->title,
'node-type' => $node->type,
);
// if comments are implemented as nodes we change the stored token data
if (module_exists('nodecomment')) {
$comment = node_load($node->comment_target_nid);
$tokens['node-id'] = $node->comment_target_nid;
$tokens['node-title'] = $comment->title;
}
if ($node->type == 'review') {
// add rating data to the list of tokens
$tokens['rating'] = $node->field_rating[0]['rating'];
}
activity_insert('nodeapi', $type, $action, $tokens);
}
break;
}
}