* Calendar/CalDAV: fixed event not show if user only participates in an exeception (not the master) and has no read-rights for any master participant

This commit is contained in:
Ralf Becker 2015-10-09 17:37:25 +00:00
parent 769399b0cc
commit 235172d623
2 changed files with 34 additions and 18 deletions

View File

@ -680,11 +680,11 @@ class calendar_bo
'id' => $event['id'], 'id' => $event['id'],
'start' => $event['start'], 'start' => $event['start'],
'end' => $event['end'], 'end' => $event['end'],
'whole_day' => $event['whole_day'],
'tzid' => $event['tzid'], 'tzid' => $event['tzid'],
'title' => lang('private'), 'title' => lang('private'),
'modified' => $event['modified'], 'modified' => $event['modified'],
'owner' => $event['owner'], 'owner' => $event['owner'],
'recur_type' => MCAL_RECUR_NONE,
'uid' => $event['uid'], 'uid' => $event['uid'],
'etag' => $event['etag'], 'etag' => $event['etag'],
'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)), 'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)),
@ -692,7 +692,17 @@ class calendar_bo
'category' => $event['category'], // category is visible anyway, eg. by using planner by cat 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat
'non_blocking' => $event['non_blocking'], 'non_blocking' => $event['non_blocking'],
'caldav_name' => $event['caldav_name'], 'caldav_name' => $event['caldav_name'],
); // we need full recurrence information, as they are relevant free/busy information
)+($event['recur_type'] ? array(
'recur_type' => $event['recur_type'],
'recur_interval' => $event['recur_interval'],
'recur_data' => $event['recur_data'],
'recur_enddate' => $event['recur_enddate'],
'recur_exception'=> $event['recur_exception'],
):array(
'reference' => $event['reference'],
'recurrence' => $event['recurrence'],
));
} }
/** /**

View File

@ -177,7 +177,7 @@ class calendar_groupdav extends groupdav_handler
if ($path == '/calendar/') if ($path == '/calendar/')
{ {
$filter['filter'] = 'owner'; $filter['filter'] = 'default';
} }
// scheduling inbox, shows only not yet accepted or rejected events // scheduling inbox, shows only not yet accepted or rejected events
elseif (substr($path,-7) == '/inbox/') elseif (substr($path,-7) == '/inbox/')
@ -647,10 +647,14 @@ class calendar_groupdav extends groupdav_handler
); );
if (is_array($expand)) $params += $expand; if (is_array($expand)) $params += $expand;
$events =& $bo->search($params); if (!($events =& $bo->search($params)))
{
return array();
}
// find master, which is not always first event, eg. when first event is an exception // find master, which is not always first event, eg. when first event is an exception
$master = null; $master = null;
$exceptions = array();
foreach($events as $k => &$recurrence) foreach($events as $k => &$recurrence)
{ {
if ($recurrence['recur_type']) if ($recurrence['recur_type'])
@ -662,20 +666,18 @@ class calendar_groupdav extends groupdav_handler
} }
} }
// if recurring event starts in future behind horizont, nothing will be returned by bo::search() // if recurring event starts in future behind horizont, nothing will be returned by bo::search()
if (!isset($master) && !($master = $bo->read($uid))) if (!isset($master)) $master = $bo->read($uid);
{
return array();
}
foreach($events as $k => &$recurrence) foreach($events as $k => &$recurrence)
{ {
//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence)); //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence));
if ($recurrence['id'] != $master['id']) // real exception if (!$master || $recurrence['id'] != $master['id']) // real exception
{ {
// user is NOT participating in this exception // user is NOT participating in this exception
if ($user && !self::isParticipant($recurrence, $user)) if ($user && !self::isParticipant($recurrence, $user))
{ {
// if he is NOT in master, delete this exception // if he is NOT in master, delete this exception
if (!self::isParticipant($master, $user)) if (!$master || !self::isParticipant($master, $user))
{ {
unset($events[$k]); unset($events[$k]);
continue; continue;
@ -695,14 +697,16 @@ class calendar_groupdav extends groupdav_handler
continue; // nothing to change continue; // nothing to change
} }
// alarms are reported on recurrences --> move them to master // alarms are reported on recurrences --> move them to master
if ($master)
{
foreach($recurrence['alarm'] as $alarm) foreach($recurrence['alarm'] as $alarm)
{ {
$master['alarm'][] = $alarm; $master['alarm'][] = $alarm;
} }
$recurrence['alarm'] = array(); $recurrence['alarm'] = array();
}
// now we need to check if this recurrence is an exception // now we need to check if this recurrence is an exception
if (!$expand && $master['participants'] == $recurrence['participants']) if (!$expand && $master && $master['participants'] == $recurrence['participants'])
{ {
//error_log('NO exception: '.array2string($recurrence)); //error_log('NO exception: '.array2string($recurrence));
unset($events[$k]); // no exception --> remove it unset($events[$k]); // no exception --> remove it
@ -711,12 +715,12 @@ class calendar_groupdav extends groupdav_handler
// this is a virtual exception now (no extra event/cal_id in DB) // this is a virtual exception now (no extra event/cal_id in DB)
//error_log('virtual exception: '.array2string($recurrence)); //error_log('virtual exception: '.array2string($recurrence));
$recurrence['recurrence'] = $recurrence['start']; $recurrence['recurrence'] = $recurrence['start'];
$recurrence['reference'] = $master['id']; if ($master) $recurrence['reference'] = $master['id'];
$recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master
// not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start'];
} }
// only add master if we are not expanding and current user participates in master (and not just some exceptions) // only add master if we are not expanding and current user participates in master (and not just some exceptions)
if (!$expand && (!$user || self::isParticipant($master, $user))) if (!$expand && $master && (!$user || self::isParticipant($master, $user)))
{ {
$events = array_merge(array($master), $events); $events = array_merge(array($master), $events);
} }
@ -1315,7 +1319,9 @@ class calendar_groupdav extends groupdav_handler
$event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server');
if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events!
if (!($retval = $this->bo->check_perms(EGW_ACL_FREEBUSY,$event, 0, 'server'))) if (!($retval = $this->bo->check_perms(EGW_ACL_FREEBUSY,$event, 0, 'server')) &&
// above can be true, if current user is not in master but just a recurrence
(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
{ {
if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval));
return $retval; return $retval;