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