diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2020-04-16 23:24:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 23:24:39 +0300 |
commit | 37182bfda5529ddb4ba2aaedd09beb1e5ae94fbb (patch) | |
tree | f6609b714e4e6cac35769f98e8f47f5e95071b5f /core/Plugin/Segment.php | |
parent | e943702e1e54bfc71d423bfd2ec2a48c0a4610f7 (diff) |
merge 3.x to 4.x (#15821)
* Avoid possible error subtable already exists but not loaded (#15779)
* Make sure to always set JSON_PIWIK to native JSON when possible (#15785)
* make sure to always set JSON_PIWIK to native JSON when possible
* rebuilt piwik.js
* Force POST for bulk requests, fix alwaysUseSendBeacon not respected for bulk requests (#15784)
* Force POST for bulk requests, fix alwaysUseSendBeacon not respected for bulk requests
* rebuilt piwik.js
* Make sure to clean up tracking failures before sending email notification (#15798)
Feedback from a customer... Eg the daily `cleanupTrackingFailures()` action might be only executed after the weekly `notifyTrackingFailures` therefore we should try to clean up failures first and then check if any are left. Avoids the case where a user opens hours later the email they receive and then there are no tracking failures reported. This could still happen but it's a bit less likely.
* 3.13.5-b1
* Faster segmented suggested values when browser archiving is disabled (#15786)
* Faster segmented suggested values when browser archiving is disabled
* make sure no segment is set
* remove wrong var type
* fix/add tests
* add more segment values
* detect if we should flatten or not
* add docs
* Fix problem when comparing segments or opening popovers (#15809)
refs #15805
* purge all old archives regardless of done value (#15800)
* purge all old archives regardless of done value, we only care about the newest usable one
* Fix test and start on new one.
* Add coverage for change in tests.
* there is no longer an inner join so should not need the idsite check
* Add more parameters to the computeNbUnique event (#15808)
* 3.13.5-b2
* One click update in two parts so new code is loaded for second. (#15770)
* One click update in two parts so new code is loaded for second.
* remove no longer needed code
Co-authored-by: Thomas Steur <tsteur@users.noreply.github.com>
Co-authored-by: Matthieu Aubry <mattab@users.noreply.github.com>
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Diffstat (limited to 'core/Plugin/Segment.php')
-rw-r--r-- | core/Plugin/Segment.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/Plugin/Segment.php b/core/Plugin/Segment.php index 0da1ebbc69..5e09c409c1 100644 --- a/core/Plugin/Segment.php +++ b/core/Plugin/Segment.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugin; use Exception; +use Piwik\Development; /** * Creates a new segment that can be used for instance within the {@link \Piwik\Columns\Dimension::configureSegment()} @@ -54,6 +55,7 @@ class Segment private $suggestedValuesCallback; private $unionOfSegments; private $isInternalSegment = false; + private $suggestedValuesApi = ''; /** * If true, this segment will only be visible to the user if the user has view access @@ -297,6 +299,32 @@ class Segment } /** + * @return string + * @ignore + */ + public function getSuggestedValuesApi() + { + return $this->suggestedValuesApi; + } + + /** + * Set callback which will be executed when user will call for suggested values for segment. + * + * @param string $suggestedValuesApi + */ + public function setSuggestedValuesApi($suggestedValuesApi) + { + if (!empty($suggestedValuesApi) && is_string($suggestedValuesApi)) { + if (Development::isEnabled() && strpos($suggestedValuesApi, '.get') === false) { + throw new Exception('Invalid suggested values API defined, expecting ".get" to be present.'); + } + } else { + $suggestedValuesApi = ''; + } + $this->suggestedValuesApi = $suggestedValuesApi; + } + + /** * You can restrict the access to this segment by passing a boolean `false`. For instance if you want to make * a certain segment only available to users having super user access you could do the following: * `$segment->setPermission(Piwik::hasUserSuperUserAccess());` @@ -346,6 +374,10 @@ class Segment $segment['suggestedValuesCallback'] = $this->suggestedValuesCallback; } + if (is_string($this->suggestedValuesApi) && !empty($this->suggestedValuesApi)) { + $segment['suggestedValuesApi'] = $this->suggestedValuesApi; + } + return $segment; } |