From bc2c4380b5b754a3b13cc7d6663b2b81d2577e2e Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 6 Mar 2013 11:11:37 +0100 Subject: Add attachment menu with Open and Download options (#1488975) --- program/steps/mail/show.inc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'program/steps/mail/show.inc') diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 437dbaafa..87555cbbe 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -147,6 +147,7 @@ function rcmail_message_attachments($attrib) global $PRINT_MODE, $MESSAGE, $RCMAIL; $out = $ol = ''; + $attachments = array(); if (sizeof($MESSAGE->attachments)) { foreach ($MESSAGE->attachments as $attach_prop) { @@ -165,21 +166,23 @@ function rcmail_message_attachments($attrib) $title = ''; } - $ol .= html::tag('li', rcmail_filetype2classname($attach_prop->mimetype, $filename), - html::a(array( + $mimetype = rcmail_fix_mimetype($attach_prop->mimetype); + $class = rcmail_filetype2classname($mimetype, $filename); + $id = 'attach' . $attach_prop->mime_id; + $link = html::a(array( 'href' => $MESSAGE->get_part_url($attach_prop->mime_id, false), - 'onclick' => sprintf( - 'return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)', - JS_OBJECT_NAME, - $attach_prop->mime_id, - rcmail_fix_mimetype($attach_prop->mimetype)), - 'title' => Q($title), - ), - Q($filename))); + 'onclick' => sprintf('return %s.command(\'load-attachment\',\'%s\',this)', + JS_OBJECT_NAME, $attach_prop->mime_id), + 'title' => Q($title), + ), Q($filename)); + $ol .= html::tag('li', array('class' => $class, 'id' => $id), $link); + + $attachments[$attach_prop->mime_id] = $mimetype; } } $out = html::tag('ul', $attrib, $ol, html::$common_attrib); + $RCMAIL->output->set_env('attachments', $attachments); } return $out; -- cgit v1.2.3