From 3c469c8392d8bdd32006cbef2123263bb8a5bbbc Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 6 Jan 2011 05:19:10 +0000 Subject: [PATCH] fixed status of all recurrences get set to "unknown", if status of a single recurrence get changed --- calendar/inc/class.calendar_so.inc.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index 9c0323e988..8ecc33c06d 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -1277,7 +1277,7 @@ ORDER BY cal_user_type, cal_usre_id if ((int) $change_since) { - $where[0] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')'; + $where[] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')'; } if ($change_since !== false) @@ -1289,13 +1289,18 @@ ORDER BY cal_user_type, cal_usre_id } // update existing entries - $existing_entries = $this->db->select($this->user_table,'DISTINCT cal_user_type,cal_user_id',$where,__LINE__,__FILE__,false,'','calendar'); + $existing_entries = $this->db->select($this->user_table,'*',$where,__LINE__,__FILE__,false,'ORDER BY cal_recur_date DESC','calendar'); // create a full list of participants which already exist in the db + // with status, quantity and role of the earliest recurence $old_participants = array(); foreach($existing_entries as $row) { - $old_participants[self::combine_user($row['cal_user_type'],$row['cal_user_id'])] = true; + $uid = self::combine_user($row['cal_user_type'],$row['cal_user_id']); + if ($row['cal_recur_date'] || !isset($old_participants[$uid])) + { + $old_participants[$uid] = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); + } } // tag participants which should be deleted @@ -1413,7 +1418,8 @@ ORDER BY cal_user_type, cal_usre_id // check if the user has any status database entries and create the default set if needed // a status update before having the necessary entries happens on e.g. group invitations - $this->participants($cal_id,array(self::combine_user($user_type,$user_id) => 'U'),0,true); +// commented out, as it causes problems when called with a single / not all participants (not sure why it is necessary anyway) +// $this->participants($cal_id,array(self::combine_user($user_type,$user_id) => 'U'),0,true); if ($status == 'G') // remove group invitations, as we dont store them in the db {