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