nodeactivity.module in Activity 5.2
File
contrib/nodeactivity.module
View source
<?php
function nodeactivity_activity_info() {
$types = node_get_types();
foreach ($types as $type) {
$token_types[$type->type] = $type->name;
}
return array(
'name' => 'nodeapi',
'module' => 'node',
'ops' => array(
'insert',
),
'types' => $token_types,
'tokens' => array(
'user' => 'user who did the action',
'user-link' => 'link to the users profile',
'node-id' => 'id of the post',
'node-title' => 'title of the post',
'node-title-link' => 'link to the node',
'node-type' => 'the type of node',
'rating' => 'rating data (if available)',
),
);
}
function nodeactivity_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 (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') {
$tokens['rating'] = $node->field_rating[0]['rating'];
}
activity_insert('nodeapi', $type, $action, $tokens);
}
break;
}
}