mailbox_display.php 23 KB

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