From e600eede2a1e77734800fe01199e0046c76d6d50 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 16 Jun 2016 18:14:02 +0200 Subject: [PATCH] fix iOS calendar crashed if event-organizer had no email address --- api/src/Accounts.php | 8 +++++++- calendar/inc/class.calendar_zpush.inc.php | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/api/src/Accounts.php b/api/src/Accounts.php index 158ec81c27..c290345021 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -536,6 +536,7 @@ class Accounts $underscore = '_'; } if (!$domain) $domain = $GLOBALS['egw_info']['server']['mail_suffix']; + if (!$domain) $domain = $_SERVER['SERVER_NAME']; $email = str_replace(array('first','last','initial','account','dot','underscore','-'), array($first,$last,substr($first,0,1),$account,$dot,$underscore,''), @@ -736,9 +737,10 @@ class Accounts * * @param int|string $account_id numeric account_id or account_lid * @param string $which ='account_lid' type to convert to: account_lid (default), account_email, ... + * @param boolean $generate_email =false true: generate an email address, if user has none * @return string|boolean converted value or false on error ($account_id not found) */ - static function id2name($account_id, $which='account_lid') + static function id2name($account_id, $which='account_lid', $generate_email=false) { if (!is_numeric($account_id) && !($account_id = self::getInstance()->name2id($account_id))) { @@ -751,6 +753,10 @@ class Accounts unset($e); return false; } + if ($generate_email && $which === 'account_email' && empty($data[$which])) + { + return self::email($data['account_firstname'], $data['account_lastname'], $data['account_lid']); + } return $data[$which]; } diff --git a/calendar/inc/class.calendar_zpush.inc.php b/calendar/inc/class.calendar_zpush.inc.php index 0a6997c631..23c95c8e9e 100644 --- a/calendar/inc/class.calendar_zpush.inc.php +++ b/calendar/inc/class.calendar_zpush.inc.php @@ -1081,7 +1081,8 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti $message->md5body = md5($event['description']); $message->organizername = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname'); - $message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); + // at least iOS calendar crashes, if organizer has no email address (true = generate an email, if user has none) + $message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email', true); $message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential @@ -1102,7 +1103,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti if (is_numeric($uid)) { $attendee->name = $GLOBALS['egw']->accounts->id2name($uid,'account_fullname'); - $attendee->email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'); + $attendee->email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email', true); } else { @@ -1113,7 +1114,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti if (!$info['email'] && $info['responsible']) { - $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email'); + $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email', true); } $attendee->name = empty($info['cn']) ? $info['name'] : $info['cn']; $attendee->email = $info['email'];