mailbox_display.php 35 KB

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