From 67ed35e6ead5d8f9e564991d131a47dee053b321 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 10 Feb 2005 00:13:37 +0000 Subject: [PATCH] fix for bug [ 1106014 ] Problems with recurring events (several bugs) --- calendar/inc/class.bocal.inc.php | 38 +++++++++++++++++---------- calendar/setup/setup.inc.php | 3 ++- calendar/setup/tables_current.inc.php | 4 +-- calendar/setup/tables_update.inc.php | 24 +++++++++++++++++ 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/calendar/inc/class.bocal.inc.php b/calendar/inc/class.bocal.inc.php index 93536287eb..a7ca111e74 100644 --- a/calendar/inc/class.bocal.inc.php +++ b/calendar/inc/class.bocal.inc.php @@ -243,30 +243,32 @@ class bocal if(count($event_ids) || count($rep_event_ids)) { - //foreach($event_ids+$rep_event_ids as $id) - foreach((array) $this->read($event_ids+$rep_event_ids,true) as $id => $event) + $db_events = (array) $this->read($event_ids+$rep_event_ids,true); + + foreach($db_events as $id => $event) { - //$event = $this->read($id,True); // = no ACL check, as other entries dont get reported !!! + if ($event['recur_type']) continue; // done in 2. step, we need the exceptions first - // recuring events are handled later, remember them for later use, no new read necessary - if ($event['recur_type']) - { - $this->insert_all_repetitions($event,$start,$end,$events,$recur_exceptions[$id]); - $events_sorted = False; - continue; - } // recur-exceptions have a reference to the original event // we remember they are their for a certain date and id, to not insert their regular recurrence if ($event['reference']) { for($ts = $event['start']['raw']; $ts < $event['end']['raw']; $ts += DAY_s) { - $recur_exceptions[$event['reference']][(int)$this->date2string($ts)] = True; + $recur_exceptions[$event['reference']][(int)$this->date2string((int)$ts)] = True; } $recur_exceptions[$event['reference']][$event['end']['full']] = True; } - $events[] = $event; + $events[] = &$db_events[$id]; + unset($db_events[$id]); } + foreach($db_events as $id => $event) + { + $this->insert_all_repetitions($event,$start,$end,$events,$recur_exceptions[$id]); + $events_sorted = False; + } + unset($db_events); + if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) { $this->debug_message('socalendar::search processed event_ids=%1, events=%2',False,$event_ids+$rep_event_ids,$events); @@ -411,10 +413,18 @@ class bocal $search_date_ymd = (int)$this->date2string($ts); $have_exception = !is_null($recur_exceptions) && isset($recur_exceptions[$search_date_ymd]); + + if (!$have_exception) // no execption by an edited event => check the deleted ones + { + foreach($event['recur_exception'] as $exception_ts) + { + $have_exception = $search_date_ymd == (int)$this->date2string($exception_ts); + } + } if ($this->debug && ($this->debug > 3 || $this->debug == 'insert_all_repetions')) { - $this->debug_message('bocal::insert_all_repetions(...,%1) checking recur_exceptions[%2]=%3',False, - $recur_exceptions,$search_date_ymd,$have_exception); + $this->debug_message('bocal::insert_all_repetions(...,%1) checking recur_exceptions[%2] and event[recur_exceptions]=%3 ==> %4',False, + $recur_exceptions,$search_date_ymd,$event['recur_exception'],$have_exception); } if ($have_exception) { diff --git a/calendar/setup/setup.inc.php b/calendar/setup/setup.inc.php index bad7ebd03a..1afd4f641c 100755 --- a/calendar/setup/setup.inc.php +++ b/calendar/setup/setup.inc.php @@ -12,7 +12,7 @@ /* $Id$ */ $setup_info['calendar']['name'] = 'calendar'; - $setup_info['calendar']['version'] = '1.0.0.004'; + $setup_info['calendar']['version'] = '1.0.0.005'; $setup_info['calendar']['app_order'] = 3; $setup_info['calendar']['enable'] = 1; @@ -62,3 +62,4 @@ + diff --git a/calendar/setup/tables_current.inc.php b/calendar/setup/tables_current.inc.php index 8bf2ace23b..0164d6e135 100644 --- a/calendar/setup/tables_current.inc.php +++ b/calendar/setup/tables_current.inc.php @@ -61,9 +61,9 @@ 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') ), - 'pk' => array(), + 'pk' => array('cal_id'), 'fk' => array(), - 'ix' => array('cal_id'), + 'ix' => array(), 'uc' => array() ), 'phpgw_cal_user' => array( diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index caa4a8d3a7..0b15df5a50 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -1135,4 +1135,28 @@ $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.004'; return $GLOBALS['setup_info']['calendar']['currentver']; } + + + $test[] = '1.0.0.004'; + function calendar_upgrade1_0_0_004() + { + $GLOBALS['phpgw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array( + 'fd' => array( + 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), + 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), + 'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'), + 'recur_enddate' => array('type' => 'int','precision' => '8'), + 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), + 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), + 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') + ), + 'pk' => array('cal_id'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + )); + + $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.005'; + return $GLOBALS['setup_info']['calendar']['currentver']; + } ?>