mailbox_display.php 25 KB

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