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:
authordiosmosis <diosmosis@users.noreply.github.com>2018-08-02 00:13:15 +0300
committerStefan Giehl <stefan@piwik.org>2018-08-02 00:13:15 +0300
commit3e6356d717d9dd59a9b73a39db3f08f4c721e255 (patch)
tree537dadde8aee0cf3ae16b5bf68deb9034499b00b /plugins/PrivacyManager
parent1aa34c3c73d367b586682d3f778967cd6b21cc70 (diff)
Add privacy policy/terms and conditions settings and display in bottom of certain pages. (#13219)
* Add privacy policy/terms and conditions settings and display in bottom of certain pages. * tweak * simplify PrivacyManager::shouldRenderFooterLinks(). * Update system test files * removes typo * do not render view if no links available * Remove footer margin in embedded widget. * ensure footer margin doesn't change (for UI tests) * update ui files
Diffstat (limited to 'plugins/PrivacyManager')
-rw-r--r--plugins/PrivacyManager/PrivacyManager.php40
-rw-r--r--plugins/PrivacyManager/SystemSettings.php64
-rw-r--r--plugins/PrivacyManager/lang/en.json11
-rw-r--r--plugins/PrivacyManager/stylesheets/footerLinks.less13
-rw-r--r--plugins/PrivacyManager/templates/footerLinks.twig5
5 files changed, 131 insertions, 2 deletions
diff --git a/plugins/PrivacyManager/PrivacyManager.php b/plugins/PrivacyManager/PrivacyManager.php
index 8eab5017b0..c289c5e0d8 100644
--- a/plugins/PrivacyManager/PrivacyManager.php
+++ b/plugins/PrivacyManager/PrivacyManager.php
@@ -26,6 +26,7 @@ use Piwik\Plugins\Goals\Archiver;
use Piwik\Plugins\Installation\FormDefaultSettings;
use Piwik\Site;
use Piwik\Tracker\GoalManager;
+use Piwik\View;
/**
* Specifically include this for Tracker API (which does not use autoloader)
@@ -177,7 +178,8 @@ class PrivacyManager extends Plugin
'Tracker.setVisitorIp' => array($this->ipAnonymizer, 'setVisitorIpAddress'),
'Installation.defaultSettingsForm.init' => 'installationFormInit',
'Installation.defaultSettingsForm.submit' => 'installationFormSubmit',
- 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys'
+ 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
+ 'Template.pageFooter' => 'renderPrivacyPolicyLinks',
);
}
@@ -222,6 +224,7 @@ class PrivacyManager extends Plugin
$stylesheets[] = "plugins/PrivacyManager/angularjs/manage-gdpr/managegdpr.directive.less";
$stylesheets[] = "plugins/PrivacyManager/stylesheets/gdprOverview.less";
$stylesheets[] = "plugins/PrivacyManager/angularjs/anonymize-log-data/anonymize-log-data.directive.less";
+ $stylesheets[] = "plugins/PrivacyManager/stylesheets/footerLinks.less";
}
/**
@@ -601,4 +604,39 @@ class PrivacyManager extends Plugin
}
return $salt;
}
+
+ public function renderPrivacyPolicyLinks(&$out)
+ {
+ $settings = new SystemSettings();
+
+ if (!$this->shouldRenderFooterLinks($settings)) {
+ return;
+ }
+
+ $privacyPolicyUrl = $settings->privacyPolicyUrl->getValue();
+ $termsAndConditionUrl = $settings->termsAndConditionUrl->getValue();
+
+ if (empty($privacyPolicyUrl) && empty($termsAndConditionUrl)) {
+ return;
+ }
+
+ $view = new View('@PrivacyManager/footerLinks.twig');
+ $view->privacyPolicyUrl = $privacyPolicyUrl;
+ $view->termsAndCondition = $termsAndConditionUrl;
+ $out .= $view->render();
+ }
+
+ private function shouldRenderFooterLinks(SystemSettings $settings)
+ {
+ if (Piwik::getCurrentUserLogin() == 'anonymous') {
+ return true;
+ }
+
+ $module = Common::getRequestVar('module', false);
+ if ($module == 'Widgetize') {
+ return (bool)$settings->showInEmbeddedWidgets->getValue();
+ }
+
+ return false;
+ }
}
diff --git a/plugins/PrivacyManager/SystemSettings.php b/plugins/PrivacyManager/SystemSettings.php
new file mode 100644
index 0000000000..e1387f8f7a
--- /dev/null
+++ b/plugins/PrivacyManager/SystemSettings.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\PrivacyManager;
+
+use Piwik\Piwik;
+use Piwik\Settings\Setting;
+use Piwik\Settings\FieldConfig;
+
+/**
+ * Defines Settings for PrivacyManager.
+ */
+class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings
+{
+ /** @var Setting */
+ public $privacyPolicyUrl;
+
+ /** @var Setting */
+ public $termsAndConditionUrl;
+
+ /** @var Setting */
+ public $showInEmbeddedWidgets;
+
+ protected function init()
+ {
+ $this->privacyPolicyUrl = $this->createPrivacyPolicyUrlSetting();
+ $this->termsAndConditionUrl = $this->createTermsAndConditionUrlSetting();
+ $this->showInEmbeddedWidgets = $this->createShowInEmbeddedWidgetsSetting();
+ }
+
+ private function createPrivacyPolicyUrlSetting()
+ {
+ return $this->makeSetting('privacyPolicyUrl', $default = '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
+ $field->title = Piwik::translate('PrivacyManager_PrivacyPolicyUrl');
+ $field->uiControl = FieldConfig::UI_CONTROL_TEXT;
+ $field->description = Piwik::translate('PrivacyManager_PrivacyPolicyUrlDescription') . ' ' .
+ Piwik::translate('PrivacyManager_PrivacyPolicyUrlDescriptionSuffix', ['anonymous']);
+ });
+ }
+
+ private function createTermsAndConditionUrlSetting()
+ {
+ return $this->makeSetting('termsAndConditionUrl', $default = '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
+ $field->title = Piwik::translate('PrivacyManager_TermsAndConditionUrl');
+ $field->uiControl = FieldConfig::UI_CONTROL_TEXT;
+ $field->description = Piwik::translate('PrivacyManager_TermsAndConditionUrlDescription') . ' ' .
+ Piwik::translate('PrivacyManager_PrivacyPolicyUrlDescriptionSuffix', ['anonymous']);
+ });
+ }
+
+ private function createShowInEmbeddedWidgetsSetting()
+ {
+ return $this->makeSetting('showInEmbeddedWidgets', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
+ $field->title = Piwik::translate('PrivacyManager_ShowInEmbeddedWidgets');
+ $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
+ $field->description = Piwik::translate('PrivacyManager_ShowInEmbeddedWidgetsDescription');
+ });
+ }
+}
diff --git a/plugins/PrivacyManager/lang/en.json b/plugins/PrivacyManager/lang/en.json
index 42e417fc7f..0f6660a62c 100644
--- a/plugins/PrivacyManager/lang/en.json
+++ b/plugins/PrivacyManager/lang/en.json
@@ -77,6 +77,15 @@
"UseAnonymizeOrderId": "Anonymize Order ID",
"UseDeleteLog": "Regularly delete old visitor logs from the database",
"UseDeleteReports": "Regularly delete old reports from the database",
- "UsersOptOut": "Users opt-out"
+ "UsersOptOut": "Users opt-out",
+ "PrivacyPolicyUrl": "Privacy Policy URL",
+ "PrivacyPolicyUrlDescription": "A link to your Privacy Policy page.",
+ "TermsAndConditionUrl": "Terms & Conditions URL",
+ "TermsAndConditionUrlDescription": "A link to your Terms & Conditions page.",
+ "PrivacyPolicyUrlDescriptionSuffix": "If you set this, it will be displayed at the bottom of the login page and on pages that the '%1$s' user can access.",
+ "ShowInEmbeddedWidgets": "Show in embedded widgets",
+ "ShowInEmbeddedWidgetsDescription": "If checked, a link to your Privacy Policy and your Terms & Conditions will be displayed at the bottom of embedded widgets.",
+ "PrivacyPolicy": "Privacy Policy",
+ "TermsAndConditions": "Terms & Conditions"
}
}
diff --git a/plugins/PrivacyManager/stylesheets/footerLinks.less b/plugins/PrivacyManager/stylesheets/footerLinks.less
new file mode 100644
index 0000000000..c7d27b7d97
--- /dev/null
+++ b/plugins/PrivacyManager/stylesheets/footerLinks.less
@@ -0,0 +1,13 @@
+#footerLinks {
+ text-align: center;
+ font-size: .7rem;
+ color: @color-silver;
+
+ a {
+ color: @color-silver;
+ text-decoration: none;
+ &:hover {
+ text-decoration: underline;
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/PrivacyManager/templates/footerLinks.twig b/plugins/PrivacyManager/templates/footerLinks.twig
new file mode 100644
index 0000000000..4d0cfd09c8
--- /dev/null
+++ b/plugins/PrivacyManager/templates/footerLinks.twig
@@ -0,0 +1,5 @@
+<div id="footerLinks">
+ {% if privacyPolicyUrl|default('') is not empty %}<a target="_blank" rel="noreferrer noopener" href="{{ privacyPolicyUrl|e('html_attr') }}">{{ 'PrivacyManager_PrivacyPolicy'|translate }}</a>{% endif %}
+ {% if privacyPolicyUrl|default('') is not empty and termsAndCondition|default('') is not empty %}|{% endif %}
+ {% if termsAndCondition|default('') is not empty %}<a target="_blank" rel="noreferrer noopener" href="{{ termsAndCondition|e('html_attr') }}">{{ 'PrivacyManager_TermsAndConditions'|translate }}</a>{% endif %}
+</div>