diff --git a/config/global.ini.php b/config/global.ini.php index 794f9dc0a27d9eb074d773f52dbb6ab16040758c..00ec6dac750ec9cd133713a79f8be54b6d3c0ba1 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 a54d6bd8365bdbd456e42230bb4a479a89ba1afb..a795aeef4c5be6135fcb5e9b9ffeb404ec8c498e 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 5080c5d509d79ced80fd78688205db2ddf6b5617..1ea461869d1cef7fa7ced8c5c60e5e95688210fc 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>