Skip to content

Commit

Permalink
Adding new option to disable the Admin settings for: Log data + Repor…
Browse files Browse the repository at this point in the history
…t data delete
  • Loading branch information
mattab committed Jan 7, 2014
1 parent 09d20bc commit 1834994
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/global.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@
; 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,
Expand Down
15 changes: 15 additions & 0 deletions plugins/PrivacyManager/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function saveSettings()
break;

case("formDeleteSettings"):
$this->checkDataPurgeAdminSettingsIsEnabled();
$settings = $this->getPurgeSettingsFromRequest();
PrivacyManager::savePurgeDataSettings($settings);
break;
Expand All @@ -66,6 +67,18 @@ public function saveSettings()
$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.
Expand Down Expand Up @@ -131,6 +144,7 @@ public function privacySettings()
$view = new View('@PrivacyManager/privacySettings');

if (Piwik::isUserIsSuperUser()) {
$view->isDataPurgeSettingsEnabled = $this->isDataPurgeSettingsEnabled();
$view->deleteData = $this->getDeleteDataInfo();
$view->anonymizeIP = $this->getAnonymizeIPInfo();
$view->dntSupport = self::isDntSupported();
Expand Down Expand Up @@ -305,4 +319,5 @@ protected function handlePluginState($state = 0)
//nothing to do
}
}

}
12 changes: 9 additions & 3 deletions plugins/PrivacyManager/templates/privacySettings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>

Expand All @@ -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/>
Expand Down Expand Up @@ -139,7 +141,7 @@
<td width="250">&nbsp;</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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 1834994

Please sign in to comment.