59177427 |
1 | <?php |
7c1b84d9 |
2 | |
3302d0d4 |
3 | /** |
a09387f4 |
4 | ** mailbox_display.php |
3302d0d4 |
5 | ** |
6 | ** This contains functions that display mailbox information, such as the |
7 | ** table row that has sender, date, subject, etc... |
8 | ** |
245a6892 |
9 | ** $Id$ |
3302d0d4 |
10 | **/ |
a4c2cd49 |
11 | |
f435778e |
12 | if (defined('mailbox_display_php')) |
13 | return; |
14 | define('mailbox_display_php', true); |
d068c0ec |
15 | |
1809bad8 |
16 | function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, $where, $what) { |
66289791 |
17 | global $checkall; |
af9404d7 |
18 | global $color, $msgs, $msort; |
f9b3e5d9 |
19 | global $sent_folder; |
9d157cec |
20 | global $message_highlight_list; |
8e265988 |
21 | global $index_order; |
cbdc5621 |
22 | |
ac53fb56 |
23 | $color_string = $color[4]; |
24 | if ($GLOBALS['alt_index_colors']) { |
25 | if (!isset($GLOBALS["row_count"])) { |
26 | $GLOBALS["row_count"] = 0; |
27 | } |
28 | $GLOBALS["row_count"]++; |
29 | if ($GLOBALS["row_count"] % 2) { |
30 | if (!isset($color[12])) $color[12] = "#EAEAEA"; |
31 | $color_string = $color[12]; |
32 | } |
b3b103cb |
33 | } |
34 | |
0d455368 |
35 | $msg = $msgs[$key]; |
d92b6f31 |
36 | |
90bc0b93 |
37 | $senderName = sqimap_find_displayable_name($msg['FROM']); |
05207a68 |
38 | $urlMailbox = urlencode($mailbox); |
f93c93b9 |
39 | $subject = processSubject($msg['SUBJECT']); |
b60b58f9 |
40 | |
926da13e |
41 | echo "<TR>\n"; |
b60b58f9 |
42 | |
90bc0b93 |
43 | if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) |
245a6892 |
44 | { |
45 | $flag = "<font color=$color[2]>"; |
6edca885 |
46 | $flag_end = '</font>'; |
245a6892 |
47 | } |
48 | else |
49 | { |
90bc0b93 |
50 | $flag = ''; |
6edca885 |
51 | $flag_end = ''; |
245a6892 |
52 | } |
367e4f70 |
53 | if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false) |
245a6892 |
54 | { |
90bc0b93 |
55 | $bold = '<b>'; |
6edca885 |
56 | $bold_end = '</b>'; |
245a6892 |
57 | } |
58 | else |
59 | { |
90bc0b93 |
60 | $bold = ''; |
6edca885 |
61 | $bold_end = ''; |
245a6892 |
62 | } |
63 | if ($mailbox == $sent_folder) |
64 | { |
90bc0b93 |
65 | $italic = '<i>'; |
6edca885 |
66 | $italic_end = '</i>'; |
245a6892 |
67 | } |
68 | else |
69 | { |
90bc0b93 |
70 | $italic = ''; |
6edca885 |
71 | $italic_end = ''; |
245a6892 |
72 | } |
90bc0b93 |
73 | if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) |
245a6892 |
74 | { |
75 | $fontstr = "<font color=\"$color[9]\">"; |
6edca885 |
76 | $fontstr_end = '</font>'; |
245a6892 |
77 | } |
78 | else |
79 | { |
90bc0b93 |
80 | $fontstr = ''; |
6edca885 |
81 | $fontstr_end = ''; |
245a6892 |
82 | } |
b60b58f9 |
83 | |
9d157cec |
84 | for ($i=0; $i < count($message_highlight_list); $i++) { |
90bc0b93 |
85 | if (trim($message_highlight_list[$i]['value']) != '') { |
86 | if ($message_highlight_list[$i]['match_type'] == 'to_cc') { |
87 | if (strpos('^^'.strtolower($msg['TO']), strtolower($message_highlight_list[$i]['value'])) || strpos('^^'.strtolower($msg['CC']), strtolower($message_highlight_list[$i]['value']))) { |
88 | $hlt_color = $message_highlight_list[$i]['color']; |
d059be8f |
89 | continue; |
90 | } |
90bc0b93 |
91 | } else if (strpos('^^'.strtolower($msg[strtoupper($message_highlight_list[$i]['match_type'])]),strtolower($message_highlight_list[$i]['value']))) { |
92 | $hlt_color = $message_highlight_list[$i]['color']; |
1195c340 |
93 | continue; |
b60b58f9 |
94 | } |
d059be8f |
95 | } |
b60b58f9 |
96 | } |
97 | |
245a6892 |
98 | if (!isset($hlt_color)) |
b3b103cb |
99 | $hlt_color = $color_string; |
1809bad8 |
100 | |
101 | if ($where && $what) { |
90bc0b93 |
102 | $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what); |
1809bad8 |
103 | } |
66289791 |
104 | |
eca500d0 |
105 | if ($checkall == 1) |
90bc0b93 |
106 | $checked = ' checked'; |
eca500d0 |
107 | else |
90bc0b93 |
108 | $checked = ''; |
3d48999d |
109 | |
8e265988 |
110 | for ($i=1; $i <= count($index_order); $i++) { |
111 | switch ($index_order[$i]) { |
112 | case 1: # checkbox |
113 | echo " <td width=1% bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n"; |
114 | break; |
115 | case 2: # from |
eca500d0 |
116 | echo " <td width=30% bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n"; |
8e265988 |
117 | break; |
118 | case 3: # date |
eca500d0 |
119 | echo " <td nowrap width=1% bgcolor=$hlt_color><center>$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end</center></td>\n"; |
8e265988 |
120 | break; |
121 | case 4: # subject |
7e73c6be |
122 | echo " <td bgcolor=$hlt_color>$bold"; |
6edca885 |
123 | if (! isset($search_stuff)) { $search_stuff = ''; } |
23fd3c8e |
124 | echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\""; |
125 | do_hook("subject_link"); |
f93c93b9 |
126 | echo ">$flag$subject$flag_end</a>$bold_end</td>\n"; |
8e265988 |
127 | break; |
128 | case 5: # flags |
9db5f5fc |
129 | $stuff = false; |
44e227c2 |
130 | echo " <td bgcolor=$hlt_color align=center width=1% nowrap><b><small>\n"; |
245a6892 |
131 | if (isset($msg['FLAG_ANSWERED']) && |
6edca885 |
132 | $msg['FLAG_ANSWERED'] == true) { |
9db5f5fc |
133 | echo "A\n"; |
134 | $stuff = true; |
8ae331c2 |
135 | } |
90bc0b93 |
136 | if ($msg['TYPE0'] == 'multipart') { |
9db5f5fc |
137 | echo "+\n"; |
138 | $stuff = true; |
8ae331c2 |
139 | } |
90bc0b93 |
140 | if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) { |
9db5f5fc |
141 | echo "<font color=$color[1]>!</font>\n"; |
142 | $stuff = true; |
143 | } |
90bc0b93 |
144 | if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) { |
f9b3e5d9 |
145 | echo "<font color=\"$color[1]\">D</font>\n"; |
146 | $stuff = true; |
147 | } |
8ae331c2 |
148 | |
9db5f5fc |
149 | if (!$stuff) echo " \n"; |
150 | echo "</small></b></td>\n"; |
8e265988 |
151 | break; |
8ae331c2 |
152 | case 6: # size |
eca500d0 |
153 | echo " <td bgcolor=$hlt_color width=1%>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n"; |
8e265988 |
154 | break; |
155 | } |
156 | } |
157 | |
7151188f |
158 | |
159 | echo "</tr>\n"; |
926da13e |
160 | } |
161 | |
162 | /** |
163 | ** This function loops through a group of messages in the mailbox and shows them |
164 | **/ |
5b6ae78a |
165 | function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) { |
166 | global $msgs, $msort; |
f9b3e5d9 |
167 | global $sent_folder; |
9d157cec |
168 | global $message_highlight_list; |
a3432f47 |
169 | global $auto_expunge; |
170 | |
eca500d0 |
171 | if ($auto_expunge == true) sqimap_mailbox_expunge($imapConnection, $mailbox, false); |
0d455368 |
172 | sqimap_mailbox_select($imapConnection, $mailbox); |
61a4ac35 |
173 | |
5b6ae78a |
174 | if (!$use_cache) { |
0d455368 |
175 | // if it's sorted |
5b6ae78a |
176 | if ($numMessages >= 1) { |
0d455368 |
177 | if ($sort < 6) { |
178 | for ($q = 0; $q < $numMessages; $q++) { |
179 | if($mailbox == $sent_folder) |
180 | $hdr = sqimap_get_small_header ($imapConnection, $q+1, true); |
181 | else |
182 | $hdr = sqimap_get_small_header ($imapConnection, $q+1, false); |
183 | |
184 | $from[$q] = $hdr->from; |
185 | $date[$q] = $hdr->date; |
186 | $subject[$q] = $hdr->subject; |
187 | $to[$q] = $hdr->to; |
188 | $priority[$q] = $hdr->priority; |
189 | $cc[$q] = $hdr->cc; |
190 | $size[$q] = $hdr->size; |
191 | $type[$q] = $hdr->type0; |
192 | $flags[$q] = sqimap_get_flags ($imapConnection, $q+1); |
a3d65705 |
193 | $id[$q] = $q + 1; |
0d455368 |
194 | } |
195 | } else { |
196 | // if it's not sorted |
197 | if ($startMessage + ($show_num - 1) < $numMessages) { |
198 | $endMessage = $startMessage + ($show_num-1); |
199 | } else { |
200 | $endMessage = $numMessages; |
201 | } |
b60b58f9 |
202 | |
0d455368 |
203 | if ($endMessage < $startMessage) { |
204 | $startMessage = $startMessage - $show_num; |
205 | if ($startMessage < 1) |
206 | $startMessage = 1; |
207 | } |
208 | |
a3d65705 |
209 | |
210 | $real_startMessage = $numMessages - $startMessage + 1; |
211 | $real_endMessage = $numMessages - $startMessage - $show_num; |
b60b58f9 |
212 | if ($real_endMessage <= 0) |
213 | $real_endMessage = 1; |
214 | |
a3d65705 |
215 | $j = 0; |
216 | for ($q = $real_startMessage; $q >= $real_endMessage; $q--) { |
0d455368 |
217 | if($mailbox == $sent_folder) |
218 | $hdr = sqimap_get_small_header ($imapConnection, $q, true); |
219 | else |
220 | $hdr = sqimap_get_small_header ($imapConnection, $q, false); |
b60b58f9 |
221 | |
0d455368 |
222 | $from[$j] = $hdr->from; |
223 | $date[$j] = $hdr->date; |
224 | $subject[$j] = $hdr->subject; |
225 | $to[$j] = $hdr->to; |
226 | $priority[$j] = $hdr->priority; |
227 | $cc[$j] = $hdr->cc; |
228 | $size[$j] = $hdr->size; |
229 | $type[$j] = $hdr->type0; |
230 | $flags[$j] = sqimap_get_flags ($imapConnection, $q); |
a3d65705 |
231 | $id[$j] = $q; |
0d455368 |
232 | $j++; |
233 | } |
b60b58f9 |
234 | } |
5b6ae78a |
235 | } |
b60b58f9 |
236 | |
5b6ae78a |
237 | $j = 0; |
0d455368 |
238 | if ($sort == 6) { |
239 | $end = $startMessage + $show_num - 1; |
cd928157 |
240 | if ($numMessages < $show_num) |
241 | $end_loop = $numMessages; |
0b03d077 |
242 | elseif ($end > $numMessages) |
243 | $end_loop = $numMessages - $startMessage + 1; |
244 | else |
cd928157 |
245 | $end_loop = $show_num; |
0d455368 |
246 | } else { |
247 | $end = $numMessages; |
cd928157 |
248 | $end_loop = $end; |
0d455368 |
249 | } |
cd928157 |
250 | while ($j < $end_loop) { |
251 | if (isset($date[$j])) { |
252 | $date[$j] = ereg_replace(' ', ' ', $date[$j]); |
253 | $tmpdate = explode(' ', trim($date[$j])); |
254 | } else { |
255 | $tmpdate = $date = array("","","","","",""); |
256 | } |
90bc0b93 |
257 | |
258 | $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate); |
259 | $messages[$j]['DATE_STRING'] = getDateString($messages[$j]['TIME_STAMP']); |
260 | $messages[$j]['ID'] = $id[$j]; |
261 | $messages[$j]['FROM'] = decodeHeader($from[$j]); |
262 | $messages[$j]['FROM-SORT'] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j]))); |
263 | $messages[$j]['SUBJECT'] = decodeHeader($subject[$j]); |
264 | $messages[$j]['SUBJECT-SORT'] = strtolower(decodeHeader($subject[$j])); |
265 | $messages[$j]['TO'] = decodeHeader($to[$j]); |
266 | $messages[$j]['PRIORITY'] = $priority[$j]; |
267 | $messages[$j]['CC'] = $cc[$j]; |
268 | $messages[$j]['SIZE'] = $size[$j]; |
269 | $messages[$j]['TYPE0'] = $type[$j]; |
e9f8ea4e |
270 | |
271 | # fix SUBJECT-SORT to remove Re: |
0d455368 |
272 | $re_abbr = # Add more here! |
90bc0b93 |
273 | 'vedr|sv|' . # Danish |
274 | 're|aw'; # English |
0d455368 |
275 | if (eregi("^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs)) |
276 | $messages[$j]['SUBJECT-SORT'] = $regs[2]; |
b60b58f9 |
277 | |
5b6ae78a |
278 | $num = 0; |
279 | while ($num < count($flags[$j])) { |
90bc0b93 |
280 | if ($flags[$j][$num] == 'Deleted') { |
281 | $messages[$j]['FLAG_DELETED'] = true; |
5b6ae78a |
282 | } |
90bc0b93 |
283 | elseif ($flags[$j][$num] == 'Answered') { |
284 | $messages[$j]['FLAG_ANSWERED'] = true; |
5b6ae78a |
285 | } |
90bc0b93 |
286 | elseif ($flags[$j][$num] == 'Seen') { |
287 | $messages[$j]['FLAG_SEEN'] = true; |
5b6ae78a |
288 | } |
90bc0b93 |
289 | elseif ($flags[$j][$num] == 'Flagged') { |
290 | $messages[$j]['FLAG_FLAGGED'] = true; |
5b6ae78a |
291 | } |
292 | $num++; |
7151188f |
293 | } |
5b6ae78a |
294 | $j++; |
3302d0d4 |
295 | } |
f9b3e5d9 |
296 | |
297 | /* Only ignore messages flagged as deleted if we are using a |
298 | * trash folder or auto_expunge */ |
245a6892 |
299 | if (((isset($move_to_trash) && $move_to_trash) |
6edca885 |
300 | || (isset($auto_expunge) && $auto_expunge)) && $sort != 6) |
b60b58f9 |
301 | { |
f9b3e5d9 |
302 | /** Find and remove the ones that are deleted */ |
303 | $i = 0; |
304 | $j = 0; |
305 | while ($j < $numMessages) { |
cd928157 |
306 | if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) { |
f9b3e5d9 |
307 | $j++; |
308 | continue; |
309 | } |
310 | $msgs[$i] = $messages[$j]; |
b60b58f9 |
311 | |
f9b3e5d9 |
312 | $i++; |
5b6ae78a |
313 | $j++; |
5b6ae78a |
314 | } |
f9b3e5d9 |
315 | $numMessages = $i; |
0d455368 |
316 | } else { |
6edca885 |
317 | if (! isset($messages)) |
318 | $messages = array(); |
0d455368 |
319 | $msgs = $messages; |
5b10f02a |
320 | } |
5b6ae78a |
321 | } |
926da13e |
322 | |
4c2d69ac |
323 | // There's gotta be messages in the array for it to sort them. |
f9b3e5d9 |
324 | if ($numMessages > 0 && ! $use_cache) { |
0e919368 |
325 | /** 0 = Date (up) 4 = Subject (up) |
326 | ** 1 = Date (dn) 5 = Subject (dn) |
327 | ** 2 = Name (up) |
328 | ** 3 = Name (dn) |
329 | **/ |
09856735 |
330 | session_unregister("msgs"); |
1c292c82 |
331 | if (($sort == 0) || ($sort == 1)) |
90bc0b93 |
332 | $msort = array_cleave ($msgs, 'TIME_STAMP'); |
1c292c82 |
333 | if (($sort == 2) || ($sort == 3)) |
90bc0b93 |
334 | $msort = array_cleave ($msgs, 'FROM-SORT'); |
1c292c82 |
335 | if (($sort == 4) || ($sort == 5)) |
90bc0b93 |
336 | $msort = array_cleave ($msgs, 'SUBJECT-SORT'); |
0d455368 |
337 | if ($sort == 6) |
338 | $msort = $msgs; |
339 | |
340 | if ($sort < 6) { |
341 | if($sort % 2) { |
342 | asort($msort); |
343 | } else { |
344 | arsort($msort); |
345 | } |
0e919368 |
346 | } |
90bc0b93 |
347 | session_register('msort'); |
4c2d69ac |
348 | } |
5b6ae78a |
349 | displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num); |
90bc0b93 |
350 | session_register('msgs'); |
9f2215a1 |
351 | } |
352 | |
353 | // generic function to convert the msgs array into an HTML table |
5b6ae78a |
354 | function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) { |
cbdc5621 |
355 | global $folder_prefix, $sent_folder; |
f9b3e5d9 |
356 | global $imapServerAddress; |
21fafac8 |
357 | global $index_order, $real_endMessage, $real_startMessage, $checkall; |
72b0f272 |
358 | |
9f2215a1 |
359 | // if cache isn't already set, do it now |
90bc0b93 |
360 | if (!session_is_registered('msgs')) |
361 | session_register('msgs'); |
362 | if (!session_is_registered('msort')) |
363 | session_register('msort'); |
90033b64 |
364 | |
9c83f905 |
365 | if ($startMessage + ($show_num - 1) < $numMessages) { |
366 | $endMessage = $startMessage + ($show_num-1); |
926da13e |
367 | } else { |
926da13e |
368 | $endMessage = $numMessages; |
369 | } |
b60b58f9 |
370 | |
8442ac08 |
371 | if ($endMessage < $startMessage) { |
372 | $startMessage = $startMessage - $show_num; |
373 | if ($startMessage < 1) |
374 | $startMessage = 1; |
375 | } |
b60b58f9 |
376 | |
9c83f905 |
377 | $nextGroup = $startMessage + $show_num; |
378 | $prevGroup = $startMessage - $show_num; |
20db5033 |
379 | $urlMailbox = urlencode($mailbox); |
926da13e |
380 | |
90bc0b93 |
381 | do_hook('mailbox_index_before'); |
926da13e |
382 | |
14eb705c |
383 | $Message = ''; |
0d1b4832 |
384 | if ($startMessage < $endMessage) { |
14eb705c |
385 | $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n"; |
f9b3e5d9 |
386 | } elseif ($startMessage == $endMessage) { |
14eb705c |
387 | $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n"; |
0d1b4832 |
388 | } |
26b6c99c |
389 | |
14eb705c |
390 | $More = ''; |
0d455368 |
391 | if ($sort == 6) { |
392 | $use = 0; |
393 | } else { |
394 | $use = 1; |
395 | } |
5b10f02a |
396 | if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) { |
0d455368 |
397 | $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n"; |
398 | $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n"; |
926da13e |
399 | } |
f9b3e5d9 |
400 | elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) { |
0d455368 |
401 | $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n"; |
14eb705c |
402 | $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n"; |
3302d0d4 |
403 | } |
f9b3e5d9 |
404 | elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) { |
14eb705c |
405 | $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n"; |
0d455368 |
406 | $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n"; |
14eb705c |
407 | } |
408 | |
245a6892 |
409 | if (! isset($msg)) |
410 | $msg = ""; |
b60b58f9 |
411 | mail_message_listing_beginning($imapConnection, |
14eb705c |
412 | "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage", |
66289791 |
413 | $mailbox, $sort, $Message, $More, $startMessage); |
14eb705c |
414 | |
8ae331c2 |
415 | $groupNum = $startMessage % ($show_num - 1); |
72b0f272 |
416 | $real_startMessage = $startMessage; |
b60b58f9 |
417 | if ($sort == 6) { |
418 | if ($endMessage - $startMessage < $show_num - 1) { |
419 | $endMessage = $endMessage - $startMessage + 1; |
420 | $startMessage = 1; |
421 | } else if ($startMessage > $show_num) { |
422 | $endMessage = $show_num; |
423 | $startMessage = 1; |
424 | } |
425 | } |
426 | |
427 | $endVar = $endMessage + 1; |
428 | |
14eb705c |
429 | // loop through and display the info for each message. |
430 | $t = 0; // $t is used for the checkbox number |
431 | if ($numMessages == 0) { // if there's no messages in this folder |
432 | echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order); |
433 | echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER></TD></TR>"; |
b60b58f9 |
434 | } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different. |
a3d65705 |
435 | if ($sort != 6) |
436 | $i = $startMessage; |
437 | else |
438 | $i = 1; |
14eb705c |
439 | reset($msort); |
6edca885 |
440 | $k = 0; |
14eb705c |
441 | do { |
442 | $key = key($msort); |
443 | next($msort); |
444 | $k++; |
445 | } while (isset ($key) && ($k < $i)); |
72b0f272 |
446 | printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0); |
14eb705c |
447 | } else { |
b60b58f9 |
448 | $i = $startMessage; |
449 | |
14eb705c |
450 | reset($msort); |
6edca885 |
451 | $k = 0; |
14eb705c |
452 | do { |
453 | $key = key($msort); |
454 | next($msort); |
455 | $k++; |
456 | } while (isset ($key) && ($k < $i)); |
457 | |
0d455368 |
458 | do { |
72b0f272 |
459 | printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0); |
14eb705c |
460 | $key = key($msort); |
461 | $t++; |
462 | $i++; |
463 | next($msort); |
b60b58f9 |
464 | } while ($i && $i < $endVar); |
14eb705c |
465 | } |
90bc0b93 |
466 | echo '</TABLE>'; |
14eb705c |
467 | |
468 | echo "</td></tr>\n"; |
469 | |
66289791 |
470 | echo "<TR BGCOLOR=\"$color[4]\"><TD>"; |
90bc0b93 |
471 | echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>'; |
eca500d0 |
472 | echo "$More</td><td align=right>\n"; |
473 | if (!$startMessage) $startMessage=1; |
323218d7 |
474 | ShowSelectAllLink($startMessage, $sort); |
66289791 |
475 | |
90bc0b93 |
476 | echo '</td></tr></table>'; |
477 | echo '</td></tr>'; |
478 | echo '</table>'; /** End of message-list table */ |
14eb705c |
479 | |
90bc0b93 |
480 | do_hook('mailbox_index_after'); |
14eb705c |
481 | } |
482 | |
483 | /* Displays the standard message list header. |
484 | * To finish the table, you need to do a "</table></table>"; |
485 | * $moveURL is the URL to submit the delete/move form to |
486 | * $mailbox is the current mailbox |
487 | * $sort is the current sorting method (-1 for no sorting available [searches]) |
488 | * $Message is a message that is centered on top of the list |
489 | * $More is a second line that is left aligned |
490 | */ |
8ae331c2 |
491 | function mail_message_listing_beginning($imapConnection, $moveURL, |
5252447e |
492 | $mailbox = '', $sort = -1, $Message = '', $More = '', $startMessage = 1) |
14eb705c |
493 | { |
f9b3e5d9 |
494 | global $color, $index_order, $auto_expunge, $move_to_trash; |
58da09bd |
495 | global $checkall, $sent_folder; |
eca500d0 |
496 | $urlMailbox = urlencode($mailbox); |
14eb705c |
497 | /** This is the beginning of the message list table. It wraps around all messages */ |
90bc0b93 |
498 | echo '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="0">'; |
8ae331c2 |
499 | |
14eb705c |
500 | if ($Message) |
501 | { |
502 | echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n"; |
503 | } |
8ae331c2 |
504 | |
66289791 |
505 | echo "<TR BGCOLOR=\"$color[4]\"><TD>"; |
90bc0b93 |
506 | echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>'; |
eca500d0 |
507 | echo "$More</td><td align=right>\n"; |
323218d7 |
508 | ShowSelectAllLink($startMessage, $sort); |
66289791 |
509 | |
90bc0b93 |
510 | echo '</td></tr></table>'; |
511 | echo '</td></tr>'; |
926da13e |
512 | |
68347a84 |
513 | /** The delete and move options */ |
f8f9bed9 |
514 | echo "<TR><TD BGCOLOR=\"$color[0]\">"; |
ed4332d1 |
515 | |
14eb705c |
516 | echo "\n\n\n<FORM name=messageList method=post action=\"$moveURL\">\n"; |
4f313fcf |
517 | echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n"; |
ed4332d1 |
518 | echo " <TR>\n"; |
98fe1e9f |
519 | echo " <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER>\n"; |
66289791 |
520 | |
521 | |
90bc0b93 |
522 | echo ' <NOBR><SMALL>'. _("Move selected to:") .'</SMALL>'; |
523 | echo ' <TT><SMALL><SELECT NAME="targetMailbox">'; |
7ce342dc |
524 | |
9f2215a1 |
525 | $boxes = sqimap_mailbox_list($imapConnection); |
7ce342dc |
526 | for ($i = 0; $i < count($boxes); $i++) { |
cbbdef2a |
527 | if (!in_array("noselect", $boxes[$i]['flags'])) { |
90bc0b93 |
528 | $box = $boxes[$i]['unformatted']; |
0cd84d75 |
529 | $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']); |
14eb705c |
530 | echo " <OPTION VALUE=\"$box\">$box2</option>\n"; |
6edca885 |
531 | } |
dd88d31f |
532 | } |
90bc0b93 |
533 | echo ' </SELECT></SMALL></TT>'; |
534 | echo ' <SMALL><INPUT TYPE=SUBMIT NAME="moveButton" VALUE="'. _("Move") ."\"></SMALL></NOBR>\n"; |
ed4332d1 |
535 | echo " </TD>\n"; |
7ce342dc |
536 | echo " <TD WIDTH=40% ALIGN=RIGHT>\n"; |
02ad7ce1 |
537 | if (! $auto_expunge) { |
90bc0b93 |
538 | echo ' <NOBR><SMALL><INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'"> '. _("mailbox") ."</SMALL></NOBR> \n"; |
f9b3e5d9 |
539 | } |
aae41ae9 |
540 | echo " <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\"> ". _("checked messages") ."</SMALL></NOBR>\n"; |
14eb705c |
541 | echo " </TD>\n"; |
ed4332d1 |
542 | echo " </TR>\n"; |
543 | |
70b455e0 |
544 | echo "</TABLE>\n"; |
90bc0b93 |
545 | do_hook('mailbox_form_before'); |
546 | echo '</TD></TR>'; |
aa4c3749 |
547 | |
f8f9bed9 |
548 | echo "<TR><TD BGCOLOR=\"$color[0]\">"; |
ac53fb56 |
549 | echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING="; |
550 | if ($GLOBALS['alt_index_colors']) { |
551 | echo "0"; |
552 | } else { |
553 | echo "1"; |
554 | } |
555 | echo " BGCOLOR=\"$color[0]\">"; |
f8f9bed9 |
556 | echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">"; |
be8e07f8 |
557 | |
74bb7ddc |
558 | $urlMailbox=urlencode($mailbox); |
8ae331c2 |
559 | |
14eb705c |
560 | // Print the headers |
8e265988 |
561 | for ($i=1; $i <= count($index_order); $i++) { |
562 | switch ($index_order[$i]) { |
563 | case 1: # checkbox |
14eb705c |
564 | case 5: # flags |
90bc0b93 |
565 | echo ' <TD WIDTH="1%"><B> </B></TD>'; |
8e265988 |
566 | break; |
14eb705c |
567 | |
8e265988 |
568 | case 2: # from |
14eb705c |
569 | if ($mailbox == $sent_folder) |
90bc0b93 |
570 | echo ' <TD WIDTH="30%"><B>'. _("To") .'</B>'; |
14eb705c |
571 | else |
90bc0b93 |
572 | echo ' <TD WIDTH="30%"><B>'. _("From") .'</B>'; |
8e265988 |
573 | |
574 | if ($sort == 2) |
575 | echo " <A HREF=\"right_main.php?newsort=3&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n"; |
f9b3e5d9 |
576 | elseif ($sort == 3) |
8e265988 |
577 | echo " <A HREF=\"right_main.php?newsort=2&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n"; |
f9b3e5d9 |
578 | elseif ($sort != -1) |
8e265988 |
579 | echo " <A HREF=\"right_main.php?newsort=3&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n"; |
eca500d0 |
580 | echo "</TD>"; |
8e265988 |
581 | break; |
14eb705c |
582 | |
8e265988 |
583 | case 3: # date |
90bc0b93 |
584 | echo ' <TD nowrap WIDTH="1%"><B>'. _("Date") .'</B>'; |
8e265988 |
585 | if ($sort == 0) |
586 | echo " <A HREF=\"right_main.php?newsort=1&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n"; |
f9b3e5d9 |
587 | elseif ($sort == 1) |
0d455368 |
588 | echo " <A HREF=\"right_main.php?newsort=6&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n"; |
8ae331c2 |
589 | elseif ($sort == 6) |
0d455368 |
590 | echo " <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n"; |
f9b3e5d9 |
591 | elseif ($sort != -1) |
8e265988 |
592 | echo " <A HREF=\"right_main.php?newsort=0&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n"; |
90bc0b93 |
593 | echo '</TD>'; |
8e265988 |
594 | break; |
14eb705c |
595 | |
8e265988 |
596 | case 4: # subject |
219fb205 |
597 | echo ' <TD><B>'. _("Subject") ."</B>\n"; |
8e265988 |
598 | if ($sort == 4) |
599 | echo " <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/up_pointer.gif\" BORDER=0></A></TD>\n"; |
f9b3e5d9 |
600 | elseif ($sort == 5) |
8e265988 |
601 | echo " <A HREF=\"right_main.php?newsort=4&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/down_pointer.gif\" BORDER=0></A></TD>\n"; |
f9b3e5d9 |
602 | elseif ($sort != -1) |
8e265988 |
603 | echo " <A HREF=\"right_main.php?newsort=5&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\"><IMG SRC=\"../images/sort_none.gif\" BORDER=0></A></TD>\n"; |
eca500d0 |
604 | echo "</TD>"; |
8e265988 |
605 | break; |
14eb705c |
606 | |
8e265988 |
607 | case 6: # size |
90bc0b93 |
608 | echo ' <TD WIDTH="1%"><b>' . _("Size")."</b></TD>\n"; |
8e265988 |
609 | break; |
610 | } |
611 | } |
14eb705c |
612 | echo "</TR>\n"; |
3302d0d4 |
613 | } |
323218d7 |
614 | |
615 | function ShowSelectAllLink($startMessage, $sort) |
616 | { |
617 | global $checkall, $PHP_SELF, $what, $where, $mailbox; |
618 | |
619 | echo "\n<A HREF=\"$PHP_SELF?mailbox=" . urlencode($mailbox) . |
620 | "&startMessage=$startMessage&sort=$sort&"; |
621 | if ( isset($checkall) && $checkall == '1') |
622 | echo "checkall=0"; |
623 | else |
624 | echo "checkall=1"; |
625 | if (isset($where) && isset($what)) |
626 | echo "&where=" . urlencode($where) . "&what=" . urlencode($what); |
627 | echo "\">"; |
628 | if (isset($checkall) && $checkall == '1') |
629 | echo _("Unselect All"); |
630 | else |
631 | echo _("Select All"); |
632 | echo "</A>\n"; |
633 | } |
f93c93b9 |
634 | |
635 | function processSubject($subject) |
636 | { |
637 | // Shouldn't ever happen -- caught too many times in the IMAP functions |
638 | if ($subject == '') |
639 | return _("(no subject)"); |
640 | |
641 | if (strlen($subject) <= 55) |
642 | return $subject; |
643 | |
644 | $ent_strlen=strlen($subject); |
645 | $trim_val=50; |
646 | $ent_offset=0; |
647 | // see if this is entities-encoded string |
648 | // If so, Iterate through the whole string, find out |
649 | // the real number of characters, and if more |
650 | // than 55, substr with an updated trim value. |
651 | while (($ent_loc = strpos($subject, '&', $ent_offset)) !== false && |
652 | ($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false) |
653 | { |
654 | $trim_val += ($ent_loc_end-$ent_loc)+1; |
655 | $ent_strlen -= $ent_loc_end-$ent_loc; |
656 | $ent_offset = $ent_loc_end+1; |
657 | } |
658 | |
659 | if ($ent_strlen <= 55) |
660 | return $subject; |
661 | |
662 | return substr($subject, 0, $trim_val) . '...'; |
663 | } |
664 | |
26b6c99c |
665 | ?> |