4 +-----------------------------------------------------------------------+
5 | program/steps/mail/show.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Display a mail message similar as a usual mail application does |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: show.inc 277 2006-07-19 19:36:35Z thomasb $
22 require_once('Mail/mimeDecode.php');
24 $PRINT_MODE = $_action=='print' ? TRUE : FALSE;
27 // similar code as in program/steps/mail/get.inc
31 $MESSAGE['headers'] = $IMAP->get_headers($_GET['_uid']);
32 $MESSAGE['source'] = rcmail_message_source($_GET['_uid']);
34 // go back to list if message not found (wrong UID)
35 if (!$MESSAGE['headers'] || !$MESSAGE['source'])
41 $mmd = new Mail_mimeDecode($MESSAGE['source']);
42 $MESSAGE['structure'] = $mmd->decode(array('include_bodies' => TRUE,
43 'decode_headers' => FALSE,
44 'decode_bodies' => FALSE));
46 $mmd->getMimeNumbers($MESSAGE['structure']);
48 $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['structure']->headers['subject']);
50 if ($MESSAGE['structure'])
51 list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message($MESSAGE['structure'],
52 array('safe' => (bool)$_GET['_safe'],
53 'prefer_html' => $CONFIG['prefer_html'],
54 'get_url' => $GET_URL.'&_part=%s'));
56 $MESSAGE['body'] = $IMAP->get_body($_GET['_uid']);
59 // mark message as read
60 if (!$MESSAGE['headers']->seen)
61 $IMAP->set_flag($_GET['_uid'], 'SEEN');
63 // give message uid to the client
64 $javascript = sprintf("%s.set_env('uid', '%s');\n", $JS_OBJECT_NAME, $_GET['_uid']);
65 $javascript .= sprintf("%s.set_env('safemode', '%b');", $JS_OBJECT_NAME, $_GET['_safe']);
68 // get previous and next message UID
69 if (!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') &&
70 $IMAP->get_capability('sort')) {
71 // Only if we use custom sorting
72 $a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']);
74 $MESSAGE['index'] = array_search((string)$_GET['_uid'], $a_msg_index, TRUE);
75 $prev = isset($a_msg_index[$MESSAGE['index']-1]) ? $a_msg_index[$MESSAGE['index']-1] : -1 ;
76 $next = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ;
78 // this assumes that we are sorted by date_DESC
79 $seq = $IMAP->get_id($_GET['_uid']);
80 $prev = $IMAP->get_uid($seq + 1);
81 $next = $IMAP->get_uid($seq - 1);
82 $MESSAGE['index'] = $IMAP->messagecount() - $seq;
86 $javascript .= sprintf("\n%s.set_env('prev_uid', '%s');", $JS_OBJECT_NAME, $prev);
88 $javascript .= sprintf("\n%s.set_env('next_uid', '%s');", $JS_OBJECT_NAME, $next);
90 $OUTPUT->add_script($javascript);
95 function rcmail_message_attachments($attrib)
97 global $CONFIG, $OUTPUT, $PRINT_MODE, $MESSAGE, $GET_URL, $JS_OBJECT_NAME;
99 if (sizeof($MESSAGE['attachments']))
101 // allow the following attributes to be added to the <ul> tag
102 $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
103 $out = '<ul' . $attrib_str . ">\n";
105 foreach ($MESSAGE['attachments'] as $attach_prop)
108 $out .= sprintf('<li>%s (%s)</li>'."\n",
109 $attach_prop['filename'],
110 show_bytes($attach_prop['size']));
112 $out .= sprintf('<li><a href="%s&_part=%s" onclick="return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)">%s</a></li>'."\n",
113 htmlentities($GET_URL),
114 $attach_prop['part_id'],
116 $attach_prop['part_id'],
117 $attach_prop['mimetype'],
118 $attach_prop['filename']);
128 // return an HTML iframe for loading mail content
129 function rcmail_messagecontent_frame($attrib)
131 global $COMM_PATH, $OUTPUT, $GET_URL, $JS_OBJECT_NAME;
133 // allow the following attributes to be added to the <iframe> tag
134 $attrib_str = create_attrib_string($attrib);
135 $framename = 'rcmailcontentwindow';
137 $out = sprintf('<iframe src="%s" name="%s"%s>%s</iframe>'."\n",
141 rcube_label('loading'));
144 $OUTPUT->add_script("$JS_OBJECT_NAME.set_env('contentframe', '$framename');");
150 function rcmail_remote_objects_msg($attrib)
152 global $CONFIG, $OUTPUT, $JS_OBJECT_NAME;
155 $attrib['id'] = 'rcmremoteobjmsg';
157 // allow the following attributes to be added to the <div> tag
158 $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
159 $out = '<div' . $attrib_str . ">";
161 $out .= rep_specialchars_output(sprintf('%s <a href="#loadimages" onclick="%s.command(\'load-images\')" title="%s">%s</a>',
162 rcube_label('blockedimages'),
164 rcube_label('showimages'),
165 rcube_label('showimages')));
169 $OUTPUT->add_script(sprintf("%s.gui_object('remoteobjectsmsg', '%s');", $JS_OBJECT_NAME, $attrib['id']));
174 if ($_action=='print')
175 parse_template('printmessage');
177 parse_template('message');