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