function views_bookmarkactivity_views_bookmark_api in Activity 5.4
Same name and namespace in other branches
- 5.2 contrib/views_bookmarkactivity.module \views_bookmarkactivity_views_bookmark_api()
- 5.3 contrib/views_bookmarkactivity/views_bookmarkactivity.module \views_bookmarkactivity_views_bookmark_api()
Implementation of hook_views_bookmark_api().
Parameters
$vb_name: bookmark type name
$vbid: id of the bookmark type
$vb_uid: user id who marked
$nid: node id that was bookmarked
File
- contrib/
views_bookmarkactivity/ views_bookmarkactivity.module, line 80
Code
function views_bookmarkactivity_views_bookmark_api($vb_name, $vbid, $vb_uid, $nid) {
$node = node_load($nid);
$types = views_bookmark_get_bookmarks();
$type = preg_replace('/\\s/', '_', drupal_strtolower($types[$vbid]->title));
// Check if both type and operation are
// enabled for activity. If not then stop here
if (!in_array($type, variable_get('views_bookmarkactivity_token_types', array(
$type,
)), TRUE) || !in_array($vb_name, variable_get('views_bookmarkactivity_op_types', array(
$vb_name,
)), TRUE)) {
return FALSE;
}
// Privacy setting check
$user = user_load(array(
'uid' => $vb_uid,
'status' => 1,
));
if (activity_user_privacy_optout($user)) {
return FALSE;
}
$data = array(
'operation' => $vb_name,
'node-id' => $node->nid,
'node-title' => $node->title,
'node-type' => $node->type,
);
$target_users_roles = array(
ACTIVITY_ALL => 'all',
$vb_uid => 'author',
);
activity_insert($vb_uid, 'views_bookmarkactivity', $type, $vb_name, $data, $target_users_roles);
}