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