* CalDAV/Calendar: store and therefore keep external organizer if he has no common name (just email) and also store its common name

This commit is contained in:
Ralf Becker 2014-03-13 10:20:17 +00:00
parent 082d1813b2
commit 8d3a2d0007
3 changed files with 17 additions and 6 deletions

View File

@ -270,7 +270,7 @@ class calendar_bo
{
$email = $id;
$name = '';
if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/i',$email,$matches))
if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches))
{
$name = $matches[1];
$email = $matches[2];
@ -1487,7 +1487,7 @@ class calendar_bo
$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
}
}
return $id2lid[$id].($append_email && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
}
/**

View File

@ -533,7 +533,7 @@ class calendar_ical extends calendar_boupdate
break;
case 'ORGANIZER':
if (!$organizerCN)
if (!$organizerURL)
{
$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
@ -2691,8 +2691,15 @@ class calendar_ical extends calendar_boupdate
{
$role = $attributes['params']['ROLE'];
}
// parse email and cn from attendee
if (preg_match('/MAILTO:([@.a-z0-9_-]+)|MAILTO:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
// CN explicit given --> use it
if (strtoupper(substr($attributes['value'], 0, 7)) == 'MAILTO:' &&
!empty($attributes['params']['CN']))
{
$email = substr($attributes['value'], 7);
$cn = $attributes['params']['CN'];
}
// try parsing email and cn from attendee
elseif (preg_match('/MAILTO:([@.a-z0-9_-]+)|MAILTO:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
$attributes['value'],$matches))
{
$email = $matches[1] ? $matches[1] : $matches[3];
@ -2731,7 +2738,7 @@ class calendar_ical extends calendar_boupdate
$uid = $this->user;
}
// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
if (!$uid) $uid = groupdav_principals::url2uid($attributes['value']);
if (!$uid) $uid = groupdav_principals::url2uid($attributes['value'], null, $cn);
// try to find an email address
if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))

View File

@ -1078,6 +1078,10 @@ class calendar_uiforms extends calendar_ui
}
elseif (($info = $this->bo->resource_info($uid)))
{
if ($uid[0] == 'e' && $info['name'] && $info['name'] != $info['email'])
{
return $info['name'].' <'.$info['email'].'>';
}
return $info['name'] ? $info['name'] : $info['email'];
}
return '#'.$uid;