You are here

function favorite_nodesactivity_favorite_nodes in Activity 6

Same name and namespace in other branches
  1. 5.4 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($operation, $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($operation, variable_get('favorite_nodesactivity_op_types', array(
    $operation,
  )), TRUE)) {
    return FALSE;
  }

  // Privacy setting check
  if (activity_user_privacy_optout($user)) {
    return FALSE;
  }

  // User hide activity permission check
  if (user_access('hide activity', $user)) {
    return FALSE;
  }
  $data = array(
    'operation' => $operation,
    '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, $operation, $data, $target_users_roles);
}