You are here

function sms_track_archive_purge in SMS Framework 6

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

Purge all archived messages after a certain number of days

Parameters

$max_age_days: Maximum age of tracked messages in days

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

File

modules/sms_track/sms_track.module, line 296
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 = time() - $max_age_secs;
    $result = db_query("DELETE FROM {sms_track} WHERE created < %d", $oldest);
  }
}