commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/steps/mail/show.inc | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
|
8 |
| Copyright (C) 2005, RoundCube Dev. - Switzerland | |
30233b
|
9 |
| Licensed under the GNU GPL | |
4e17e6
|
10 |
| | |
T |
11 |
| PURPOSE: | |
|
12 |
| Display a mail message similar as a usual mail application does | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
|
18 |
$Id$ |
|
19 |
|
|
20 |
*/ |
|
21 |
|
|
22 |
require_once('Mail/mimeDecode.php'); |
|
23 |
|
|
24 |
$PRINT_MODE = $_action=='print' ? TRUE : FALSE; |
|
25 |
|
1a98a6
|
26 |
// allow this request to be cached |
T |
27 |
send_future_expire_header(); |
4e17e6
|
28 |
|
T |
29 |
// similar code as in program/steps/mail/get.inc |
|
30 |
if ($_GET['_uid']) |
|
31 |
{ |
8d4bcd
|
32 |
$MESSAGE = array('UID' => get_input_value('_uid', RCUBE_INPUT_GET)); |
T |
33 |
$MESSAGE['headers'] = $IMAP->get_headers($MESSAGE['UID']); |
|
34 |
$MESSAGE['structure'] = $IMAP->get_structure($MESSAGE['UID']); |
b19097
|
35 |
|
4e17e6
|
36 |
// go back to list if message not found (wrong UID) |
8d4bcd
|
37 |
if (!$MESSAGE['headers'] || !$MESSAGE['structure']) |
4e17e6
|
38 |
{ |
b19097
|
39 |
show_message('messageopenerror', 'error'); |
T |
40 |
if ($_action=='preview' && template_exists('messagepreview')) |
|
41 |
parse_template('messagepreview'); |
|
42 |
else |
|
43 |
{ |
|
44 |
$_action = 'list'; |
|
45 |
return; |
|
46 |
} |
4e17e6
|
47 |
} |
T |
48 |
|
8d4bcd
|
49 |
$MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject); |
T |
50 |
|
4e17e6
|
51 |
if ($MESSAGE['structure']) |
8d4bcd
|
52 |
list($MESSAGE['parts'], $MESSAGE['attachments']) = rcmail_parse_message( |
T |
53 |
$MESSAGE['structure'], |
|
54 |
array('safe' => (bool)$_GET['_safe'], |
|
55 |
'prefer_html' => $CONFIG['prefer_html'], |
|
56 |
'get_url' => $GET_URL.'&_part=%s') |
|
57 |
); |
4e17e6
|
58 |
else |
8d4bcd
|
59 |
$MESSAGE['body'] = $IMAP->get_body($MESSAGE['UID']); |
4e17e6
|
60 |
|
T |
61 |
|
|
62 |
// mark message as read |
1a98a6
|
63 |
if (!$MESSAGE['headers']->seen && $_action != 'preview') |
4e17e6
|
64 |
$IMAP->set_flag($_GET['_uid'], 'SEEN'); |
T |
65 |
|
|
66 |
// give message uid to the client |
8d4bcd
|
67 |
$javascript = sprintf("%s.set_env('uid', '%s');\n", $JS_OBJECT_NAME, $MESSAGE['UID']); |
4e17e6
|
68 |
$javascript .= sprintf("%s.set_env('safemode', '%b');", $JS_OBJECT_NAME, $_GET['_safe']); |
T |
69 |
|
e6f360
|
70 |
$next = $prev = -1; |
d17008
|
71 |
// get previous, first, next and last message UID |
e6f360
|
72 |
if (!($_SESSION['sort_col'] == 'date' && $_SESSION['sort_order'] == 'DESC') && |
8d4bcd
|
73 |
$IMAP->get_capability('sort')) |
T |
74 |
{ |
|
75 |
// Only if we use custom sorting |
|
76 |
$a_msg_index = $IMAP->message_index(NULL, $_SESSION['sort_col'], $_SESSION['sort_order']); |
e6f360
|
77 |
|
8d4bcd
|
78 |
$MESSAGE['index'] = array_search((string)$MESSAGE['UID'], $a_msg_index, TRUE); |
T |
79 |
$prev = isset($a_msg_index[$MESSAGE['index']-1]) ? $a_msg_index[$MESSAGE['index']-1] : -1 ; |
d17008
|
80 |
$first = count($a_msg_index)>0 ? $a_msg_index[0] : -1; |
8d4bcd
|
81 |
$next = isset($a_msg_index[$MESSAGE['index']+1]) ? $a_msg_index[$MESSAGE['index']+1] : -1 ; |
d17008
|
82 |
$last = count($a_msg_index)>0 ? $a_msg_index[count($a_msg_index)-1] : -1; |
8d4bcd
|
83 |
} |
T |
84 |
else |
|
85 |
{ |
|
86 |
// this assumes that we are sorted by date_DESC |
|
87 |
$seq = $IMAP->get_id($MESSAGE['UID']); |
|
88 |
$prev = $IMAP->get_uid($seq + 1); |
d17008
|
89 |
$first = $IMAP->get_uid($IMAP->messagecount()); |
8d4bcd
|
90 |
$next = $IMAP->get_uid($seq - 1); |
d17008
|
91 |
$last = $IMAP->get_uid(1); |
8d4bcd
|
92 |
$MESSAGE['index'] = $IMAP->messagecount() - $seq; |
T |
93 |
} |
4e17e6
|
94 |
|
e6f360
|
95 |
if ($prev > 0) |
T |
96 |
$javascript .= sprintf("\n%s.set_env('prev_uid', '%s');", $JS_OBJECT_NAME, $prev); |
d17008
|
97 |
if ($first >0) |
S |
98 |
$javascript .= sprintf("\n%s.set_env('first_uid', '%s');", $JS_OBJECT_NAME, $first); |
e6f360
|
99 |
if ($next > 0) |
T |
100 |
$javascript .= sprintf("\n%s.set_env('next_uid', '%s');", $JS_OBJECT_NAME, $next); |
d17008
|
101 |
if ($last >0) |
S |
102 |
$javascript .= sprintf("\n%s.set_env('last_uid', '%s');", $JS_OBJECT_NAME, $last); |
4e17e6
|
103 |
|
T |
104 |
$OUTPUT->add_script($javascript); |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
function rcmail_message_attachments($attrib) |
|
110 |
{ |
|
111 |
global $CONFIG, $OUTPUT, $PRINT_MODE, $MESSAGE, $GET_URL, $JS_OBJECT_NAME; |
|
112 |
|
|
113 |
if (sizeof($MESSAGE['attachments'])) |
|
114 |
{ |
|
115 |
// allow the following attributes to be added to the <ul> tag |
|
116 |
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); |
|
117 |
$out = '<ul' . $attrib_str . ">\n"; |
|
118 |
|
|
119 |
foreach ($MESSAGE['attachments'] as $attach_prop) |
|
120 |
{ |
|
121 |
if ($PRINT_MODE) |
|
122 |
$out .= sprintf('<li>%s (%s)</li>'."\n", |
8d4bcd
|
123 |
$attach_prop->filename, |
T |
124 |
show_bytes($attach_prop->size)); |
4e17e6
|
125 |
else |
078adf
|
126 |
$out .= sprintf('<li><a href="%s&_part=%s" onclick="return %s.command(\'load-attachment\',{part:\'%s\', mimetype:\'%s\'},this)">%s</a></li>'."\n", |
ea206d
|
127 |
htmlspecialchars($GET_URL), |
8d4bcd
|
128 |
$attach_prop->mime_id, |
4e17e6
|
129 |
$JS_OBJECT_NAME, |
8d4bcd
|
130 |
$attach_prop->mime_id, |
T |
131 |
$attach_prop->mimetype, |
|
132 |
$attach_prop->filename); |
4e17e6
|
133 |
} |
T |
134 |
|
|
135 |
$out .= "</ul>"; |
|
136 |
return $out; |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
function rcmail_remote_objects_msg($attrib) |
|
143 |
{ |
|
144 |
global $CONFIG, $OUTPUT, $JS_OBJECT_NAME; |
|
145 |
|
|
146 |
if (!$attrib['id']) |
|
147 |
$attrib['id'] = 'rcmremoteobjmsg'; |
|
148 |
|
|
149 |
// allow the following attributes to be added to the <div> tag |
|
150 |
$attrib_str = create_attrib_string($attrib, array('style', 'class', 'id')); |
|
151 |
$out = '<div' . $attrib_str . ">"; |
|
152 |
|
|
153 |
$out .= rep_specialchars_output(sprintf('%s <a href="#loadimages" onclick="%s.command(\'load-images\')" title="%s">%s</a>', |
|
154 |
rcube_label('blockedimages'), |
|
155 |
$JS_OBJECT_NAME, |
|
156 |
rcube_label('showimages'), |
|
157 |
rcube_label('showimages'))); |
|
158 |
|
|
159 |
$out .= '</div>'; |
|
160 |
|
|
161 |
$OUTPUT->add_script(sprintf("%s.gui_object('remoteobjectsmsg', '%s');", $JS_OBJECT_NAME, $attrib['id'])); |
|
162 |
return $out; |
|
163 |
} |
|
164 |
|
|
165 |
|
b19097
|
166 |
if ($_action=='print' && template_exists('printmessage')) |
4e17e6
|
167 |
parse_template('printmessage'); |
b19097
|
168 |
else if ($_action=='preview' && template_exists('messagepreview')) |
T |
169 |
parse_template('messagepreview'); |
4e17e6
|
170 |
else |
T |
171 |
parse_template('message'); |
|
172 |
?> |