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