savePurgeDataSettings() публичный статический Метод

Saves the supplied data purging settings.
public static savePurgeDataSettings ( array $settings )
$settings array The settings to save.
Пример #1
0
 public function saveSettings()
 {
     Piwik::checkUserIsSuperUser();
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $this->checkTokenInUrl();
         switch (Common::getRequestVar('form')) {
             case "formMaskLength":
                 $this->handlePluginState(Common::getRequestVar("anonymizeIPEnable", 0));
                 $trackerConfig = Config::getInstance()->Tracker;
                 $trackerConfig['ip_address_mask_length'] = Common::getRequestVar("maskLength", 1);
                 $trackerConfig['use_anonymized_ip_for_visit_enrichment'] = Common::getRequestVar("useAnonymizedIpForVisitEnrichment", 1);
                 Config::getInstance()->Tracker = $trackerConfig;
                 Config::getInstance()->forceSave();
                 break;
             case "formDeleteSettings":
                 $this->checkDataPurgeAdminSettingsIsEnabled();
                 $settings = $this->getPurgeSettingsFromRequest();
                 PrivacyManager::savePurgeDataSettings($settings);
                 break;
             default:
                 //do nothing
                 break;
         }
     }
     $notification = new Notification(Piwik::translate('General_YourChangesHaveBeenSaved'));
     $notification->context = Notification::CONTEXT_SUCCESS;
     Notification\Manager::notify('PrivacyManager_ChangesHaveBeenSaved', $notification);
     $this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1));
 }
Пример #2
0
 public function saveSettings()
 {
     Piwik::checkUserHasSuperUserAccess();
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $this->checkTokenInUrl();
         switch (Common::getRequestVar('form')) {
             case "formMaskLength":
                 $enable = Common::getRequestVar("anonymizeIPEnable", 0);
                 if ($enable == 1) {
                     IPAnonymizer::activate();
                 } else {
                     if ($enable == 0) {
                         IPAnonymizer::deactivate();
                     } else {
                         // pass
                     }
                 }
                 $privacyConfig = new Config();
                 $privacyConfig->ipAddressMaskLength = Common::getRequestVar("maskLength", 1);
                 $privacyConfig->useAnonymizedIpForVisitEnrichment = Common::getRequestVar("useAnonymizedIpForVisitEnrichment", 1);
                 break;
             case "formDeleteSettings":
                 $this->checkDataPurgeAdminSettingsIsEnabled();
                 $settings = $this->getPurgeSettingsFromRequest();
                 PrivacyManager::savePurgeDataSettings($settings);
                 break;
             default:
                 //do nothing
                 break;
         }
     }
     $notification = new Notification(Piwik::translate('General_YourChangesHaveBeenSaved'));
     $notification->context = Notification::CONTEXT_SUCCESS;
     Notification\Manager::notify('PrivacyManager_ChangesHaveBeenSaved', $notification);
     $this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1));
 }
Пример #3
0
 public function test_markArchivesAsInvalidated_DoesNotInvalidateDatesBeforePurgeThreshold()
 {
     PrivacyManager::savePurgeDataSettings(array('delete_logs_enable' => 1, 'delete_logs_older_than' => 180));
     $dateBeforeThreshold = Date::factory('today')->subDay(190);
     $thresholdDate = Date::factory('today')->subDay(180);
     $dateAfterThreshold = Date::factory('today')->subDay(170);
     // can't test more than day since today will change, causing the test to fail w/ other periods randomly
     $this->insertArchiveRow(1, $dateBeforeThreshold, 'day');
     $this->insertArchiveRow(1, $dateAfterThreshold, 'day');
     /** @var ArchiveInvalidator $archiveInvalidator */
     $archiveInvalidator = self::$fixture->piwikEnvironment->getContainer()->get('Piwik\\Archive\\ArchiveInvalidator');
     $result = $archiveInvalidator->markArchivesAsInvalidated(array(1), array($dateBeforeThreshold, $dateAfterThreshold), 'day');
     $this->assertEquals($thresholdDate->toString(), $result->minimumDateWithLogs);
     $expectedProcessedDates = array($dateAfterThreshold->toString());
     $this->assertEquals($expectedProcessedDates, $result->processedDates);
     $expectedWarningDates = array($dateBeforeThreshold->toString());
     $this->assertEquals($expectedWarningDates, $result->warningDates);
     $invalidatedArchives = $this->getInvalidatedIdArchives();
     $countInvalidatedArchives = 0;
     foreach ($invalidatedArchives as $idarchives) {
         $countInvalidatedArchives += count($idarchives);
     }
     $this->assertEquals(1, $countInvalidatedArchives);
 }
Пример #4
0
 /**
  * Tests that purgeData works correctly when the 'keep segment reports' setting is set to true.
  *
  * @group Integration
  */
 public function testPurgeDataDeleteReportsKeepSegmentsReports()
 {
     PrivacyManager::savePurgeDataSettings(array('delete_reports_keep_day_reports' => 1, 'delete_reports_keep_segment_reports' => 1));
     // get purge data prediction
     $prediction = PrivacyManager::getPurgeEstimate();
     // perform checks on prediction
     $events = 3;
     // only the event action for the three purged day, dayAgo=x are purged (others are still in use)
     $expectedPrediction = array(Common::prefixTable('log_conversion') => 6, Common::prefixTable('log_link_visit_action') => 6 + $events, Common::prefixTable('log_visit') => 3, Common::prefixTable('log_conversion_item') => 3, Common::prefixTable('archive_numeric_2012_01') => -1, Common::prefixTable('archive_blob_2012_01') => 9);
     $this->assertEquals($expectedPrediction, $prediction);
     // purge data
     $this->_setTimeToRun();
     $this->assertTrue($this->instance->deleteLogData());
     $this->assertTrue($this->instance->deleteReportData());
     // perform checks
     $this->checkLogDataPurged();
     $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 6, $janNumericRemaining = 70);
     // 1 segmented blob + 5 day blobs
 }
Пример #5
0
 private function savePurgeDataSettings($settings)
 {
     Piwik::checkUserHasSuperUserAccess();
     $this->checkDataPurgeAdminSettingsIsEnabled();
     PrivacyManager::savePurgeDataSettings($settings);
     return true;
 }