You are here

function sms_track_archive_purge in SMS Framework 7

Same name and namespace in other branches
  1. 6.2 modules/sms_track/sms_track.module \sms_track_archive_purge()
  2. 6 modules/sms_track/sms_track.module \sms_track_archive_purge()

Purge all archived messages after a certain number of days

Parameters

int $max_age_days: (optional) Maximum age of tracked messages in days. If null or not supplied, the pre-configured value is used (default is 0).

1 call to sms_track_archive_purge()
sms_track_cron in modules/sms_track/sms_track.module
Implements hook_cron().

File

modules/sms_track/sms_track.module, line 325
Message tracking feature module for Drupal SMS Framework.

Code

function sms_track_archive_purge($max_age_days = NULL) {

  // Get the configured max_age from the variable table if not given.
  if (is_null($max_age_days)) {
    $max_age_days = variable_get('sms_track_archive_max_age_days', 0);
  }

  // Purge with no survivors.
  if ($max_age_days > 0) {
    $max_age_secs = $max_age_days * 86400;
    $oldest = REQUEST_TIME - $max_age_secs;
    $result = db_delete('sms_track')
      ->condition('created', $oldest, '<')
      ->execute();
  }
}