You are here

function nodeviewcountcount_count_node_views in Node view count 7

Same name and namespace in other branches
  1. 7.3 includes/nodeviewcount.api.inc \nodeviewcountcount_count_node_views()
  2. 7.2 includes/nodeviewcount.api.inc \nodeviewcountcount_count_node_views()

Count node views.

Parameters

object $node: Chosen node for counting.

object|NULL $user: Chosen user for counting.

bool $distinct_users: Distinct user or not.

Return value

int Count of node views.

File

includes/nodeviewcount.api.inc, line 103

Code

function nodeviewcountcount_count_node_views($node, $user = NULL, $distinct_users = FALSE) {
  $is_node_count = nodeviewcount_is_node_type_count($node);
  if (!$is_node_count) {
    return FALSE;
  }
  $is_user_count = nodeviewcount_is_user_role_count($user);
  if (!is_null($user) && !$is_user_count) {
    return FALSE;
  }
  $node_view_count = nodeviewcount_db_count_node_views($node, $user, $distinct_users);
  return $node_view_count;
}