diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index b17350199c..a75f16e53a 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -845,7 +845,7 @@ class calendar_boupdate extends calendar_bo $details['olddate'] = $olddate->format($timeformat); } - list($subject,$body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); + list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); $popup = ''; switch($part_prefs['calendar']['update_format']) { @@ -868,7 +868,8 @@ class calendar_boupdate extends calendar_bo $subject = $event['title']; // fall through case 'extended': - $body .= "\n\n".lang('Event Details follow').":\n"; + + $details_body = lang('Event Details follow').":\n"; foreach($event_arr as $key => $val) { if(!empty($details[$key])) @@ -879,15 +880,14 @@ class calendar_boupdate extends calendar_bo case 'priority': case 'link': case 'description': + case 'title': break; default: - $popup .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); + $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); break; } } } - // description need to be separated from body by fancy separator - $body .= "\n*~*~*~*~*~*~*~*~*~*\n\n".$details['description']; break; } // send via notification_app @@ -897,14 +897,22 @@ class calendar_boupdate extends calendar_bo //error_log(__METHOD__."() notifying $userid from $senderid: $subject"); $notification = new notifications(); $notification->set_receivers(array($userid)); - $notification->set_message($body); $notification->set_sender($senderid); $notification->set_subject($subject); // as we want ical body to be just describtion, we can NOT set links, as they get appended to body if ($part_prefs['calendar']['update_format'] != 'ical') { + $notification->set_message($notify_body."\n\n".$details['description']."\n\n".$details_body); $notification->set_links(array($details['link_arr'])); } + else + { + // set message (without separator) for popup notifications + $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); + + // iCal: description need to be separated from body by fancy separator + $notification->set_message($notify_body."\n\n".$details_body."\n*~*~*~*~*~*~*~*~*~*\n\n".$details['description']); + } if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } $notification->send(); } diff --git a/notifications/inc/class.notifications.inc.php b/notifications/inc/class.notifications.inc.php index c427103e58..7fb0d24f85 100644 --- a/notifications/inc/class.notifications.inc.php +++ b/notifications/inc/class.notifications.inc.php @@ -290,7 +290,7 @@ final class notifications { */ public function set_popupmessage($_message) { //popup requires html - if(strlen($_message) == strlen(strip_tags($_message))) $_message=nl2br($_message); + if(strlen($_message) == strlen(strip_tags($_message))) $_message = self::plain2html($_message); $this->message_popup = $_message; return true; } @@ -518,12 +518,23 @@ final class notifications { if(!empty($_message_html)) { $messages['html'] = $_message_html; } else { - $messages['html'] = nl2br($_message_plain); + $messages['html'] = self::plain2html($_message_plain); } if (!empty($_message_popup)) $messages['popup']=$_message_popup; return $messages; } + /** + * Create html from plaintext message + * + * @param string $_plain + * @return string html message + */ + public static function plain2html($_plain) + { + return nl2br(html::htmlspecialchars($_plain, true)); + } + /** * prepends another message to the messages array * diff --git a/notifications/inc/class.notifications_email.inc.php b/notifications/inc/class.notifications_email.inc.php index 2f0c276851..205ce942bc 100644 --- a/notifications/inc/class.notifications_email.inc.php +++ b/notifications/inc/class.notifications_email.inc.php @@ -96,26 +96,17 @@ class notifications_email implements notifications_iface { $this->mail->From = $this->sender->account_email; $this->mail->FromName = $this->sender->account_fullname; $this->mail->Subject = $_subject; - //error_log(__METHOD__.__LINE__.array2string($_attachments)); - $isMeetingRequestNotif = false; + // add iCal invitation as mulitpart alternative for calendar notifications if ($_attachments && stripos($_attachments[0]->type,"text/calendar; method=")!==false) { $this->mail->AltExtended = $_attachments[0]->string; $this->mail->AltExtendedContentType = $_attachments[0]->type; unset($_attachments[0]); - $isMeetingRequestNotif = true; } - // do not send html part if this is a meeting request notification $this->mail->IsHTML(($isMeetingRequestNotif?false:true)); - if ($isMeetingRequestNotif===false) - { - $this->mail->Body = $body_html; - $this->mail->AltBody = $body_plain; - } - else - { - $this->mail->Body = $body_plain; - } + $this->mail->Body = $body_html; + $this->mail->AltBody = $body_plain; + if(is_array($_attachments) && count($_attachments) > 0) { foreach($_attachments as $attachment)