* Mail: iCal attachments are shown as such, only meeting requests trigger calendar interface with accept/reject buttons

This commit is contained in:
Ralf Becker 2016-08-23 17:22:03 +02:00
parent 521c0e74fe
commit 6a4c89d61a
2 changed files with 25 additions and 28 deletions

View File

@ -4424,9 +4424,10 @@ class Mail
* @param Horde_Mime_Part $_structure structure for parsing
* @param string $_htmlMode how to display a message, html, plain text, ...
* @param boolean $_preserveSeen flag to preserve the seenflag by using body.peek
* @param Horde_Mime_Part& $partCalendar =null on return text/calendar part, if one was contained or false
* @return array containing the desired part
*/
function getMultipartAlternative($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false)
function getMultipartAlternative($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$partCalendar=null)
{
// a multipart/alternative has exactly 2 parts (text and html OR text and something else)
// sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that
@ -4460,6 +4461,10 @@ class Mail
case 'html':
if ($mimePart->getBytes() > 0) $partHTML = $mimePart;
break;
case 'calendar':
if ($mimePart->getBytes() > 0) $partCalendar = $mimePart;
break;
}
break;
@ -4795,9 +4800,10 @@ class Mail
* @param Horde_Mime_Part $_structure = null if given use structure for parsing
* @param boolean $_preserveSeen flag to preserve the seenflag by using body.peek
* @param string $_folder folder to work on
* @param Horde_Mime_part& $calendar_part =null on return calendar-part or null, if there is none
* @return array containing the message body, mimeType and charset
*/
function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '')
function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '', &$calendar_part=null)
{
if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>";
if($_htmlOptions != '') {
@ -4849,7 +4855,7 @@ class Mail
switch($_structure->getSubType())
{
case 'alternative':
$bodyParts = array($this->getMultipartAlternative($_uid, $_structure, $this->htmlOptions, $_preserveSeen));
$bodyParts = array($this->getMultipartAlternative($_uid, $_structure, $this->htmlOptions, $_preserveSeen, $calendar_part));
break;
case 'nil': // multipart with no Alternative

View File

@ -2853,33 +2853,24 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
$structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false);
$bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox);
$calendar_part = null;
$bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox, $calendar_part);
//error_log(__METHOD__.__LINE__.array2string($bodyParts));
// attachments here are only fetched to determine if there is a meeting request
// and if. use the appropriate action. so we do not need embedded images
$fetchEmbeddedImages = false;
$attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true,true,$mailbox);
//error_log(__METHOD__.__LINE__.array2string($attachments));
foreach ($attachments as &$attach)
// for meeting requests (multipart alternative with text/calendar part) let calendar render it
if ($calendar_part && isset($GLOBALS['egw_info']['user']['apps']['calendar']))
{
if (strtolower($attach['mimeType']) == 'text/calendar' &&
isset($GLOBALS['egw_info']['user']['apps']['calendar']) &&
($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'],$attach['is_winmail'],(strtolower($attach['mimeType']) == 'text/calendar'?false:true))))
{
//error_log(__METHOD__.__LINE__.array2string($attachment));
Api\Cache::setSession('calendar', 'ical', array(
'charset' => $attach['charset'] ? $attach['charset'] : 'utf-8',
'attachment' => $attachment['attachment'],
'method' => $attach['method'],
'sender' => $mailbox,
));
$this->mail_bo->htmlOptions = $bufferHtmlOptions;
Api\Translation::add_app('calendar');
ExecMethod( 'calendar.calendar_uiforms.meeting',
array('event'=>null,'msg'=>'','useSession'=>true)
);
}
$charset = $calendar_part->getContentTypeParameter('charset');
$this->mail_bo->fetchPartContents($uid, $calendar_part);
Api\Cache::setSession('calendar', 'ical', array(
'charset' => $charset ? $charset : 'utf-8',
'attachment' => $calendar_part->getContents(),
'method' => $calendar_part->getContentTypeParameter('method'),
));
$this->mail_bo->htmlOptions = $bufferHtmlOptions;
Api\Translation::add_app('calendar');
return ExecMethod('calendar.calendar_uiforms.meeting',
array('event'=>null,'msg'=>'','useSession'=>true)
);
}
// Compose the content of the frame
$frameHtml =