some more role related fixes: updating participants, if quantity or role changes

This commit is contained in:
Ralf Becker 2009-08-07 10:20:58 +00:00
parent a41aceaaae
commit 0a1a7f4637
2 changed files with 13 additions and 9 deletions

View File

@ -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 '<p>'.__METHOD__.'('.array2string($event).",$ignore_acl)</p>\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']) &&

View File

@ -513,8 +513,8 @@ ORDER BY cal_user_type, cal_usre_id
$minimum_uid_length = 8;
}
//echo '<p>'.__METHOD__."(,$change_since) event="; _debug_array($event);
//error_log(__METHOD__."(".str_replace(array("\n",' '),'',print_r($event,true)).",$set_recurrences,$change_since,$etag)");
//echo '<p>'.__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);