From 1834994a8675e19d472335acdc987eb5c529c86c Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Wed, 8 Jan 2014 10:51:05 +1300 Subject: [PATCH] Adding new option to disable the Admin settings for: Log data + Report data delete --- config/global.ini.php | 3 +++ plugins/PrivacyManager/Controller.php | 15 +++++++++++++++ .../PrivacyManager/templates/privacySettings.twig | 12 +++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/config/global.ini.php b/config/global.ini.php index 794f9dc0a2..00ec6dac75 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -370,6 +370,9 @@ enable_plugins_admin = 1 ; By setting this option to 0, you can prevent Super User from editing the Geolocation settings. enable_geolocation_admin = 1 +; By setting this option to 0, the old log data and old report data features will be hidden from the UI +; Note: log purging and old data purging still occurs, just the Super User cannot change the settings. +enable_delete_old_data_admin = 1 [Tracker] ; Piwik uses first party cookies by default. If set to 1, diff --git a/plugins/PrivacyManager/Controller.php b/plugins/PrivacyManager/Controller.php index a54d6bd836..a795aeef4c 100644 --- a/plugins/PrivacyManager/Controller.php +++ b/plugins/PrivacyManager/Controller.php @@ -50,6 +50,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin break; case("formDeleteSettings"): + $this->checkDataPurgeAdminSettingsIsEnabled(); $settings = $this->getPurgeSettingsFromRequest(); PrivacyManager::savePurgeDataSettings($settings); break; @@ -66,6 +67,18 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1)); } + private function checkDataPurgeAdminSettingsIsEnabled() + { + if (!$this->isDataPurgeSettingsEnabled()) { + throw new \Exception("Configuring deleting log data and report data has been disabled by Piwik admins."); + } + } + + private function isDataPurgeSettingsEnabled() + { + return (bool) Config::getInstance()->General['enable_delete_old_data_settings_admin']; + } + /** * Utility function. Gets the delete logs/reports settings from the request and uses * them to populate config arrays. @@ -131,6 +144,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view = new View('@PrivacyManager/privacySettings'); if (Piwik::isUserIsSuperUser()) { + $view->isDataPurgeSettingsEnabled = $this->isDataPurgeSettingsEnabled(); $view->deleteData = $this->getDeleteDataInfo(); $view->anonymizeIP = $this->getAnonymizeIPInfo(); $view->dntSupport = self::isDntSupported(); @@ -305,4 +319,5 @@ class Controller extends \Piwik\Plugin\ControllerAdmin //nothing to do } } + } diff --git a/plugins/PrivacyManager/templates/privacySettings.twig b/plugins/PrivacyManager/templates/privacySettings.twig index 5080c5d509..1ea461869d 100644 --- a/plugins/PrivacyManager/templates/privacySettings.twig +++ b/plugins/PrivacyManager/templates/privacySettings.twig @@ -7,7 +7,7 @@ <p>{{ 'PrivacyManager_Teaser'|translate('<a href="#anonymizeIPAnchor">',"</a>",'<a href="#deleteLogsAnchor">',"</a>",'<a href="#optOutAnchor">',"</a>")|raw }} See also our official guide <strong><a href='http://piwik.org/privacy/' target='_blank'>Web Analytics Privacy</a></strong></p> <h2 id="anonymizeIPAnchor">{{ 'PrivacyManager_UseAnonymizeIp'|translate }}</h2> - <form method="post" action="{{ {'action':'saveSettings', 'form':'formMaskLength', 'token_auth':token_auth} | urlRewriteWithParameters }}" id="formMaskLength" name="formMaskLength"> + <form method="post" action="{{ {'action':'saveSettings', 'form':'formMaskLength', 'token_auth':token_auth} | urlRewriteWithParameters }}" id="formMaskLength"> <div id='anonymizeIpSettings'> <table class="adminTable" style='width:800px;'> <tr> @@ -79,6 +79,8 @@ <input type="submit" value="{{ 'General_Save'|translate }}" id="privacySettingsSubmit" class="submit"/> </form> + + {% if isDataPurgeSettingsEnabled %} <div class="ui-confirm" id="confirmDeleteSettings"> <h2 id="deleteLogsConfirm">{{ 'PrivacyManager_DeleteLogsConfirm'|translate }}</h2> @@ -99,7 +101,7 @@ </div> <h2 id="deleteLogsAnchor">{{ 'PrivacyManager_DeleteDataSettings'|translate }}</h2> <p>{{ 'PrivacyManager_DeleteDataDescription'|translate }} {{ 'PrivacyManager_DeleteDataDescription2'|translate }}</p> - <form method="post" action="{{ {'action':'saveSettings','form':'formDeleteSettings','token_auth':token_auth} | urlRewriteWithParameters }}" id="formDeleteSettings" name="formMaskLength"> + <form method="post" action="{{ {'action':'saveSettings','form':'formDeleteSettings','token_auth':token_auth} | urlRewriteWithParameters }}" id="formDeleteSettings"> <table class="adminTable" style='width:800px;'> <tr id='deleteLogSettingEnabled'> <td width="250">{{ 'PrivacyManager_UseDeleteLog'|translate }}<br/> @@ -139,7 +141,7 @@ <td width="250"> </td> <td width="500"> <label>{{ 'PrivacyManager_DeleteLogsOlderThan'|translate }} - <input type="text" id="deleteOlderThan" value="{{ deleteData.config.delete_logs_older_than }}" style="width:35px;" + <input type="text" id="deleteOlderThan" value="{{ deleteData.config.delete_logs_older_than }}" style="width:55px;" name="deleteOlderThan"/> {{ 'CoreHome_PeriodDays'|translate }}</label><br/> <span class="form-description">{{ 'PrivacyManager_LeastDaysInput'|translate("1") }}</span> @@ -265,6 +267,10 @@ </table> <input type="button" value="{{ 'General_Save'|translate }}" id="deleteLogSettingsSubmit" class="submit"/> </form> + + {% endif %} + + <h2 id="DNT">{{ 'PrivacyManager_DoNotTrack_SupportDNTPreference'|translate }}</h2> <table class="adminTable" style='width:800px;'> <tr> -- GitLab