From 01335f787d3652db37a7f611c6d89197c038ebfd Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 14 Aug 2020 18:03:30 +0200 Subject: [PATCH] * Calendar/CalDAV: config to replace email-domain eg. for a migration --- api/src/CalDAV/Principals.php | 7 +++++++ calendar/inc/class.calendar_ical.inc.php | 7 +++++++ calendar/templates/default/config.xet | 12 +++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/api/src/CalDAV/Principals.php b/api/src/CalDAV/Principals.php index df0a59aaad..2f63cde115 100644 --- a/api/src/CalDAV/Principals.php +++ b/api/src/CalDAV/Principals.php @@ -1033,6 +1033,13 @@ class Principals extends Handler break; case 'mailto': + // check if we need to replace email domain with something else in participants (mail address migration) + if (!empty($rest) && !empty($GLOBALS['egw_info']['server']['calendar_domain_replace']) && + !empty($GLOBALS['egw_info']['server']['calendar_domain_replace_with'])) + { + $rest = preg_replace('/@' . preg_quote($GLOBALS['egw_info']['server']['calendar_domain_replace'], '/') . '(>|$)/i', + '@' . $GLOBALS['egw_info']['server']['calendar_domain_replace_with'] . '$1', $e = $rest); + } if (($uid = $GLOBALS['egw']->accounts->name2id($rest, 'account_email'))) { $type = $uid > 0 ? 'users' : 'groups'; diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 5314499e25..76ac9a1187 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -2797,6 +2797,13 @@ class calendar_ical extends calendar_boupdate { $email = $attributes['value']; } + // check if we need to replace email domain with something else in participants (mail address migration) + if (!empty($email) && !empty($GLOBALS['egw_info']['server']['calendar_domain_replace']) && + !empty($GLOBALS['egw_info']['server']['calendar_domain_replace_with'])) + { + $email = preg_replace('/@'.preg_quote($GLOBALS['egw_info']['server']['calendar_domain_replace'], '/').'(>|$)/i', + '@'.$GLOBALS['egw_info']['server']['calendar_domain_replace_with'].'$1', $e=$email); + } // try X-EGROUPWARE-UID, but only if it resolves to same email (otherwise we are in trouble if different EGw installs talk to each other) if (!$uid && !empty($attributes['params']['X-EGROUPWARE-UID']) && ($res_info = $this->resource_info($attributes['params']['X-EGROUPWARE-UID'])) && diff --git a/calendar/templates/default/config.xet b/calendar/templates/default/config.xet index 16c5503857..18249cabe6 100644 --- a/calendar/templates/default/config.xet +++ b/calendar/templates/default/config.xet @@ -5,7 +5,7 @@