From 3ccd187698a4cfb6e76ba5ffb575e5738f2fb9dd Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 14 Jun 2011 18:17:22 +0000 Subject: [PATCH] * Calendar: added purge interval of half a year --- calendar/inc/class.calendar_boupdate.inc.php | 15 +++++++-------- calendar/inc/class.calendar_hooks.inc.php | 8 +++++--- calendar/templates/default/config.tpl | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index c8ff8a58e5..d51aa23f55 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -2350,15 +2350,14 @@ class calendar_boupdate extends calendar_bo } } /** - * Delete events that are more than $age years old - * - * Purges old events from the database - * - * @param int $age How many years old the event must be before it is deleted - */ + * Delete events that are more than $age years old + * + * Purges old events from the database + * + * @param int|float $age How many years old the event must be before it is deleted + */ function purge($age) { - $time = strtotime("-$age years", time()); - $this->so->purge($time); + $this->so->purge(time() - 365*24*3600*(float)$age); } } diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index fdc3f2bbef..504241c73b 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -572,18 +572,20 @@ class calendar_hooks } // Not part of the class, since config hooks are still using the old style -function calendar_purge_old($config) { +function calendar_purge_old($config) +{ $id = 'calendar_purge'; // Cancel old purge ExecMethod('phpgwapi.asyncservice.cancel_timer', $id); - if((int)$config > 0) { + if((int)$config > 0) + { $result = ExecMethod2('phpgwapi.asyncservice.set_timer', array('month' => '*', 'day' => 1), $id, 'calendar.calendar_boupdate.purge', - (int)$config + (float)$config ); } if(!$result) diff --git a/calendar/templates/default/config.tpl b/calendar/templates/default/config.tpl index 5508ce0e6d..b8b529dd83 100644 --- a/calendar/templates/default/config.tpl +++ b/calendar/templates/default/config.tpl @@ -77,6 +77,7 @@