You are here

function favorite_nodesactivity_favorite_nodes in Activity 5.4

Same name and namespace in other branches
  1. 6 contrib/favorite_nodesactivity/favorite_nodesactivity.module \favorite_nodesactivity_favorite_nodes()

Implementation of hook_favorite_nodes().

File

contrib/favorite_nodesactivity/favorite_nodesactivity.module, line 78

Code

function favorite_nodesactivity_favorite_nodes($op, $node) {
  global $user;
  $type = 'favorites';

  // Check if both type and operation are
  // enabled for activity. If not then stop here
  if (!in_array($type, variable_get('favorite_nodesactivity_token_types', array(
    $type,
  )), TRUE) || !in_array($op, variable_get('favorite_nodesactivity_op_types', array(
    $op,
  )), TRUE)) {
    return FALSE;
  }

  // Privacy setting check
  if (activity_user_privacy_optout($user)) {
    return FALSE;
  }
  $data = array(
    'operation' => $op,
    'node-id' => $node->nid,
    'node-title' => $node->title,
    'node-type' => $node->type,
  );
  $target_users_roles = array(
    ACTIVITY_ALL => 'all',
    $user->uid => 'author',
  );
  activity_insert($user->uid, 'favorite_nodesactivity', $type, $op, $data, $target_users_roles);
}