Skip to content

Commit

Permalink
Minor changes Re: isDataPurgeSettingsEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Jan 7, 2014
1 parent 4170bbd commit 546ef83
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions core/Plugin/ControllerAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Piwik\Plugin;

use Piwik\Config as PiwikConfig;
use Piwik\Config;
use Piwik\Menu\MenuAdmin;
use Piwik\Menu\MenuTop;
use Piwik\Notification;
Expand Down Expand Up @@ -129,6 +130,7 @@ static public function setBasicVariablesAdminView(View $view)
$view->topMenu = MenuTop::getInstance()->getMenu();
$view->currentAdminMenuName = MenuAdmin::getInstance()->getCurrentAdminMenuName();

$view->isDataPurgeSettingsEnabled = self::isDataPurgeSettingsEnabled();
$view->enableFrames = PiwikConfig::getInstance()->General['enable_framed_settings'];
if (!$view->enableFrames) {
$view->setXFrameOptions('sameorigin');
Expand All @@ -147,6 +149,10 @@ static public function setBasicVariablesAdminView(View $view)
NotificationManager::cancelAllNonPersistent();
}

static protected function isDataPurgeSettingsEnabled()
{
return (bool) Config::getInstance()->General['enable_delete_old_data_settings_admin'];
}

static protected function getPiwikVersion()
{
Expand Down
3 changes: 3 additions & 0 deletions plugins/CoreAdminHome/templates/generalSettings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@
<input type="submit" value="{{ 'General_Save'|translate }}" id="generalSettingsSubmit" class="submit"/>
<br/>
<br/>

{% if isDataPurgeSettingsEnabled %}
{% set clickDeleteLogSettings %}{{ 'PrivacyManager_DeleteDataSettings'|translate }}{% endset %}
<h2>{{ 'PrivacyManager_DeleteDataSettings'|translate }}</h2>
<p>
Expand All @@ -243,6 +245,7 @@
{{ 'PrivacyManager_ClickHereSettings'|translate("'" ~ clickDeleteLogSettings ~ "'") }}
</a>
</p>
{% endif %}
{% endif %}
<h2>{{ 'CoreAdminHome_OptOutForYourVisitors'|translate }}</h2>

Expand Down
10 changes: 3 additions & 7 deletions plugins/PrivacyManager/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,11 @@ public function saveSettings()

private function checkDataPurgeAdminSettingsIsEnabled()
{
if (!$this->isDataPurgeSettingsEnabled()) {
if (!self::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 @@ -144,7 +139,6 @@ 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 @@ -189,6 +183,8 @@ public function executeDataPurge()

protected function getDeleteDBSizeEstimate($getSettingsFromQuery = false, $forceEstimate = false)
{
$this->checkDataPurgeAdminSettingsIsEnabled();

// get the purging settings & create two purger instances
if ($getSettingsFromQuery) {
$settings = $this->getPurgeSettingsFromRequest();
Expand Down

0 comments on commit 546ef83

Please sign in to comment.