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)', ), ); } /** * Implementation of hook_nodeapi() */ 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 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; } }