59177427 |
1 | <?php |
2ba13803 |
2 | |
35586184 |
3 | /** |
0fdc2fb6 |
4 | * mailbox_display.php |
5 | * |
6 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
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 | * |
31841a9e |
12 | * @version $Id$ |
0fdc2fb6 |
13 | * @package squirrelmail |
14 | */ |
a4c2cd49 |
15 | |
d6c32258 |
16 | /** The standard includes.. */ |
b68edc75 |
17 | require_once(SM_PATH . 'functions/strings.php'); |
18 | require_once(SM_PATH . 'functions/html.php'); |
19 | require_once(SM_PATH . 'class/html.class.php'); |
20 | require_once(SM_PATH . 'functions/imap_mailbox.php'); |
26454147 |
21 | require_once(SM_PATH . 'functions/imap_messages.php'); |
22 | require_once(SM_PATH . 'functions/mime.php'); |
b531f8ea |
23 | require_once(SM_PATH . 'functions/forms.php'); |
43fdb2a4 |
24 | |
d6c32258 |
25 | /** |
0fdc2fb6 |
26 | * default value for page_selector_max |
27 | */ |
6c930ade |
28 | define('PG_SEL_MAX', 10); |
29 | |
03975a39 |
30 | define('SQSORT_NONE',0); |
31 | define('SQSORT_DATE_ASC',1); |
32 | define('SQSORT_DATE_DEC',2); |
33 | define('SQSORT_FROM_ASC',3); |
34 | define('SQSORT_FROM_DEC',4); |
35 | define('SQSORT_SUBJ_ASC',5); |
36 | define('SQSORT_SUBJ_DEC',6); |
37 | define('SQSORT_SIZE_ASC',7); |
38 | define('SQSORT_SIZE_DEC',8); |
39 | define('SQSORT_TO_ASC',9); |
40 | define('SQSORT_TO_DEC',10); |
41 | define('SQSORT_CC_ASC',11); |
42 | define('SQSORT_CC_DEC',12); |
43 | define('SQSORT_INT_DATE_ASC',13); |
44 | define('SQSORT_INT_DATE_DEC',14); |
d6c32258 |
45 | /** |
0fdc2fb6 |
46 | * @param mixed $start UNDOCUMENTED |
47 | */ |
48 | function elapsed($start) { |
49 | |
50 | $end = microtime(); |
51 | list($start2, $start1) = explode(" ", $start); |
52 | list($end2, $end1) = explode(" ", $end); |
53 | $diff1 = $end1 - $start1; |
54 | $diff2 = $end2 - $start2; |
55 | if( $diff2 < 0 ){ |
56 | $diff1 -= 1; |
57 | $diff2 += 1.0; |
58 | } |
59 | return $diff2 + $diff1; |
098ea084 |
60 | } |
61 | |
c7df3f1b |
62 | /** |
0fdc2fb6 |
63 | * Displays message listing |
64 | * |
65 | * @param mixed $t UNDOCUMENTED |
66 | * @param bool $not_last UNDOCUMENTED |
67 | * @param mixed $key UNDOCUMENTED |
68 | * @param string $mailbox mail folder |
69 | * @param mixed $start_msg UNDOCUMENTED |
70 | * @param mixed $where UNDOCUMENTED |
71 | * @param mixed $what UNDOCUMENTED |
72 | */ |
73 | |
74 | function printMessageInfo($t, $last=false, $msg, $mailbox, |
75 | $start_msg, $where, $what) { |
8008456a |
76 | global $checkall, |
0fdc2fb6 |
77 | $color, $td_str, |
78 | $default_use_priority, |
79 | $message_highlight_list, |
80 | $index_order, |
81 | $indent_array, /* indent subject by */ |
82 | $pos, /* Search postion (if any) */ |
83 | $thread_sort_messages, /* thread sorting on/off */ |
84 | $row_count, |
85 | $truncate_sender, /* number of characters for From/To field (<= 0 for unchanged) */ |
86 | $email_address, |
87 | $show_recipient_instead, /* show recipient name instead of default identity */ |
88 | $use_icons, /* indicates to use icons or text markers */ |
89 | $icon_theme; /* icons theming */ |
459e3347 |
90 | |
e9e5f0fa |
91 | $color_string = $color[4]; |
8008456a |
92 | |
03975a39 |
93 | // initialisation: |
94 | $sSubject = (isset($msg['SUBJECT']) && $msg['SUBJECT'] != '') ? $msg['SUBJECT'] : _("(no subject)"); |
95 | $sFrom = (isset($msg['FROM'])) ? $msg['FROM'] : _("Unknown sender"); |
96 | $sTo = (isset($msg['TO'])) ? $msg['TO'] : _("Unknown recipient"); |
97 | $sCc = (isset($msg['CC'])) ? $msg['CC'] : ''; |
98 | $aFlags = (isset($msg['FLAGS'])) ? $msg['FLAGS'] : array(); |
99 | $iPrio = (isset($msg['PRIORITY'])) ? $msg['PRIORITY'] : 3; |
100 | $iSize = (isset($msg['SIZE'])) ? $msg['SIZE'] : 0; |
101 | $sType0 = (isset($msg['TYPE0'])) ? $msg['TYPE0'] : 'text'; |
102 | $sType1 = (isset($msg['TYPE1'])) ? $msg['TYPE1'] : 'plain'; |
103 | $sDate = (isset($msg['DATE'])) ? getDateString(getTimeStamp(explode(' ',$msg['DATE']))) : ''; |
104 | $iId = (isset($msg['ID'])) ? $msg['ID'] : false; |
105 | |
106 | sqgetGlobalVar('indent_array',$indent_array,SQ_SESSION); |
107 | if (!$iId) { |
108 | return; |
109 | } |
110 | |
8008456a |
111 | if ($GLOBALS['alt_index_colors']) { |
112 | if (!isset($row_count)) { |
113 | $row_count = 0; |
114 | } |
115 | $row_count++; |
116 | if ($row_count % 2) { |
117 | if (!isset($color[12])) { |
118 | $color[12] = '#EAEAEA'; |
119 | } |
120 | $color_string = $color[12]; |
121 | } |
bdfb67f8 |
122 | } |
8008456a |
123 | |
8008456a |
124 | $urlMailbox = urlencode($mailbox); |
e9e5f0fa |
125 | |
53ad5f60 |
126 | $bSentFolder = handleAsSent($mailbox); |
1ae2832e |
127 | if ((!$bSentFolder) && ($show_recipient_instead)) { |
128 | // If the From address is the same as $email_address, then handle as Sent |
03975a39 |
129 | $from_array = parseAddress($sFrom, 1); |
1ae2832e |
130 | if (!isset($email_address)) { |
131 | global $datadir, $username; |
132 | $email_address = getPref($datadir, $username, 'email_address'); |
133 | } |
134 | $bHandleAsSent = ((isset($from_array[0][0])) && ($from_array[0][0] == $email_address)); |
098ea084 |
135 | } |
1ae2832e |
136 | else |
137 | $bHandleAsSent = $bSentFolder; |
53ad5f60 |
138 | // If this is a Sent message, display To address instead of From |
03975a39 |
139 | if ($bHandleAsSent) { |
140 | $sFrom = $sTo; |
141 | } |
53ad5f60 |
142 | // Passing 1 below results in only 1 address being parsed, thus defeating the following code |
03975a39 |
143 | $sFrom = parseAddress($sFrom/*,1*/); |
9701e9c8 |
144 | |
0fdc2fb6 |
145 | /* |
e9e5f0fa |
146 | * This is done in case you're looking into Sent folders, |
147 | * because you can have multiple receivers. |
148 | */ |
03975a39 |
149 | $senderNames = $sFrom; |
098ea084 |
150 | $senderName = ''; |
26454147 |
151 | $senderAddress = ''; |
098ea084 |
152 | if (sizeof($senderNames)){ |
153 | foreach ($senderNames as $senderNames_part) { |
e9e5f0fa |
154 | if ($senderName != '') { |
155 | $senderName .= ', '; |
26454147 |
156 | $senderAddress .= ', '; |
e9e5f0fa |
157 | } |
26454147 |
158 | $sender_address_part = htmlspecialchars($senderNames_part[0]); |
53ad5f60 |
159 | $sender_name_part = str_replace(' ',' ', decodeHeader($senderNames_part[1])); |
26454147 |
160 | if ($sender_name_part) { |
161 | $senderName .= $sender_name_part; |
162 | $senderAddress .= $sender_name_part . ' <' . $sender_address_part . '>'; |
098ea084 |
163 | } else { |
26454147 |
164 | $senderName .= $sender_address_part; |
165 | $senderAddress .= $sender_address_part; |
098ea084 |
166 | } |
167 | } |
937c81fa |
168 | } |
53ad5f60 |
169 | // If Sent, prefix with To: but only if not Sent folder |
170 | if ($bHandleAsSent ^ $bSentFolder) { |
171 | $senderName = _("To:") . ' ' . $senderName; |
172 | $senderAddress = _("To:") . ' ' . $senderAddress; |
173 | } |
459e3347 |
174 | |
eaa4f45f |
175 | if ($truncate_sender > 0) |
0fdc2fb6 |
176 | $senderName = truncateWithEntities($senderName, $truncate_sender); |
459e3347 |
177 | |
5786ef5a |
178 | echo html_tag( 'tr','','','','VALIGN="top"') . "\n"; |
8008456a |
179 | |
03975a39 |
180 | if (isset($aFlags['\\flagged']) && ($aFlags['\\flagged'] == true)) { |
8008456a |
181 | $flag = "<font color=\"$color[2]\">"; |
182 | $flag_end = '</font>'; |
183 | } else { |
184 | $flag = ''; |
185 | $flag_end = ''; |
bdfb67f8 |
186 | } |
03975a39 |
187 | if (!isset($aFlags['\\seen']) || ($aFlags['\\seen'] == false)) { |
8008456a |
188 | $bold = '<b>'; |
189 | $bold_end = '</b>'; |
190 | } else { |
191 | $bold = ''; |
192 | $bold_end = ''; |
bdfb67f8 |
193 | } |
53ad5f60 |
194 | if ($bHandleAsSent) { |
8008456a |
195 | $italic = '<i>'; |
196 | $italic_end = '</i>'; |
197 | } else { |
198 | $italic = ''; |
199 | $italic_end = ''; |
200 | } |
03975a39 |
201 | if (isset($aFlags['\\deleted']) && $aFlags['\\deleted']) { |
8008456a |
202 | $fontstr = "<font color=\"$color[9]\">"; |
203 | $fontstr_end = '</font>'; |
204 | } else { |
205 | $fontstr = ''; |
206 | $fontstr_end = ''; |
207 | } |
208 | |
d215ca7d |
209 | if ($where && $what) { |
210 | $searchstr = '&where='.$where.'&what='.$what; |
211 | } else { |
212 | $searchstr = ''; |
6a622b59 |
213 | } |
9701e9c8 |
214 | |
3667f469 |
215 | $matches = array('TO' => 'sTo', 'CC' => 'sCc', 'FROM' => 'sFrom', 'SUBJECT' => 'sSubject'); |
937c81fa |
216 | if (is_array($message_highlight_list) && count($message_highlight_list)) { |
03975a39 |
217 | $sTo = parseAddress($sTo); |
218 | $sCc = parseAddress($sCc); |
8008456a |
219 | foreach ($message_highlight_list as $message_highlight_list_part) { |
220 | if (trim($message_highlight_list_part['value']) != '') { |
c0d04f97 |
221 | $high_val = strtolower($message_highlight_list_part['value']); |
222 | $match_type = strtoupper($message_highlight_list_part['match_type']); |
8415b2d3 |
223 | if($match_type == 'TO_CC') { |
224 | $match = array('TO', 'CC'); |
225 | } else { |
226 | $match = array($match_type); |
227 | } |
228 | foreach($match as $match_type) { |
229 | switch($match_type) { |
230 | case('TO'): |
231 | case('CC'): |
232 | case('FROM'): |
3667f469 |
233 | foreach ($$matches[$match_type] as $address) { |
9701e9c8 |
234 | $address[0] = decodeHeader($address[0], true, false); |
235 | $address[1] = decodeHeader($address[1], true, false); |
8415b2d3 |
236 | if (strstr('^^' . strtolower($address[0]), $high_val) || |
237 | strstr('^^' . strtolower($address[1]), $high_val)) { |
238 | $hlt_color = $message_highlight_list_part['color']; |
239 | break 4; |
240 | } |
937c81fa |
241 | } |
937c81fa |
242 | break; |
8415b2d3 |
243 | default: |
3667f469 |
244 | $headertest = strtolower(decodeHeader($$matches[$match_type], true, false)); |
9701e9c8 |
245 | if (strstr('^^' . $headertest, $high_val)) { |
937c81fa |
246 | $hlt_color = $message_highlight_list_part['color']; |
4669e892 |
247 | break 3; |
937c81fa |
248 | } |
8415b2d3 |
249 | break; |
250 | } |
8008456a |
251 | } |
252 | } |
253 | } |
254 | } |
255 | |
256 | if (!isset($hlt_color)) { |
257 | $hlt_color = $color_string; |
258 | } |
5e0efebf |
259 | $col = 0; |
03975a39 |
260 | $sSubject = str_replace(' ', ' ', decodeHeader($sSubject)); |
261 | if (isset($indent_array[$iId])) { |
262 | $subject = processSubject($sSubject, $indent_array[$iId]); |
263 | } else { |
264 | $subject = processSubject($sSubject, 0); |
265 | } |
6a622b59 |
266 | if (sizeof($index_order)) { |
8008456a |
267 | foreach ($index_order as $index_order_part) { |
268 | switch ($index_order_part) { |
269 | case 1: /* checkbox */ |
270 | echo html_tag( 'td', |
03975a39 |
271 | addCheckBox("msg[$t]", $checkall, $iId), |
0fdc2fb6 |
272 | 'center', |
273 | $hlt_color ); |
8008456a |
274 | break; |
275 | case 2: /* from */ |
26454147 |
276 | if ($senderAddress != $senderName) { |
277 | $senderAddress = strtr($senderAddress, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); |
278 | $title = ' title="' . str_replace('"', "''", $senderAddress) . '"'; |
279 | } |
280 | else |
281 | $title = ''; |
8008456a |
282 | echo html_tag( 'td', |
0fdc2fb6 |
283 | $italic . $bold . $flag . $fontstr . $senderName . |
284 | $fontstr_end . $flag_end . $bold_end . $italic_end, |
285 | 'left', |
286 | $hlt_color, $title ); |
8008456a |
287 | break; |
288 | case 3: /* date */ |
03975a39 |
289 | if ($sDate == '') { |
290 | $sDate = _("Unknown date"); |
53d9fbc5 |
291 | } |
8008456a |
292 | echo html_tag( 'td', |
03975a39 |
293 | $bold . $flag . $fontstr . $sDate . |
0fdc2fb6 |
294 | $fontstr_end . $flag_end . $bold_end, |
295 | 'center', |
296 | $hlt_color, |
297 | 'nowrap' ); |
8008456a |
298 | break; |
299 | case 4: /* subject */ |
300 | $td_str = $bold; |
301 | if ($thread_sort_messages == 1) { |
03975a39 |
302 | if (isset($indent_array[$iId])) { |
303 | $td_str .= str_repeat(" ",$indent_array[$iId]); |
8008456a |
304 | } |
305 | } |
e9e5f0fa |
306 | $td_str .= '<a href="read_body.php?mailbox='.$urlMailbox |
6a622b59 |
307 | . '&passed_id='. $msg["ID"] |
308 | . '&startMessage='.$start_msg.$searchstr.'"'; |
158fa340 |
309 | $td_str .= ' ' .concat_hook_function('subject_link', array($start_msg, $searchstr)); |
03975a39 |
310 | if ($subject != $sSubject) { |
8008456a |
311 | $title = get_html_translation_table(HTML_SPECIALCHARS); |
312 | $title = array_flip($title); |
03975a39 |
313 | $title = strtr($sSubject, $title); |
8008456a |
314 | $title = str_replace('"', "''", $title); |
315 | $td_str .= " title=\"$title\""; |
316 | } |
317 | $td_str .= ">$flag$subject$flag_end</a>$bold_end"; |
c1c17724 |
318 | echo html_tag( 'td', $td_str, 'left', $hlt_color ); |
8008456a |
319 | break; |
320 | case 5: /* flags */ |
6a622b59 |
321 | |
6395c46d |
322 | // icon message markers |
323 | // |
324 | if ($use_icons && $icon_theme != 'none') { |
325 | $td_str = "<b><small>"; |
03975a39 |
326 | if (isset($aFlags['\\flagged']) && $aFlags['\\flagged'] == true) { |
55103ede |
327 | $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/flagged.png" border="0" height="10" width="10" /> '; |
6395c46d |
328 | } |
329 | if ($default_use_priority) { |
03975a39 |
330 | if ( ($iPrio == 1) || ($iPrio == 2) ) { |
55103ede |
331 | $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/prio_high.png" border="0" height="10" width="5" /> '; |
6395c46d |
332 | } |
03975a39 |
333 | else if ($iPrio == 5) { |
55103ede |
334 | $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/prio_low.png" border="0" height="10" width="5" /> '; |
6395c46d |
335 | } |
0fdc2fb6 |
336 | else { |
55103ede |
337 | $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/transparent.png" border="0" width="5" /> '; |
6395c46d |
338 | } |
339 | } |
03975a39 |
340 | if ($sType1 == 'mixed') { |
55103ede |
341 | $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/attach.png" border="0" height="10" width="6" />'; |
0fdc2fb6 |
342 | } else { |
55103ede |
343 | $td_str .= '<img src="' . SM_PATH . 'images/themes/' . $icon_theme . '/transparent.png" border="0" width="6" />'; |
6395c46d |
344 | } |
345 | |
346 | $msg_icon = ''; |
03975a39 |
347 | if (!isset($aFlags['\\seen']) || ($aFlags['\\seen']) == false) { |
6395c46d |
348 | $msg_alt = '(' . _("New") . ')'; |
349 | $msg_title = '(' . _("New") . ')'; |
350 | $msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_new'; |
0fdc2fb6 |
351 | } else { |
6395c46d |
352 | $msg_alt = '(' . _("Read") . ')'; |
353 | $msg_title = '(' . _("Read") . ')'; |
354 | $msg_icon .= SM_PATH . 'images/themes/' . $icon_theme . '/msg_read'; |
355 | } |
03975a39 |
356 | if (isset($aFlags['\\deleted']) && ($aFlags['\\deleted']) == true) { |
6395c46d |
357 | $msg_icon .= '_deleted'; |
358 | } |
03975a39 |
359 | if (isset($aFlags['\\answered']) && ($aFlags['\\answered']) == true) { |
d3685401 |
360 | $msg_alt = '(' . _("Answered") . ')'; |
361 | $msg_title = '(' . _("Answered") . ')'; |
6395c46d |
362 | $msg_icon .= '_reply'; |
363 | } |
55103ede |
364 | $td_str .= '<img src="' . $msg_icon . '.png" border="0" alt="'. $msg_alt . '" title="' . $msg_title . '" height="12" width="18" />'; |
6395c46d |
365 | $td_str .= '</small></b>'; |
366 | echo html_tag( 'td', |
0fdc2fb6 |
367 | $td_str, |
368 | 'right', |
369 | $hlt_color, |
370 | 'nowrap' ); |
8008456a |
371 | } |
6395c46d |
372 | |
373 | |
374 | // plain text message markers |
375 | // |
376 | else { |
377 | $stuff = false; |
378 | $td_str = "<b><small>"; |
03975a39 |
379 | if (isset($aFlags['\\answered']) && $aFlags['\\answered'] == true) { |
6395c46d |
380 | $td_str .= _("A"); |
8008456a |
381 | $stuff = true; |
382 | } |
03975a39 |
383 | if ($sType1 == 'mixed') { |
6395c46d |
384 | $td_str .= '+'; |
8008456a |
385 | $stuff = true; |
386 | } |
6395c46d |
387 | if ($default_use_priority) { |
03975a39 |
388 | if ( ($iPrio == 1) || ($iPrio == 2) ) { |
6395c46d |
389 | $td_str .= "<font color=\"$color[1]\">!</font>"; |
390 | $stuff = true; |
391 | } |
03975a39 |
392 | if ($iPrio == 5) { |
6395c46d |
393 | $td_str .= "<font color=\"$color[8]\">?</font>"; |
394 | $stuff = true; |
395 | } |
396 | } |
03975a39 |
397 | if (isset($aFlags['\\deleted']) && $aFlags['\\deleted'] == true) { |
6395c46d |
398 | $td_str .= "<font color=\"$color[1]\">D</font>"; |
399 | $stuff = true; |
400 | } |
401 | if (!$stuff) { |
402 | $td_str .= ' '; |
403 | } |
404 | $td_str .= '</small></b>'; |
405 | echo html_tag( 'td', |
0fdc2fb6 |
406 | $td_str, |
407 | 'center', |
408 | $hlt_color, |
409 | 'nowrap' ); |
8008456a |
410 | } |
8008456a |
411 | break; |
412 | case 6: /* size */ |
8008456a |
413 | echo html_tag( 'td', |
03975a39 |
414 | $bold . $fontstr . show_readable_size($iSize) . |
0fdc2fb6 |
415 | $fontstr_end . $bold_end, |
416 | 'right', |
417 | $hlt_color ); |
8008456a |
418 | break; |
419 | } |
ed230bc3 |
420 | ++$col; |
8008456a |
421 | } |
bdfb67f8 |
422 | } |
1c198ef7 |
423 | if ($last) { |
424 | echo '</tr>'."\n"; |
425 | } else { |
55103ede |
426 | echo '</tr>' . "\n" . '<tr><td colspan="' . $col . '" bgcolor="' . |
0fdc2fb6 |
427 | $color[0] . '" height="1"></td></tr>' . "\n"; |
6a622b59 |
428 | } |
e9e5f0fa |
429 | } |
430 | |
c7df3f1b |
431 | /** |
03975a39 |
432 | * Does the $sort $_GET var to field mapping |
0fdc2fb6 |
433 | * |
03975a39 |
434 | * @param int $sort Field to sort on |
435 | * @param bool $bServerSort Server sorting is true |
436 | * @param mixed $key UNDOCUMENTED |
437 | * @return string $sSortField Field tosort on |
0fdc2fb6 |
438 | */ |
03975a39 |
439 | function getSortField($sort,$bServerSort) { |
440 | switch($sort) { |
441 | case SQSORT_NONE: |
442 | $sSortField = 'UID'; |
443 | break; |
444 | case SQSORT_DATE_ASC: |
445 | case SQSORT_DATE_DEC: |
446 | $sSortField = 'DATE'; |
447 | break; |
448 | case SQSORT_FROM_ASC: |
449 | case SQSORT_FROM_DEC: |
450 | $sSortField = 'FROM'; |
451 | break; |
452 | case SQSORT_SUBJ_ASC: |
453 | case SQSORT_SUBJ_DEC: |
454 | $sSortField = 'SUBJECT'; |
455 | break; |
456 | case SQSORT_SIZE_ASC: |
457 | case SQSORT_SIZE_DEC: |
458 | $sSortField = ($bServerSort) ? 'SIZE' : 'RFC822.SIZE'; |
459 | break; |
460 | case SQSORT_TO_ASC: |
461 | case SQSORT_TO_DEC: |
462 | $sSortField = 'TO'; |
463 | break; |
464 | case SQSORT_CC_ASC: |
465 | case SQSORT_CC_DEC: |
466 | $sSortField = 'CC'; |
467 | break; |
468 | case SQSORT_INT_DATE_ASC: |
469 | case SQSORT_INT_DATE_DEC: |
470 | $sSortField = ($bServerSort) ? 'ARRIVAL' : 'INTERNALDATE'; |
471 | break; |
472 | default: $sSortField = 'DATE'; |
473 | break; |
fe6efa94 |
474 | } |
03975a39 |
475 | return $sSortField; |
e9e5f0fa |
476 | } |
477 | |
03975a39 |
478 | function get_sorted_msgs_list($imapConnection,$sort,$mode,&$error) { |
479 | $bDirection = ($sort % 2); |
480 | $error = false; |
481 | switch ($mode) { |
482 | case 'thread': |
483 | $id = get_thread_sort($imapConnection); |
484 | if ($id === false) { |
485 | $error = '<b><small><center><font color=red>' . |
486 | _("Thread sorting is not supported by your IMAP server.") . '<br />' . |
487 | _("Please report this to the system administrator."). |
488 | '</center></small></b>'; |
489 | } |
490 | break; |
491 | case 'server_sort': |
492 | $sSortField = getSortField($sort,true); |
493 | $id = sqimap_get_sort_order($imapConnection, $sSortField, $bDirection); |
494 | if ($id === false) { |
495 | $error = '<b><small><center><font color=red>' . |
496 | _( "Server-side sorting is not supported by your IMAP server.") . '<br />' . |
497 | _("Please report this to the system administrator."). |
498 | '</center></small></b>'; |
83cdc70b |
499 | } |
03975a39 |
500 | break; |
501 | default: |
502 | $sSortField = getSortField($sort,false); |
503 | $id = get_squirrel_sort($imapConnection, $sSortField, $bDirection); |
504 | break; |
e9e5f0fa |
505 | } |
03975a39 |
506 | return $id; |
e9e5f0fa |
507 | } |
508 | |
c7df3f1b |
509 | /** |
0fdc2fb6 |
510 | * This function loops through a group of messages in the mailbox |
511 | * and shows them to the user. |
512 | * |
513 | * @param mixed $imapConnection |
514 | * @param string $mailbox mail folder |
515 | * @param mixed $num_msgs |
516 | * @param mixed $start_msg |
517 | * @param mixed $sort |
518 | * @param mixed $color |
519 | * @param mixed $show_num |
520 | * @param mixed $use_cache |
521 | * @param mixed $mode |
522 | */ |
6a622b59 |
523 | function showMessagesForMailbox($imapConnection, $mailbox, $num_msgs, |
524 | $start_msg, $sort, $color, $show_num, |
fb75a74e |
525 | $use_cache, $mode='',$mbxresponse) { |
03975a39 |
526 | global $msgs, $msort, $auto_expunge, $thread_sort_messages,$server_sort_array, |
0fdc2fb6 |
527 | $allow_server_sort, $server_sort_order; |
1c198ef7 |
528 | /* if there's no messages in this folder */ |
529 | if ($mbxresponse['EXISTS'] == 0) { |
530 | $string = '<b>' . _("THIS FOLDER IS EMPTY") . '</b>'; |
531 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">'; |
532 | echo ' <tr><td>'; |
533 | echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'; |
534 | echo ' <tr><td><br />'; |
535 | echo ' <table cellpadding="1" cellspacing="5" align="center" border="0">'; |
536 | echo ' <tr>' . html_tag( 'td', $string."\n", 'left') |
537 | . '</tr>'; |
538 | echo ' </table>'; |
539 | echo ' <br /></td></tr>'; |
540 | echo ' </table></td></tr>'; |
541 | echo ' </table>'; |
542 | return; |
543 | } |
544 | |
6a622b59 |
545 | if ($mbxresponse['EXISTS'] > 0) { |
546 | /* if $start_msg is lower than $num_msgs, we probably deleted all messages |
0fdc2fb6 |
547 | * in the last page. We need to re-adjust the start_msg |
548 | */ |
aa0da530 |
549 | |
6a622b59 |
550 | if($start_msg > $num_msgs) { |
551 | $start_msg -= $show_num; |
552 | if($start_msg < 1) { |
553 | $start_msg = 1; |
554 | } |
e9e5f0fa |
555 | } |
4e9f35e4 |
556 | |
6a622b59 |
557 | /* This code and the next if() block check for |
0fdc2fb6 |
558 | * server-side sorting methods. The $id array is |
559 | * formatted and $sort is set to 6 to disable |
560 | * SM internal sorting |
561 | */ |
6a622b59 |
562 | |
563 | if ($thread_sort_messages == 1) { |
564 | $mode = 'thread'; |
03975a39 |
565 | } else if ($allow_server_sort == 1) { |
566 | $mode = 'server_sort'; |
6a622b59 |
567 | } else { |
568 | $mode = ''; |
569 | } |
8008456a |
570 | |
03975a39 |
571 | if (isset($mbxresponse['SORT_ARRAY']) && is_array($mbxresponse['SORT_ARRAY'])) { |
572 | $id = $mbxresponse['SORT_ARRAY']; |
573 | if (sqsession_is_registered('msgs')) { |
574 | sqsession_unregister('msgs'); |
575 | } |
576 | $id_slice = array_slice($id,$start_msg-1, $show_num); |
577 | if (count($id_slice)) { |
578 | $msgs = sqimap_get_small_header_list($imapConnection,$id_slice,$show_num); |
579 | } else { |
580 | return false; |
581 | } |
582 | sqsession_register($msgs, 'msgs'); |
583 | } else { |
584 | if (sqsession_is_registered('server_sort_array')) { |
585 | sqsession_unregister('server_sort_array'); |
586 | } |
587 | $id = get_sorted_msgs_list($imapConnection,$sort,$mode,$error); |
588 | if ($id !== false) { |
589 | sqsession_register($id, 'server_sort_array'); |
590 | $id_slice = array_slice($id,$start_msg-1, $show_num); |
591 | if (count($id_slice)) { |
592 | $msgs = sqimap_get_small_header_list($imapConnection,$id_slice,$show_num); |
6a622b59 |
593 | } else { |
03975a39 |
594 | return false; |
6a622b59 |
595 | } |
03975a39 |
596 | sqsession_register($msgs, 'msgs'); |
597 | } else { |
598 | echo $error; |
599 | return false; |
600 | } |
7b73b809 |
601 | |
03975a39 |
602 | } |
6a622b59 |
603 | } /* if exists > 0 */ |
604 | |
605 | $res = getEndMessage($start_msg, $show_num, $num_msgs); |
606 | $start_msg = $res[0]; |
607 | $end_msg = $res[1]; |
608 | |
609 | $paginator_str = get_paginator_str($mailbox, $start_msg, $end_msg, |
0fdc2fb6 |
610 | $num_msgs, $show_num, $sort); |
6a622b59 |
611 | |
612 | $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs); |
613 | |
614 | do_hook('mailbox_index_before'); |
abafb676 |
615 | ?> |
616 | <table border="0" width="100%" cellpadding="0" cellspacing="0"> |
0fdc2fb6 |
617 | <tr> |
abafb676 |
618 | <td> |
0fdc2fb6 |
619 | <?php mail_message_listing_beginning($imapConnection, $mbxresponse, $mailbox, $sort, |
620 | $msg_cnt_str, $paginator_str, $start_msg); ?> |
abafb676 |
621 | </td> |
0fdc2fb6 |
622 | </tr> |
623 | <tr><td height="5" bgcolor="<?php echo $color[4]; ?>"></td></tr> |
624 | <tr> |
abafb676 |
625 | <td> |
0fdc2fb6 |
626 | <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[9]; ?>"> |
abafb676 |
627 | <tr> |
0fdc2fb6 |
628 | <td> |
abafb676 |
629 | <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>"> |
0fdc2fb6 |
630 | <tr> |
abafb676 |
631 | <td> |
0fdc2fb6 |
632 | <?php |
03975a39 |
633 | printHeader($mailbox, $sort, $color, !$thread_sort_messages, $start_msg); |
4669e892 |
634 | displayMessageArray($imapConnection, $num_msgs, $start_msg, |
03975a39 |
635 | $id, $msgs, $mailbox, $sort, $show_num,0,0); |
0fdc2fb6 |
636 | ?> |
abafb676 |
637 | </td> |
0fdc2fb6 |
638 | </tr> |
abafb676 |
639 | </table> |
0fdc2fb6 |
640 | </td> |
abafb676 |
641 | </tr> |
0fdc2fb6 |
642 | </table> |
643 | <?php |
4669e892 |
644 | mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color); |
0fdc2fb6 |
645 | ?> |
abafb676 |
646 | </td> |
0fdc2fb6 |
647 | </tr> |
abafb676 |
648 | </table> |
649 | <?php |
8415b2d3 |
650 | //$t = elapsed($start); |
46a49f65 |
651 | //echo("elapsed time = $t seconds\n"); |
6c930ade |
652 | } |
bdfb67f8 |
653 | |
e9e5f0fa |
654 | |
c7df3f1b |
655 | /** |
0fdc2fb6 |
656 | * Generic function to convert the msgs array into an HTML table. |
657 | * |
658 | * @param resource $imapConnection |
659 | * @param int $num_msgs total number of messages in the mailbox |
660 | * @param int $start_msg offset in messages to sisplay |
661 | * @param array $msort sorted array which is used to map the index to the unsorted $msgs index |
662 | * @param string $mailbox mail folder name |
663 | * @param int $sort sort order. 6 means no sorting or server side / thread sort |
664 | * @param array $color |
665 | * @param int $show_num number of messages to show |
666 | * @param mixed $where |
667 | * @param mixed $what |
668 | */ |
669 | |
670 | // fix me: |
671 | // $color not used |
672 | // remove thread stuff |
673 | // remove $msgs global and add it as argument (i hate globals) |
6a622b59 |
674 | function displayMessageArray($imapConnection, $num_msgs, $start_msg, |
03975a39 |
675 | $id, $msgs, $mailbox, $sort, |
0fdc2fb6 |
676 | $show_num, $where=0, $what=0) { |
a966982b |
677 | |
1c198ef7 |
678 | // if client side sorting and no sort we only fetch num_msgs so the start_msg in the $msgs |
679 | // array must be corrected |
03975a39 |
680 | $i = $start_msg -1; |
6a622b59 |
681 | |
682 | /* |
0fdc2fb6 |
683 | * Loop through and display the info for each message. |
684 | * ($t is used for the checkbox number) |
685 | */ |
03975a39 |
686 | |
0fdc2fb6 |
687 | $iEnd = $i + $show_num; |
1c198ef7 |
688 | for ($j=$i,$t=0;$j<$iEnd;++$j) { |
03975a39 |
689 | if (isset($id[$j])) { |
690 | $last = (isset($id[$j+1]) || $j == $iEnd) ? false : true; |
691 | $msg = $msgs[$id[$j]]; |
0fdc2fb6 |
692 | printMessageInfo($t, $last, $msg, $mailbox, |
1c198ef7 |
693 | $start_msg, $where, $what); |
0fdc2fb6 |
694 | ++$t; |
6a622b59 |
695 | } else { |
1c198ef7 |
696 | break; |
6a622b59 |
697 | } |
94ac35c6 |
698 | } |
bdfb67f8 |
699 | } |
700 | |
c7df3f1b |
701 | /** |
0fdc2fb6 |
702 | * Displays the standard message list header. |
703 | * |
704 | * To finish the table, you need to do a "</table></table>"; |
705 | * |
706 | * @param mixed $imapConnection |
707 | * @param array $mbxresponse the array with the results of SELECT against the current mailbox |
708 | * @param string $mailbox the current mailbox |
709 | * @param mixed $sort the current sorting method (-1 for no sorting available [searches]) |
710 | * @param mixed $msg_cnt_str |
711 | * @param mixed $paginator |
712 | * @param mixed $start_msg |
713 | */ |
6a622b59 |
714 | function mail_message_listing_beginning ($imapConnection, |
0fdc2fb6 |
715 | $mbxresponse, |
716 | $mailbox = '', $sort = -1, |
717 | $msg_cnt_str = '', |
718 | $paginator = ' ', |
719 | $start_msg = 1) { |
fd181f53 |
720 | global $color, $auto_expunge, $base_uri, $show_flag_buttons, |
0fdc2fb6 |
721 | $allow_server_sort, $server_sort_order, |
722 | $PHP_SELF, $allow_thread_sort, $thread_sort_messages; |
6a622b59 |
723 | |
724 | $php_self = $PHP_SELF; |
725 | /* fix for incorrect $PHP_SELF */ |
726 | if (strpos($php_self, 'move_messages.php')) { |
727 | $php_self = str_replace('move_messages.php', 'right_main.php', $php_self); |
728 | } |
729 | $urlMailbox = urlencode($mailbox); |
e35045b7 |
730 | |
6a622b59 |
731 | if (preg_match('/^(.+)\?.+$/',$php_self,$regs)) { |
732 | $source_url = $regs[1]; |
733 | } else { |
734 | $source_url = $php_self; |
735 | } |
736 | |
737 | if (!isset($msg)) { |
738 | $msg = ''; |
739 | } |
abafb676 |
740 | |
741 | if (!strpos($php_self,'?')) { |
742 | $location = $php_self.'?mailbox=INBOX&startMessage=1'; |
743 | } else { |
744 | $location = $php_self; |
745 | } |
746 | |
b531f8ea |
747 | $moveFields = addHidden('msg', $msg). |
0fdc2fb6 |
748 | addHidden('mailbox', $mailbox). |
749 | addHidden('startMessage', $start_msg). |
750 | addHidden('location', $location); |
8fe969f6 |
751 | |
5e0539cd |
752 | /* build thread sorting links */ |
753 | if ($allow_thread_sort == TRUE) { |
0fdc2fb6 |
754 | if ($thread_sort_messages == 1 ) { |
5e0539cd |
755 | $set_thread = 2; |
756 | $thread_name = _("Unthread View"); |
0fdc2fb6 |
757 | } elseif ($thread_sort_messages == 0) { |
5e0539cd |
758 | $set_thread = 1; |
759 | $thread_name = _("Thread View"); |
0fdc2fb6 |
760 | } |
761 | $thread_link_str = '<small>[<a href="' . $source_url . '?sort=' |
762 | . $sort . '&start_messages=1&set_thread=' . $set_thread |
763 | . '&mailbox=' . urlencode($mailbox) . '">' . $thread_name |
764 | . '</a>]</small>'; |
5e0539cd |
765 | } |
766 | else |
767 | $thread_link_str =''; |
768 | |
6a622b59 |
769 | /* |
0fdc2fb6 |
770 | * This is the beginning of the message list table. |
771 | * It wraps around all messages |
772 | */ |
3027826a |
773 | $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $mailbox); |
774 | $form_name = "FormMsgs" . $safe_name; |
3da12e67 |
775 | |
3027826a |
776 | echo '<form name="' . $form_name . '" method="post" action="move_messages.php">' ."\n" |
0fdc2fb6 |
777 | . $moveFields; |
abafb676 |
778 | ?> |
0fdc2fb6 |
779 | <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>"> |
abafb676 |
780 | <tr> |
0fdc2fb6 |
781 | <td> |
abafb676 |
782 | <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0"> |
0fdc2fb6 |
783 | <tr> |
74091b64 |
784 | <td align="left"><small><?php echo $paginator . $thread_link_str; ?></small></td> |
d8a255fe |
785 | <td align="center"></td> |
abafb676 |
786 | <td align="right"><small><?php echo $msg_cnt_str; ?></small></td> |
0fdc2fb6 |
787 | </tr> |
abafb676 |
788 | </table> |
0fdc2fb6 |
789 | </td> |
abafb676 |
790 | </tr> |
791 | <tr width="100%" cellpadding="1" cellspacing="0" border="0" bgcolor="<?php echo $color[0]; ?>"> |
0fdc2fb6 |
792 | <td> |
abafb676 |
793 | <table border="0" width="100%" cellpadding="1" cellspacing="0"> |
0fdc2fb6 |
794 | <tr> |
abafb676 |
795 | <td align="left"> |
0fdc2fb6 |
796 | <small><?php |
4669e892 |
797 | |
fd181f53 |
798 | // display flag buttons only if supported |
4669e892 |
799 | if ($show_flag_buttons && $mbxresponse != NULL && |
0fdc2fb6 |
800 | array_search('\\flagged',$mbxresponse['PERMANENTFLAGS'], true) !== FALSE) { |
1a531551 |
801 | echo getButton('SUBMIT', 'markUnflagged',_("Unflag")); |
fd181f53 |
802 | echo getButton('SUBMIT', 'markFlagged',_("Flag")); |
803 | echo ' '; |
fd181f53 |
804 | } |
4669e892 |
805 | if (array_search('\\seen',$mbxresponse['PERMANENTFLAGS'], true) !== FALSE) { |
806 | echo getButton('SUBMIT', 'markUnread',_("Unread")); |
807 | echo getButton('SUBMIT', 'markRead',_("Read")); |
808 | echo ' '; |
809 | } |
98a9cc03 |
810 | |
abafb676 |
811 | echo getButton('SUBMIT', 'attache',_("Forward")); |
812 | echo ' '; |
4669e892 |
813 | if (array_search('\\deleted',$mbxresponse['PERMANENTFLAGS'], true) !== FALSE) { |
814 | echo getButton('SUBMIT', 'delete',_("Delete")); |
815 | echo '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash"); |
816 | echo ' '; |
817 | } |
818 | if (!$auto_expunge && $mbxresponse['RIGHTS'] != 'READ-ONLY') { |
0fdc2fb6 |
819 | echo getButton('SUBMIT', 'expungeButton',_("Expunge")) .' ' . _("mailbox") . "\n"; |
820 | echo ' '; |
abafb676 |
821 | } |
822 | do_hook('mailbox_display_buttons'); |
0fdc2fb6 |
823 | ?></small> |
abafb676 |
824 | </td> |
4669e892 |
825 | <?php |
826 | if (array_search('\\deleted',$mbxresponse['PERMANENTFLAGS'], true) !== FALSE) { |
827 | echo '<td align="right"> |
0fdc2fb6 |
828 | <small>'; |
5e0539cd |
829 | //echo $thread_link_str; //previous behaviour |
4669e892 |
830 | getMbxList($imapConnection); |
831 | echo getButton('SUBMIT', 'moveButton',_("Move")) . "\n |
0fdc2fb6 |
832 | </small>"; |
4669e892 |
833 | } |
834 | ?> |
abafb676 |
835 | </td> |
0fdc2fb6 |
836 | </tr> |
abafb676 |
837 | </table> |
0fdc2fb6 |
838 | </td> |
abafb676 |
839 | </tr> |
0fdc2fb6 |
840 | </table> |
a966982b |
841 | |
abafb676 |
842 | <?php |
1b91be0c |
843 | do_hook('mailbox_form_before'); |
6c766fd5 |
844 | |
8008456a |
845 | /* if using server sort we highjack the |
0fdc2fb6 |
846 | * the $sort var and use $server_sort_order |
847 | * instead. but here we reset sort for a bit |
848 | * since its easy |
849 | */ |
8008456a |
850 | if ($allow_server_sort == TRUE) { |
851 | $sort = $server_sort_order; |
852 | } |
e9e5f0fa |
853 | } |
a966982b |
854 | |
c7df3f1b |
855 | /** |
0fdc2fb6 |
856 | * FIXME: Undocumented function |
857 | * |
858 | * @param mixed $num_msgs |
859 | * @param mixed $paginator_str |
860 | * @param mixed $msg_cnt_str |
861 | * @param mixed $color |
862 | */ |
e9e5f0fa |
863 | function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str, $color) { |
0fdc2fb6 |
864 | if ($num_msgs) { |
4b920601 |
865 | /* space between list and footer */ |
abafb676 |
866 | ?> |
0fdc2fb6 |
867 | <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr> |
868 | <tr> |
abafb676 |
869 | <td> |
0fdc2fb6 |
870 | <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>"> |
abafb676 |
871 | <tr> |
0fdc2fb6 |
872 | <td> |
abafb676 |
873 | <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0"> |
0fdc2fb6 |
874 | <tr> |
abafb676 |
875 | <td align="left"><small><?php echo $paginator_str; ?></small></td> |
876 | <td align="right"><small><?php echo $msg_cnt_str; ?></small></td> |
0fdc2fb6 |
877 | </tr> |
abafb676 |
878 | </table> |
0fdc2fb6 |
879 | </td> |
abafb676 |
880 | </tr> |
0fdc2fb6 |
881 | </table> |
abafb676 |
882 | </td> |
0fdc2fb6 |
883 | </tr> |
abafb676 |
884 | <?php |
0fdc2fb6 |
885 | } |
6a622b59 |
886 | /* End of message-list table */ |
a966982b |
887 | |
6a622b59 |
888 | do_hook('mailbox_index_after'); |
c7df3f1b |
889 | echo "</form>\n"; |
a966982b |
890 | } |
891 | |
c7df3f1b |
892 | /** |
0fdc2fb6 |
893 | * FIXME: Undocumented function |
894 | * |
895 | * @param string $mailbox |
896 | * @param mixed $sort |
897 | * @param mixed $color |
898 | * @param bool $showsort |
899 | * @param mixed $start_msg |
900 | */ |
97006a72 |
901 | function printHeader($mailbox, $sort, $color, $showsort=true, $start_msg=1) { |
03975a39 |
902 | global $index_order, $internal_date_sort; |
1b91be0c |
903 | echo html_tag( 'tr' ,'' , 'center', $color[5] ); |
e4b5f9d1 |
904 | |
905 | /* calculate the width of the subject column based on the |
0fdc2fb6 |
906 | * widths of the other columns */ |
e4b5f9d1 |
907 | $widths = array(1=>1,2=>25,3=>5,4=>0,5=>1,6=>5); |
908 | $subjectwidth = 100; |
909 | foreach($index_order as $item) { |
4669e892 |
910 | $subjectwidth -= $widths[$item]; |
e4b5f9d1 |
911 | } |
912 | |
913 | foreach ($index_order as $item) { |
914 | switch ($item) { |
8008456a |
915 | case 1: /* checkbox */ |
3da12e67 |
916 | echo html_tag( 'td',get_selectall_link($start_msg, $sort, $mailbox) , '', '', 'width="1%"' ); |
abafb676 |
917 | break; |
8008456a |
918 | case 5: /* flags */ |
abafb676 |
919 | echo html_tag( 'td','' , '', '', 'width="1%"' ); |
8008456a |
920 | break; |
921 | case 2: /* from */ |
922 | if (handleAsSent($mailbox)) { |
1b91be0c |
923 | echo html_tag( 'td' ,'' , 'left', '', 'width="25%"' ) |
0fdc2fb6 |
924 | . '<b>' . _("To") . '</b>'; |
03975a39 |
925 | if ($showsort) { |
926 | ShowSortButton($sort, $mailbox, SQSORT_TO_ASC, SQSORT_TO_DEC); |
927 | } |
8008456a |
928 | } else { |
1b91be0c |
929 | echo html_tag( 'td' ,'' , 'left', '', 'width="25%"' ) |
0fdc2fb6 |
930 | . '<b>' . _("From") . '</b>'; |
03975a39 |
931 | if ($showsort) { |
932 | ShowSortButton($sort, $mailbox, SQSORT_FROM_ASC, SQSORT_FROM_DEC); |
933 | } |
8008456a |
934 | } |
1b91be0c |
935 | echo "</td>\n"; |
8008456a |
936 | break; |
937 | case 3: /* date */ |
1b91be0c |
938 | echo html_tag( 'td' ,'' , 'left', '', 'width="5%" nowrap' ) |
0fdc2fb6 |
939 | . '<b>' . _("Date") . '</b>'; |
a966982b |
940 | if ($showsort) { |
03975a39 |
941 | if ($internal_date_sort) { |
942 | ShowSortButton($sort, $mailbox, SQSORT_INT_DATE_ASC, SQSORT_INT_DATE_DEC); |
943 | } else { |
944 | ShowSortButton($sort, $mailbox, SQSORT_DATE_ASC, SQSORT_DATE_DEC); |
945 | } |
8008456a |
946 | } |
1b91be0c |
947 | echo "</td>\n"; |
8008456a |
948 | break; |
a966982b |
949 | case 4: /* subject */ |
e4b5f9d1 |
950 | echo html_tag( 'td' ,'' , 'left', '', 'width="'.$subjectwidth.'%"' ) |
0fdc2fb6 |
951 | . '<b>' . _("Subject") . '</b>'; |
a966982b |
952 | if ($showsort) { |
03975a39 |
953 | ShowSortButton($sort, $mailbox, SQSORT_SUBJ_ASC, SQSORT_SUBJ_DEC); |
8008456a |
954 | } |
1b91be0c |
955 | echo "</td>\n"; |
8008456a |
956 | break; |
957 | case 6: /* size */ |
03975a39 |
958 | echo html_tag( 'td', '', 'center','','width="5%" nowrap') |
959 | . '<b>' . _("Size") . '</b>'; |
960 | if ($showsort) { |
961 | ShowSortButton($sort, $mailbox, SQSORT_SIZE_ASC, SQSORT_SIZE_DEC); |
962 | } |
963 | echo "</td>\n"; |
8008456a |
964 | break; |
965 | } |
bdfb67f8 |
966 | } |
1b91be0c |
967 | echo "</tr>\n"; |
bdfb67f8 |
968 | } |
969 | |
e9e5f0fa |
970 | |
c7df3f1b |
971 | /** |
0fdc2fb6 |
972 | * This function shows the sort button. Isn't this a good comment? |
973 | * |
974 | * @param mixed $sort |
975 | * @param string $mailbox |
976 | * @param mixed $Down |
977 | * @param mixed $Up |
978 | */ |
94a4ea53 |
979 | function ShowSortButton($sort, $mailbox, $Down, $Up ) { |
6a622b59 |
980 | global $PHP_SELF; |
94a4ea53 |
981 | |
6a622b59 |
982 | /* Figure out which image we want to use. */ |
983 | if ($sort != $Up && $sort != $Down) { |
984 | $img = 'sort_none.png'; |
985 | $which = $Up; |
986 | } elseif ($sort == $Up) { |
987 | $img = 'up_pointer.png'; |
988 | $which = $Down; |
6c930ade |
989 | } else { |
6a622b59 |
990 | $img = 'down_pointer.png'; |
03975a39 |
991 | $which = 0; |
e35045b7 |
992 | } |
6a622b59 |
993 | |
994 | if (preg_match('/^(.+)\?.+$/',$PHP_SELF,$regs)) { |
995 | $source_url = $regs[1]; |
e35045b7 |
996 | } else { |
6a622b59 |
997 | $source_url = $PHP_SELF; |
6c930ade |
998 | } |
6a622b59 |
999 | |
1000 | /* Now that we have everything figured out, show the actual button. */ |
1001 | echo ' <a href="' . $source_url .'?newsort=' . $which |
0fdc2fb6 |
1002 | . '&startMessage=1&mailbox=' . urlencode($mailbox) |
1003 | . '"><img src="../images/' . $img |
1004 | . '" border="0" width="12" height="10" alt="sort" title="' |
1005 | . _("Click here to change the sorting of the message list") .' /"></a>'; |
6a622b59 |
1006 | } |
1007 | |
c7df3f1b |
1008 | /** |
0fdc2fb6 |
1009 | * FIXME: Undocumented function |
1010 | * |
1011 | * @param mixed $start_msg |
1012 | * @param mixed $sort |
1013 | * @param string $mailbox |
1014 | */ |
3da12e67 |
1015 | function get_selectall_link($start_msg, $sort, $mailbox) { |
1016 | global $checkall, $what, $where, $javascript_on; |
6a622b59 |
1017 | global $PHP_SELF, $PG_SHOWNUM; |
1018 | |
1019 | $result = ''; |
1020 | if ($javascript_on) { |
3027826a |
1021 | $safe_name = preg_replace("/[^0-9A-Za-z_]/", '_', $mailbox); |
1022 | $func_name = "CheckAll" . $safe_name; |
1023 | $form_name = "FormMsgs" . $safe_name; |
6a622b59 |
1024 | $result = '<script language="JavaScript" type="text/javascript">' |
1025 | . "\n<!-- \n" |
3027826a |
1026 | . "function " . $func_name . "() {\n" |
1027 | . " for (var i = 0; i < document." . $form_name . ".elements.length; i++) {\n" |
3962deff |
1028 | . " if(document." . $form_name . ".elements[i].type == 'checkbox' && " |
e0b57c62 |
1029 | . " document." . $form_name . ".elements[i].name.substring(0,3) == 'msg'){\n" |
3027826a |
1030 | . " document." . $form_name . ".elements[i].checked = " |
1031 | . " !(document." . $form_name . ".elements[i].checked);\n" |
6a622b59 |
1032 | . " }\n" |
1033 | . " }\n" |
1034 | . "}\n" |
1035 | . "//-->\n" |
abafb676 |
1036 | . '</script>' |
c7df3f1b |
1037 | . '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="'.$func_name.'();" />'; |
abafb676 |
1038 | // . <a href="javascript:void(0)" onClick="' . $func_name . '();">' . _("Toggle All") |
1039 | // . "</a>\n"; |
e35045b7 |
1040 | } else { |
6a622b59 |
1041 | if (strpos($PHP_SELF, "?")) { |
1042 | $result .= "<a href=\"$PHP_SELF&mailbox=" . urlencode($mailbox) |
1043 | . "&startMessage=$start_msg&sort=$sort&checkall="; |
1044 | } else { |
1045 | $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox) |
1046 | . "&startMessage=$start_msg&sort=$sort&checkall="; |
1047 | } |
1048 | if (isset($checkall) && $checkall == '1') { |
1049 | $result .= '0'; |
1050 | } else { |
1051 | $result .= '1'; |
1052 | } |
1053 | |
1054 | if (isset($where) && isset($what)) { |
1055 | $result .= '&where=' . urlencode($where) |
1056 | . '&what=' . urlencode($what); |
1057 | } |
1058 | $result .= "\">"; |
98a9cc03 |
1059 | $result .= _("All"); |
c7df3f1b |
1060 | $result .= "</a>\n"; |
e35045b7 |
1061 | } |
23d6bd09 |
1062 | |
6a622b59 |
1063 | /* Return our final result. */ |
1064 | return ($result); |
bdfb67f8 |
1065 | } |
1a0e0983 |
1066 | |
c7df3f1b |
1067 | /** |
0fdc2fb6 |
1068 | * This function computes the "Viewing Messages..." string. |
1069 | * |
1070 | * @param integer $start_msg first message number |
1071 | * @param integer $end_msg last message number |
1072 | * @param integer $num_msgs total number of message in folder |
1073 | * @return string |
1074 | */ |
bdfb67f8 |
1075 | function get_msgcnt_str($start_msg, $end_msg, $num_msgs) { |
6a622b59 |
1076 | /* Compute the $msg_cnt_str. */ |
1077 | $result = ''; |
1078 | if ($start_msg < $end_msg) { |
c7df3f1b |
1079 | $result = sprintf(_("Viewing Messages: %s to %s (%s total)"), |
0fdc2fb6 |
1080 | '<b>'.$start_msg.'</b>', '<b>'.$end_msg.'</b>', $num_msgs); |
6a622b59 |
1081 | } else if ($start_msg == $end_msg) { |
c7df3f1b |
1082 | $result = sprintf(_("Viewing Message: %s (1 total)"), '<b>'.$start_msg.'</b>'); |
6a622b59 |
1083 | } else { |
c7df3f1b |
1084 | $result = '<br />'; |
6a622b59 |
1085 | } |
1086 | /* Return our result string. */ |
1087 | return ($result); |
bdfb67f8 |
1088 | } |
1089 | |
c7df3f1b |
1090 | /** |
0fdc2fb6 |
1091 | * Generate a paginator link. |
1092 | * |
1093 | * @param mixed $box |
1094 | * @param mixed $start_msg |
1095 | * @param mixed $use |
1096 | * @param string $text text used for paginator link |
1097 | * @return string |
1098 | */ |
6c930ade |
1099 | function get_paginator_link($box, $start_msg, $use, $text) { |
e35045b7 |
1100 | |
c7df3f1b |
1101 | $result = "<a href=\"right_main.php?use_mailbox_cache=$use" |
6a622b59 |
1102 | . "&startMessage=$start_msg&mailbox=$box\" " |
c7df3f1b |
1103 | . ">$text</a>"; |
6a622b59 |
1104 | |
6a622b59 |
1105 | return ($result); |
7b294953 |
1106 | } |
1107 | |
c7df3f1b |
1108 | /** |
0fdc2fb6 |
1109 | * This function computes the paginator string. |
1110 | * |
1111 | * @param mixed $box |
1112 | * @param mixed $start_msg |
1113 | * @param mixed $end_msg |
1114 | * @param integer $num_msgs |
1115 | * @param mixed $show_num |
1116 | * @param mixed $sort |
1117 | */ |
6a622b59 |
1118 | function get_paginator_str($box, $start_msg, $end_msg, $num_msgs, |
0fdc2fb6 |
1119 | $show_num, $sort) { |
dcc1cc82 |
1120 | global $username, $data_dir, $use_mailbox_cache, $color, $PG_SHOWNUM; |
6a622b59 |
1121 | |
1122 | /* Initialize paginator string chunks. */ |
1123 | $prv_str = ''; |
1124 | $nxt_str = ''; |
eac26493 |
1125 | $pg_str = ''; |
6a622b59 |
1126 | $all_str = ''; |
6a622b59 |
1127 | |
1128 | $box = urlencode($box); |
1129 | |
1130 | /* Create simple strings that will be creating the paginator. */ |
1131 | $spc = ' '; /* This will be used as a space. */ |
1132 | $sep = '|'; /* This will be used as a seperator. */ |
1133 | |
1134 | /* Get some paginator preference values. */ |
1135 | $pg_sel = getPref($data_dir, $username, 'page_selector', SMPREF_ON); |
1136 | $pg_max = getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX); |
1137 | |
1138 | /* Make sure that our start message number is not too big. */ |
1139 | $start_msg = min($start_msg, $num_msgs); |
1140 | |
1141 | /* Decide whether or not we will use the mailbox cache. */ |
1142 | /* Not sure why $use_mailbox_cache is even passed in. */ |
1143 | if ($sort == 6) { |
1144 | $use = 0; |
1145 | } else { |
1146 | $use = 1; |
1147 | } |
1148 | |
1149 | /* Compute the starting message of the previous and next page group. */ |
1150 | $next_grp = $start_msg + $show_num; |
1151 | $prev_grp = $start_msg - $show_num; |
1152 | |
1153 | /* Compute the basic previous and next strings. */ |
1154 | if (($next_grp <= $num_msgs) && ($prev_grp >= 0)) { |
1155 | $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous")); |
1156 | $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next")); |
1157 | } else if (($next_grp > $num_msgs) && ($prev_grp >= 0)) { |
1158 | $prv_str = get_paginator_link($box, $prev_grp, $use, _("Previous")); |
abafb676 |
1159 | $nxt_str = _("Next"); |
6a622b59 |
1160 | } else if (($next_grp <= $num_msgs) && ($prev_grp < 0)) { |
abafb676 |
1161 | $prv_str = _("Previous"); |
6a622b59 |
1162 | $nxt_str = get_paginator_link($box, $next_grp, $use, _("Next")); |
1163 | } |
1164 | |
1165 | /* Page selector block. Following code computes page links. */ |
1166 | if ($pg_sel && ($num_msgs > $show_num)) { |
1167 | /* Most importantly, what is the current page!!! */ |
1168 | $cur_pg = intval($start_msg / $show_num) + 1; |
1169 | |
1170 | /* Compute total # of pages and # of paginator page links. */ |
1171 | $tot_pgs = ceil($num_msgs / $show_num); /* Total number of Pages */ |
1172 | $vis_pgs = min($pg_max, $tot_pgs - 1); /* Visible Pages */ |
1173 | |
1174 | /* Compute the size of the four quarters of the page links. */ |
1175 | |
1176 | /* If we can, just show all the pages. */ |
1177 | if (($tot_pgs - 1) <= $pg_max) { |
1178 | $q1_pgs = $cur_pg - 1; |
1179 | $q2_pgs = $q3_pgs = 0; |
1180 | $q4_pgs = $tot_pgs - $cur_pg; |
1181 | |
e35045b7 |
1182 | /* Otherwise, compute some magic to choose the four quarters. */ |
6a622b59 |
1183 | } else { |
1184 | /* |
0fdc2fb6 |
1185 | * Compute the magic base values. Added together, |
1186 | * these values will always equal to the $pag_pgs. |
1187 | * NOTE: These are DEFAULT values and do not take |
1188 | * the current page into account. That is below. |
1189 | */ |
6a622b59 |
1190 | $q1_pgs = floor($vis_pgs/4); |
1191 | $q2_pgs = round($vis_pgs/4, 0); |
1192 | $q3_pgs = ceil($vis_pgs/4); |
1193 | $q4_pgs = round(($vis_pgs - $q2_pgs)/3, 0); |
1194 | |
1195 | /* Adjust if the first quarter contains the current page. */ |
1196 | if (($cur_pg - $q1_pgs) < 1) { |
1197 | $extra_pgs = ($q1_pgs - ($cur_pg - 1)) + $q2_pgs; |
1198 | $q1_pgs = $cur_pg - 1; |
1199 | $q2_pgs = 0; |
1200 | $q3_pgs += ceil($extra_pgs / 2); |
1201 | $q4_pgs += floor($extra_pgs / 2); |
1202 | |
1203 | /* Adjust if the first and second quarters intersect. */ |
1204 | } else if (($cur_pg - $q2_pgs - ceil($q2_pgs/3)) <= $q1_pgs) { |
1205 | $extra_pgs = $q2_pgs; |
176204a5 |
1206 | $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 3/4); |
1207 | $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 3/4); |
6a622b59 |
1208 | $q3_pgs += ceil($extra_pgs / 2); |
1209 | $q4_pgs += floor($extra_pgs / 2); |
1210 | |
1211 | /* Adjust if the fourth quarter contains the current page. */ |
1212 | } else if (($cur_pg + $q4_pgs) >= $tot_pgs) { |
1213 | $extra_pgs = ($q4_pgs - ($tot_pgs - $cur_pg)) + $q3_pgs; |
1214 | $q3_pgs = 0; |
1215 | $q4_pgs = $tot_pgs - $cur_pg; |
1216 | $q1_pgs += floor($extra_pgs / 2); |
1217 | $q2_pgs += ceil($extra_pgs / 2); |
1218 | |
1219 | /* Adjust if the third and fourth quarter intersect. */ |
1220 | } else if (($cur_pg + $q3_pgs + 1) >= ($tot_pgs - $q4_pgs + 1)) { |
1221 | $extra_pgs = $q3_pgs; |
176204a5 |
1222 | $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 3/4); |
1223 | $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 3/4); |
6a622b59 |
1224 | $q1_pgs += floor($extra_pgs / 2); |
1225 | $q2_pgs += ceil($extra_pgs / 2); |
1226 | } |
1227 | } |
e35045b7 |
1228 | |
6a622b59 |
1229 | /* |
0fdc2fb6 |
1230 | * I am leaving this debug code here, commented out, because |
1231 | * it is a really nice way to see what the above code is doing. |
1232 | * echo "qts = $q1_pgs/$q2_pgs/$q3_pgs/$q4_pgs = " |
1233 | * . ($q1_pgs + $q2_pgs + $q3_pgs + $q4_pgs) . '<br />'; |
1234 | */ |
6a622b59 |
1235 | |
1236 | /* Print out the page links from the compute page quarters. */ |
1237 | |
1238 | /* Start with the first quarter. */ |
1239 | if (($q1_pgs == 0) && ($cur_pg > 1)) { |
1240 | $pg_str .= "...$spc"; |
1241 | } else { |
1242 | for ($pg = 1; $pg <= $q1_pgs; ++$pg) { |
1243 | $start = (($pg-1) * $show_num) + 1; |
1244 | $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc; |
1245 | } |
1246 | if ($cur_pg - $q2_pgs - $q1_pgs > 1) { |
1247 | $pg_str .= "...$spc"; |
1248 | } |
1249 | } |
1250 | |
1251 | /* Continue with the second quarter. */ |
1252 | for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) { |
1253 | $start = (($pg-1) * $show_num) + 1; |
1254 | $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc; |
1255 | } |
1256 | |
1257 | /* Now print the current page. */ |
1258 | $pg_str .= $cur_pg . $spc; |
1259 | |
1260 | /* Next comes the third quarter. */ |
1261 | for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) { |
1262 | $start = (($pg-1) * $show_num) + 1; |
1263 | $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc; |
1264 | } |
1265 | |
1266 | /* And last, print the forth quarter page links. */ |
1267 | if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) { |
1268 | $pg_str .= "...$spc"; |
1269 | } else { |
1270 | if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) { |
1271 | $pg_str .= "...$spc"; |
1272 | } |
1273 | for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) { |
1274 | $start = (($pg-1) * $show_num) + 1; |
1275 | $pg_str .= get_paginator_link($box, $start, $use, $pg) . $spc; |
1276 | } |
1277 | } |
1278 | } else if ($PG_SHOWNUM == 999999) { |
c7df3f1b |
1279 | $pg_str = "<a href=\"right_main.php?PG_SHOWALL=0" |
6a622b59 |
1280 | . "&use_mailbox_cache=$use&startMessage=1&mailbox=$box\" " |
c7df3f1b |
1281 | . ">" ._("Paginate") . '</a>'; |
6a622b59 |
1282 | } |
1283 | |
6a622b59 |
1284 | /* Put all the pieces of the paginator string together. */ |
1285 | /** |
0fdc2fb6 |
1286 | * Hairy code... But let's leave it like it is since I am not certain |
1287 | * a different approach would be any easier to read. ;) |
1288 | */ |
6a622b59 |
1289 | $result = ''; |
abafb676 |
1290 | if ( $prv_str != '' || $nxt_str != '' ) |
1291 | { |
0fdc2fb6 |
1292 | $result .= '['; |
1293 | $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : ''); |
1294 | $result .= ($nxt_str != '' ? $nxt_str : ''); |
1295 | $result .= ']' . $spc ; |
1296 | |
1297 | /* Compute the 'show all' string. */ |
1298 | $all_str = "<a href=\"right_main.php?PG_SHOWALL=1" |
1299 | . "&use_mailbox_cache=$use&startMessage=1&mailbox=$box\" " |
1300 | . ">" . _("Show All") . '</a>'; |
abafb676 |
1301 | } |
eac26493 |
1302 | |
1303 | $result .= ($pg_str != '' ? $spc . '['.$spc.$pg_str.']' . $spc : ''); |
abafb676 |
1304 | $result .= ($all_str != '' ? $spc . '['.$all_str.']' . $spc . $spc : ''); |
6a622b59 |
1305 | |
1306 | /* If the resulting string is blank, return a non-breaking space. */ |
1307 | if ($result == '') { |
1308 | $result = ' '; |
1309 | } |
e35045b7 |
1310 | |
6a622b59 |
1311 | /* Return our final magical paginator string. */ |
1312 | return ($result); |
bdfb67f8 |
1313 | } |
1314 | |
c7df3f1b |
1315 | /** |
0fdc2fb6 |
1316 | * FIXME: Undocumented function |
1317 | */ |
eaa4f45f |
1318 | function truncateWithEntities($subject, $trim_at) |
1319 | { |
341aa42f |
1320 | $ent_strlen = strlen($subject); |
1321 | if (($trim_at <= 0) || ($ent_strlen <= $trim_at)) |
6a622b59 |
1322 | return $subject; |
eaa4f45f |
1323 | |
1324 | global $languages, $squirrelmail_language; |
6a622b59 |
1325 | |
6a622b59 |
1326 | /* |
0fdc2fb6 |
1327 | * see if this is entities-encoded string |
1328 | * If so, Iterate through the whole string, find out |
1329 | * the real number of characters, and if more |
1330 | * than $trim_at, substr with an updated trim value. |
1331 | */ |
341aa42f |
1332 | $trim_val = $trim_at; |
1333 | $ent_offset = 0; |
1334 | $ent_loc = 0; |
a1440f89 |
1335 | while ( $ent_loc < $trim_val && (($ent_loc = strpos($subject, '&', $ent_offset)) !== false) && |
1336 | (($ent_loc_end = strpos($subject, ';', $ent_loc+3)) !== false) ) { |
1337 | $trim_val += ($ent_loc_end-$ent_loc); |
6a622b59 |
1338 | $ent_offset = $ent_loc_end+1; |
1339 | } |
341aa42f |
1340 | if (($trim_val > $trim_at) && ($ent_strlen > $trim_val) && (strpos($subject,';',$trim_val) < ($trim_val + 6))) { |
a1440f89 |
1341 | $i = strpos($subject,';',$trim_val); |
1342 | if ($i) { |
1343 | $trim_val = strpos($subject,';',$trim_val); |
1344 | } |
46a49f65 |
1345 | } |
341aa42f |
1346 | // only print '...' when we're actually dropping part of the subject |
1347 | if ($ent_strlen <= $trim_val) |
6a622b59 |
1348 | return $subject; |
6a622b59 |
1349 | |
1350 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
1351 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { |
1352 | return $languages[$squirrelmail_language]['XTRA_CODE']('strimwidth', $subject, $trim_val); |
1353 | } |
ecaf6352 |
1354 | |
341aa42f |
1355 | return substr_replace($subject, '...', $trim_val); |
bdfb67f8 |
1356 | } |
f93c93b9 |
1357 | |
c7df3f1b |
1358 | /** |
0fdc2fb6 |
1359 | * FIXME: Undocumented function |
1360 | */ |
eaa4f45f |
1361 | function processSubject($subject, $threadlevel = 0) { |
1362 | /* Shouldn't ever happen -- caught too many times in the IMAP functions */ |
1363 | if ($subject == '') { |
1364 | return _("(no subject)"); |
1365 | } |
1366 | |
3fc1a95f |
1367 | global $truncate_subject; /* number of characters for Subject field (<= 0 for unchanged) */ |
1368 | $trim_at = $truncate_subject; |
eaa4f45f |
1369 | |
1370 | /* if this is threaded, subtract two chars per indentlevel */ |
1371 | if (($threadlevel > 0) && ($threadlevel <= 10)) |
1372 | $trim_at -= (2*$threadlevel); |
1373 | |
1374 | return truncateWithEntities($subject, $trim_at); |
1375 | } |
1376 | |
c7df3f1b |
1377 | /** |
0fdc2fb6 |
1378 | * FIXME: Undocumented function |
1379 | * |
1380 | * @param mixed $imapConnection |
1381 | * @param mixed $boxes |
1382 | */ |
26454147 |
1383 | function getMbxList($imapConnection, $boxes = 0) { |
6a622b59 |
1384 | global $lastTargetMailbox; |
1385 | echo ' <small> <tt><select name="targetMailbox">'; |
4669e892 |
1386 | echo sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox)), 0, $boxes); |
c7df3f1b |
1387 | echo ' </select></tt> '; |
e9e5f0fa |
1388 | } |
1389 | |
c7df3f1b |
1390 | /** |
0fdc2fb6 |
1391 | * Creates button |
1392 | * |
1393 | * @deprecated see form functions available in 1.5.1 and 1.4.3. |
1394 | * @param string $type |
1395 | * @param string $name |
1396 | * @param string $value |
1397 | * @param string $js |
1398 | * @param bool $enabled |
1399 | */ |
1a531551 |
1400 | function getButton($type, $name, $value, $js = '', $enabled = TRUE) { |
98a9cc03 |
1401 | $disabled = ( $enabled ? '' : 'disabled ' ); |
1a531551 |
1402 | $js = ( $js ? $js.' ' : '' ); |
c7df3f1b |
1403 | return '<input '.$disabled.$js. |
0fdc2fb6 |
1404 | 'type="'.$type. |
1405 | '" name="'.$name. |
c7df3f1b |
1406 | '" value="'.$value . |
1407 | '" style="padding: 0px; margin: 0px" />'; |
e9e5f0fa |
1408 | } |
1409 | |
c7df3f1b |
1410 | /** |
0fdc2fb6 |
1411 | * Puts string into cell, aligns it and adds <small> tag |
1412 | * |
1413 | * @param string $string string |
1414 | * @param string $align alignment |
1415 | */ |
e9e5f0fa |
1416 | function getSmallStringCell($string, $align) { |
6a622b59 |
1417 | return html_tag('td', |
1418 | '<small>' . $string . ': </small>', |
1419 | $align, |
1420 | '', |
1421 | 'nowrap' ); |
e9e5f0fa |
1422 | } |
1423 | |
c7df3f1b |
1424 | /** |
0fdc2fb6 |
1425 | * FIXME: Undocumented function |
1426 | * |
1427 | * @param integer $start_msg |
1428 | * @param integer $show_num |
1429 | * @param integer $num_msgs |
1430 | */ |
e9e5f0fa |
1431 | function getEndMessage($start_msg, $show_num, $num_msgs) { |
6a622b59 |
1432 | if ($start_msg + ($show_num - 1) < $num_msgs){ |
1433 | $end_msg = $start_msg + ($show_num - 1); |
1434 | } else { |
1435 | $end_msg = $num_msgs; |
1436 | } |
e9e5f0fa |
1437 | |
6a622b59 |
1438 | if ($end_msg < $start_msg) { |
1439 | $start_msg = $start_msg - $show_num; |
1440 | if ($start_msg < 1) { |
1441 | $start_msg = 1; |
1442 | } |
e9e5f0fa |
1443 | } |
6a622b59 |
1444 | return (array($start_msg,$end_msg)); |
e9e5f0fa |
1445 | } |
1446 | |
c7df3f1b |
1447 | /** |
0fdc2fb6 |
1448 | * This should go in imap_mailbox.php |
1449 | * @param string $mailbox |
1450 | */ |
a3439b27 |
1451 | function handleAsSent($mailbox) { |
6a8e7cae |
1452 | global $handleAsSent_result; |
4669e892 |
1453 | |
6a622b59 |
1454 | /* First check if this is the sent or draft folder. */ |
6a8e7cae |
1455 | $handleAsSent_result = isSentMailbox($mailbox) || isDraftMailbox($mailbox); |
a3439b27 |
1456 | |
6a622b59 |
1457 | /* Then check the result of the handleAsSent hook. */ |
1458 | do_hook('check_handleAsSent_result', $mailbox); |
a3439b27 |
1459 | |
6a622b59 |
1460 | /* And return the result. */ |
6a8e7cae |
1461 | return $handleAsSent_result; |
6a622b59 |
1462 | } |
e842b215 |
1463 | |
b531f8ea |
1464 | ?> |