diff --git a/calendar/inc/class.calendar_activesync.inc.php b/calendar/inc/class.calendar_activesync.inc.php index c28f98c9e4..51c170f33d 100644 --- a/calendar/inc/class.calendar_activesync.inc.php +++ b/calendar/inc/class.calendar_activesync.inc.php @@ -314,7 +314,7 @@ return array(); // temporary disabling meeting requests from calendar /** * Generate SyncMeetingRequest object from an event array * - * Used by (calendar|felamimail)_activesync + * Used by (calendar|mail)_activesync * * @param array|string $event event array or string with iCal * @return SyncMeetingRequest or null ical not parsable @@ -546,8 +546,8 @@ return array(); // temporary disabling meeting requests from calendar // store event, ignore conflicts and skip notifications, as AS clients do their own notifications $skip_notification = false; - if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations']) && - $GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations']=='send') + if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='send') { $skip_notification = true; // to avoid double notification from client AND Server } diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 4d4e0153fc..a7f26c5372 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -2288,6 +2288,32 @@ class calendar_ical extends calendar_boupdate return $events; } + /** + * Get email of organizer of first vevent in given iCalendar + * + * @param string $_ical + * @return string|boolean + */ + public static function getIcalOrganizer($_ical) + { + $vcal = new Horde_Icalendar; + if (!$vcal->parsevCalendar($_ical, 'VCALENDAR')) + { + return false; + } + if (($vevent = $vcal->findComponentByAttribute('Vevent', 'ORGANIZER'))) + { + $organizer = $vevent->getAttribute('ORGANIZER'); + if (stripos($organizer, 'mailto:') === 0) + { + return substr($organizer, 7); + } + $params = $vevent->getAttribute('ORGANIZER', true); + return $params['email']; + } + return false; + } + /** * Callback for egw_ical_iterator to convert Horde_iCalendar_Vevent to EGw event array * diff --git a/calendar/inc/class.calendar_zpush.inc.php b/calendar/inc/class.calendar_zpush.inc.php index 96209bafb2..f550e74a7c 100644 --- a/calendar/inc/class.calendar_zpush.inc.php +++ b/calendar/inc/class.calendar_zpush.inc.php @@ -319,7 +319,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti /** * Generate SyncMeetingRequest object from an event array * - * Used by (calendar|felamimail)_activesync + * Used by (calendar|mail)_zpush * * @param array|string $event event array or string with iCal * @return SyncMeetingRequest or null ical not parsable @@ -557,8 +557,8 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti // store event, ignore conflicts and skip notifications, as AS clients do their own notifications $skip_notification = false; - if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations']) && - $GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations']=='send') + if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) && + $GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='send') { $skip_notification = true; // to avoid double notification from client AND Server } diff --git a/mail/inc/class.mail_zpush.inc.php b/mail/inc/class.mail_zpush.inc.php index 02678d4bb5..e9e0c2a209 100644 --- a/mail/inc/class.mail_zpush.inc.php +++ b/mail/inc/class.mail_zpush.inc.php @@ -456,18 +456,14 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, if ($use_orgbody) { ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") use_orgbody = true ContentType:".$ContentType); // if it is a ClientSideMeetingRequest, we report it as send at all times - if (stripos($ContentType,'text/calendar') !== false ) + if (($cal_body = $mailObject->findBody('calendar')) && + ($cSMRMethod = $cal_body->getContentTypeParameter('method'))) { - $body = ($text_body = $mailObject->findBody('calendar')) ? $text_body->getContents() : null; - $Body = $body; - $AltBody = "
".nl2br($body)."
"; - if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request"); - // try figuring out the METHOD -> [ContentType] => text/calendar; name=meeting.ics; method=REQUEST - $tA = explode(' ',$ContentType); - foreach ((array)$tA as $k => $p) + if ($cSMRMethod == 'REPLY' && class_exists('calendar_ical')) { - if (stripos($p,"method=")!==false) $cSMRMethod= trim(str_replace('METHOD=','',strtoupper($p))); + $organizer = calendar_ical::getIcalOrganizer($cal_body->getContents()); } + if ($this->debugLevel) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") we have a Client Side Meeting Request from organizer=$organizer"); $ClientSideMeetingRequest = true; } } @@ -477,7 +473,13 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, foreach((array)$toMailAddr as $address) { foreach(emailadmin_imapbase::parseAddressList((get_magic_quotes_gpc()?stripslashes($address):$address)) as $addressObject) { $emailAddress = $addressObject->mailbox. ($addressObject->host ? '@'.$addressObject->host : ''); - if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && calendar_boupdate::email_update_requested($emailAddress,(isset($cSMRMethod)?$cSMRMethod:'REQUEST'))) continue; + if ($ClientSideMeetingRequest === true && $allowSendingInvitations == 'sendifnocalnotif' && + calendar_boupdate::email_update_requested($emailAddress, isset($cSMRMethod) ? $cSMRMethod : 'REQUEST', + $organizer && !strcasecmp($emailAddress, $organizer) ? 'CHAIR' : '')) + { + ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") skiping mail to organizer '$organizer', as it will be send by calendar app"); + continue; + } $mailObject->AddAddress($emailAddress, $addressObject->personal); $toCount++; } @@ -500,7 +502,11 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, $bccCount++; } } - if ($toCount+$ccCount+$bccCount == 0) return 0; // noone to send mail to + // typical organizer reply will end here with nothing send --> return true, because we suppressed the send above + if ($toCount+$ccCount+$bccCount == 0) + { + return $ClientSideMeetingRequest && $allowSendingInvitations === 'sendifnocalnotif' && $organizer ? true : 0; // noone to send mail to + } if ($ClientSideMeetingRequest === true && $allowSendingInvitations===false) return true; // as we use our mailer (horde mailer) it is detecting / setting the mimetype by itself while creating the mail /* @@ -694,7 +700,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, try { $mailObject->Send(); } - catch(phpmailerException $e) { + catch(Exception $e) { ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") The email could not be sent. Last-SMTP-error: ". $e->getMessage()); $send = false; }