From f29e94da41cfe8d3a6846912941717203085fdf5 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 9 Apr 2011 15:24:04 +0000 Subject: [PATCH] * Calendar: fixed status of all recurrences get set to "unknown", if status of a single recurrence get changed (#2916) --- 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 825301a878..5627b97f6d 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -1186,7 +1186,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) @@ -1198,13 +1198,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 @@ -1322,7 +1327,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 {