* Forgot to mention that "Download this as a file" now sets showHeaders
[squirrelmail.git] / functions / mailbox_display.php
CommitLineData
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
b3b103cb 23 if (!isset($GLOBALS["row_count"])) {
24 $GLOBALS["row_count"] = 0;
25 }
26 $GLOBALS["row_count"]++;
27 if ($GLOBALS["row_count"] % 2) {
28 if (!isset($color[12])) $color[12] = "#EAEAEA";
29 $color_string = $color[12];
30 } else {
31 $color_string = $color[4];
32 }
33
0d455368 34 $msg = $msgs[$key];
d92b6f31 35
90bc0b93 36 $senderName = sqimap_find_displayable_name($msg['FROM']);
05207a68 37 $urlMailbox = urlencode($mailbox);
f93c93b9 38 $subject = processSubject($msg['SUBJECT']);
b60b58f9 39
926da13e 40 echo "<TR>\n";
b60b58f9 41
90bc0b93 42 if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true)
245a6892 43 {
44 $flag = "<font color=$color[2]>";
6edca885 45 $flag_end = '</font>';
245a6892 46 }
47 else
48 {
90bc0b93 49 $flag = '';
6edca885 50 $flag_end = '';
245a6892 51 }
367e4f70 52 if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false)
245a6892 53 {
90bc0b93 54 $bold = '<b>';
6edca885 55 $bold_end = '</b>';
245a6892 56 }
57 else
58 {
90bc0b93 59 $bold = '';
6edca885 60 $bold_end = '';
245a6892 61 }
62 if ($mailbox == $sent_folder)
63 {
90bc0b93 64 $italic = '<i>';
6edca885 65 $italic_end = '</i>';
245a6892 66 }
67 else
68 {
90bc0b93 69 $italic = '';
6edca885 70 $italic_end = '';
245a6892 71 }
90bc0b93 72 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'])
245a6892 73 {
74 $fontstr = "<font color=\"$color[9]\">";
6edca885 75 $fontstr_end = '</font>';
245a6892 76 }
77 else
78 {
90bc0b93 79 $fontstr = '';
6edca885 80 $fontstr_end = '';
245a6892 81 }
b60b58f9 82
9d157cec 83 for ($i=0; $i < count($message_highlight_list); $i++) {
90bc0b93 84 if (trim($message_highlight_list[$i]['value']) != '') {
85 if ($message_highlight_list[$i]['match_type'] == 'to_cc') {
86 if (strpos('^^'.strtolower($msg['TO']), strtolower($message_highlight_list[$i]['value'])) || strpos('^^'.strtolower($msg['CC']), strtolower($message_highlight_list[$i]['value']))) {
87 $hlt_color = $message_highlight_list[$i]['color'];
d059be8f 88 continue;
89 }
90bc0b93 90 } else if (strpos('^^'.strtolower($msg[strtoupper($message_highlight_list[$i]['match_type'])]),strtolower($message_highlight_list[$i]['value']))) {
91 $hlt_color = $message_highlight_list[$i]['color'];
1195c340 92 continue;
b60b58f9 93 }
d059be8f 94 }
b60b58f9 95 }
96
245a6892 97 if (!isset($hlt_color))
b3b103cb 98 $hlt_color = $color_string;
1809bad8 99
100 if ($where && $what) {
90bc0b93 101 $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what);
1809bad8 102 }
66289791 103
eca500d0 104 if ($checkall == 1)
90bc0b93 105 $checked = ' checked';
eca500d0 106 else
90bc0b93 107 $checked = '';
3d48999d 108
8e265988 109 for ($i=1; $i <= count($index_order); $i++) {
110 switch ($index_order[$i]) {
111 case 1: # checkbox
112 echo " <td width=1% bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
113 break;
114 case 2: # from
eca500d0 115 echo " <td width=30% bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n";
8e265988 116 break;
117 case 3: # date
eca500d0 118 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 119 break;
120 case 4: # subject
7e73c6be 121 echo " <td bgcolor=$hlt_color>$bold";
6edca885 122 if (! isset($search_stuff)) { $search_stuff = ''; }
23fd3c8e 123 echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\"";
124 do_hook("subject_link");
f93c93b9 125 echo ">$flag$subject$flag_end</a>$bold_end</td>\n";
8e265988 126 break;
127 case 5: # flags
9db5f5fc 128 $stuff = false;
44e227c2 129 echo " <td bgcolor=$hlt_color align=center width=1% nowrap><b><small>\n";
245a6892 130 if (isset($msg['FLAG_ANSWERED']) &&
6edca885 131 $msg['FLAG_ANSWERED'] == true) {
9db5f5fc 132 echo "A\n";
133 $stuff = true;
8ae331c2 134 }
90bc0b93 135 if ($msg['TYPE0'] == 'multipart') {
9db5f5fc 136 echo "+\n";
137 $stuff = true;
8ae331c2 138 }
90bc0b93 139 if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) {
9db5f5fc 140 echo "<font color=$color[1]>!</font>\n";
141 $stuff = true;
142 }
90bc0b93 143 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
f9b3e5d9 144 echo "<font color=\"$color[1]\">D</font>\n";
145 $stuff = true;
146 }
8ae331c2 147
9db5f5fc 148 if (!$stuff) echo "&nbsp;\n";
149 echo "</small></b></td>\n";
8e265988 150 break;
8ae331c2 151 case 6: # size
eca500d0 152 echo " <td bgcolor=$hlt_color width=1%>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n";
8e265988 153 break;
154 }
155 }
156
7151188f 157
158 echo "</tr>\n";
926da13e 159 }
160
161 /**
162 ** This function loops through a group of messages in the mailbox and shows them
163 **/
5b6ae78a 164 function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
165 global $msgs, $msort;
f9b3e5d9 166 global $sent_folder;
9d157cec 167 global $message_highlight_list;
a3432f47 168 global $auto_expunge;
169
eca500d0 170 if ($auto_expunge == true) sqimap_mailbox_expunge($imapConnection, $mailbox, false);
0d455368 171 sqimap_mailbox_select($imapConnection, $mailbox);
61a4ac35 172
5b6ae78a 173 if (!$use_cache) {
0d455368 174 // if it's sorted
5b6ae78a 175 if ($numMessages >= 1) {
0d455368 176 if ($sort < 6) {
177 for ($q = 0; $q < $numMessages; $q++) {
178 if($mailbox == $sent_folder)
179 $hdr = sqimap_get_small_header ($imapConnection, $q+1, true);
180 else
181 $hdr = sqimap_get_small_header ($imapConnection, $q+1, false);
182
183 $from[$q] = $hdr->from;
184 $date[$q] = $hdr->date;
185 $subject[$q] = $hdr->subject;
186 $to[$q] = $hdr->to;
187 $priority[$q] = $hdr->priority;
188 $cc[$q] = $hdr->cc;
189 $size[$q] = $hdr->size;
190 $type[$q] = $hdr->type0;
191 $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
a3d65705 192 $id[$q] = $q + 1;
0d455368 193 }
194 } else {
195 // if it's not sorted
196 if ($startMessage + ($show_num - 1) < $numMessages) {
197 $endMessage = $startMessage + ($show_num-1);
198 } else {
199 $endMessage = $numMessages;
200 }
b60b58f9 201
0d455368 202 if ($endMessage < $startMessage) {
203 $startMessage = $startMessage - $show_num;
204 if ($startMessage < 1)
205 $startMessage = 1;
206 }
207
a3d65705 208
209 $real_startMessage = $numMessages - $startMessage + 1;
210 $real_endMessage = $numMessages - $startMessage - $show_num;
b60b58f9 211 if ($real_endMessage <= 0)
212 $real_endMessage = 1;
213
a3d65705 214 $j = 0;
215 for ($q = $real_startMessage; $q >= $real_endMessage; $q--) {
0d455368 216 if($mailbox == $sent_folder)
217 $hdr = sqimap_get_small_header ($imapConnection, $q, true);
218 else
219 $hdr = sqimap_get_small_header ($imapConnection, $q, false);
b60b58f9 220
0d455368 221 $from[$j] = $hdr->from;
222 $date[$j] = $hdr->date;
223 $subject[$j] = $hdr->subject;
224 $to[$j] = $hdr->to;
225 $priority[$j] = $hdr->priority;
226 $cc[$j] = $hdr->cc;
227 $size[$j] = $hdr->size;
228 $type[$j] = $hdr->type0;
229 $flags[$j] = sqimap_get_flags ($imapConnection, $q);
a3d65705 230 $id[$j] = $q;
0d455368 231 $j++;
232 }
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)
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
0d455368 274 if (eregi("^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs))
275 $messages[$j]['SUBJECT-SORT'] = $regs[2];
b60b58f9 276
5b6ae78a 277 $num = 0;
278 while ($num < count($flags[$j])) {
90bc0b93 279 if ($flags[$j][$num] == 'Deleted') {
280 $messages[$j]['FLAG_DELETED'] = true;
5b6ae78a 281 }
90bc0b93 282 elseif ($flags[$j][$num] == 'Answered') {
283 $messages[$j]['FLAG_ANSWERED'] = true;
5b6ae78a 284 }
90bc0b93 285 elseif ($flags[$j][$num] == 'Seen') {
286 $messages[$j]['FLAG_SEEN'] = true;
5b6ae78a 287 }
90bc0b93 288 elseif ($flags[$j][$num] == 'Flagged') {
289 $messages[$j]['FLAG_FLAGGED'] = true;
5b6ae78a 290 }
291 $num++;
7151188f 292 }
5b6ae78a 293 $j++;
3302d0d4 294 }
f9b3e5d9 295
296 /* Only ignore messages flagged as deleted if we are using a
297 * trash folder or auto_expunge */
245a6892 298 if (((isset($move_to_trash) && $move_to_trash)
6edca885 299 || (isset($auto_expunge) && $auto_expunge)) && $sort != 6)
b60b58f9 300 {
f9b3e5d9 301 /** Find and remove the ones that are deleted */
302 $i = 0;
303 $j = 0;
304 while ($j < $numMessages) {
cd928157 305 if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) {
f9b3e5d9 306 $j++;
307 continue;
308 }
309 $msgs[$i] = $messages[$j];
b60b58f9 310
f9b3e5d9 311 $i++;
5b6ae78a 312 $j++;
5b6ae78a 313 }
f9b3e5d9 314 $numMessages = $i;
0d455368 315 } else {
6edca885 316 if (! isset($messages))
317 $messages = array();
0d455368 318 $msgs = $messages;
5b10f02a 319 }
5b6ae78a 320 }
926da13e 321
4c2d69ac 322 // There's gotta be messages in the array for it to sort them.
f9b3e5d9 323 if ($numMessages > 0 && ! $use_cache) {
0e919368 324 /** 0 = Date (up) 4 = Subject (up)
325 ** 1 = Date (dn) 5 = Subject (dn)
326 ** 2 = Name (up)
327 ** 3 = Name (dn)
328 **/
09856735 329 session_unregister("msgs");
1c292c82 330 if (($sort == 0) || ($sort == 1))
90bc0b93 331 $msort = array_cleave ($msgs, 'TIME_STAMP');
1c292c82 332 if (($sort == 2) || ($sort == 3))
90bc0b93 333 $msort = array_cleave ($msgs, 'FROM-SORT');
1c292c82 334 if (($sort == 4) || ($sort == 5))
90bc0b93 335 $msort = array_cleave ($msgs, 'SUBJECT-SORT');
0d455368 336 if ($sort == 6)
337 $msort = $msgs;
338
339 if ($sort < 6) {
340 if($sort % 2) {
341 asort($msort);
342 } else {
343 arsort($msort);
344 }
0e919368 345 }
90bc0b93 346 session_register('msort');
4c2d69ac 347 }
5b6ae78a 348 displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
90bc0b93 349 session_register('msgs');
9f2215a1 350 }
351
352 // generic function to convert the msgs array into an HTML table
5b6ae78a 353 function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
cbdc5621 354 global $folder_prefix, $sent_folder;
f9b3e5d9 355 global $imapServerAddress;
21fafac8 356 global $index_order, $real_endMessage, $real_startMessage, $checkall;
72b0f272 357
9f2215a1 358 // if cache isn't already set, do it now
90bc0b93 359 if (!session_is_registered('msgs'))
360 session_register('msgs');
361 if (!session_is_registered('msort'))
362 session_register('msort');
90033b64 363
9c83f905 364 if ($startMessage + ($show_num - 1) < $numMessages) {
365 $endMessage = $startMessage + ($show_num-1);
926da13e 366 } else {
926da13e 367 $endMessage = $numMessages;
368 }
b60b58f9 369
8442ac08 370 if ($endMessage < $startMessage) {
371 $startMessage = $startMessage - $show_num;
372 if ($startMessage < 1)
373 $startMessage = 1;
374 }
b60b58f9 375
9c83f905 376 $nextGroup = $startMessage + $show_num;
377 $prevGroup = $startMessage - $show_num;
20db5033 378 $urlMailbox = urlencode($mailbox);
926da13e 379
90bc0b93 380 do_hook('mailbox_index_before');
926da13e 381
14eb705c 382 $Message = '';
0d1b4832 383 if ($startMessage < $endMessage) {
14eb705c 384 $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
f9b3e5d9 385 } elseif ($startMessage == $endMessage) {
14eb705c 386 $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
0d1b4832 387 }
26b6c99c 388
14eb705c 389 $More = '';
0d455368 390 if ($sort == 6) {
391 $use = 0;
392 } else {
393 $use = 1;
394 }
5b10f02a 395 if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
0d455368 396 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
397 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
926da13e 398 }
f9b3e5d9 399 elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
0d455368 400 $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
14eb705c 401 $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
3302d0d4 402 }
f9b3e5d9 403 elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
14eb705c 404 $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
0d455368 405 $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
14eb705c 406 }
407
245a6892 408 if (! isset($msg))
409 $msg = "";
b60b58f9 410 mail_message_listing_beginning($imapConnection,
14eb705c 411 "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
66289791 412 $mailbox, $sort, $Message, $More, $startMessage);
14eb705c 413
8ae331c2 414 $groupNum = $startMessage % ($show_num - 1);
72b0f272 415 $real_startMessage = $startMessage;
b60b58f9 416 if ($sort == 6) {
417 if ($endMessage - $startMessage < $show_num - 1) {
418 $endMessage = $endMessage - $startMessage + 1;
419 $startMessage = 1;
420 } else if ($startMessage > $show_num) {
421 $endMessage = $show_num;
422 $startMessage = 1;
423 }
424 }
425
426 $endVar = $endMessage + 1;
427
14eb705c 428 // loop through and display the info for each message.
429 $t = 0; // $t is used for the checkbox number
430 if ($numMessages == 0) { // if there's no messages in this folder
431 echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
432 echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp;</CENTER></TD></TR>";
b60b58f9 433 } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
a3d65705 434 if ($sort != 6)
435 $i = $startMessage;
436 else
437 $i = 1;
14eb705c 438 reset($msort);
6edca885 439 $k = 0;
14eb705c 440 do {
441 $key = key($msort);
442 next($msort);
443 $k++;
444 } while (isset ($key) && ($k < $i));
72b0f272 445 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
14eb705c 446 } else {
b60b58f9 447 $i = $startMessage;
448
14eb705c 449 reset($msort);
6edca885 450 $k = 0;
14eb705c 451 do {
452 $key = key($msort);
453 next($msort);
454 $k++;
455 } while (isset ($key) && ($k < $i));
456
0d455368 457 do {
72b0f272 458 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
14eb705c 459 $key = key($msort);
460 $t++;
461 $i++;
462 next($msort);
b60b58f9 463 } while ($i && $i < $endVar);
14eb705c 464 }
90bc0b93 465 echo '</TABLE>';
14eb705c 466
467 echo "</td></tr>\n";
468
66289791 469 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
90bc0b93 470 echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
eca500d0 471 echo "$More</td><td align=right>\n";
472 if (!$startMessage) $startMessage=1;
323218d7 473 ShowSelectAllLink($startMessage, $sort);
66289791 474
90bc0b93 475 echo '</td></tr></table>';
476 echo '</td></tr>';
477 echo '</table>'; /** End of message-list table */
14eb705c 478
90bc0b93 479 do_hook('mailbox_index_after');
14eb705c 480 }
481
482 /* Displays the standard message list header.
483 * To finish the table, you need to do a "</table></table>";
484 * $moveURL is the URL to submit the delete/move form to
485 * $mailbox is the current mailbox
486 * $sort is the current sorting method (-1 for no sorting available [searches])
487 * $Message is a message that is centered on top of the list
488 * $More is a second line that is left aligned
489 */
8ae331c2 490 function mail_message_listing_beginning($imapConnection, $moveURL,
5252447e 491 $mailbox = '', $sort = -1, $Message = '', $More = '', $startMessage = 1)
14eb705c 492 {
f9b3e5d9 493 global $color, $index_order, $auto_expunge, $move_to_trash;
58da09bd 494 global $checkall, $sent_folder;
eca500d0 495 $urlMailbox = urlencode($mailbox);
14eb705c 496 /** This is the beginning of the message list table. It wraps around all messages */
90bc0b93 497 echo '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="0">';
8ae331c2 498
14eb705c 499 if ($Message)
500 {
501 echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n";
502 }
8ae331c2 503
66289791 504 echo "<TR BGCOLOR=\"$color[4]\"><TD>";
90bc0b93 505 echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
eca500d0 506 echo "$More</td><td align=right>\n";
323218d7 507 ShowSelectAllLink($startMessage, $sort);
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++) {
cbbdef2a 526 if (!in_array("noselect", $boxes[$i]['flags'])) {
90bc0b93 527 $box = $boxes[$i]['unformatted'];
0cd84d75 528 $box2 = str_replace(' ', '&nbsp;', $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") .'">&nbsp;'. _("mailbox") ."</SMALL></NOBR>&nbsp;&nbsp;\n";
f9b3e5d9 538 }
aae41ae9 539 echo " <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\">&nbsp;". _("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]\">";
f435778e 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>&nbsp;</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
219fb205 590 echo ' <TD><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 }
323218d7 607
608 function ShowSelectAllLink($startMessage, $sort)
609 {
610 global $checkall, $PHP_SELF, $what, $where, $mailbox;
611
612 echo "\n<A HREF=\"$PHP_SELF?mailbox=" . urlencode($mailbox) .
613 "&startMessage=$startMessage&sort=$sort&";
614 if ( isset($checkall) && $checkall == '1')
615 echo "checkall=0";
616 else
617 echo "checkall=1";
618 if (isset($where) && isset($what))
619 echo "&where=" . urlencode($where) . "&what=" . urlencode($what);
620 echo "\">";
621 if (isset($checkall) && $checkall == '1')
622 echo _("Unselect All");
623 else
624 echo _("Select All");
625 echo "</A>\n";
626 }
f93c93b9 627
628 function processSubject($subject)
629 {
630 // Shouldn't ever happen -- caught too many times in the IMAP functions
631 if ($subject == '')
632 return _("(no subject)");
633
634 if (strlen($subject) <= 55)
635 return $subject;
636
637 $ent_strlen=strlen($subject);
638 $trim_val=50;
639 $ent_offset=0;
640 // see if this is entities-encoded string
641 // If so, Iterate through the whole string, find out
642 // the real number of characters, and if more
643 // than 55, substr with an updated trim value.
644 while (($ent_loc = strpos($subject, '&', $ent_offset)) !== false &&
645 ($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false)
646 {
647 $trim_val += ($ent_loc_end-$ent_loc)+1;
648 $ent_strlen -= $ent_loc_end-$ent_loc;
649 $ent_offset = $ent_loc_end+1;
650 }
651
652 if ($ent_strlen <= 55)
653 return $subject;
654
655 return substr($subject, 0, $trim_val) . '...';
656 }
657
26b6c99c 658?>