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