mailbox_display.php 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  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, $server_sort_order;
  472. /* If cache isn't already set, do it now. */
  473. if (!session_is_registered('msgs')) {
  474. session_register('msgs');
  475. }
  476. if (!session_is_registered('msort')) {
  477. session_register('msort');
  478. }
  479. if ($start_msg + ($show_num - 1) < $num_msgs){
  480. $end_msg = $start_msg + ($show_num - 1);
  481. } else {
  482. $end_msg = $num_msgs;
  483. }
  484. if ($end_msg < $start_msg) {
  485. $start_msg = $start_msg - $show_num;
  486. if ($start_msg < 1) {
  487. $start_msg = 1;
  488. }
  489. }
  490. $urlMailbox = urlencode($mailbox);
  491. do_hook('mailbox_index_before');
  492. $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs);
  493. $paginator_str = get_paginator_str($urlMailbox, $start_msg, $end_msg,
  494. $num_msgs, $show_num, $sort);
  495. if (!isset($msg)) {
  496. $msg = '';
  497. }
  498. /* get indent level for subject display */
  499. if ($thread_sort_messages == 1 ) {
  500. $indent_array = get_parent_level($imapConnection);
  501. }
  502. $fstring = "move_messages.php?msg=$msg&amp;mailbox=$urlMailbox"
  503. . "&amp;startMessage=$start_msg";
  504. mail_message_listing_beginning($imapConnection, $fstring,
  505. $mailbox, $sort, $msg_cnt_str,
  506. $paginator_str, $start_msg);
  507. $groupNum = $start_msg % ($show_num - 1);
  508. $real_startMessage = $start_msg;
  509. if ($sort == 6) {
  510. if ($end_msg - $start_msg < $show_num - 1) {
  511. $end_msg = $end_msg - $start_msg + 1;
  512. $start_msg = 1;
  513. } else if ($start_msg > $show_num) {
  514. $end_msg = $show_num;
  515. $start_msg = 1;
  516. }
  517. }
  518. $endVar = $end_msg + 1;
  519. /*
  520. * Loop through and display the info for each message.
  521. * ($t is used for the checkbox number)
  522. */
  523. $t = 0;
  524. if ($num_msgs == 0) {
  525. /* if there's no messages in this folder */
  526. echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN="
  527. . count($index_order) . ">\n"
  528. . " <CENTER><BR><B>". _("THIS FOLDER IS EMPTY")
  529. . "</B><BR>&nbsp;</CENTER>\n"
  530. . "</TD></TR>";
  531. } elseif ($start_msg == $end_msg) {
  532. /* if there's only one message in the box, handle it differently. */
  533. if ($sort != 6){
  534. $i = $start_msg;
  535. } else {
  536. $i = 1;
  537. }
  538. reset($msort);
  539. $k = 0;
  540. do {
  541. $key = key($msort);
  542. next($msort);
  543. $k++;
  544. } while (isset ($key) && ($k < $i));
  545. printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort,
  546. $real_startMessage, 0, 0);
  547. } else {
  548. $i = $start_msg;
  549. reset($msort);
  550. $k = 0;
  551. do {
  552. $key = key($msort);
  553. next($msort);
  554. $k++;
  555. } while (isset ($key) && ($k < $i));
  556. do {
  557. printMessageInfo($imapConnection, $t, $i, $key, $mailbox,
  558. $sort, $real_startMessage, 0, 0);
  559. $key = key($msort);
  560. $t++;
  561. $i++;
  562. next($msort);
  563. } while ($i && $i < $endVar);
  564. }
  565. echo '</table>'
  566. . "<table bgcolor=\"$color[9]\" width=\"100%\" border=0 cellpadding=1 "
  567. . "cellspacing=1><tr BGCOLOR=\"$color[4]\"><td>"
  568. . "<table width=\"100%\" BGCOLOR=\"$color[4]\" border=0 cellpadding=1 "
  569. . "cellspacing=0><tr><td>$paginator_str</td>"
  570. . "<td align=right>$msg_cnt_str</td></tr></table>"
  571. . "</td></tr></table>";
  572. /* End of message-list table */
  573. do_hook('mailbox_index_after');
  574. echo "</TABLE></FORM>\n";
  575. }
  576. /*
  577. * Displays the standard message list header. To finish the table,
  578. * you need to do a "</table></table>";
  579. *
  580. * $moveURL is the URL to submit the delete/move form to
  581. * $mailbox is the current mailbox
  582. * $sort is the current sorting method (-1 for no sorting available [searches])
  583. * $Message is a message that is centered on top of the list
  584. * $More is a second line that is left aligned
  585. */
  586. function mail_message_listing_beginning ($imapConnection, $moveURL,
  587. $mailbox = '', $sort = -1,
  588. $msg_cnt_str = '',
  589. $paginator = '&nbsp;',
  590. $start_msg = 1) {
  591. global $color, $index_order, $auto_expunge, $move_to_trash, $base_uri,
  592. $checkall, $sent_folder, $draft_folder, $thread_sort_messages,
  593. $allow_thread_sort, $allow_server_sort, $server_sort_order,
  594. $lastTargetMailbox;
  595. $urlMailbox = urlencode($mailbox);
  596. /*
  597. * This is the beginning of the message list table.
  598. * It wraps around all messages
  599. */
  600. echo "<FORM name=\"messageList\" method=post action=\"$moveURL\">\n"
  601. . "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"1\" "
  602. . "CELLSPACING=\"0\">\n<TR BGCOLOR=\"$color[0]\"><TD>"
  603. . " <TABLE BGCOLOR=\"$color[4]\" width=\"100%\" CELLPADDING=\"2\" "
  604. . "CELLSPACING=\"0\" BORDER=\"0\"><TR>\n"
  605. . " <TD ALIGN=LEFT>$paginator\n";
  606. echo " <TD ALIGN=RIGHT>$msg_cnt_str</TD>\n"
  607. . " </TR></TABLE>\n"
  608. . '</TD></TR>'
  609. . "<TR><TD BGCOLOR=\"$color[0]\">\n"
  610. . "<TABLE BGCOLOR=\"$color[0]\" BORDER=0 cellpadding=0 "
  611. . "cellspacing=0 width=\"100%\">\n"
  612. . " <TR>\n"
  613. . " <TD ALIGN=LEFT VALIGN=MIDDLE NOWRAP>\n"
  614. . ' <SMALL>&nbsp;' . _("Move Selected To:") . "</SMALL>\n"
  615. . " </TD>\n"
  616. . " <TD ALIGN=RIGHT NOWRAP>\n"
  617. . ' <SMALL>&nbsp;' . _("Transform Selected Messages")
  618. . ": &nbsp; </SMALL><BR>\n"
  619. . " </TD>\n"
  620. . " </TR>\n"
  621. . " <TR>\n"
  622. . " <TD ALIGN=\"LEFT\" VALIGN=\"MIDDLE\" NOWRAP>\n"
  623. . ' <SMALL>&nbsp;<TT><SELECT NAME="targetMailbox">';
  624. $boxes = sqimap_mailbox_list($imapConnection);
  625. foreach ($boxes as $boxes_part) {
  626. if (!in_array('noselect', $boxes_part['flags'])) {
  627. $box = $boxes_part['unformatted'];
  628. $box2 = str_replace(' ', '&nbsp;', imap_utf7_decode_local($boxes_part['unformatted-disp']));
  629. if( $box2 == 'INBOX' ) {
  630. $box2 = _("INBOX");
  631. }
  632. if ($lastTargetMailbox == $box) {
  633. echo " <OPTION VALUE=\"$box\" SELECTED>$box2</OPTION>\n";
  634. }
  635. else {
  636. echo " <OPTION VALUE=\"$box\">$box2</OPTION>\n";
  637. }
  638. }
  639. }
  640. echo ' </SELECT></TT>&nbsp;'
  641. . '<INPUT TYPE="SUBMIT" NAME="moveButton" VALUE="' . _("Move") . '">&nbsp;'
  642. . '<INPUT TYPE="SUBMIT" NAME="attache" VALUE="' . _("Forward")
  643. . "\">&nbsp;\n" . "</SMALL>\n";
  644. echo " </TD>\n"
  645. . " <TD ALIGN=\"RIGHT\" NOWRAP>";
  646. if (!$auto_expunge) {
  647. echo '<INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="' . _("Expunge")
  648. . '">&nbsp;' . _("mailbox") . '&nbsp;';
  649. }
  650. echo '<INPUT TYPE="SUBMIT" NAME="markRead" VALUE="' . _("Read") . '">'
  651. . '<INPUT TYPE="SUBMIT" NAME="markUnread" VALUE="' . _("Unread") . '">'
  652. . '<INPUT TYPE="SUBMIT" VALUE="' . _("Delete") . '">&nbsp;'
  653. . "</TD>\n"
  654. . " </TR>\n";
  655. /* draws thread sorting links */
  656. if ($allow_thread_sort == TRUE) {
  657. if ($thread_sort_messages == 1 ) {
  658. $set_thread = 2;
  659. $thread_name = _("Unthread View");
  660. }
  661. elseif ($thread_sort_messages == 0) {
  662. $set_thread = 1;
  663. $thread_name = _("Thread View");
  664. }
  665. echo '<tr><td>&nbsp;<a href=' . "$base_uri" . 'src/right_main.php?sort='
  666. . "$sort" . '&start_messages=1&set_thread=' . "$set_thread"
  667. . '&mailbox=' . urlencode($mailbox) . '><small>' . $thread_name
  668. . '</a></small>&nbsp;</td></tr>';
  669. }
  670. echo "</TABLE>\n";
  671. do_hook('mailbox_form_before');
  672. echo '</TD></TR>'
  673. . "<TR><TD BGCOLOR=\"$color[0]\">"
  674. . '<TABLE WIDTH="100%" BORDER=0 CELLPADDING=2 CELLSPACING=';
  675. if ($GLOBALS['alt_index_colors']){
  676. echo '0';
  677. } else {
  678. echo '1';
  679. }
  680. echo " BGCOLOR=\"$color[0]\">"
  681. . "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
  682. /* if using server sort we highjack the
  683. * the $sort var and use $server_sort_order
  684. * instead. but here we reset sort for a bit
  685. * since its easy
  686. */
  687. if ($allow_server_sort == TRUE) {
  688. $sort = $server_sort_order;
  689. }
  690. /* Print the headers. */
  691. for ($i=1; $i <= count($index_order); $i++) {
  692. switch ($index_order[$i]) {
  693. case 1: /* checkbox */
  694. case 5: /* flags */
  695. echo ' <TD WIDTH="1%"><B>&nbsp;</B></TD>';
  696. break;
  697. case 2: /* from */
  698. if (handleAsSent($mailbox)) {
  699. echo ' <TD WIDTH="25%"><B>' . _("To") . '</B>';
  700. } else {
  701. echo ' <TD WIDTH="25%"><B>' . _("From") . '</B>';
  702. }
  703. if ($allow_thread_sort != TRUE || $thread_sort_messages != 1) {
  704. ShowSortButton($sort, $mailbox, 2, 3);
  705. }
  706. echo "</TD>\n";
  707. break;
  708. case 3: /* date */
  709. echo ' <TD NOWRAP WIDTH="5%"><B>' . _("Date") . '</B>';
  710. if ($allow_thread_sort != TRUE || $thread_sort_messages != 1) {
  711. ShowSortButton($sort, $mailbox, 0, 1);
  712. }
  713. echo "</TD>\n";
  714. break;
  715. case 4: /* subject */
  716. echo ' <TD><B>' . _("Subject") . '</B> ';
  717. if ($allow_thread_sort != TRUE || $thread_sort_messages != 1) {
  718. ShowSortButton($sort, $mailbox, 4, 5);
  719. }
  720. echo "</TD>\n";
  721. break;
  722. case 6: /* size */
  723. echo ' <TD WIDTH="5%"><b>' . _("Size") . "</b></TD>\n";
  724. break;
  725. }
  726. }
  727. /* if using server-sorting,
  728. * send sort back to 6
  729. */
  730. if ($allow_server_sort == TRUE) {
  731. $sort = 6;
  732. }
  733. echo "</TR>\n";
  734. }
  735. /*
  736. * This function shows the sort button. Isn't this a good comment?
  737. */
  738. function ShowSortButton($sort, $mailbox, $Up, $Down) {
  739. /* Figure out which image we want to use. */
  740. if ($sort != $Up && $sort != $Down) {
  741. $img = 'sort_none.png';
  742. $which = $Up;
  743. } elseif ($sort == $Up) {
  744. $img = 'up_pointer.png';
  745. $which = $Down;
  746. } else {
  747. $img = 'down_pointer.png';
  748. $which = 6;
  749. }
  750. /* Now that we have everything figured out, show the actual button. */
  751. echo ' <a href="right_main.php?newsort=' . $which
  752. . '&amp;startMessage=1&amp;mailbox=' . urlencode($mailbox)
  753. . '"><IMG SRC="../images/' . $img
  754. . '" BORDER=0 WIDTH=12 HEIGHT=10 ALT="sort"></a>';
  755. }
  756. function get_selectall_link($start_msg, $sort) {
  757. global $checkall, $what, $where, $mailbox, $javascript_on;
  758. global $PHP_SELF, $PG_SHOWNUM;
  759. $result = '';
  760. if ($javascript_on) {
  761. $result =
  762. '<script language="JavaScript" type="text/javascript">'
  763. . "\n<!-- \n"
  764. . "function CheckAll() {\n"
  765. . " for (var i = 0; i < document.messageList.elements.length; i++) {\n"
  766. . " if(document.messageList.elements[i].type == 'checkbox'){\n"
  767. . " document.messageList.elements[i].checked = "
  768. . " !(document.messageList.elements[i].checked);\n"
  769. . " }\n"
  770. . " }\n"
  771. . "}\n"
  772. . "//-->\n"
  773. . '</script><a href="#" onClick="CheckAll();">' . _("Toggle All")
  774. . "</a>\n";
  775. } else {
  776. if (strpos($PHP_SELF, "?")) {
  777. $result .= "<a href=\"$PHP_SELF&amp;mailbox=" . urlencode($mailbox)
  778. . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
  779. } else {
  780. $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox)
  781. . "&amp;startMessage=$start_msg&amp;sort=$sort&amp;checkall=";
  782. }
  783. if (isset($checkall) && $checkall == '1') {
  784. $result .= '0';
  785. } else {
  786. $result .= '1';
  787. }
  788. if (isset($where) && isset($what)) {
  789. $result .= '&amp;where=' . urlencode($where)
  790. . '&amp;what=' . urlencode($what);
  791. }
  792. $result .= "\">";
  793. if (isset($checkall) && ($checkall == '1')) {
  794. $result .= _("Unselect All");
  795. } else {
  796. $result .= _("Select All");
  797. }
  798. $result .= "</A>\n";
  799. }
  800. /* Return our final result. */
  801. return ($result);
  802. }
  803. /*
  804. * This function computes the "Viewing Messages..." string.
  805. */
  806. function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
  807. /* Compute the $msg_cnt_str. */
  808. $result = '';
  809. if ($start_msg < $end_msg) {
  810. $result = sprintf(_("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"),
  811. $start_msg, $end_msg, $num_msgs);
  812. } else if ($start_msg == $end_msg) {
  813. $result = sprintf(_("Viewing Message: <B>%s</B> (1 total)"), $start_msg);
  814. } else {
  815. $result = '<br>';
  816. }
  817. /* Return our result string. */
  818. return ($result);
  819. }
  820. /*
  821. * Generate a paginator link.
  822. */
  823. function get_paginator_link($box, $start_msg, $use, $text) {
  824. $result = "<A HREF=\"right_main.php?use_mailbox_cache=$use"
  825. . "&amp;startMessage=$start_msg&amp;mailbox=$box\" "
  826. . "TARGET=\"right\">$text</A>";
  827. return ($result);
  828. }
  829. /*
  830. * This function computes the paginator string.
  831. */
  832. function get_paginator_str($box, $start_msg, $end_msg, $num_msgs,
  833. $show_num, $sort) {
  834. global $username, $data_dir, $use_mailbox_cache, $color, $PG_SHOWNUM;
  835. /* Initialize paginator string chunks. */
  836. $prv_str = '';
  837. $nxt_str = '';
  838. $pg_str = '';
  839. $all_str = '';
  840. $tgl_str = '';
  841. /* Create simple strings that will be creating the paginator. */
  842. $spc = '&nbsp;'; /* This will be used as a space. */
  843. $sep = '|'; /* This will be used as a seperator. */
  844. /* Get some paginator preference values. */
  845. $pg_sel = getPref($data_dir, $username, 'page_selector', SMPREF_ON);
  846. $pg_max = getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX);
  847. /* Make sure that our start message number is not too big. */
  848. $start_msg = min($start_msg, $num_msgs);
  849. /* Decide whether or not we will use the mailbox cache. */
  850. /* Not sure why $use_mailbox_cache is even passed in. */
  851. if ($sort == 6) {
  852. $use = 0;
  853. } else {
  854. $use = 1;
  855. }
  856. /* Compute the starting message of the previous and next page group. */
  857. $next_grp = $start_msg + $show_num;
  858. $prev_grp = $start_msg - $show_num;
  859. /* Compute the basic previous and next strings. */
  860. if (($next_grp <= $num_msgs) && ($prev_grp >= 0)) {
  861. $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
  862. $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
  863. } else if (($next_grp > $num_msgs) && ($prev_grp >= 0)) {
  864. $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous"));
  865. $nxt_str = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
  866. } else if (($next_grp <= $num_msgs) && ($prev_grp < 0)) {
  867. $prv_str = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
  868. $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next"));
  869. }
  870. /* Page selector block. Following code computes page links. */
  871. if ($pg_sel && ($num_msgs > $show_num)) {
  872. /* Most importantly, what is the current page!!! */
  873. $cur_pg = intval($start_msg / $show_num) + 1;
  874. /* Compute total # of pages and # of paginator page links. */
  875. $tot_pgs = ceil($num_msgs / $show_num); /* Total number of Pages */
  876. $vis_pgs = min($pg_max, $tot_pgs - 1); /* Visible Pages */
  877. /* Compute the size of the four quarters of the page links. */
  878. /* If we can, just show all the pages. */
  879. if (($tot_pgs - 1) <= $pg_max) {
  880. $q1_pgs = $cur_pg - 1;
  881. $q2_pgs = $q3_pgs = 0;
  882. $q4_pgs = $tot_pgs - $cur_pg;
  883. /* Otherwise, compute some magic to choose the four quarters. */
  884. } else {
  885. /*
  886. * Compute the magic base values. Added together,
  887. * these values will always equal to the $pag_pgs.
  888. * NOTE: These are DEFAULT values and do not take
  889. * the current page into account. That is below.
  890. */
  891. $q1_pgs = floor($vis_pgs/4);
  892. $q2_pgs = round($vis_pgs/4, 0);
  893. $q3_pgs = ceil($vis_pgs/4);
  894. $q4_pgs = round(($vis_pgs - $q2_pgs)/3, 0);
  895. /* Adjust if the first quarter contains the current page. */
  896. if (($cur_pg - $q1_pgs) < 1) {
  897. $extra_pgs = ($q1_pgs - ($cur_pg - 1)) + $q2_pgs;
  898. $q1_pgs = $cur_pg - 1;
  899. $q2_pgs = 0;
  900. $q3_pgs += ceil($extra_pgs / 2);
  901. $q4_pgs += floor($extra_pgs / 2);
  902. /* Adjust if the first and second quarters intersect. */
  903. } else if (($cur_pg - $q2_pgs - ceil($q2_pgs/3)) <= $q1_pgs) {
  904. $extra_pgs = $q2_pgs;
  905. $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 0.75);
  906. $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 0.75);
  907. $q3_pgs += ceil($extra_pgs / 2);
  908. $q4_pgs += floor($extra_pgs / 2);
  909. /* Adjust if the fourth quarter contains the current page. */
  910. } else if (($cur_pg + $q4_pgs) >= $tot_pgs) {
  911. $extra_pgs = ($q4_pgs - ($tot_pgs - $cur_pg)) + $q3_pgs;
  912. $q3_pgs = 0;
  913. $q4_pgs = $tot_pgs - $cur_pg;
  914. $q1_pgs += floor($extra_pgs / 2);
  915. $q2_pgs += ceil($extra_pgs / 2);
  916. /* Adjust if the third and fourth quarter intersect. */
  917. } else if (($cur_pg + $q3_pgs + 1) >= ($tot_pgs - $q4_pgs + 1)) {
  918. $extra_pgs = $q3_pgs;
  919. $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
  920. $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 0.75);
  921. $q1_pgs += floor($extra_pgs / 2);
  922. $q2_pgs += ceil($extra_pgs / 2);
  923. }
  924. }
  925. /*
  926. * I am leaving this debug code here, commented out, because
  927. * it is a really nice way to see what the above code is doing.
  928. * echo "qts = $q1_pgs/$q2_pgs/$q3_pgs/$q4_pgs = "
  929. * . ($q1_pgs + $q2_pgs + $q3_pgs + $q4_pgs) . '<br>';
  930. */
  931. /* Print out the page links from the compute page quarters. */
  932. /* Start with the first quarter. */
  933. if (($q1_pgs == 0) && ($cur_pg > 1)) {
  934. $pg_str .= "...$spc";
  935. } else {
  936. for ($pg = 1; $pg <= $q1_pgs; ++$pg) {
  937. $start = (($pg-1) * $show_num) + 1;
  938. $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
  939. }
  940. if ($cur_pg - $q2_pgs - $q1_pgs > 1) {
  941. $pg_str .= "...$spc";
  942. }
  943. }
  944. /* Continue with the second quarter. */
  945. for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) {
  946. $start = (($pg-1) * $show_num) + 1;
  947. $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
  948. }
  949. /* Now print the current page. */
  950. $pg_str .= $cur_pg . $spc;
  951. /* Next comes the third quarter. */
  952. for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) {
  953. $start = (($pg-1) * $show_num) + 1;
  954. $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
  955. }
  956. /* And last, print the forth quarter page links. */
  957. if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) {
  958. $pg_str .= "...$spc";
  959. } else {
  960. if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) {
  961. $pg_str .= "...$spc";
  962. }
  963. for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) {
  964. $start = (($pg-1) * $show_num) + 1;
  965. $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
  966. }
  967. }
  968. } else if ($PG_SHOWNUM == 999999) {
  969. $pg_str = "<A HREF=\"right_main.php?PG_SHOWALL=0"
  970. . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
  971. . "TARGET=\"right\">" ._("Paginate") . '</A>' . $spc;
  972. }
  973. /* If necessary, compute the 'show all' string. */
  974. if (($prv_str != '') || ($nxt_str != '')) {
  975. $all_str = "<A HREF=\"right_main.php?PG_SHOWALL=1"
  976. . "&amp;use_mailbox_cache=$use&amp;startMessage=1&amp;mailbox=$box\" "
  977. . "TARGET=\"right\">" . _("Show All") . '</A>';
  978. }
  979. /* Last but not least, get the value for the toggle all link. */
  980. $tgl_str = get_selectall_link($start_msg, $sort);
  981. /* Put all the pieces of the paginator string together. */
  982. /**
  983. * Hairy code... But let's leave it like it is since I am not certain
  984. * a different approach would be any easier to read. ;)
  985. */
  986. $result = '';
  987. $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : '');
  988. $result .= ($nxt_str != '' ? $nxt_str . $spc . $sep . $spc : '');
  989. $result .= ($pg_str != '' ? $pg_str : '');
  990. $result .= ($all_str != '' ? $sep . $spc . $all_str . $spc : '');
  991. $result .= ($result != '' ? $sep . $spc . $tgl_str: $tgl_str);
  992. /* If the resulting string is blank, return a non-breaking space. */
  993. if ($result == '') {
  994. $result = '&nbsp;';
  995. }
  996. /* Return our final magical paginator string. */
  997. return ($result);
  998. }
  999. function processSubject($subject) {
  1000. /* Shouldn't ever happen -- caught too many times in the IMAP functions */
  1001. if ($subject == '')
  1002. return _("(no subject)");
  1003. if (strlen($subject) <= 55)
  1004. return $subject;
  1005. $ent_strlen=strlen($subject);
  1006. $trim_val=50;
  1007. $ent_offset=0;
  1008. /*
  1009. * see if this is entities-encoded string
  1010. * If so, Iterate through the whole string, find out
  1011. * the real number of characters, and if more
  1012. * than 55, substr with an updated trim value.
  1013. */
  1014. while ( (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) &&
  1015. (($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false) ) {
  1016. $trim_val += ($ent_loc_end-$ent_loc)+1;
  1017. $ent_strlen -= $ent_loc_end-$ent_loc;
  1018. $ent_offset = $ent_loc_end+1;
  1019. }
  1020. if ($ent_strlen <= 55){
  1021. return $subject;
  1022. }
  1023. return substr($subject, 0, $trim_val) . '...';
  1024. }
  1025. function handleAsSent($mailbox) {
  1026. global $sent_folder, $draft_folder, $handleAsSent_result;
  1027. /* First check if this is the sent or draft folder. */
  1028. $handleAsSent_result = (($mailbox == $sent_folder)
  1029. || ($mailbox == $draft_folder));
  1030. /* Then check the result of the handleAsSent hook. */
  1031. do_hook('check_handleAsSent_result', $mailbox);
  1032. /* And return the result. */
  1033. return ($handleAsSent_result);
  1034. }
  1035. ?>