From e3a023794fc9bfcdc219ae2e9b4ed10f7651c5a3 Mon Sep 17 00:00:00 2001 From: Thomas Steur <thomas.steur@googlemail.com> Date: Fri, 13 Jun 2014 02:25:30 +0200 Subject: [PATCH] added possibility to set a permission on the segment object, fix category of deviceType --- core/Plugin/Segment.php | 29 ++++++++++++++----- .../DevicesDetection/Columns/DeviceType.php | 1 + plugins/Events/Columns/TotalEvents.php | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/core/Plugin/Segment.php b/core/Plugin/Segment.php index 520fa26c0f..52c2b04b8f 100644 --- a/core/Plugin/Segment.php +++ b/core/Plugin/Segment.php @@ -24,6 +24,7 @@ class Segment private $sqlFilter; private $sqlFilterValue; private $acceptValues; + private $permission; public function __construct() { @@ -36,7 +37,7 @@ class Segment } /** - * @param mixed $acceptValues + * @param string $acceptValues */ public function setAcceptValues($acceptValues) { @@ -44,7 +45,7 @@ class Segment } /** - * @param mixed $category + * @param string $category */ public function setCategory($category) { @@ -52,7 +53,7 @@ class Segment } /** - * @param mixed $name + * @param string $name */ public function setName($name) { @@ -60,7 +61,7 @@ class Segment } /** - * @param mixed $segment + * @param string $segment */ public function setSegment($segment) { @@ -68,7 +69,7 @@ class Segment } /** - * @param mixed $sqlFilter + * @param string|\Closure $sqlFilter */ public function setSqlFilter($sqlFilter) { @@ -76,7 +77,7 @@ class Segment } /** - * @param mixed $sqlFilterValue + * @param string|array $sqlFilterValue */ public function setSqlFilterValue($sqlFilterValue) { @@ -84,7 +85,7 @@ class Segment } /** - * @param mixed $sqlSegment + * @param string $sqlSegment */ public function setSqlSegment($sqlSegment) { @@ -100,13 +101,21 @@ class Segment } /** - * @param mixed $type + * @param string $type See constansts TYPE_* */ public function setType($type) { $this->type = $type; } + /** + * @param bool $permission + */ + public function setPermission($permission) + { + $this->permission = $permission; + } + public function toArray() { $segment = array( @@ -129,6 +138,10 @@ class Segment $segment['acceptedValues'] = $this->acceptValues; } + if (isset($this->permission)) { + $segment['permission'] = $this->permission; + } + return $segment; } } diff --git a/plugins/DevicesDetection/Columns/DeviceType.php b/plugins/DevicesDetection/Columns/DeviceType.php index 5c8369f46a..5d8d892a27 100644 --- a/plugins/DevicesDetection/Columns/DeviceType.php +++ b/plugins/DevicesDetection/Columns/DeviceType.php @@ -24,6 +24,7 @@ class DeviceType extends Base $deviceTypeList = implode(", ", DeviceDetector::$deviceTypes); $segment = new Segment(); + $segment->setCategory('General_Visit'); $segment->setSegment('deviceType'); $segment->setName('DevicesDetection_DeviceType'); $segment->setAcceptValues($deviceTypeList); diff --git a/plugins/Events/Columns/TotalEvents.php b/plugins/Events/Columns/TotalEvents.php index 885aed9846..67ed9d7ae6 100644 --- a/plugins/Events/Columns/TotalEvents.php +++ b/plugins/Events/Columns/TotalEvents.php @@ -22,7 +22,7 @@ class TotalEvents extends VisitDimension $segment->setSegment('events'); $segment->setName('Events_TotalEvents'); $segment->setAcceptValues('To select all visits who triggered an Event, use: &segment=events>0'); - $segment->setCategory(Piwik::translate('General_Visit')); + $segment->setCategory('General_Visit'); $segment->setType(Segment::TYPE_METRIC); $this->addSegment($segment); } -- GitLab