You are here

function piwik_reports_get_sites in Piwik Reports 7.4

Same name and namespace in other branches
  1. 7.3 piwik_reports.module \piwik_reports_get_sites()

Return a list of sites which statistic are accessible on piwik server.

Parameters

string $token_auth: Piwik server token auth.

Return value

array Array of sites returned from Piwik reports API.

2 calls to piwik_reports_get_sites()
piwik_reports_admin_settings_form in ./piwik_reports.module
Return the $form that handles piwik reports config page.
piwik_reports_reports in ./piwik_reports.pages.inc
Return the $form that handles piwik reports.

File

./piwik_reports.module, line 516
Defines features and functions common to Piwik Reports.

Code

function piwik_reports_get_sites($token_auth) {

  // TODO: shall I cache this?
  $result = drupal_http_request(piwik_reports_get_url() . 'index.php?module=API&method=SitesManager.getSitesWithAtLeastViewAccess&format=JSON&token_auth=' . $token_auth);
  if (empty($result->data)) {
    $sites = array();
  }
  else {
    $sites = drupal_json_decode($result->data);
  }
  return $sites;
}