mailbox_display.php 26 KB

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