You are here

function _piwik_visibility_user in Piwik Web Analytics 8

Same name and namespace in other branches
  1. 5 piwik.module \_piwik_visibility_user()
  2. 6.2 piwik.module \_piwik_visibility_user()
  3. 6 piwik.module \_piwik_visibility_user()
  4. 7.2 piwik.module \_piwik_visibility_user()
  5. 7 piwik.module \_piwik_visibility_user()

Tracking visibility check for an user object.

Parameters

object $account: A user object containing an array of roles to check.

Return value

bool TRUE if the current user is being tracked by Piwik, otherwise FALSE.

1 call to _piwik_visibility_user()
piwik_page_attachments in ./piwik.module
Implements hook_page_attachments().

File

./piwik.module, line 566
Drupal Module: Piwik.

Code

function _piwik_visibility_user($account) {
  $config = \Drupal::config('piwik.settings');
  $enabled = FALSE;

  // Is current user a member of a role that should be tracked?
  if (_piwik_visibility_roles($account)) {

    // Use the user's block visibility setting, if necessary.
    if (($visibility_user_account_mode = $config
      ->get('visibility.user_account_mode')) != 0) {
      $user_data_piwik = \Drupal::service('user.data')
        ->get('piwik', $account
        ->id());
      if ($account
        ->id() && isset($user_data_piwik['user_account_users'])) {
        $enabled = $user_data_piwik['user_account_users'];
      }
      else {
        $enabled = $visibility_user_account_mode == 1;
      }
    }
    else {
      $enabled = TRUE;
    }
  }
  return $enabled;
}