From b018cf1dad2f96dd15464b4617599298b5f02e3e Mon Sep 17 00:00:00 2001
From: Matthieu Aubry <mattab@users.noreply.github.com>
Date: Tue, 5 Sep 2017 16:38:21 +1200
Subject: [PATCH] Add a link to Campaign tracking docs + URL Builder +
 Marketing Campaigns Reporting plugin (#11997)

* Add a link to Campaign tracking docs + URL Builder + Marketing Campaigns Reporting plugin

* Update UI tests
---
 .../ProfessionalServices.php                    |  12 ++++++++++++
 .../templates/promoBelowCampaigns.twig          |   7 +++++++
 plugins/Referrers/Reports/GetCampaigns.php      |  15 +++++++++++++++
 ...grationTest_admin_diagnostics_configfile.png | Bin 132 -> 132 bytes
 .../UIIntegrationTest_referrers_campaigns.png   | Bin 130 -> 130 bytes
 5 files changed, 34 insertions(+)
 create mode 100644 plugins/ProfessionalServices/templates/promoBelowCampaigns.twig

diff --git a/plugins/ProfessionalServices/ProfessionalServices.php b/plugins/ProfessionalServices/ProfessionalServices.php
index d11bc22b38..5e6ef3f6f0 100644
--- a/plugins/ProfessionalServices/ProfessionalServices.php
+++ b/plugins/ProfessionalServices/ProfessionalServices.php
@@ -26,6 +26,7 @@ class ProfessionalServices extends \Piwik\Plugin
             'Template.afterGoalCannotAddNewGoal' => array('function' => 'getGoalOverviewPromo', 'after' => true),
             'Template.endGoalEditTable' => array('function' => 'getGoalFunnelOverviewPromo', 'after' => true),
             'Template.afterEventsReport' => 'getEventsPromo',
+            'Template.afterCampaignsReport' => 'getCampaignsPromo',
             'Template.afterReferrersKeywordsReport' => 'getSearchKeywordsPerformancePromo',
             'Template.afterOverlaySidebar' => 'getHeatmapPromo',
             'Template.afterVisitorProfileOverview' => 'getSessionRecordingPromo',
@@ -124,6 +125,17 @@ class ProfessionalServices extends \Piwik\Plugin
         $out .= $view->render();
     }
 
+    public function getCampaignsPromo(&$out)
+    {
+        if ($this->isRequestForDashboardWidget()) {
+            return;
+        }
+
+        $view = new View('@ProfessionalServices/promoBelowCampaigns');
+        $view->displayMarketingCampaignsReportingAd = !$this->isPluginActivated('MarketingCampaignsReporting');
+        $out .= $view->render();
+    }
+
     private function shouldShowPromoForPlugin($pluginName)
     {
         return !$this->isPluginActivated($pluginName) && !$this->isRequestForDashboardWidget();
diff --git a/plugins/ProfessionalServices/templates/promoBelowCampaigns.twig b/plugins/ProfessionalServices/templates/promoBelowCampaigns.twig
new file mode 100644
index 0000000000..f929642bd5
--- /dev/null
+++ b/plugins/ProfessionalServices/templates/promoBelowCampaigns.twig
@@ -0,0 +1,7 @@
+<p style="margin-top:3em" class=" alert-info alert">Did you know?
+    <br/> <a target="_blank" rel="noreferrer" href="https://piwik.org/docs/tracking-campaigns/">Campaign tracking</a> lets you measure the effectiveness of your marketing campaigns such as emails marketing, paid search, banner ads, affiliates links, etc.
+    Use the <a target="_blank" rel="noreferrer" href="https://piwik.org/docs/tracking-campaigns/">URL Builder tool</a> to create your links with new URL campaign parameters.
+    {% if displayMarketingCampaignsReportingAd %}
+        <br/> Install our <a target="_blank" rel="noreferrer" href="https://plugins.piwik.org/MarketingCampaignsReporting">Marketing Campaigns Reporting plugin</a> to get even more campaigns reports and new segments for up to five marketing channels (campaign, source, medium, keyword, content).
+    {% endif %}
+</p>
\ No newline at end of file
diff --git a/plugins/Referrers/Reports/GetCampaigns.php b/plugins/Referrers/Reports/GetCampaigns.php
index 1d375423d8..a1b5f6fd94 100644
--- a/plugins/Referrers/Reports/GetCampaigns.php
+++ b/plugins/Referrers/Reports/GetCampaigns.php
@@ -8,6 +8,7 @@
  */
 namespace Piwik\Plugins\Referrers\Reports;
 
+use Piwik\EventDispatcher;
 use Piwik\Piwik;
 use Piwik\Plugin\ViewDataTable;
 use Piwik\Plugins\Referrers\Columns\Campaign;
@@ -34,6 +35,20 @@ class GetCampaigns extends Base
         $view->config->addTranslation('label', $this->dimension->getName());
 
         $view->requestConfig->filter_limit = 25;
+
+        $this->configureFooterMessage($view);
     }
 
+
+    protected function configureFooterMessage(ViewDataTable $view)
+    {
+        if ($this->isSubtableReport) {
+            // no footer message for subtables
+            return;
+        }
+
+        $out = '';
+        EventDispatcher::getInstance()->postEvent('Template.afterCampaignsReport', array(&$out));
+        $view->config->show_footer_message = $out;
+    }
 }
diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png
index 1cebb1c2bb7187a76b993cd8408d68b9174b78db..92d654820c72cc7e2ebfe7f614dfc9fe9a1a36f6 100644
GIT binary patch
delta 85
zcmWN@yAgmO3;@uxWeP_i<Re+a9g;xqtnI8Bz>)P;Z*6OP<#cdYVx-hSMVbL%egIVP
fjMUUttqZlZ|L7ILvJGW2oE)Rv*E4q%md?F=0rVGN

delta 85
zcmV~$u@S%^2mrvdb&8AtK@gV64hndeI$df9$jJHMWtUGbbPzRSnnJ4yQ@BTi6&`Eo
efDSCf4HF5MB%c|EvjZV>OtSjiZyv-d(zX8hQWpaN

diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_referrers_campaigns.png b/tests/UI/expected-screenshots/UIIntegrationTest_referrers_campaigns.png
index ca47e8302ff5e2526df3460399d6d45f278135ff..298502dcc72e93511388067dbea6b8e25ff15ecd 100644
GIT binary patch
delta 83
zcmWN`xe<UM5CFg-r3y>9ALzj*;5cTC%?zo)l6BMFX{Xmtl%^0M>Z7s<tGL=?i-M(t
d0*6E_BB92Anhx?lry*9F>Xh&6iKBpl<`0N#6<+`V

delta 83
zcmV~$u@QhE3<c1$WeP_CLI~NxB_R2^v$nHj0!Q|}eeC1wSF5&YbSp*F4Bcc<Cb+Q(
e`?8W}AQotj3gu7-mssHx-GQ8*`^8D3($Ww0*BB)L

-- 
GitLab