From 0a1a7f4637be69fe325a46aaf2f7ba4ad68b2804 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 7 Aug 2009 10:20:58 +0000 Subject: [PATCH] some more role related fixes: updating participants, if quantity or role changes --- calendar/inc/class.calendar_boupdate.inc.php | 8 +++++--- calendar/inc/class.calendar_so.inc.php | 14 ++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index fc091f61c5..b0386073e5 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -131,7 +131,8 @@ class calendar_boupdate extends calendar_bo $quantity = $users = array(); foreach($event['participants'] as $uid => $status) { - if ($status[0] == 'R') continue; // ignore rejected participants + calendar_so::split_status($status,$q,$r); + if ($status == 'R') continue; // ignore rejected participants if ($uid < 0) // group, check it's members too { @@ -141,7 +142,7 @@ class calendar_boupdate extends calendar_bo $users[] = $uid; if (in_array($uid[0],$types_with_quantity)) { - $quantity[$uid] = max(1,(int) substr($status,2)); + $quantity[$uid] = $q; } } $overlapping_events =& $this->search(array( @@ -677,7 +678,8 @@ class calendar_boupdate extends calendar_bo */ function save($event, $ignore_acl=false) { - //error_log(__METHOD__."(".str_replace(array("\n",' '),'',print_r($event,true)).",$etag)"); + //echo '

'.__METHOD__.'('.array2string($event).",$ignore_acl)

\n"; + //error_log(__METHOD__.'('.array2string($event).",$etag)"); // check if user has the permission to update / create the event if (!$ignore_acl && ($event['id'] && !$this->check_perms(EGW_ACL_EDIT,$event['id']) || !$event['id'] && !$this->check_perms(EGW_ACL_EDIT,0,$event['owner']) && diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index 967263fc4a..5dab1fb47f 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -513,8 +513,8 @@ ORDER BY cal_user_type, cal_usre_id $minimum_uid_length = 8; } - //echo '

'.__METHOD__."(,$change_since) event="; _debug_array($event); - //error_log(__METHOD__."(".str_replace(array("\n",' '),'',print_r($event,true)).",$set_recurrences,$change_since,$etag)"); + //echo '

'.__METHOD__.'('.array2string($event).",$change_since) event="; _debug_array($event); + //error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag)"); $cal_id = (int) $event['id']; unset($event['id']); @@ -911,17 +911,19 @@ ORDER BY cal_user_type, cal_usre_id } // existing participants must not be updated - foreach($this->db->select($this->user_table,'DISTINCT cal_user_type,cal_user_id',$where,__LINE__,__FILE__,false,'','calendar') as $row) + foreach($this->db->select($this->user_table,'DISTINCT cal_user_type,cal_user_id,cal_quantity,cal_role',$where,__LINE__,__FILE__,false,'','calendar') as $row) { - $existing_participants[] = self::combine_user($row['cal_user_type'],$row['cal_user_id']); + $existing_participants[self::combine_user($row['cal_user_type'],$row['cal_user_id'])] = self::combine_status('',$row['cal_quantity'],$row['cal_role']); } } if (!count($recurrences)) $recurrences[] = 0; // insert the default one foreach($participants as $uid => $status) { - if (in_array($uid,$existing_participants)) continue; // don't update existing participants - + if (isset($existing_participants[$uid]) && substr($status,1) == $existing_participants[$uid]) + { + continue; // dont update existing participants, if quantity or role is not changed + } $id = null; self::split_user($uid,$type,$id); self::split_status($status,$quantity,$role);