| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Plugins\AnonymousPiwikUsageMeasurement\Tracker; |
|
|
| use Piwik\Common; |
| use Piwik\Plugins\AnonymousPiwikUsageMeasurement\SystemSettings; |
| use Piwik\SettingsPiwik; |
| use Piwik\Tests\Framework\Fixture; |
|
|
| |
| |
| |
| class Targets |
| { |
| |
| |
| |
| private $settings; |
|
|
| public function __construct(SystemSettings $settings) |
| { |
| $this->settings = $settings; |
| } |
|
|
| public function getTargets() |
| { |
| $targets = array(); |
|
|
| $ownSiteId = $this->settings->ownPiwikSiteId->getValue(); |
| if ($ownSiteId) { |
| $piwikUrl = SettingsPiwik::getPiwikUrl(); |
| if (!Common::stringEndsWith($piwikUrl, '/')) { |
| $piwikUrl .= '/'; |
| } |
| $targets[] = array( |
| 'url' => $piwikUrl . 'matomo.php', |
| 'idSite' => (int) $ownSiteId, |
| 'useAnonymization' => $this->settings->anonymizeSelfPiwik->getValue() |
| ); |
| } |
|
|
| $customUrl = $this->settings->customPiwikSiteUrl->getValue(); |
| $customSiteId = $this->settings->customPiwikSiteId->getValue(); |
| if ($customUrl && $customSiteId) { |
| $targets[] = array( |
| 'url' => $customUrl, |
| 'idSite' => (int) $customSiteId, |
| 'useAnonymization' => $this->settings->anonymizeCustomPiwik->getValue() |
| ); |
| } |
|
|
| if (defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE && Common::isPhpCliMode()) { |
| foreach ($targets as &$target) { |
| $target['token_auth'] = Fixture::getTokenAuth(); |
| } |
| } |
|
|
| return $targets; |
| } |
| } |
|
|