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