diff options
author | Stefan Giehl <stefan@piwik.org> | 2018-05-02 11:11:34 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2018-05-02 11:11:34 +0300 |
commit | 22e958e64f71eb9badf1c7edd7cc4cc0b57b3381 (patch) | |
tree | 4198e88f10399bd07eaed5a09606fef40deedea3 /plugins/Goals | |
parent | e0ba54094b86d85ed0cce487cd2dff11804f9aca (diff) |
Show number of Goals created in the System summary widget (#12798)
* Show overall goal count in system summary
* update UI files
Diffstat (limited to 'plugins/Goals')
-rw-r--r-- | plugins/Goals/Goals.php | 16 | ||||
-rw-r--r-- | plugins/Goals/Model.php | 7 | ||||
-rw-r--r-- | plugins/Goals/lang/en.json | 1 |
3 files changed, 21 insertions, 3 deletions
diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index ecf6fa4ad2..78de5bb791 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -16,6 +16,7 @@ use Piwik\Piwik; use Piwik\Plugin\ArchivedMetric; use Piwik\Plugin\ComputedMetric; use Piwik\Plugin\ReportsProvider; +use Piwik\Plugins\CoreHome\SystemSummary; use Piwik\Tracker\GoalManager; use Piwik\Category\Subcategory; @@ -82,13 +83,22 @@ class Goals extends \Piwik\Plugin 'SitesManager.deleteSite.end' => 'deleteSiteGoals', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations', - 'Category.addSubcategories' => 'addSubcategories', - 'Metric.addMetrics' => 'addMetrics', - 'Metric.addComputedMetrics' => 'addComputedMetrics' + 'Category.addSubcategories' => 'addSubcategories', + 'Metric.addMetrics' => 'addMetrics', + 'Metric.addComputedMetrics' => 'addComputedMetrics', + 'System.addSystemSummaryItems' => 'addSystemSummaryItems', ); return $hooks; } + public function addSystemSummaryItems(&$systemSummary) + { + $goalModel = new Model(); + $numGoals = $goalModel->getActiveGoalCount(); + + $systemSummary[] = new SystemSummary\Item($key = 'goals', Piwik::translate('Goals_NGoals', $numGoals), $value = null, array('module' => 'Goals', 'action' => 'manage'), $icon = 'icon-goal', $order = 7); + } + public function addComputedMetrics(MetricsList $list, ComputedMetricFactory $computedMetricFactory) { $idSite = Common::getRequestVar('idSite', 0, 'int'); diff --git a/plugins/Goals/Model.php b/plugins/Goals/Model.php index 66f0d91fea..be27163037 100644 --- a/plugins/Goals/Model.php +++ b/plugins/Goals/Model.php @@ -99,6 +99,13 @@ class Model Db::query($query, $bind); } + public function getActiveGoalCount() + { + return (int) Db::fetchOne("SELECT count(*) FROM " . $this->table . " + WHERE deleted = 0"); + + } + private function getDb() { return Db::get(); diff --git a/plugins/Goals/lang/en.json b/plugins/Goals/lang/en.json index 6a2e5b3bd0..9c5b9e4c97 100644 --- a/plugins/Goals/lang/en.json +++ b/plugins/Goals/lang/en.json @@ -64,6 +64,7 @@ "GoalIsTriggeredWhen": "Goal is triggered when", "GoalName": "Goal Name", "Goals": "Goals", + "NGoals": "%s goals", "ManageGoals": "Manage Goals", "GoalsOverview": "Goals Overview", "GoalsOverviewDocumentation": "This is an overview of your goal conversions. Initially, the graph shows the sum of all conversions. %s Below the graph, you can see conversion reports for each of your goals. The sparklines can be enlarged by clicking on them.", |