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