- Fix purging of old events so it doesn't delete everything

- Trick config into calling the hook when purging is turned off so cron job is cancelled
This commit is contained in:
Nathan Gray 2010-07-01 15:27:37 +00:00
parent 0867ed78d8
commit f8431b00a7
3 changed files with 12 additions and 8 deletions

View File

@ -578,12 +578,14 @@ function calendar_purge_old($config) {
// Cancel old purge
ExecMethod('phpgwapi.asyncservice.cancel_timer', $id);
$result = ExecMethod2('phpgwapi.asyncservice.set_timer',
array('month' => '*', 'day' => 1),
$id,
'calendar.calendar_boupdate.purge',
(int)$config
);
if((int)$config > 0) {
$result = ExecMethod2('phpgwapi.asyncservice.set_timer',
array('month' => '*', 'day' => 1),
$id,
'calendar.calendar_boupdate.purge',
(int)$config
);
}
if(!$result)
{
$GLOBALS['config_error'] = 'Unable to schedule purge';

View File

@ -1516,7 +1516,9 @@ ORDER BY cal_user_type, cal_usre_id
$sql = "DELETE egw_cal.* FROM egw_cal
LEFT JOIN egw_cal_repeats ON
egw_cal_repeats.cal_id = egw_cal.cal_id
WHERE egw_cal_repeats.cal_id IS NULL || (recur_enddate < $date && recur_enddate != 0)";
JOIN egw_cal_dates ON
egw_cal.cal_id = egw_cal_dates.cal_id
WHERE cal_end < $date AND (egw_cal_repeats.cal_id IS NULL || (recur_enddate < $date && recur_enddate != 0))";
$this->db->query($sql, __LINE__, __FILE__);
// Get a list of what we just deleted for links

View File

@ -72,7 +72,7 @@
<td>&nbsp;{lang_Automatically_purge_old_events_after}</td>
<td>
<select name="newsettings[calendar_purge_old]">
<option value="">{lang_No_automatic_purging}</option>
<option value="0ff">{lang_No_automatic_purging}</option>
<option value="1"{selected_calendar_purge_old_1}>1 {lang_year}</option>
<option value="2"{selected_calendar_purge_old_2}>2 {lang_years}</option>
<option value="3"{selected_calendar_purge_old_3}>3 {lang_years}</option>