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