Пример #1
0
 /**
  * Returns an array describing what data would be purged if both log data & report
  * purging is invoked.
  *
  * The returned array maps table names with the number of rows that will be deleted.
  * If the table name is mapped with -1, the table will be dropped.
  *
  * @param array $settings The config options to use in the estimate. If null, the real
  *                        options are used.
  * @return array
  */
 public static function getPurgeEstimate($settings = null)
 {
     if (is_null($settings)) {
         $settings = self::getPurgeDataSettings();
     }
     $result = array();
     if ($settings['delete_logs_enable']) {
         $logDataPurger = LogDataPurger::make($settings);
         $result = array_merge($result, $logDataPurger->getPurgeEstimate());
     }
     if ($settings['delete_reports_enable']) {
         $reportsPurger = ReportsPurger::make($settings, self::getAllMetricsToKeep());
         $result = array_merge($result, $reportsPurger->getPurgeEstimate());
     }
     return $result;
 }
Пример #2
0
 /**
  * Executes a data purge, deleting log data and report data using the current config
  * options. Echo's the result of getDatabaseSize after purging.
  */
 public function executeDataPurge()
 {
     $this->checkDataPurgeAdminSettingsIsEnabled();
     Piwik::checkUserHasSuperUserAccess();
     $this->checkTokenInUrl();
     // if the request isn't a POST, redirect to index
     if ($_SERVER["REQUEST_METHOD"] != "POST" && !Common::isPhpCliMode()) {
         $this->redirectToIndex('PrivacyManager', 'privacySettings');
         return;
     }
     $settings = PrivacyManager::getPurgeDataSettings();
     if ($settings['delete_logs_enable']) {
         /** @var LogDataPurger $logDataPurger */
         $logDataPurger = StaticContainer::get('Piwik\\Plugins\\PrivacyManager\\LogDataPurger');
         $logDataPurger->purgeData($settings['delete_logs_older_than']);
     }
     if ($settings['delete_reports_enable']) {
         $reportsPurger = ReportsPurger::make($settings, PrivacyManager::getAllMetricsToKeep());
         $reportsPurger->purgeData(true);
     }
 }
Пример #3
0
 /**
  * Executes a data purge, deleting log data and report data using the current config
  * options. Echo's the result of getDatabaseSize after purging.
  */
 public function executeDataPurge()
 {
     Piwik::checkUserHasSuperUserAccess();
     $this->checkTokenInUrl();
     // if the request isn't a POST, redirect to index
     if ($_SERVER["REQUEST_METHOD"] != "POST" && !Common::isPhpCliMode()) {
         $this->redirectToIndex('PrivacyManager', 'privacySettings');
         return;
     }
     $settings = PrivacyManager::getPurgeDataSettings();
     if ($settings['delete_logs_enable']) {
         $logDataPurger = LogDataPurger::make($settings);
         $logDataPurger->purgeData();
     }
     if ($settings['delete_reports_enable']) {
         $reportsPurger = ReportsPurger::make($settings, PrivacyManager::getAllMetricsToKeep());
         $reportsPurger->purgeData(true);
     }
 }
Пример #4
0
 /**
  * Returns an array describing what data would be purged if both log data & report
  * purging is invoked.
  *
  * The returned array maps table names with the number of rows that will be deleted.
  * If the table name is mapped with -1, the table will be dropped.
  *
  * @param array $settings The config options to use in the estimate. If null, the real
  *                        options are used.
  * @return array
  */
 public static function getPurgeEstimate($settings = null)
 {
     if (is_null($settings)) {
         $settings = self::getPurgeDataSettings();
     }
     $result = array();
     if ($settings['delete_logs_enable']) {
         /** @var LogDataPurger $logDataPurger */
         $logDataPurger = StaticContainer::get('Piwik\\Plugins\\PrivacyManager\\LogDataPurger');
         $result = array_merge($result, $logDataPurger->getPurgeEstimate($settings['delete_logs_older_than']));
     }
     if ($settings['delete_reports_enable']) {
         $reportsPurger = ReportsPurger::make($settings, self::getAllMetricsToKeep());
         $result = array_merge($result, $reportsPurger->getPurgeEstimate());
     }
     return $result;
 }