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