diff options
Diffstat (limited to 'plugins/CustomDimensions/DataTable')
4 files changed, 164 insertions, 0 deletions
diff --git a/plugins/CustomDimensions b/plugins/CustomDimensions deleted file mode 160000 -Subproject 318661a2fb1ef3b3e5d6d999ae8b9628cb5a113 diff --git a/plugins/CustomDimensions/DataTable/Filter/AddSegmentMetadata.php b/plugins/CustomDimensions/DataTable/Filter/AddSegmentMetadata.php new file mode 100644 index 0000000000..759c148c9c --- /dev/null +++ b/plugins/CustomDimensions/DataTable/Filter/AddSegmentMetadata.php @@ -0,0 +1,54 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CustomDimensions\DataTable\Filter; + +use Piwik\DataTable\BaseFilter; +use Piwik\DataTable\Row; +use Piwik\DataTable; +use Piwik\Plugins\CustomDimensions\Archiver; +use Piwik\Plugins\CustomDimensions\Tracker\CustomDimensionsRequestProcessor; + +class AddSegmentMetadata extends BaseFilter +{ + private $idDimension; + + /** + * Constructor. + * + * @param DataTable $table The table to eventually filter. + */ + public function __construct($table, $idDimension) + { + parent::__construct($table); + $this->idDimension = $idDimension; + } + + /** + * @param DataTable $table + */ + public function filter($table) + { + $dimension = CustomDimensionsRequestProcessor::buildCustomDimensionTrackingApiName($this->idDimension); + + foreach ($table->getRows() as $row) { + $label = $row->getColumn('label'); + if ($label !== false) { + if ($label === Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED) { + $label = ''; + } + $row->setMetadata('segment', $dimension . '==' . urlencode($label)); + } + + $subTable = $row->getSubtable(); + if ($subTable) { + $subTable->filter('Piwik\Plugins\CustomDimensions\DataTable\Filter\AddSubtableSegmentMetadata', array($this->idDimension, $label)); + } + } + } +}
\ No newline at end of file diff --git a/plugins/CustomDimensions/DataTable/Filter/AddSubtableSegmentMetadata.php b/plugins/CustomDimensions/DataTable/Filter/AddSubtableSegmentMetadata.php new file mode 100644 index 0000000000..a6ecdd779f --- /dev/null +++ b/plugins/CustomDimensions/DataTable/Filter/AddSubtableSegmentMetadata.php @@ -0,0 +1,63 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CustomDimensions\DataTable\Filter; + +use Piwik\DataTable\BaseFilter; +use Piwik\DataTable\Row; +use Piwik\DataTable; +use Piwik\Plugins\CustomDimensions\Archiver; +use Piwik\Plugins\CustomDimensions\Tracker\CustomDimensionsRequestProcessor; +use Piwik\Tracker\PageUrl; + +class AddSubtableSegmentMetadata extends BaseFilter +{ + private $idDimension; + private $dimensionValue; + + /** + * Constructor. + * + * @param DataTable $table The table to eventually filter. + */ + public function __construct($table, $idDimension, $dimensionValue) + { + parent::__construct($table); + $this->idDimension = $idDimension; + $this->dimensionValue = $dimensionValue; + } + + /** + * @param DataTable $table + */ + public function filter($table) + { + if (!$this->dimensionValue) { + return; + } + + $dimension = CustomDimensionsRequestProcessor::buildCustomDimensionTrackingApiName($this->idDimension); + + if ($this->dimensionValue === Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED) { + $dimensionValue = ''; + } else { + $dimensionValue = urlencode($this->dimensionValue); + } + + $conditionAnd = ';'; + $partDimension = $dimension . '==' . $dimensionValue . $conditionAnd; + + foreach ($table->getRows() as $row) { + $label = $row->getColumn('label'); + if ($label !== false) { + $row->setMetadata('segment', $partDimension . 'actionUrl=$' . urlencode($label)); + $row->setMetadata('url', urlencode($label)); + } + } + } +}
\ No newline at end of file diff --git a/plugins/CustomDimensions/DataTable/Filter/RemoveUserIfNeeded.php b/plugins/CustomDimensions/DataTable/Filter/RemoveUserIfNeeded.php new file mode 100644 index 0000000000..dde4985376 --- /dev/null +++ b/plugins/CustomDimensions/DataTable/Filter/RemoveUserIfNeeded.php @@ -0,0 +1,47 @@ +<?php +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CustomDimensions\DataTable\Filter; + +use Piwik\DataTable\BaseFilter; +use Piwik\DataTable\Row; +use Piwik\DataTable; +use Piwik\Metrics; +use Piwik\Plugins\CoreHome\Columns\UserId; + +class RemoveUserIfNeeded extends BaseFilter +{ + private $idSite; + private $period; + private $date; + + /** + * Constructor. + * + * @param DataTable $table The table to eventually filter. + */ + public function __construct($table, $idSite, $period, $date) + { + parent::__construct($table); + $this->idSite = $idSite; + $this->period = $period; + $this->date = $date; + } + + /** + * @param DataTable $table + */ + public function filter($table) + { + $userId = new UserId(); + if (!$userId->hasDataTableUsers($table) && + !$userId->isUsedInAtLeastOneSite(array($this->idSite), $this->period, $this->date)) { + $table->deleteColumn(Metrics::INDEX_NB_USERS); + } + } +}
\ No newline at end of file |