X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmailbox_display.php;h=566b953b427561b5543ea673a238f95c1b23523a;hb=1885d09307d573c399992182272dc5c46dd2cc11;hp=678606b174eb68bbca2d25e4459199ea9be3661b;hpb=efe9ae2aa367382336c29928e8188dfad60129be;p=squirrelmail.git
diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php
index 678606b1..566b953b 100644
--- a/functions/mailbox_display.php
+++ b/functions/mailbox_display.php
@@ -1,703 +1,1107 @@
\n";
-
- if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) {
- $flag = "";
- $flag_end = ' ';
- } else {
- $flag = '';
- $flag_end = '';
+ $senderName .= sqimap_find_displayable_name($senderNames_part);
+ }
+ }
+
+ if( $mailbox == 'None' ) {
+ $boxes = sqimap_mailbox_list($imapConnection);
+ $mailbox = $boxes[0]['unformatted'];
+ unset( $boxes );
+ }
+ $urlMailbox = urlencode($mailbox);
+ $subject = processSubject($msg['SUBJECT']);
+ echo "
\n";
+
+ if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) {
+ $flag = "";
+ $flag_end = ' ';
+ } else {
+ $flag = '';
+ $flag_end = '';
+ }
+ if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) {
+ $bold = '';
+ $bold_end = ' ';
+ } else {
+ $bold = '';
+ $bold_end = '';
+ }
+ if (handleAsSent($mailbox)) {
+ $italic = '';
+ $italic_end = ' ';
+ } else {
+ $italic = '';
+ $italic_end = '';
+ }
+ if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
+ $fontstr = "";
+ $fontstr_end = ' ';
+ } else {
+ $fontstr = '';
+ $fontstr_end = '';
+ }
+
+ /**
+ * AAAAH! Make my eyes stop bleeding!
+ * Who wrote this?!
+ */
+ if (sizeof($message_highlight_list)){
+ foreach ($message_highlight_list as $message_highlight_list_part) {
+ if (trim($message_highlight_list_part['value']) != '') {
+ if ($message_highlight_list_part['match_type'] == 'to_cc') {
+ if (strstr('^^' . strtolower($msg['TO']),
+ strtolower($message_highlight_list_part['value']))
+ || strstr('^^'.strtolower($msg['CC']),
+ strtolower($message_highlight_list_part['value']))) {
+ $hlt_color = $message_highlight_list_part['color'];
+ continue;
+ }
+ } else
+ if (strstr('^^' . strtolower($msg[strtoupper($message_highlight_list_part['match_type'])]),
+ strtolower($message_highlight_list_part['value']))) {
+ $hlt_color = $message_highlight_list_part['color'];
+ continue;
+ }
}
- if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) {
- $bold = '';
- $bold_end = ' ';
- } else {
- $bold = '';
- $bold_end = '';
+ }
+ }
+
+ if (!isset($hlt_color)) {
+ $hlt_color = $color_string;
+ }
+
+ if ($where && $what) {
+ if(!isset($pos) || $pos == '') {
+ $pos = '0';
+ }
+ $search_stuff = "&pos=" . urlencode($pos)
+ . "&where=" . urlencode($where) . '&what=' . urlencode($what);
+ } else {
+ $search_stuff = '';
+ }
+
+ $checked = ($checkall == 1) ? ' checked' : '';
+
+ if (sizeof($index_order)){
+ foreach ($index_order as $index_order_part) {
+ switch ($index_order_part) {
+ case 1: /* checkbox */
+ echo " "
+ . " \n";
+ break;
+ case 2: /* from */
+ echo " $italic$bold$flag$fontstr"
+ . "$senderName$fontstr_end$flag_end$bold_end$italic_end \n";
+ break;
+ case 3: /* date */
+ echo " $bold$flag$fontstr"
+ . $msg["DATE_STRING"]
+ . "$fontstr_end$flag_end$bold_end \n";
+ break;
+ case 4: /* subject */
+ echo " $bold";
+ if ($thread_sort_messages == 1) {
+ if (isset($indent_array[$msg["ID"]])) {
+ echo str_repeat(" ",$indent_array[$msg["ID"]]);
+ }
+ }
+ echo "$flag$subject$flag_end $bold_end \n";
+ break;
+ case 5: /* flags */
+ $stuff = false;
+ echo " \n";
+ if (isset($msg['FLAG_ANSWERED']) && $msg['FLAG_ANSWERED'] == true) {
+ echo _("A") . "\n";
+ $stuff = true;
+ }
+ if ($msg['TYPE0'] == 'multipart') {
+ echo "+\n";
+ $stuff = true;
+ }
+ if ($default_use_priority) {
+ if ( ($msg['PRIORITY'][0] == 1) || ($msg['PRIORITY'][0] == 2) ) {
+ echo "! \n";
+ $stuff = true;
+ }
+ if ($msg['PRIORITY'][0] == 5) {
+ echo "? \n";
+ $stuff = true;
+ }
+ }
+ if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'] == true) {
+ echo "D \n";
+ $stuff = true;
+ }
+ if (!$stuff) {
+ echo " \n";
+ }
+ echo " \n";
+ break;
+ case 6: /* size */
+ echo " $bold$fontstr"
+ . show_readable_size($msg['SIZE']) . "$fontstr_end$bold_end \n";
+ break;
}
-
- if (($mailbox == $sent_folder) || ($mailbox == $draft_folder)) {
- $italic = '';
- $italic_end = ' ';
- } else {
- $italic = '';
- $italic_end = '';
+ }
+ }
+ echo " \n";
+}
+
+/*
+ * This function loops through a group of messages in the mailbox
+ * and shows them to the user.
+ */
+function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs,
+ $start_msg, $sort, $color, $show_num,
+ $use_cache) {
+ global $msgs, $msort,
+ $sent_folder, $draft_folder,
+ $message_highlight_list,
+ $auto_expunge, $thread_sort_messages, $allow_server_sort,
+ $data_dir, $username, $server_sort_order;
+
+ /* This code and the next if() block check for
+ * server-side sorting methods. The $id array is
+ * formatted and $sort is set to 6 to disable
+ * SM internal sorting
+ */
+ if ($thread_sort_messages == 1) {
+ $id = get_thread_sort($imapConnection);
+ if ($id == 'no') {
+ echo '';
-
- echo "";
-
- echo "' .
- "$More ";
- ShowSelectAllLink($startMessage, $sort);
- echo "
\n ";
-
- /** The delete and move options */
- echo "";
-
- echo "\n ';
-
- echo "";
- echo "';
+ */
+
+ /* Print out the page links from the compute page quarters. */
+
+ /* Start with the first quarter. */
+ if (($q1_pgs == 0) && ($cur_pg > 1)) {
+ $pg_str .= "...$spc";
} else {
- echo "1";
+ for ($pg = 1; $pg <= $q1_pgs; ++$pg) {
+ $start = (($pg-1) * $show_num) + 1;
+ $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
+ }
+ if ($cur_pg - $q2_pgs - $q1_pgs > 1) {
+ $pg_str .= "...$spc";
+ }
}
- echo " BGCOLOR=\"$color[0]\">";
- echo "";
-
- /* Print the headers. */
- for ($i=1; $i <= count($index_order); $i++) {
- switch ($index_order[$i]) {
- case 1: /* checkbox */
- case 5: /* flags */
- echo ' ';
- break;
-
- case 2: /* from */
- if (($mailbox == $sent_folder)
- || ($mailbox == $draft_folder)) {
- echo ' '. _("To") .' ';
- } else {
- echo ' '. _("From") .' ';
- }
-
- ShowSortButton($sort, $mailbox, 2, 3);
- echo " \n";
- break;
-
- case 3: /* date */
- echo ' '. _("Date") .' ';
- ShowSortButton($sort, $mailbox, 0, 1);
- echo " \n";
- break;
-
- case 4: /* subject */
- echo ' '. _("Subject") .' ';
- ShowSortButton($sort, $mailbox, 4, 5);
- echo " \n";
- break;
-
- case 6: /* size */
- echo ' ' . _("Size")." \n";
- break;
- }
+
+ /* Continue with the second quarter. */
+ for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) {
+ $start = (($pg-1) * $show_num) + 1;
+ $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
}
- echo " \n";
- }
-
- /*******************************************************************/
- /* This function shows the sort button. Isn't this a good comment? */
- /*******************************************************************/
- function ShowSortButton($sort, $mailbox, $Up, $Down) {
- /* Figure out which image we want to use. */
- if ($sort != $Up && $sort != $Down) {
- $img = 'sort_none.gif';
- $which = $Up;
- } elseif ($sort == $Up) {
- $img = 'up_pointer.gif';
- $which = $Down;
- } else {
- $img = 'down_pointer.gif';
- $which = 6;
+
+ /* Now print the current page. */
+ $pg_str .= $cur_pg . $spc;
+
+ /* Next comes the third quarter. */
+ for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) {
+ $start = (($pg-1) * $show_num) + 1;
+ $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
}
-
- /* Now that we have everything figured out, show the actual button. */
- echo ' ';
- }
-
- function ShowSelectAllLink($startMessage, $sort) {
- global $checkall, $PHP_SELF, $what, $where, $mailbox;
-
- echo ' \n\n";
-
- echo "";
- if (isset($checkall) && $checkall == '1')
- echo _("Unselect All");
- else
- echo _("Select All");
-
- echo " \n \n";
- }
-
- function processSubject($subject)
- {
- // Shouldn't ever happen -- caught too many times in the IMAP functions
- if ($subject == '')
- return _("(no subject)");
-
- if (strlen($subject) <= 55)
- return $subject;
-
- $ent_strlen=strlen($subject);
- $trim_val=50;
- $ent_offset=0;
- // see if this is entities-encoded string
- // If so, Iterate through the whole string, find out
- // the real number of characters, and if more
- // than 55, substr with an updated trim value.
- while (($ent_loc = strpos($subject, '&', $ent_offset)) !== false &&
- ($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false)
- {
- $trim_val += ($ent_loc_end-$ent_loc)+1;
- $ent_strlen -= $ent_loc_end-$ent_loc;
- $ent_offset = $ent_loc_end+1;
+
+ /* And last, print the forth quarter page links. */
+ if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) {
+ $pg_str .= "...$spc";
+ } else {
+ if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) {
+ $pg_str .= "...$spc";
+ }
+ for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) {
+ $start = (($pg-1) * $show_num) + 1;
+ $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc;
+ }
}
-
- if ($ent_strlen <= 55)
- return $subject;
-
- return substr($subject, 0, $trim_val) . '...';
- }
-
-?>
\ No newline at end of file
+ } else if ($PG_SHOWNUM == 999999) {
+ $pg_str = "" ._("Paginate") . ' ' . $spc;
+ }
+
+ /* If necessary, compute the 'show all' string. */
+ if (($prv_str != '') || ($nxt_str != '')) {
+ $all_str = "" . _("Show All") . ' ';
+ }
+
+ /* Last but not least, get the value for the toggle all link. */
+ $tgl_str = get_selectall_link($start_msg, $sort);
+
+ /* Put all the pieces of the paginator string together. */
+ /**
+ * Hairy code... But let's leave it like it is since I am not certain
+ * a different approach would be any easier to read. ;)
+ */
+ $result = '';
+ $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : '');
+ $result .= ($nxt_str != '' ? $nxt_str . $spc . $sep . $spc : '');
+ $result .= ($pg_str != '' ? $pg_str : '');
+ $result .= ($all_str != '' ? $sep . $spc . $all_str . $spc : '');
+ $result .= ($result != '' ? $sep . $spc . $tgl_str: $tgl_str);
+
+ /* If the resulting string is blank, return a non-breaking space. */
+ if ($result == '') {
+ $result = ' ';
+ }
+
+ /* Return our final magical paginator string. */
+ return ($result);
+}
+
+function processSubject($subject) {
+ /* Shouldn't ever happen -- caught too many times in the IMAP functions */
+ if ($subject == '')
+ return _("(no subject)");
+
+ if (strlen($subject) <= 55)
+ return $subject;
+
+ $ent_strlen=strlen($subject);
+ $trim_val=50;
+ $ent_offset=0;
+ /*
+ * see if this is entities-encoded string
+ * If so, Iterate through the whole string, find out
+ * the real number of characters, and if more
+ * than 55, substr with an updated trim value.
+ */
+ while ( (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) &&
+ (($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false) ) {
+ $trim_val += ($ent_loc_end-$ent_loc)+1;
+ $ent_strlen -= $ent_loc_end-$ent_loc;
+ $ent_offset = $ent_loc_end+1;
+ }
+
+ if ($ent_strlen <= 55){
+ return $subject;
+ }
+
+ return substr($subject, 0, $trim_val) . '...';
+}
+
+function handleAsSent($mailbox) {
+ global $sent_folder, $draft_folder, $handleAsSent_result;
+
+ /* First check if this is the sent or draft folder. */
+ $handleAsSent_result = (($mailbox == $sent_folder)
+ || ($mailbox == $draft_folder));
+
+ /* Then check the result of the handleAsSent hook. */
+ do_hook('check_handleAsSent_result', $mailbox);
+
+ /* And return the result. */
+ return ($handleAsSent_result);
+}
+
+?>