PageRenderTime 63ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1_4_0/squirrelmail/functions/mailbox_display.php

#
PHP | 1252 lines | 973 code | 128 blank | 151 comment | 248 complexity | 8e6aa758b869e0ac38f6d6a652f23289 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. <?php
  2. /**
  3. * mailbox_display.php
  4. *
  5. * Copyright (c) 1999-2003 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * This contains functions that display mailbox information, such as the
  9. * table row that has sender, date, subject, etc...
  10. *
  11. * $Id: mailbox_display.php 4695 2003-03-27 16:47:48Z philippe_mingo $
  12. */
  13. require_once(SM_PATH . 'functions/strings.php');
  14. require_once(SM_PATH . 'functions/html.php');
  15. require_once(SM_PATH . 'class/html.class.php');
  16. require_once(SM_PATH . 'functions/imap_mailbox.php');
  17. /* Default value for page_selector_max. */
  18. define('PG_SEL_MAX', 10);
  19. function elapsed($start)
  20. {
  21. $end = microtime();
  22. list($start2, $start1) = explode(" ", $start);
  23. list($end2, $end1) = explode(" ", $end);
  24. $diff1 = $end1 - $start1;
  25. $diff2 = $end2 - $start2;
  26. if( $diff2 < 0 ){
  27. $diff1 -= 1;
  28. $diff2 += 1.0;
  29. }
  30. return $diff2 + $diff1;
  31. }
  32. function printMessageInfo($imapConnection, $t, $not_last=true, $key, $mailbox,
  33. $start_msg, $where, $what) {
  34. global $checkall,
  35. $color, $msgs, $msort, $td_str, $msg,
  36. $default_use_priority,
  37. $message_highlight_list,
  38. $index_order,
  39. $indent_array, /* indent subject by */
  40. $pos, /* Search postion (if any) */
  41. $thread_sort_messages, /* thread sorting on/off */
  42. $server_sort_order, /* sort value when using server-sorting */
  43. $row_count,
  44. $allow_server_sort; /* enable/disable server-side sorting */
  45. $color_string = $color[4];
  46. if ($GLOBALS['alt_index_colors']) {
  47. if (!isset($row_count)) {
  48. $row_count = 0;
  49. }
  50. $row_count++;
  51. if ($row_count % 2) {
  52. if (!isset($color[12])) {
  53. $color[12] = '#EAEAEA';
  54. }
  55. $color_string = $color[12];
  56. }
  57. }
  58. $msg = $msgs[$key];
  59. if($mailbox == 'None') {
  60. $boxes = sqimap_mailbox_list($imapConnection);
  61. $mailbox = $boxes[0]['unformatted'];
  62. unset($boxes);
  63. }
  64. $urlMailbox = urlencode($mailbox);
  65. if (handleAsSent($mailbox)) {
  66. $msg['FROM'] = $msg['TO'];
  67. }
  68. /*
  69. * This is done in case you're looking into Sent folders,
  70. * because you can have multiple receivers.
  71. */
  72. $senderNames = $msg['FROM'];
  73. $senderName = '';
  74. if (sizeof($senderNames)){
  75. foreach ($senderNames as $senderNames_part) {
  76. if ($senderName != '') {
  77. $senderName .= ', ';
  78. }
  79. if ($senderNames_part[1]) {
  80. $senderName .= decodeHeader($senderNames_part[1]);
  81. } else {
  82. $senderName .= htmlspecialchars($senderNames_part[0]);
  83. }
  84. }
  85. }
  86. $subject_full = decodeHeader($msg['SUBJECT']);
  87. $subject = processSubject($subject_full, $indent_array[$msg['ID']]);
  88. echo html_tag( 'tr','','','','VALIGN="top"') . "\n";
  89. if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) {
  90. $flag = "<font color=\"$color[2]\">";
  91. $flag_end = '</font>';
  92. } else {
  93. $flag = '';
  94. $flag_end = '';
  95. }
  96. if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) {
  97. $bold = '<b>';
  98. $bold_end = '</b>';
  99. } else {
  100. $bold = '';
  101. $bold_end = '';
  102. }
  103. if (handleAsSent($mailbox)) {
  104. $italic = '<i>';
  105. $italic_end = '</i>';
  106. } else {
  107. $italic = '';
  108. $italic_end = '';
  109. }
  110. if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
  111. $fontstr = "<font color=\"$color[9]\">";
  112. $fontstr_end = '</font>';
  113. } else {
  114. $fontstr = '';
  115. $fontstr_end = '';
  116. }
  117. if ($where && $what) {
  118. $searchstr = '&amp;where='.$where.'&amp;what='.$what;
  119. } else {
  120. $searchstr = '';
  121. }
  122. /**
  123. * AAAAH! Make my eyes stop bleeding!
  124. * Who wrote this?!
  125. */
  126. if (is_array($message_highlight_list) && count($message_highlight_list)){
  127. foreach ($message_highlight_list as $message_highlight_list_part) {
  128. if (trim($message_highlight_list_part['value']) != '') {
  129. $high_val = strtolower($message_highlight_list_part['value']);
  130. $match_type = strtoupper($message_highlight_list_part['match_type']);
  131. if ($match_type == 'TO_CC') {
  132. foreach ($msg['TO'] as $address) {
  133. if (strstr('^^' . strtolower($address[0]), $high_val) ||
  134. strstr('^^' . strtolower($address[1]), $high_val)) {
  135. $hlt_color = $message_highlight_list_part['color'];
  136. continue;
  137. }
  138. }
  139. foreach ($msg['CC'] as $address) {
  140. if( strstr('^^' . strtolower($address[0]), $high_val) ||
  141. strstr('^^' . strtolower($address[1]), $high_val)) {
  142. $hlt_color = $message_highlight_list_part['color'];
  143. continue;
  144. }
  145. }
  146. } else {
  147. if (strstr('^^' . strtolower($msg[$match_type]), $high_val)) {
  148. $hlt_color = $message_highlight_list_part['color'];
  149. continue;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. if (!isset($hlt_color)) {
  156. $hlt_color = $color_string;
  157. }
  158. $checked = ($checkall == 1) ? ' CHECKED' : '';
  159. $col = 0;
  160. if (sizeof($index_order)) {
  161. foreach ($index_order as $index_order_part) {
  162. switch ($index_order_part) {
  163. case 1: /* checkbox */
  164. echo html_tag( 'td',
  165. "<input type=checkbox name=\"msg[$t]\" value=\"".$msg['ID']."\"$checked>",
  166. 'center',
  167. $hlt_color );
  168. break;
  169. case 2: /* from */
  170. echo html_tag( 'td',
  171. $italic . $bold . $flag . $fontstr . $senderName .
  172. $fontstr_end . $flag_end . $bold_end . $italic_end,
  173. 'left',
  174. $hlt_color );
  175. break;
  176. case 3: /* date */
  177. $date_string = $msg['DATE_STRING'] . '';
  178. if ($date_string == '') {
  179. $date_string = _("Unknown date");
  180. }
  181. echo html_tag( 'td',
  182. $bold . $flag . $fontstr . $date_string .
  183. $fontstr_end . $flag_end . $bold_end,
  184. 'center',
  185. $hlt_color,
  186. 'nowrap' );
  187. break;
  188. case 4: /* subject */
  189. $td_str = $bold;
  190. if ($thread_sort_messages == 1) {
  191. if (isset($indent_array[$msg['ID']])) {
  192. $td_str .= str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;",$indent_array[$msg['ID']]);
  193. }
  194. }
  195. $td_str .= '<a href="read_body.php?mailbox='.$urlMailbox
  196. . '&amp;passed_id='. $msg["ID"]
  197. . '&amp;startMessage='.$start_msg.$searchstr.'"';
  198. do_hook("subject_link");
  199. if ($subject != $subject_full) {
  200. $title = get_html_translation_table(HTML_SPECIALCHARS);
  201. $title = array_flip($title);
  202. $title = strtr($subject_full, $title);
  203. $title = str_replace('"', "''", $title);
  204. $td_str .= " title=\"$title\"";
  205. }
  206. $td_str .= ">$flag$subject$flag_end</a>$bold_end";
  207. echo html_tag( 'td', $td_str, 'left', $hlt_color );
  208. break;
  209. case 5: /* flags */
  210. $stuff = false;
  211. $td_str = "<b><small>";
  212. if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) {
  213. $td_str .= _("A");
  214. $stuff = true;
  215. }
  216. if ($msg['TYPE0'] == 'multipart') {
  217. $td_str .= '+';
  218. $stuff = true;
  219. }
  220. if ($default_use_priority) {
  221. if ( ($msg['PRIORITY'] == 1) || ($msg['PRIORITY'] == 2) ) {
  222. $td_str .= "<font color=\"$color[1]\">!</font>";
  223. $stuff = true;
  224. }
  225. if ($msg['PRIORITY'] == 5) {
  226. $td_str .= "<font color=\"$color[8]\">?</font>";
  227. $stuff = true;
  228. }
  229. }
  230. if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) {
  231. $td_str .= "<font color=\"$color[1]\">D</font>";
  232. $stuff = true;
  233. }
  234. if (!$stuff) {
  235. $td_str .= '&nbsp;';
  236. }
  237. do_hook("msg_envelope");
  238. $td_str .= '</small></b>';
  239. echo html_tag( 'td',
  240. $td_str,
  241. 'center',
  242. $hlt_color,
  243. 'nowrap' );
  244. break;
  245. case 6: /* size */
  246. echo html_tag( 'td',
  247. $bold . $fontstr . show_readable_size($msg['SIZE']) .
  248. $fontstr_end . $bold_end,
  249. 'right',
  250. $hlt_color );
  251. break;
  252. }
  253. ++$col;
  254. }
  255. }
  256. if ($not_last) {
  257. echo '</tr>' . "\n" . '<tr><td COLSPAN="' . $col . '" BGCOLOR="' .
  258. $color[0] . '" HEIGHT="1"></td></tr>' . "\n";
  259. } else {
  260. echo '</tr>'."\n";
  261. }
  262. }
  263. function getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id) {
  264. if ($id != 'no') {
  265. $id = array_slice($id, ($start_msg-1), $show_num);
  266. $end = $start_msg + $show_num - 1;
  267. if ($num_msgs < $show_num) {
  268. $end_loop = $num_msgs;
  269. } else if ($end > $num_msgs) {
  270. $end_loop = $num_msgs - $start_msg + 1;
  271. } else {
  272. $end_loop = $show_num;
  273. }
  274. return fillMessageArray($imapConnection,$id,$end_loop);
  275. } else {
  276. return false;
  277. }
  278. }
  279. function getThreadMessages($imapConnection, $start_msg, $show_num, $num_msgs) {
  280. $id = get_thread_sort($imapConnection);
  281. return getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
  282. }
  283. function getServerSortMessages($imapConnection, $start_msg, $show_num,
  284. $num_msgs, $server_sort_order, $mbxresponse) {
  285. $id = sqimap_get_sort_order($imapConnection, $server_sort_order,$mbxresponse);
  286. return getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
  287. }
  288. function getSelfSortMessages($imapConnection, $start_msg, $show_num,
  289. $num_msgs, $sort, $mbxresponse) {
  290. $msgs = array();
  291. if ($num_msgs >= 1) {
  292. $id = sqimap_get_php_sort_order ($imapConnection, $mbxresponse);
  293. if ($sort < 6 ) {
  294. $end = $num_msgs;
  295. $end_loop = $end;
  296. } else {
  297. /* if it's not sorted */
  298. if ($start_msg + ($show_num - 1) < $num_msgs) {
  299. $end_msg = $start_msg + ($show_num - 1);
  300. } else {
  301. $end_msg = $num_msgs;
  302. }
  303. if ($end_msg < $start_msg) {
  304. $start_msg = $start_msg - $show_num;
  305. if ($start_msg < 1) {
  306. $start_msg = 1;
  307. }
  308. }
  309. $id = array_slice(array_reverse($id), ($start_msg-1), $show_num);
  310. $end = $start_msg + $show_num - 1;
  311. if ($num_msgs < $show_num) {
  312. $end_loop = $num_msgs;
  313. } else if ($end > $num_msgs) {
  314. $end_loop = $num_msgs - $start_msg + 1;
  315. } else {
  316. $end_loop = $show_num;
  317. }
  318. }
  319. $msgs = fillMessageArray($imapConnection,$id,$end_loop);
  320. }
  321. return $msgs;
  322. }
  323. /*
  324. * This function loops through a group of messages in the mailbox
  325. * and shows them to the user.
  326. */
  327. function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
  328. $start_msg, $sort, $color, $show_num,
  329. $use_cache, $mode='') {
  330. global $msgs, $msort, $auto_expunge, $thread_sort_messages,
  331. $allow_server_sort, $server_sort_order;
  332. /*
  333. * For some reason, on PHP 4.3+, this being unset, and set in the session causes havoc
  334. * so setting it to an empty array beforehand seems to clean up the issue, and stopping the
  335. * "Your script possibly relies on a session side-effect which existed until PHP 4.2.3" error
  336. */
  337. if (!isset($msort)) {
  338. $msort = array();
  339. }
  340. if (!isset($msgs)) {
  341. $msgs = array();
  342. }
  343. $start = microtime();
  344. /* If autoexpunge is turned on, then do it now. */
  345. $mbxresponse = sqimap_mailbox_select($imapConnection, $mailbox);
  346. $srt = $sort;
  347. /* If autoexpunge is turned on, then do it now. */
  348. if ($auto_expunge == true) {
  349. $exp_cnt = sqimap_mailbox_expunge($imapConnection, $mailbox, false, '');
  350. $mbxresponse['EXISTS'] = $mbxresponse['EXISTS'] - $exp_cnt;
  351. $num_msgs = $mbxresponse['EXISTS'];
  352. }
  353. if ($mbxresponse['EXISTS'] > 0) {
  354. /* if $start_msg is lower than $num_msgs, we probably deleted all messages
  355. * in the last page. We need to re-adjust the start_msg
  356. */
  357. if($start_msg > $num_msgs) {
  358. $start_msg -= $show_num;
  359. if($start_msg < 1) {
  360. $start_msg = 1;
  361. }
  362. }
  363. /* This code and the next if() block check for
  364. * server-side sorting methods. The $id array is
  365. * formatted and $sort is set to 6 to disable
  366. * SM internal sorting
  367. */
  368. if ($thread_sort_messages == 1) {
  369. $mode = 'thread';
  370. } elseif ($allow_server_sort == 1) {
  371. $mode = 'serversort';
  372. } else {
  373. $mode = '';
  374. }
  375. sqsession_unregister('msort');
  376. sqsession_unregister('msgs');
  377. switch ($mode) {
  378. case 'thread':
  379. $id = get_thread_sort($imapConnection);
  380. $msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
  381. if ($msgs === false) {
  382. echo '<b><small><center><font color=red>' .
  383. _("Thread sorting is not supported by your IMAP server.<br>Please report this to the system administrator.").
  384. '</center></small></b>';
  385. $thread_sort_messages = 0;
  386. $msort = $msgs = array();
  387. } else {
  388. $msort= $msgs;
  389. $sort = 6;
  390. }
  391. break;
  392. case 'serversort':
  393. $id = sqimap_get_sort_order($imapConnection, $sort, $mbxresponse);
  394. $msgs = getServerMessages($imapConnection, $start_msg, $show_num, $num_msgs, $id);
  395. if ($msgs === false) {
  396. echo '<b><small><center><font color=red>' .
  397. _( "Server-side sorting is not supported by your IMAP server.<br>Please report this to the system administrator.").
  398. '</center></small></b>';
  399. $sort = $server_sort_order;
  400. $allow_server_sort = FALSE;
  401. $msort = $msgs = array();
  402. $id = array();
  403. } else {
  404. $msort = $msgs;
  405. $sort = 6;
  406. }
  407. break;
  408. default:
  409. if (!$use_cache) {
  410. $msgs = getSelfSortMessages($imapConnection, $start_msg, $show_num,
  411. $num_msgs, $sort, $mbxresponse);
  412. $msort = calc_msort($msgs, $sort);
  413. } /* !use cache */
  414. break;
  415. } // switch
  416. sqsession_register($msort, 'msort');
  417. sqsession_register($msgs, 'msgs');
  418. } /* if exists > 0 */
  419. $res = getEndMessage($start_msg, $show_num, $num_msgs);
  420. $start_msg = $res[0];
  421. $end_msg = $res[1];
  422. $paginator_str = get_paginator_str($mailbox, $start_msg, $end_msg,
  423. $num_msgs, $show_num, $sort);
  424. $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs);
  425. do_hook('mailbox_index_before');
  426. echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
  427. echo '<tr><td>';
  428. mail_message_listing_beginning($imapConnection, $mailbox, $sort,
  429. $msg_cnt_str, $paginator_str, $start_msg);
  430. echo '</td></tr>';
  431. /* line between the button area and the list */
  432. echo '<tr><td HEIGHT="5" BGCOLOR="'.$color[4].'"></td></tr>';
  433. echo '<tr><td>';
  434. echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
  435. echo ' <tr><td>';
  436. echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[5].'">';
  437. echo '<tr><td>';
  438. printHeader($mailbox, $srt, $color, !$thread_sort_messages);
  439. displayMessageArray($imapConnection, $num_msgs, $start_msg,
  440. $msort, $mailbox, $sort, $color, $show_num,0,0);
  441. echo '</td></tr></table></td></tr></table>';
  442. mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color);
  443. echo '</td></tr></table>';
  444. $t = elapsed($start);
  445. //echo("elapsed time = $t seconds\n");
  446. }
  447. function calc_msort($msgs, $sort) {
  448. /*
  449. * 0 = Date (up)
  450. * 1 = Date (dn)
  451. * 2 = Name (up)
  452. * 3 = Name (dn)
  453. * 4 = Subject (up)
  454. * 5 = Subject (dn)
  455. */
  456. if (($sort == 0) || ($sort == 1)) {
  457. foreach ($msgs as $item) {
  458. $msort[] = $item['TIME_STAMP'];
  459. }
  460. } elseif (($sort == 2) || ($sort == 3)) {
  461. foreach ($msgs as $item) {
  462. $msort[] = $item['FROM-SORT'];
  463. }
  464. } elseif (($sort == 4) || ($sort == 5)) {
  465. foreach ($msgs as $item) {
  466. $msort[] = $item['SUBJECT-SORT'];
  467. }
  468. } else {
  469. $msort = $msgs;
  470. }
  471. if ($sort < 6) {
  472. if ($sort % 2) {
  473. asort($msort);
  474. } else {
  475. arsort($msort);
  476. }
  477. }
  478. return $msort;
  479. }
  480. function fillMessageArray($imapConnection, $id, $count) {
  481. return sqimap_get_small_header_list($imapConnection, $id);
  482. }
  483. /* Generic function to convert the msgs array into an HTML table. */
  484. function displayMessageArray($imapConnection, $num_msgs, $start_msg,
  485. $msort, $mailbox, $sort, $color,
  486. $show_num, $where=0, $what=0) {
  487. global $imapServerAddress, $use_mailbox_cache, $index_order,
  488. $indent_array, $thread_sort_messages, $allow_server_sort,
  489. $server_sort_order, $PHP_SELF;
  490. $res = getEndMessage($start_msg, $show_num, $num_msgs);
  491. $start_msg = $res[0];
  492. $end_msg = $res[1];
  493. $urlMailbox = urlencode($mailbox);
  494. /* get indent level for subject display */
  495. if ($thread_sort_messages == 1 && $num_msgs) {
  496. $indent_array = get_parent_level($imapConnection);
  497. }
  498. $real_startMessage = $start_msg;
  499. if ($sort == 6) {
  500. if ($end_msg - $start_msg < $show_num - 1) {
  501. $end_msg = $end_msg - $start_msg + 1;
  502. $start_msg = 1;
  503. } else if ($start_msg > $show_num) {
  504. $end_msg = $show_num;
  505. $start_msg = 1;
  506. }
  507. }
  508. $endVar = $end_msg + 1;
  509. /*
  510. * Loop through and display the info for each message.
  511. * ($t is used for the checkbox number)
  512. */
  513. $t = 0;
  514. /* messages display */
  515. if (!$num_msgs) {
  516. /* if there's no messages in this folder */
  517. echo html_tag( 'tr',
  518. html_tag( 'td',
  519. "<BR><b>" . _("THIS FOLDER IS EMPTY") . "</b><BR>&nbsp;",
  520. 'center',
  521. $color[4],
  522. 'COLSPAN="' . count($index_order) . '"'
  523. )
  524. );
  525. } elseif ($start_msg == $end_msg) {
  526. /* if there's only one message in the box, handle it differently. */
  527. if ($sort != 6) {
  528. $i = $start_msg;
  529. } else {
  530. $i = 1;
  531. }
  532. reset($msort);
  533. $k = 0;
  534. do {
  535. $key = key($msort);
  536. next($msort);
  537. $k++;
  538. } while (isset ($key) && ($k < $i));
  539. printMessageInfo($imapConnection, $t, true, $key, $mailbox,
  540. $real_startMessage, $where, $what);
  541. } else {
  542. $i = $start_msg;
  543. reset($msort);
  544. $k = 0;
  545. do {
  546. $key = key($msort);
  547. next($msort);
  548. $k++;
  549. } while (isset ($key) && ($k < $i));
  550. $not_last = true;
  551. do {
  552. if (!$i || $i == $endVar-1) $not_last = false;
  553. printMessageInfo($imapConnection, $t, $not_last, $key, $mailbox,
  554. $real_startMessage, $where, $what);
  555. $key = key($msort);
  556. $t++;
  557. $i++;
  558. next($msort);
  559. } while ($i && $i < $endVar);
  560. }
  561. }
  562. /*
  563. * Displays the standard message list header. To finish the table,
  564. * you need to do a "</table></table>";
  565. *
  566. * $moveURL is the URL to submit the delete/move form to
  567. * $mailbox is the current mailbox
  568. * $sort is the current sorting method (-1 for no sorting available [searches])
  569. * $Message is a message that is centered on top of the list
  570. * $More is a second line that is left aligned
  571. */
  572. function mail_message_listing_beginning ($imapConnection,
  573. $mailbox = '', $sort = -1,
  574. $msg_cnt_str = '',
  575. $paginator = '&nbsp;',
  576. $start_msg = 1) {
  577. global $color, $auto_expunge, $base_uri, $thread_sort_messages,
  578. $allow_thread_sort, $allow_server_sort, $server_sort_order,
  579. $PHP_SELF;
  580. $php_self = $PHP_SELF;
  581. /* fix for incorrect $PHP_SELF */
  582. if (strpos($php_self, 'move_messages.php')) {
  583. $php_self = str_replace('move_messages.php', 'right_main.php', $php_self);
  584. }
  585. $urlMailbox = urlencode($mailbox);
  586. if (preg_match('/^(.+)\?.+$/',$php_self,$regs)) {
  587. $source_url = $regs[1];
  588. } else {
  589. $source_url = $php_self;
  590. }
  591. if (!isset($msg)) {
  592. $msg = '';
  593. }
  594. $moveFields = '<input type="hidden" name="msg" value="'.htmlspecialchars($msg).'">' .
  595. '<input type="hidden" name="mailbox" value="'.htmlspecialchars($mailbox).'">' .
  596. '<input type="hidden" name="startMessage" value="'.htmlspecialchars($start_msg).'">';
  597. // $moveURL = "move_messages.php?msg=$msg&amp;mailbox=$urlMailbox"
  598. // . "&amp;startMessage=$start_msg";
  599. /*
  600. * This is the beginning of the message list table.
  601. * It wraps around all messages
  602. */
  603. echo '<form name="messageList" method="post" action="move_messages.php">' ."\n"
  604. . $moveFields
  605. . html_tag( 'table' ,
  606. html_tag( 'tr',
  607. html_tag( 'td' ,
  608. html_tag( 'table' ,
  609. html_tag( 'tr',
  610. html_tag( 'td', $paginator, 'left' ) .
  611. html_tag( 'td', $msg_cnt_str, 'right' )
  612. )
  613. , '', $color[4], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
  614. , 'left', '', '' )
  615. , '', $color[0] )
  616. , '', '', 'border="0" width="100%" cellpadding="1" cellspacing="0"' );
  617. /* line between header and button area */
  618. echo '<tr><td HEIGHT="5" BGCOLOR="'.$color[4].'"></td></tr>';
  619. echo '<tr><td>';
  620. echo html_tag( 'tr' ) . "\n"
  621. . html_tag( 'td' ,'' , 'left', '', '' )
  622. . html_tag( 'table' ,'' , '', $color[9], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
  623. . '<tr><td>'
  624. . html_tag( 'table' ,'' , '', $color[0], 'border="0" width="100%" cellpadding="1" cellspacing="0"' )
  625. . html_tag( 'tr',
  626. getSmallStringCell(_("Move Selected To"), 'left', 'nowrap') .
  627. getSmallStringCell(_("Transform Selected Messages"), 'right')
  628. )
  629. . html_tag( 'tr' ) ."\n"
  630. . html_tag( 'td', '', 'left', '', 'valign="middle" nowrap' );
  631. getMbxList($imapConnection);
  632. echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n";
  633. echo getButton('SUBMIT', 'attache',_("Forward")) . "\n";
  634. echo " </TD>\n"
  635. . html_tag( 'td', '', 'right', '', 'nowrap' );
  636. if (!$auto_expunge) {
  637. echo getButton('SUBMIT', 'expungeButton',_("Expunge"))
  638. .'&nbsp;' . _("mailbox") . "\n";
  639. }
  640. echo getButton('SUBMIT', 'markRead',_("Read"));
  641. echo getButton('SUBMIT', 'markUnread',_("Unread"));
  642. echo getButton('SUBMIT', 'delete',_("Delete")) ."&nbsp;\n";
  643. if (!strpos($php_self,'mailbox')) {
  644. $location = $php_self.'?mailbox=INBOX&amp;startMessage=1';
  645. } else {
  646. $location = $php_self;
  647. }
  648. echo '<INPUT TYPE="HIDDEN" NAME="location" VALUE="'.$location.'">';
  649. echo "</TD>\n"
  650. . " </TR>\n";
  651. /* draws thread sorting links */
  652. if ($allow_thread_sort == TRUE) {
  653. if ($thread_sort_messages == 1 ) {
  654. $set_thread = 2;
  655. $thread_name = _("Unthread View");
  656. } elseif ($thread_sort_messages == 0) {
  657. $set_thread = 1;
  658. $thread_name = _("Thread View");
  659. }
  660. echo html_tag( 'tr' ,
  661. html_tag( 'td' ,
  662. '&nbsp;<a href=' . $source_url . '?sort='
  663. . "$sort" . '&start_messages=1&set_thread=' . "$set_thread"
  664. . '&mailbox=' . urlencode($mailbox) . '><small>' . $thread_name
  665. . '</a></small>&nbsp;'
  666. , '', '', '' )
  667. , '', '', '' );
  668. }
  669. echo "</TABLE></td></tr></table></td></tr>\n";
  670. do_hook('mailbox_form_before');
  671. /* if using server sort we highjack the
  672. * the $sort var and use $server_sort_order
  673. * instead. but here we reset sort for a bit
  674. * since its easy
  675. */
  676. if ($allow_server_sort == TRUE) {
  677. $sort = $server_sort_order;
  678. }
  679. }
  680. function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color) {
  681. if ($num_msgs) {
  682. /* space between list and footer */
  683. echo '<tr><td HEIGHT="5" BGCOLOR="'.$color[4].'" COLSPAN="1">';
  684. echo '</td></tr><tr><td>';
  685. echo html_tag( 'table',
  686. html_tag( 'tr',
  687. html_tag( 'td',
  688. html_tag( 'table',
  689. html_tag( 'tr',
  690. html_tag( 'td', $paginator_str ) .
  691. html_tag( 'td', $msg_cnt_str, 'right' )
  692. )
  693. , '', $color[4], 'width="100%" border="0" cellpadding="1" cellspacing="0"' )
  694. )
  695. )
  696. , '', $color[9], 'width="100%" border="0" cellpadding="1" cellspacing="0"' );
  697. echo '</td></tr>';
  698. }
  699. /* End of message-list table */
  700. do_hook('mailbox_index_after');
  701. echo "</FORM>\n";
  702. }
  703. function printHeader($mailbox, $sort, $color, $showsort=true) {
  704. global $index_order;
  705. echo html_tag( 'tr' ,'' , 'center', $color[5] );
  706. /* calculate the width of the subject column based on the
  707. * widths of the other columns */
  708. $widths = array(1=>1,2=>25,3=>5,4=>0,5=>1,6=>5);
  709. $subjectwidth = 100;
  710. foreach($index_order as $item) {
  711. $subjectwidth -= $widths[$item];
  712. }
  713. foreach ($index_order as $item) {
  714. switch ($item) {
  715. case 1: /* checkbox */
  716. case 5: /* flags */
  717. echo html_tag( 'td' ,'&nbsp;' , '', '', 'width="1%"' );
  718. break;
  719. case 2: /* from */
  720. if (handleAsSent($mailbox)) {
  721. echo html_tag( 'td' ,'' , 'left', '', 'width="25%"' )
  722. . '<b>' . _("To") . '</b>';
  723. } else {
  724. echo html_tag( 'td' ,'' , 'left', '', 'width="25%"' )
  725. . '<b>' . _("From") . '</b>';
  726. }
  727. if ($showsort) {
  728. ShowSortButton($sort, $mailbox, 2, 3);
  729. }
  730. echo "</td>\n";
  731. break;
  732. case 3: /* date */
  733. echo html_tag( 'td' ,'' , 'left', '', 'width="5%" nowrap' )
  734. . '<b>' . _("Date") . '</b>';
  735. if ($showsort) {
  736. ShowSortButton($sort, $mailbox, 0, 1);
  737. }
  738. echo "</td>\n";
  739. break;
  740. case 4: /* subject */
  741. echo html_tag( 'td' ,'' , 'left', '', 'width="'.$subjectwidth.'%"' )
  742. . '<b>' . _("Subject") . '</b>';
  743. if ($showsort) {
  744. ShowSortButton($sort, $mailbox, 4, 5);
  745. }
  746. echo "</td>\n";
  747. break;
  748. case 6: /* size */
  749. echo html_tag( 'td', '<b>' . _("Size") . '</b>', 'center', '', 'width="5%" nowrap' );
  750. break;
  751. }
  752. }
  753. echo "</tr>\n";
  754. }
  755. /*
  756. * This function shows the sort button. Isn't this a good comment?
  757. */
  758. function ShowSortButton($sort, $mailbox, $Up, $Down ) {
  759. global $PHP_SELF;
  760. /* Figure out which image we want to use. */
  761. if ($sort != $Up && $sort != $Down) {
  762. $img = 'sort_none.png';
  763. $which = $Up;
  764. } elseif ($sort == $Up) {
  765. $img = 'up_pointer.png';
  766. $which = $Down;
  767. } else {
  768. $img = 'down_pointer.png';
  769. $which = 6;
  770. }
  771. if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
  772. $source_url = $regs[1];
  773. } else {
  774. $source_url = $PHP_SELF;
  775. }
  776. /* Now that we have everything figured out, show the actual button. */
  777. echo ' <a href="' . $source_url .'?newsort=' . $which
  778. . '&amp;startMessage=1&amp;mailbox=' . urlencode($mailbox)
  779. . '"><IMG SRC="../images/' . $img
  780. . '" BORDER=0 WIDTH=12 HEIGHT=10 ALT="sort"></a>';
  781. }
  782. function get_selectall_link($start_msg, $sort) {
  783. global $checkall, $what, $where, $mailbox, $javascript_on;
  784. global $PHP_SELF, $PG_SHOWNUM;
  785. $result = '';
  786. if ($javascript_on) {
  787. $result = '<script language="JavaScript" type="text/javascript">'
  788. . "\n<!-- \n"
  789. . "function CheckAll() {\n"
  790. . " for (var i = 0; i < document.messageList.elements.length; i++) {\n"
  791. . " if(document.messageList.elements[i].type == 'checkbox'){\n"
  792. . " document.messageList.elements[i].checked = "
  793. . " !(document.messageList.elements[i].checked);\n"
  794. . " }\n"
  795. . " }\n"
  796. . "}\n"
  797. . "//-->\n"
  798. . '</script><a href="#" onClick="CheckAll();">' . _("Toggle All")
  799. . "</a>\n";
  800. } else {
  801. if (strpos($PHP_SELF, "?")) {
  802. $result .= "<a href=\"$PHP_SELF&amp;mailbox=" . urlencode($mailbox)
  803. . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
  804. } else {
  805. $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox)
  806. . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
  807. }
  808. if (isset($checkall) && $checkall == '1') {
  809. $result .= '0';
  810. } else {
  811. $result .= '1';
  812. }
  813. if (isset($where) && isset($what)) {
  814. $result .= '&amp;where=' . urlencode($where)
  815. . '&amp;what=' . urlencode($what);
  816. }
  817. $result .= "\">";
  818. if (isset($checkall) && ($checkall == '1')) {
  819. $result .= _("Unselect All");
  820. } else {
  821. $result .= _("Select All");
  822. }
  823. $result .= "</A>\n";
  824. }
  825. /* Return our final result. */
  826. return ($result);
  827. }
  828. /*
  829. * This function computes the "Viewing Messages..." string.
  830. */
  831. function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
  832. /* Compute the $msg_cnt_str. */
  833. $result = '';
  834. if ($start_msg < $end_msg) {
  835. $result = sprintf(_("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"),
  836. $start_msg, $end_msg, $num_msgs);
  837. } else if ($start_msg == $end_msg) {
  838. $result = sprintf(_("Viewing Message: <B>%s</B> (1 total)"), $start_msg);
  839. } else {
  840. $result = '<br>';
  841. }
  842. /* Return our result string. */
  843. return ($result);
  844. }
  845. /*
  846. * Generate a paginator link.
  847. */
  848. function get_paginator_link($box, $start_msg, $use, $text) {
  849. global $PHP_SELF;
  850. $result = "<A HREF=\"right_main.php?use_mailbox_cache=$use"
  851. . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
  852. . "TARGET=\"right\">$text</A>";
  853. return ($result);
  854. /*
  855. if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) {
  856. $source_url = $regs[1];
  857. } else {
  858. $source_url = $PHP_SELF;
  859. }
  860. $result = '<A HREF="'. $source_url . "?use_mailbox_cache=$use"
  861. . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
  862. . "TARGET=\"right\">$text</A>";
  863. return ($result);
  864. */
  865. }
  866. /*
  867. * This function computes the paginator string.
  868. */
  869. function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
  870. $show_num, $sort) {
  871. global $username, $data_dir, $use_mailbox_cache, $color, $PG_SHOWNUM;
  872. /* Initialize paginator string chunks. */
  873. $prv_str = '';
  874. $nxt_str = '';
  875. $pg_str = '';
  876. $all_str = '';
  877. $tgl_str = '';
  878. $box = urlencode($box);
  879. /* Create simple strings that will be creating the paginator. */
  880. $spc = '&nbsp;'; /* This will be used as a space. */
  881. $sep = '|'; /* This will be used as a seperator. */
  882. /* Get some paginator preference values. */
  883. $pg_sel = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
  884. $pg_max = getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX);
  885. /* Make sure that our start message number is not too big. */
  886. $start_msg = min($start_msg, $num_msgs);
  887. /* Decide whether or not we will use the mailbox cache. */
  888. /* Not sure why $use_mailbox_cache is even passed in. */
  889. if ($sort == 6) {
  890. $use = 0;
  891. } else {
  892. $use = 1;
  893. }
  894. /* Compute the starting message of the previous and next page group. */
  895. $next_grp = $start_msg + $show_num;
  896. $prev_grp = $start_msg - $show_num;
  897. /* Compute the basic previous and next strings. */
  898. if (($next_grp <= $num_msgs) && ($prev_grp >= 0)) {
  899. $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
  900. $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
  901. } else if (($next_grp > $num_msgs) && ($prev_grp >= 0)) {
  902. $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
  903. $nxt_str = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
  904. } else if (($next_grp <= $num_msgs) && ($prev_grp < 0)) {
  905. $prv_str = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
  906. $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
  907. }
  908. /* Page selector block. Following code computes page links. */
  909. if ($pg_sel && ($num_msgs > $show_num)) {
  910. /* Most importantly, what is the current page!!! */
  911. $cur_pg = intval($start_msg / $show_num) + 1;
  912. /* Compute total # of pages and # of paginator page links. */
  913. $tot_pgs = ceil($num_msgs / $show_num); /* Total number of Pages */
  914. $vis_pgs = min($pg_max, $tot_pgs - 1); /* Visible Pages */
  915. /* Compute the size of the four quarters of the page links. */
  916. /* If we can, just show all the pages. */
  917. if (($tot_pgs - 1) <= $pg_max) {
  918. $q1_pgs = $cur_pg - 1;
  919. $q2_pgs = $q3_pgs = 0;
  920. $q4_pgs = $tot_pgs - $cur_pg;
  921. /* Otherwise, compute some magic to choose the four quarters. */
  922. } else {
  923. /*
  924. * Compute the magic base values. Added together,
  925. * these values will always equal to the $pag_pgs.
  926. * NOTE: These are DEFAULT values and do not take
  927. * the current page into account. That is below.
  928. */
  929. $q1_pgs = floor($vis_pgs/4);
  930. $q2_pgs = round($vis_pgs/4, 0);
  931. $q3_pgs = ceil($vis_pgs/4);
  932. $q4_pgs = round(($vis_pgs - $q2_pgs)/3, 0);
  933. /* Adjust if the first quarter contains the current page. */
  934. if (($cur_pg - $q1_pgs) < 1) {
  935. $extra_pgs = ($q1_pgs - ($cur_pg - 1)) + $q2_pgs;
  936. $q1_pgs = $cur_pg - 1;
  937. $q2_pgs = 0;
  938. $q3_pgs += ceil($extra_pgs / 2);
  939. $q4_pgs += floor($extra_pgs / 2);
  940. /* Adjust if the first and second quarters intersect. */
  941. } else if (($cur_pg - $q2_pgs - ceil($q2_pgs/3)) <= $q1_pgs) {
  942. $extra_pgs = $q2_pgs;
  943. $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 0.75);
  944. $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 0.75);
  945. $q3_pgs += ceil($extra_pgs / 2);
  946. $q4_pgs += floor($extra_pgs / 2);
  947. /* Adjust if the fourth quarter contains the current page. */
  948. } else if (($cur_pg + $q4_pgs) >= $tot_pgs) {
  949. $extra_pgs = ($q4_pgs - ($tot_pgs - $cur_pg)) + $q3_pgs;
  950. $q3_pgs = 0;
  951. $q4_pgs = $tot_pgs - $cur_pg;
  952. $q1_pgs += floor($extra_pgs / 2);
  953. $q2_pgs += ceil($extra_pgs / 2);
  954. /* Adjust if the third and fourth quarter intersect. */
  955. } else if (($cur_pg + $q3_pgs + 1) >= ($tot_pgs - $q4_pgs + 1)) {
  956. $extra_pgs = $q3_pgs;
  957. $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
  958. $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
  959. $q1_pgs += floor($extra_pgs / 2);
  960. $q2_pgs += ceil($extra_pgs / 2);
  961. }
  962. }
  963. /*
  964. * I am leaving this debug code here, commented out, because
  965. * it is a really nice way to see what the above code is doing.
  966. * echo "qts = $q1_pgs/$q2_pgs/$q3_pgs/$q4_pgs = "
  967. * . ($q1_pgs + $q2_pgs + $q3_pgs + $q4_pgs) . '<br>';
  968. */
  969. /* Print out the page links from the compute page quarters. */
  970. /* Start with the first quarter. */
  971. if (($q1_pgs == 0) && ($cur_pg > 1)) {
  972. $pg_str .= "...$spc";
  973. } else {
  974. for ($pg = 1; $pg <= $q1_pgs; ++$pg) {
  975. $start = (($pg-1) * $show_num) + 1;
  976. $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
  977. }
  978. if ($cur_pg - $q2_pgs - $q1_pgs > 1) {
  979. $pg_str .= "...$spc";
  980. }
  981. }
  982. /* Continue with the second quarter. */
  983. for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) {
  984. $start = (($pg-1) * $show_num) + 1;
  985. $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
  986. }
  987. /* Now print the current page. */
  988. $pg_str .= $cur_pg . $spc;
  989. /* Next comes the third quarter. */
  990. for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) {
  991. $start = (($pg-1) * $show_num) + 1;
  992. $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
  993. }
  994. /* And last, print the forth quarter page links. */
  995. if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) {
  996. $pg_str .= "...$spc";
  997. } else {
  998. if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) {
  999. $pg_str .= "...$spc";
  1000. }
  1001. for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) {
  1002. $start = (($pg-1) * $show_num) + 1;
  1003. $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
  1004. }
  1005. }
  1006. } else if ($PG_SHOWNUM == 999999) {
  1007. $pg_str = "<A HREF=\"right_main.php?PG_SHOWALL=0"
  1008. . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
  1009. . "TARGET=\"right\">" ._("Paginate") . '</A>' . $spc;
  1010. }
  1011. /* If necessary, compute the 'show all' string. */
  1012. if (($prv_str != '') || ($nxt_str != '')) {
  1013. $all_str = "<A HREF=\"right_main.php?PG_SHOWALL=1"
  1014. . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
  1015. . "TARGET=\"right\">" . _("Show All") . '</A>';
  1016. }
  1017. /* Last but not least, get the value for the toggle all link. */
  1018. $tgl_str = get_selectall_link($start_msg, $sort);
  1019. /* Put all the pieces of the paginator string together. */
  1020. /**
  1021. * Hairy code... But let's leave it like it is since I am not certain
  1022. * a different approach would be any easier to read. ;)
  1023. */
  1024. $result = '';
  1025. $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : '');
  1026. $result .= ($nxt_str != '' ? $nxt_str . $spc . $sep . $spc : '');
  1027. $result .= ($pg_str != '' ? $pg_str : '');
  1028. $result .= ($all_str != '' ? $sep . $spc . $all_str . $spc : '');
  1029. $result .= ($result != '' ? $sep . $spc . $tgl_str: $tgl_str);
  1030. /* If the resulting string is blank, return a non-breaking space. */
  1031. if ($result == '') {
  1032. $result = '&nbsp;';
  1033. }
  1034. /* Return our final magical paginator string. */
  1035. return ($result);
  1036. }
  1037. function processSubject($subject, $threadlevel = 0) {
  1038. global $languages, $squirrelmail_language;
  1039. /* Shouldn't ever happen -- caught too many times in the IMAP functions */
  1040. if ($subject == '')
  1041. return _("(no subject)");
  1042. $trim_at = 55;
  1043. /* if this is threaded, subtract two chars per indentlevel */
  1044. if($threadlevel > 0 && $threadlevel <= 10)
  1045. $trim_at -= (2*$threadlevel);
  1046. if (strlen($subject) <= $trim_at)
  1047. return $subject;
  1048. $ent_strlen = $orig_len = strlen($subject);
  1049. $trim_val = $trim_at - 5;
  1050. $ent_offset = 0;
  1051. /*
  1052. * see if this is entities-encoded string
  1053. * If so, Iterate through the whole string, find out
  1054. * the real number of characters, and if more
  1055. * than 55, substr with an updated trim value.
  1056. */
  1057. $step = $ent_loc = 0;
  1058. while ( $ent_loc < $trim_val && (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) &&
  1059. (($ent_loc_end = strpos($subject, ';', $ent_loc+3)) !== false) ) {
  1060. $trim_val += ($ent_loc_end-$ent_loc);
  1061. $ent_offset = $ent_loc_end+1;
  1062. ++$step;
  1063. }
  1064. if (($trim_val > 50) && (strlen($subject) > ($trim_val))&& (strpos($subject,';',$trim_val) < ($trim_val +6))) {
  1065. $i = strpos($subject,';',$trim_val);
  1066. if ($i) {
  1067. $trim_val = strpos($subject,';',$trim_val);
  1068. }
  1069. }
  1070. if ($ent_strlen <= $trim_at){
  1071. return $subject;
  1072. }
  1073. if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
  1074. function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
  1075. return $languages[$squirrelmail_language]['XTRA_CODE']('strimwidth', $subject, $trim_val);
  1076. }
  1077. return substr($subject, 0, $trim_val) . '...';
  1078. }
  1079. function getMbxList($imapConnection) {
  1080. global $lastTargetMailbox;
  1081. echo ' <small>&nbsp;<tt><select name="targetMailbox">';
  1082. echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)) );
  1083. echo ' </SELECT></TT>&nbsp;';
  1084. }
  1085. function getButton($type, $name, $value) {
  1086. return '<INPUT TYPE="'.$type.'" NAME="'.$name.'" VALUE="'.$value . '">';
  1087. }
  1088. function getSmallStringCell($string, $align) {
  1089. return html_tag('td',
  1090. '<small>' . $string . ':&nbsp; </small>',
  1091. $align,
  1092. '',
  1093. 'nowrap' );
  1094. }
  1095. function getEndMessage($start_msg, $show_num, $num_msgs) {
  1096. if ($start_msg + ($show_num - 1) < $num_msgs){
  1097. $end_msg = $start_msg + ($show_num - 1);
  1098. } else {
  1099. $end_msg = $num_msgs;
  1100. }
  1101. if ($end_msg < $start_msg) {
  1102. $start_msg = $start_msg - $show_num;
  1103. if ($start_msg < 1) {
  1104. $start_msg = 1;
  1105. }
  1106. }
  1107. return (array($start_msg,$end_msg));
  1108. }
  1109. function handleAsSent($mailbox) {
  1110. global $handleAsSent_result;
  1111. /* First check if this is the sent or draft folder. */
  1112. $handleAsSent_result = isSentMailbox($mailbox) || isDraftMailbox($mailbox);
  1113. /* Then check the result of the handleAsSent hook. */
  1114. do_hook('check_handleAsSent_result', $mailbox);
  1115. /* And return the result. */
  1116. return $handleAsSent_result;
  1117. }
  1118. ?>