You are here

function nodeviewcount_is_user_role_count in Node view count 7

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

Check user on user roles for node view count.

Parameters

object $user: The user for checking.

Return value

bool TRUE if the user role checked for count views, otherwise FALSE.

2 calls to nodeviewcount_is_user_role_count()
nodeviewcountcount_count_node_views in includes/nodeviewcount.api.inc
Count node views.
nodeviewcount_node_view in ./nodeviewcount.module
Implements hook_node_view().

File

includes/nodeviewcount.api.inc, line 73

Code

function nodeviewcount_is_user_role_count($user) {
  $nodeviewcount_user_roles = variable_get('nodeviewcount_user_roles', array());
  $excluded_user_roles = variable_get('nodeviewcount_excluded_user_roles', array());
  $user_roles_ids = array_keys($user->roles);
  foreach ($user_roles_ids as $role_id) {
    if (!empty($excluded_user_roles[$role_id])) {
      return FALSE;
    }
  }
  foreach ($user_roles_ids as $role_id) {
    if (!empty($nodeviewcount_user_roles[$role_id])) {
      return TRUE;
    }
  }
  return FALSE;
}