* 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:16:41 +00:00
parent 77dbee8aff
commit 3a901f8196
3 changed files with 17 additions and 6 deletions

View File

@ -263,7 +263,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];
@ -1477,7 +1477,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

@ -530,7 +530,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')) . '"';
@ -2675,8 +2675,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];
@ -2715,7 +2722,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

@ -848,6 +848,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;