function nodeactivity_nodeapi in Activity 5.3
Same name and namespace in other branches
- 5.4 contrib/nodeactivity/nodeactivity.module \nodeactivity_nodeapi()
- 5.2 contrib/nodeactivity.module \nodeactivity_nodeapi()
- 6 contrib/nodeactivity/nodeactivity.module \nodeactivity_nodeapi()
Implementation of hook_nodeapi()
File
- contrib/
nodeactivity/ nodeactivity.module, line 66
Code
function nodeactivity_nodeapi($node, $op, $teaser, $page) {
switch ($op) {
case 'insert':
case 'update':
case 'delete':
if ($node->status == 1) {
$operation = $op == 'insert' ? t('create') : t($op);
$type = $node->type;
// This is all the information you'll need later in order to build
// the activity message.
$user = user_load(array(
'uid' => $node->uid,
));
$data = array(
'operation' => $operation,
'node-id' => $node->nid,
'author-uid' => $node->uid,
'node-title' => $node->title,
'node-type' => strtolower(node_get_types('name', $node->type)),
'node-title-link' => l($node->title, 'node/' . $node->nid),
'author-name' => $node->name,
);
// This determines who sees messages based on this data.
// This implementation will ensure that the activity is shown
// to the special group ACTIVITY_ALL (everybody, basically),
// as well as to the person who inserted, updated or deleted the node.
// The use of the role (all and author) ensures that we know later how
// to address the person... ie "You" or "Bob".
$target_users_roles = array(
ACTIVITY_ALL => 'all',
$node->uid => 'author',
);
activity_insert('nodeactivity', $type, $op, $data, $target_users_roles);
}
break;
}
}