Ejemplo n.º 1
0
 /**
  * Returns true if a report with the given year & month should be purged or not.
  *
  * If reportsOlderThan is set to null or not supplied, this function will check if
  * a report should be purged, based on existing configuration. In this case, if
  * delete_reports_enable is set to 0, this function will return false.
  *
  * @param int $reportDateYear The year of the report in question.
  * @param int $reportDateMonth The month of the report in question.
  * @param int|Date $reportsOlderThan If an int, the number of months a report must be older than
  *                                         in order to be purged. If a date, the date a report must be
  *                                         older than in order to be purged.
  * @return bool
  */
 public static function shouldReportBePurged($reportDateYear, $reportDateMonth, $reportsOlderThan = null)
 {
     // if no 'older than' value/date was supplied, use existing config
     if (is_null($reportsOlderThan)) {
         // if report deletion is not enabled, the report shouldn't be purged
         $settings = self::getPurgeDataSettings();
         if ($settings['delete_reports_enable'] == 0) {
             return false;
         }
         $reportsOlderThan = $settings['delete_reports_older_than'];
     }
     // if a integer was supplied, assume it is the number of months a report must be older than
     if (!$reportsOlderThan instanceof Date) {
         $reportsOlderThan = Date::factory('today')->subMonth(1 + $reportsOlderThan);
     }
     return ReportsPurger::shouldReportBePurged($reportDateYear, $reportDateMonth, $reportsOlderThan);
 }