You are here

function _eloqua_visibility_roles in Eloqua 7

Based on visibility setting this function returns TRUE if the Eloqua code should be added for the current role and otherwise FALSE.

1 call to _eloqua_visibility_roles()
eloqua_init in ./eloqua.module
Implements hook_init().

File

./eloqua.module, line 95
Eloqua Integration Module

Code

function _eloqua_visibility_roles($user) {
  $visibility = variable_get('eloqua_visibility_roles', 0);
  $enabled = $visibility;
  $roles = variable_get('eloqua_roles', array());
  if (array_sum($roles) > 0) {

    // One or more roles are selected.
    foreach (array_keys($user->roles) as $rid) {

      // Is the current user a member of one of these roles?
      if (isset($roles[$rid]) && $rid == $roles[$rid]) {

        // Current user is a member of a role that should be tracked/excluded from tracking.
        $enabled = !$visibility;
        break;
      }
    }
  }
  else {

    // No role is selected for tracking, therefore all roles should be tracked.
    $enabled = TRUE;
  }
  return $enabled;
}