You are here

function _zopim_visibility_roles in Zopim Live Chat 6.2

Same name and namespace in other branches
  1. 6 zopim.module \_zopim_visibility_roles()
  2. 7 zopim.module \_zopim_visibility_roles()

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

1 call to _zopim_visibility_roles()
_zopim_visibility_user in ./zopim.module
Tracking visibility check for an user object.

File

./zopim.module, line 250

Code

function _zopim_visibility_roles($account) {
  $settings = zopim_get_settings();
  $enabled = TRUE;
  $roles = $settings['visibility']['role'];
  if (array_sum($roles) > 0) {

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

      // Is the current user a member of one role selected in admin settings?
      if (isset($roles[$rid]) && $rid == $roles[$rid]) {

        // Current user is a member of a role that is selected in admin settings.
        $enabled = FALSE;
        break;
      }
    }
  }
  return $enabled;
}