mailbox_display.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <?php
  2. /**
  3. ** mailbox_display.php
  4. **
  5. ** This contains functions that display mailbox information, such as the
  6. ** table row that has sender, date, subject, etc...
  7. **
  8. ** $Id$
  9. **/
  10. $mailbox_display_php = true;
  11. function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, $where, $what) {
  12. global $checkall;
  13. global $color, $msgs, $msort;
  14. global $sent_folder;
  15. global $message_highlight_list;
  16. global $index_order;
  17. $msg = $msgs[$key];
  18. $senderName = sqimap_find_displayable_name($msg['FROM']);
  19. $urlMailbox = urlencode($mailbox);
  20. $subject = trim($msg['SUBJECT']);
  21. if ($subject == '')
  22. $subject = _("(no subject)");
  23. echo "<TR>\n";
  24. if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true)
  25. {
  26. $flag = "<font color=$color[2]>";
  27. $flag_end = '</font>';
  28. }
  29. else
  30. {
  31. $flag = '';
  32. $flag_end = '';
  33. }
  34. if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false)
  35. {
  36. $bold = '<b>';
  37. $bold_end = '</b>';
  38. }
  39. else
  40. {
  41. $bold = '';
  42. $bold_end = '';
  43. }
  44. if ($mailbox == $sent_folder)
  45. {
  46. $italic = '<i>';
  47. $italic_end = '</i>';
  48. }
  49. else
  50. {
  51. $italic = '';
  52. $italic_end = '';
  53. }
  54. if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'])
  55. {
  56. $fontstr = "<font color=\"$color[9]\">";
  57. $fontstr_end = '</font>';
  58. }
  59. else
  60. {
  61. $fontstr = '';
  62. $fontstr_end = '';
  63. }
  64. for ($i=0; $i < count($message_highlight_list); $i++) {
  65. if (trim($message_highlight_list[$i]['value']) != '') {
  66. if ($message_highlight_list[$i]['match_type'] == 'to_cc') {
  67. if (strpos('^^'.strtolower($msg['TO']), strtolower($message_highlight_list[$i]['value'])) || strpos('^^'.strtolower($msg['CC']), strtolower($message_highlight_list[$i]['value']))) {
  68. $hlt_color = $message_highlight_list[$i]['color'];
  69. continue;
  70. }
  71. } else if (strpos('^^'.strtolower($msg[strtoupper($message_highlight_list[$i]['match_type'])]),strtolower($message_highlight_list[$i]['value']))) {
  72. $hlt_color = $message_highlight_list[$i]['color'];
  73. continue;
  74. }
  75. }
  76. }
  77. if (!isset($hlt_color))
  78. $hlt_color = $color[4];
  79. if ($where && $what) {
  80. $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what);
  81. }
  82. if ($checkall == 1)
  83. $checked = ' checked';
  84. else
  85. $checked = '';
  86. for ($i=1; $i <= count($index_order); $i++) {
  87. switch ($index_order[$i]) {
  88. case 1: # checkbox
  89. echo " <td width=1% bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
  90. break;
  91. case 2: # from
  92. echo " <td width=30% bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n";
  93. break;
  94. case 3: # date
  95. echo " <td nowrap width=1% bgcolor=$hlt_color><center>$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end</center></td>\n";
  96. break;
  97. case 4: # subject
  98. echo " <td bgcolor=$hlt_color>$bold";
  99. if (! isset($search_stuff)) { $search_stuff = ''; }
  100. echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\"";
  101. do_hook("subject_link");
  102. echo ">$flag";
  103. if (strlen($subject) > 55)
  104. echo substr($subject, 0, 50) . '...';
  105. else
  106. echo $subject;
  107. echo "$flag_end</a>$bold_end</td>\n";
  108. break;
  109. case 5: # flags
  110. $stuff = false;
  111. echo " <td bgcolor=$hlt_color align=center width=1% nowrap><b><small>\n";
  112. if (isset($msg['FLAG_ANSWERED']) &&
  113. $msg['FLAG_ANSWERED'] == true) {
  114. echo "A\n";
  115. $stuff = true;
  116. }
  117. if ($msg['TYPE0'] == 'multipart') {
  118. echo "+\n";
  119. $stuff = true;
  120. }
  121. if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) {
  122. echo "<font color=$color[1]>!</font>\n";
  123. $stuff = true;
  124. }
  125. if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
  126. echo "<font color=\"$color[1]\">D</font>\n";
  127. $stuff = true;
  128. }
  129. if (!$stuff) echo "&nbsp;\n";
  130. echo "</small></b></td>\n";
  131. break;
  132. case 6: # size
  133. echo " <td bgcolor=$hlt_color width=1%>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n";
  134. break;
  135. }
  136. }
  137. echo "</tr>\n";
  138. }
  139. /**
  140. ** This function loops through a group of messages in the mailbox and shows them
  141. **/
  142. function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
  143. global $msgs, $msort;
  144. global $sent_folder;
  145. global $message_highlight_list;
  146. global $auto_expunge;
  147. if ($auto_expunge == true) sqimap_mailbox_expunge($imapConnection, $mailbox, false);
  148. sqimap_mailbox_select($imapConnection, $mailbox);
  149. if (!$use_cache) {
  150. // if it's sorted
  151. if ($numMessages >= 1) {
  152. if ($sort < 6) {
  153. for ($q = 0; $q < $numMessages; $q++) {
  154. if($mailbox == $sent_folder)
  155. $hdr = sqimap_get_small_header ($imapConnection, $q+1, true);
  156. else
  157. $hdr = sqimap_get_small_header ($imapConnection, $q+1, false);
  158. $from[$q] = $hdr->from;
  159. $date[$q] = $hdr->date;
  160. $subject[$q] = $hdr->subject;
  161. $to[$q] = $hdr->to;
  162. $priority[$q] = $hdr->priority;
  163. $cc[$q] = $hdr->cc;
  164. $size[$q] = $hdr->size;
  165. $type[$q] = $hdr->type0;
  166. $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
  167. $id[$q] = $q + 1;
  168. }
  169. } else {
  170. // if it's not sorted
  171. if ($startMessage + ($show_num - 1) < $numMessages) {
  172. $endMessage = $startMessage + ($show_num-1);
  173. } else {
  174. $endMessage = $numMessages;
  175. }
  176. if ($endMessage < $startMessage) {
  177. $startMessage = $startMessage - $show_num;
  178. if ($startMessage < 1)
  179. $startMessage = 1;
  180. }
  181. $real_startMessage = $numMessages - $startMessage + 1;
  182. $real_endMessage = $numMessages - $startMessage - $show_num;
  183. if ($real_endMessage <= 0)
  184. $real_endMessage = 1;
  185. $j = 0;
  186. for ($q = $real_startMessage; $q >= $real_endMessage; $q--) {
  187. if($mailbox == $sent_folder)
  188. $hdr = sqimap_get_small_header ($imapConnection, $q, true);
  189. else
  190. $hdr = sqimap_get_small_header ($imapConnection, $q, false);
  191. $from[$j] = $hdr->from;
  192. $date[$j] = $hdr->date;
  193. $subject[$j] = $hdr->subject;
  194. $to[$j] = $hdr->to;
  195. $priority[$j] = $hdr->priority;
  196. $cc[$j] = $hdr->cc;
  197. $size[$j] = $hdr->size;
  198. $type[$j] = $hdr->type0;
  199. $flags[$j] = sqimap_get_flags ($imapConnection, $q);
  200. $id[$j] = $q;
  201. $j++;
  202. }
  203. }
  204. }
  205. $j = 0;
  206. if ($sort == 6) {
  207. $end = $startMessage + $show_num - 1;
  208. } else {
  209. $end = $numMessages;
  210. }
  211. if ($end > $numMessages) $end = $numMessages;
  212. while ($j < $end) {
  213. $date[$j] = ereg_replace(' ', ' ', $date[$j]);
  214. $tmpdate = explode(' ', trim($date[$j]));
  215. $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate);
  216. $messages[$j]['DATE_STRING'] = getDateString($messages[$j]['TIME_STAMP']);
  217. $messages[$j]['ID'] = $id[$j];
  218. $messages[$j]['FROM'] = decodeHeader($from[$j]);
  219. $messages[$j]['FROM-SORT'] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
  220. $messages[$j]['SUBJECT'] = decodeHeader($subject[$j]);
  221. $messages[$j]['SUBJECT-SORT'] = strtolower(decodeHeader($subject[$j]));
  222. $messages[$j]['TO'] = decodeHeader($to[$j]);
  223. $messages[$j]['PRIORITY'] = $priority[$j];
  224. $messages[$j]['CC'] = $cc[$j];
  225. $messages[$j]['SIZE'] = $size[$j];
  226. $messages[$j]['TYPE0'] = $type[$j];
  227. # fix SUBJECT-SORT to remove Re:
  228. $re_abbr = # Add more here!
  229. 'vedr|sv|' . # Danish
  230. 're|aw'; # English
  231. if (eregi("^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs))
  232. $messages[$j]['SUBJECT-SORT'] = $regs[2];
  233. $num = 0;
  234. while ($num < count($flags[$j])) {
  235. if ($flags[$j][$num] == 'Deleted') {
  236. $messages[$j]['FLAG_DELETED'] = true;
  237. }
  238. elseif ($flags[$j][$num] == 'Answered') {
  239. $messages[$j]['FLAG_ANSWERED'] = true;
  240. }
  241. elseif ($flags[$j][$num] == 'Seen') {
  242. $messages[$j]['FLAG_SEEN'] = true;
  243. }
  244. elseif ($flags[$j][$num] == 'Flagged') {
  245. $messages[$j]['FLAG_FLAGGED'] = true;
  246. }
  247. $num++;
  248. }
  249. $j++;
  250. }
  251. /* Only ignore messages flagged as deleted if we are using a
  252. * trash folder or auto_expunge */
  253. if (((isset($move_to_trash) && $move_to_trash)
  254. || (isset($auto_expunge) && $auto_expunge)) && $sort != 6)
  255. {
  256. /** Find and remove the ones that are deleted */
  257. $i = 0;
  258. $j = 0;
  259. while ($j < $numMessages) {
  260. if ($messages[$j]['FLAG_DELETED'] == true) {
  261. $j++;
  262. continue;
  263. }
  264. $msgs[$i] = $messages[$j];
  265. $i++;
  266. $j++;
  267. }
  268. $numMessages = $i;
  269. } else {
  270. if (! isset($messages))
  271. $messages = array();
  272. $msgs = $messages;
  273. }
  274. }
  275. // There's gotta be messages in the array for it to sort them.
  276. if ($numMessages > 0 && ! $use_cache) {
  277. /** 0 = Date (up) 4 = Subject (up)
  278. ** 1 = Date (dn) 5 = Subject (dn)
  279. ** 2 = Name (up)
  280. ** 3 = Name (dn)
  281. **/
  282. session_unregister("msgs");
  283. if (($sort == 0) || ($sort == 1))
  284. $msort = array_cleave ($msgs, 'TIME_STAMP');
  285. if (($sort == 2) || ($sort == 3))
  286. $msort = array_cleave ($msgs, 'FROM-SORT');
  287. if (($sort == 4) || ($sort == 5))
  288. $msort = array_cleave ($msgs, 'SUBJECT-SORT');
  289. if ($sort == 6)
  290. $msort = $msgs;
  291. if ($sort < 6) {
  292. if($sort % 2) {
  293. asort($msort);
  294. } else {
  295. arsort($msort);
  296. }
  297. }
  298. session_register('msort');
  299. }
  300. displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
  301. session_register('msgs');
  302. }
  303. // generic function to convert the msgs array into an HTML table
  304. function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
  305. global $folder_prefix, $sent_folder;
  306. global $imapServerAddress;
  307. global $index_order, $real_endMessage, $real_startMessage, $checkall;
  308. // if cache isn't already set, do it now
  309. if (!session_is_registered('msgs'))
  310. session_register('msgs');
  311. if (!session_is_registered('msort'))
  312. session_register('msort');
  313. if ($startMessage + ($show_num - 1) < $numMessages) {
  314. $endMessage = $startMessage + ($show_num-1);
  315. } else {
  316. $endMessage = $numMessages;
  317. }
  318. if ($endMessage < $startMessage) {
  319. $startMessage = $startMessage - $show_num;
  320. if ($startMessage < 1)
  321. $startMessage = 1;
  322. }
  323. $nextGroup = $startMessage + $show_num;
  324. $prevGroup = $startMessage - $show_num;
  325. $urlMailbox = urlencode($mailbox);
  326. do_hook('mailbox_index_before');
  327. $Message = '';
  328. if ($startMessage < $endMessage) {
  329. $Message = _("Viewing messages") ." <B>$startMessage</B> ". _("to") ." <B>$endMessage</B> ($numMessages " . _("total") . ")\n";
  330. } elseif ($startMessage == $endMessage) {
  331. $Message = _("Viewing message") ." <B>$startMessage</B> ($numMessages " . _("total") . ")\n";
  332. }
  333. $More = '';
  334. if ($sort == 6) {
  335. $use = 0;
  336. } else {
  337. $use = 1;
  338. }
  339. if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
  340. $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
  341. $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
  342. }
  343. elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
  344. $More = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") ."</A> | \n";
  345. $More .= "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
  346. }
  347. elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
  348. $More = "<FONT COLOR=\"$color[9]\">"._("Previous")."</FONT> | \n";
  349. $More .= "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
  350. }
  351. if (! isset($msg))
  352. $msg = "";
  353. mail_message_listing_beginning($imapConnection,
  354. "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$startMessage",
  355. $mailbox, $sort, $Message, $More, $startMessage);
  356. $groupNum = $startMessage % ($show_num - 1);
  357. $real_startMessage = $startMessage;
  358. if ($sort == 6) {
  359. if ($endMessage - $startMessage < $show_num - 1) {
  360. $endMessage = $endMessage - $startMessage + 1;
  361. $startMessage = 1;
  362. } else if ($startMessage > $show_num) {
  363. $endMessage = $show_num;
  364. $startMessage = 1;
  365. }
  366. }
  367. $endVar = $endMessage + 1;
  368. // loop through and display the info for each message.
  369. $t = 0; // $t is used for the checkbox number
  370. if ($numMessages == 0) { // if there's no messages in this folder
  371. echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order);
  372. echo "><CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR>&nbsp;</CENTER></TD></TR>";
  373. } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
  374. if ($sort != 6)
  375. $i = $startMessage;
  376. else
  377. $i = 1;
  378. reset($msort);
  379. $k = 0;
  380. do {
  381. $key = key($msort);
  382. next($msort);
  383. $k++;
  384. } while (isset ($key) && ($k < $i));
  385. printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
  386. } else {
  387. $i = $startMessage;
  388. reset($msort);
  389. $k = 0;
  390. do {
  391. $key = key($msort);
  392. next($msort);
  393. $k++;
  394. } while (isset ($key) && ($k < $i));
  395. do {
  396. printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
  397. $key = key($msort);
  398. $t++;
  399. $i++;
  400. next($msort);
  401. } while ($i && $i < $endVar);
  402. }
  403. echo '</TABLE>';
  404. echo "</td></tr>\n";
  405. echo "<TR BGCOLOR=\"$color[4]\"><TD>";
  406. echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
  407. echo "$More</td><td align=right>\n";
  408. if (!$startMessage) $startMessage=1;
  409. if ( $checkall == '1')
  410. echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$real_startMessage&sort=$sort\">" . _("Unselect All") . "</A>\n";
  411. else
  412. echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$real_startMessage&sort=$sort&checkall=1\">" . _("Select All") . "</A>\n";
  413. echo '</td></tr></table>';
  414. echo '</td></tr>';
  415. echo '</table>'; /** End of message-list table */
  416. do_hook('mailbox_index_after');
  417. }
  418. /* Displays the standard message list header.
  419. * To finish the table, you need to do a "</table></table>";
  420. * $moveURL is the URL to submit the delete/move form to
  421. * $mailbox is the current mailbox
  422. * $sort is the current sorting method (-1 for no sorting available [searches])
  423. * $Message is a message that is centered on top of the list
  424. * $More is a second line that is left aligned
  425. */
  426. function mail_message_listing_beginning($imapConnection, $moveURL,
  427. $mailbox = '', $sort = -1, $Message = '', $More = '', $startMessage = 1)
  428. {
  429. global $color, $index_order, $auto_expunge, $move_to_trash;
  430. global $checkall, $sent_folder;
  431. $urlMailbox = urlencode($mailbox);
  432. /** This is the beginning of the message list table. It wraps around all messages */
  433. echo '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="0">';
  434. if ($Message)
  435. {
  436. echo "<TR BGCOLOR=\"$color[4]\"><TD align=center>$Message</td></tr>\n";
  437. }
  438. echo "<TR BGCOLOR=\"$color[4]\"><TD>";
  439. echo '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td>';
  440. echo "$More</td><td align=right>\n";
  441. if ( $checkall == '1')
  442. echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$startMessage&sort=$sort\">" . _("Unselect All") . "</A>\n";
  443. else
  444. echo "\n<A HREF=\"right_main.php?mailbox=$urlMailbox&startMessage=$startMessage&sort=$sort&checkall=1\">" . _("Select All") . "</A>\n";
  445. echo '</td></tr></table>';
  446. echo '</td></tr>';
  447. /** The delete and move options */
  448. echo "<TR><TD BGCOLOR=\"$color[0]\">";
  449. echo "\n\n\n<FORM name=messageList method=post action=\"$moveURL\">\n";
  450. echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
  451. echo " <TR>\n";
  452. echo " <TD WIDTH=60% ALIGN=LEFT VALIGN=CENTER>\n";
  453. echo ' <NOBR><SMALL>'. _("Move selected to:") .'</SMALL>';
  454. echo ' <TT><SMALL><SELECT NAME="targetMailbox">';
  455. $boxes = sqimap_mailbox_list($imapConnection);
  456. for ($i = 0; $i < count($boxes); $i++) {
  457. if (!in_array("noselect", $boxes[$i]["flags"])) {
  458. $box = $boxes[$i]['unformatted'];
  459. $box2 = replace_spaces($boxes[$i]['unformatted-disp']);
  460. echo " <OPTION VALUE=\"$box\">$box2</option>\n";
  461. }
  462. }
  463. echo ' </SELECT></SMALL></TT>';
  464. echo ' <SMALL><INPUT TYPE=SUBMIT NAME="moveButton" VALUE="'. _("Move") ."\"></SMALL></NOBR>\n";
  465. echo " </TD>\n";
  466. echo " <TD WIDTH=40% ALIGN=RIGHT>\n";
  467. if (! $auto_expunge) {
  468. echo ' <NOBR><SMALL><INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'">&nbsp;'. _("mailbox") ."</SMALL></NOBR>&nbsp;&nbsp;\n";
  469. }
  470. echo " <NOBR><SMALL><INPUT TYPE=SUBMIT VALUE=\"". _("Delete") ."\">&nbsp;". _("checked messages") ."</SMALL></NOBR>\n";
  471. echo " </TD>\n";
  472. echo " </TR>\n";
  473. echo "</TABLE>\n";
  474. do_hook('mailbox_form_before');
  475. echo '</TD></TR>';
  476. echo "<TR><TD BGCOLOR=\"$color[0]\">";
  477. echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">";
  478. echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
  479. $urlMailbox=urlencode($mailbox);
  480. // Print the headers
  481. for ($i=1; $i <= count($index_order); $i++) {
  482. switch ($index_order[$i]) {
  483. case 1: # checkbox
  484. case 5: # flags
  485. echo ' <TD WIDTH="1%"><B>&nbsp;</B></TD>';
  486. break;
  487. case 2: # from
  488. if ($mailbox == $sent_folder)
  489. echo ' <TD WIDTH="30%"><B>'. _("To") .'</B>';
  490. else
  491. echo ' <TD WIDTH="30%"><B>'. _("From") .'</B>';
  492. if ($sort == 2)
  493. 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";
  494. elseif ($sort == 3)
  495. 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";
  496. elseif ($sort != -1)
  497. 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";
  498. echo "</TD>";
  499. break;
  500. case 3: # date
  501. echo ' <TD nowrap WIDTH="1%"><B>'. _("Date") .'</B>';
  502. if ($sort == 0)
  503. 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";
  504. elseif ($sort == 1)
  505. 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";
  506. elseif ($sort == 6)
  507. 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";
  508. elseif ($sort != -1)
  509. 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";
  510. echo '</TD>';
  511. break;
  512. case 4: # subject
  513. echo ' <TD WIDTH=%><B>'. _("Subject") ."</B>\n";
  514. if ($sort == 4)
  515. 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";
  516. elseif ($sort == 5)
  517. 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";
  518. elseif ($sort != -1)
  519. 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";
  520. echo "</TD>";
  521. break;
  522. case 6: # size
  523. echo ' <TD WIDTH="1%"><b>' . _("Size")."</b></TD>\n";
  524. break;
  525. }
  526. }
  527. echo "</TR>\n";
  528. }
  529. ?>