* InfoLog/CalDAV: removed delegation now removes event in sync-report eg. in Smooth-Sync

This commit is contained in:
Ralf Becker 2016-09-12 10:55:39 +02:00
parent 70b22e3377
commit dfb260d809
2 changed files with 31 additions and 7 deletions

View File

@ -253,10 +253,16 @@ class infolog_groupdav extends Api\CalDAV\Handler
'col_filter' => $filter,
'custom_fields' => true, // otherwise custom fields get NOT loaded!
);
$check_responsible = false;
if (substr($task_filter, -8) == '+deleted')
{
$check_responsible = substr($task_filter, 0, 4) == 'user' ?
(int)substr($task_filter, 4) : $GLOBALS['egw_info']['user']['account_id'];
}
if (!$calendar_data)
{
$query['cols'] = array('info_id', 'info_datemodified', 'info_uid', 'caldav_name', 'info_subject', 'info_status');
$query['cols'] = array('main.info_id AS info_id', 'info_datemodified', 'info_uid', 'caldav_name', 'info_subject', 'info_status');
}
if (is_array($start))
@ -284,7 +290,10 @@ class infolog_groupdav extends Api\CalDAV\Handler
unset($requested_multiget_ids[$k]);
}
// sync-collection report: deleted entry need to be reported without properties
if ($task['info_status'] == 'deleted')
if ($task['info_status'] == 'deleted' ||
// or event is reported as removed from collection, because collection owner is no longer an attendee
$check_responsible && $task['info_owner'] != $check_responsible &&
!infolog_so::is_responsible_user($task, $check_responsible))
{
$files[] = array('path' => $path.urldecode($this->get_path($task)));
continue;

View File

@ -91,14 +91,28 @@ class infolog_so
* Check if user is responsible for an entry: he or one of his memberships is in responsible
*
* @param array $info infolog entry as array
* @param int $user =null user to check for, default $this->user
* @return boolean
*/
function is_responsible($info,$user=null)
{
if (!$user) $user = $this->user;
return self::is_responsible_user($info, $user);
}
/**
* Check if user is responsible for an entry: he or one of his memberships is in responsible
*
* @param array $info infolog entry as array
* @param int $user =null user to check for
* @return boolean
*/
static function is_responsible_user($info, $user)
{
static $um_cache = array();
if ($user == $this->user) $user_and_memberships =& $um_cache[$user];
$user_and_memberships =& $um_cache[$user];
if (!isset($user_and_memberships))
{
$user_and_memberships = $GLOBALS['egw']->accounts->memberships($user,true);
@ -201,9 +215,10 @@ class infolog_so
function aclFilter($_filter = False)
{
$vars = null;
preg_match('/(my|responsible|delegated|own|privat|private|all|user)([0-9,-]*)/',$_filter,$vars);
preg_match('/(my|responsible|delegated|own|privat|private|all|user)([0-9,-]*)(+deleted)?/',$_filter,$vars);
$filter = $vars[1];
$f_user = $vars[2];
$deleted_too = !empty($vars[3]);
if (isset($this->acl_filter[$filter.$f_user]))
{
@ -247,12 +262,12 @@ class infolog_so
}
$public_access = $this->db->expression($this->info_table,array('info_owner' => $public_user_list));
// implicit read-rights for responsible user
$filtermethod .= " OR (".$this->responsible_filter($this->user).')';
$filtermethod .= " OR (".$this->responsible_filter($this->user, $deleted_too).')';
// private: own entries plus the one user is responsible for
if ($filter == 'private' || $filter == 'privat' || $filter == 'own')
{
$filtermethod .= " OR (".$this->responsible_filter($this->user).
$filtermethod .= " OR (".$this->responsible_filter($this->user, $deleted_too).
($filter == 'own' && count($public_user_list) ? // offer's should show up in own, eg. startpage, but need read-access
" OR info_status = 'offer' AND $public_access" : '').")".
" AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
@ -274,7 +289,7 @@ class infolog_so
{
$filtermethod .= $this->db->expression($this->info_table,' AND (',array(
'info_owner' => $f_user,
)," AND $this->users_table.account_id IS NULL OR ",$this->responsible_filter($f_user),')');
)," AND $this->users_table.account_id IS NULL OR ",$this->responsible_filter($f_user, $deleted_too),')');
}
}
//echo "<p>aclFilter(filter='$_filter',user='$f_user') = '$filtermethod', privat_user_list=".print_r($privat_user_list,True).", public_user_list=".print_r($public_user_list,True)."</p>\n";