Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Goals/API.php')
-rw-r--r--plugins/Goals/API.php36
1 files changed, 30 insertions, 6 deletions
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php
index e1db0d187c..dedc555fc7 100644
--- a/plugins/Goals/API.php
+++ b/plugins/Goals/API.php
@@ -54,6 +54,24 @@ class API extends \Piwik\Plugin\API
const AVG_PRICE_VIEWED = 'avg_price_viewed';
/**
+ * Return a single goal.
+ *
+ * @param int $idSite
+ * @param int $idGoal
+ * @return array An array of goal attributes.
+ */
+ public function getGoal($idSite, $idGoal)
+ {
+ Piwik::checkUserHasViewAccess($idSite);
+
+ $goal = $this->getModel()->getActiveGoal($idSite, $idGoal);
+
+ if (!empty($goal)) {
+ return $this->formatGoal($goal);
+ }
+ }
+
+ /**
* Returns all Goals for a given website, or list of websites
*
* @param string|array $idSite Array or Comma separated list of website IDs to request the goals for
@@ -76,12 +94,7 @@ class API extends \Piwik\Plugin\API
$cleanedGoals = array();
foreach ($goals as &$goal) {
- if ($goal['match_attribute'] == 'manually') {
- unset($goal['pattern']);
- unset($goal['pattern_type']);
- unset($goal['case_sensitive']);
- }
- $cleanedGoals[$goal['idgoal']] = $goal;
+ $cleanedGoals[$goal['idgoal']] = $this->formatGoal($goal);
}
$cache->save($cacheId, $cleanedGoals);
@@ -90,6 +103,17 @@ class API extends \Piwik\Plugin\API
return $cache->fetch($cacheId);
}
+ private function formatGoal($goal)
+ {
+ if ($goal['match_attribute'] == 'manually') {
+ unset($goal['pattern']);
+ unset($goal['pattern_type']);
+ unset($goal['case_sensitive']);
+ }
+
+ return $goal;
+ }
+
/**
* Creates a Goal for a given website.
*