Make sure the message was actually seen, not just that 'seen' is in aFlags
[squirrelmail.git] / templates / default / message_list.tpl
1 <?php
2
3 /**
4 * message_list.tpl
5 *
6 * Template for viewing a messages list
7 *
8 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @version $Id$
11 * @package squirrelmail
12 * @subpackage templates
13 */
14
15 /** add required includes */
16 include_once(SM_PATH . 'templates/util_message_list.php');
17
18 /* retrieve the template vars */
19 extract($t);
20
21 do_hook('mailbox_index_before');
22
23 /**
24 * Calculate string "Viewing message x to y (z total)"
25 */
26 $msg_cnt_str = '';
27 if ($pageOffset < $end_msg) {
28 $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
29 '<em>'.$pageOffset.'</em>', '<em>'.$end_msg.'</em>', $iNumberOfMessages);
30 } else if ($pageOffset == $end_msg) {
31 $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<em>'.$pageOffset.'</em>', $iNumberOfMessages);
32 }
33
34
35
36 if (!($sort & SQSORT_THREAD) && $enablesort) {
37 $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
38 SQM_COL_DATE => array(SQSORT_DATE_DESC , SQSORT_DATE_ASC),
39 SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC),
40 SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC),
41 SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC),
42 SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC),
43 SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC));
44 } else {
45 $aSortSupported = array();
46 }
47
48 // figure out which columns should serve as labels for checkbox:
49 // we try to grab the two columns before and after the checkbox,
50 // except the subject column, since it is the link that opens
51 // the message view
52 //
53 // if $javascript_on is set, then the highlighting code takes
54 // care of this; just skip it
55 //
56 $show_label_columns = array();
57 $index_order_part = array();
58 if (!($javascript_on && $fancy_index_highlite)) {
59 $get_next_two = 0;
60 $last_order_part = 0;
61 $last_last_order_part = 0;
62 foreach ($aOrder as $index_order_part) {
63 if ($index_order_part == SQM_COL_CHECK) {
64 $get_next_two = 1;
65 if ($last_last_order_part != SQM_COL_SUBJ)
66 $show_label_columns[] = $last_last_order_part;
67 if ($last_order_part != SQM_COL_SUBJ)
68 $show_label_columns[] = $last_order_part;
69
70 } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
71 $show_label_columns[] = $index_order_part;
72 $get_next_two++;
73 }
74 $last_last_order_part = $last_order_part;
75 $last_order_part = $index_order_part;
76 }
77 }
78
79 /**
80 * Check usage of images for attachments, flags and priority
81 */
82 $bIcons = ($use_icons && $icon_theme) ? true : false;
83
84 /**
85 * Location of icon images
86 */
87 if ($bIcons) {
88 $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
89 }
90
91 // set this to an empty string to turn off extra
92 // highlighting of checked rows
93 //
94 //$clickedColor = '';
95 $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
96
97 ?>
98 <div id="message_list">
99 <form id="<?php echo $form_id;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
100 <table class="table_empty" cellspacing="0">
101 <tr>
102 <td>
103 <table class="table_standard" cellspacing="0">
104 <tr>
105 <td>
106 <table class="table_empty" cellspacing="0">
107 <tr>
108 <td class="links_paginator">
109 <!-- paginator and thread link string -->
110 <?php
111 /**
112 * because the template is included in the display function we refer to $oTemplate with $this
113 */
114 $paginator_str = $this->fetch('paginator.tpl');
115 echo $paginator_str . $thread_link_str ."\n"; ?>
116 <!-- end paginator and thread link string -->
117 </td>
118 <!-- message count string -->
119 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
120 <!-- end message count string -->
121 </tr>
122 </table>
123 </td>
124 </tr>
125 <?php
126 if (count($aFormElements)) {
127 ?>
128 <!-- start message list form control -->
129 <tr class="message_list_controls" cellspacing="0">
130 <td>
131 <table class="table_empty" cellspacing="0">
132 <tr>
133 <td class="message_control_buttons" cellspacing="0">
134
135 <?php
136 foreach ($aFormElements as $key => $value) {
137 switch ($value[1]) {
138 case 'submit':
139 if ($key != 'moveButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
140 ?>
141 <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />&nbsp;
142 <?php
143 }
144 break;
145 case 'checkbox':
146 if ($key != 'bypass_trash') {
147 ?>
148 <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>&nbsp;
149 <?php
150 }
151 break;
152 case 'hidden':
153 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
154 break;
155 default: break;
156 }
157 }
158 ?>
159 </td>
160 <td class="message_control_delete">
161
162
163 <?php
164 if (isset($aFormElements['delete'])) {
165 ?>
166 <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" class="message_control_button" />&nbsp;
167 <?php
168 if (isset($aFormElements['bypass_trash'])) {
169 ?>
170 <input type="checkbox" name="bypass_trash" /><?php echo $aFormElements['bypass_trash'][0]; ?>&nbsp;
171 <?php
172 }
173 if (isset($aFormElements['undeleteButton'])) {
174 ?>
175 <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" class="message_control_button" />&nbsp;
176 <?php
177 }
178 ?>
179 </td>
180 <?php
181 } // if (isset($aFormElements['delete']))
182 if (isset($aFormElements['moveButton'])) {
183 ?>
184 <td class="message_control_move">
185 <select name="targetMailbox">
186 <?php echo $aFormElements['targetMailbox'][0];?>
187 </select>
188 <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
189 </td>
190
191 <?php
192 } // if (isset($aFormElements['move']))
193 ?>
194 </tr>
195 </table>
196 </td>
197 </tr>
198 <!-- end message list form control -->
199 <?php
200 } // if (count($aFormElements))
201 ?>
202 </table>
203 <?php
204 do_hook('mailbox_form_before');
205 ?>
206 </td>
207 </tr>
208 <tr><td class="spacer"></td></tr>
209 <tr>
210 <td>
211 <table class="table_messageListWrapper" cellspacing="0">
212 <tr>
213 <td>
214 <table class="table_messageList" cellspacing="0">
215 <!-- table header start -->
216 <?php
217 /*
218 * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
219 * rendering this table if we use THEAD and TH tags. No other browser or platform has
220 * this issue. We will use TR/TD w/ another CSS class to work around this.
221 */
222 ?>
223 <tr class="headerRow">
224 <?php
225 $aWidth = calcMessageListColumnWidth($aOrder);
226 foreach($aOrder as $iCol) {
227 ?>
228 <td style="width:<?php echo $aWidth[$iCol]; ?>%">
229 <?php
230 switch ($iCol) {
231 case SQM_COL_CHECK:
232 if ($javascript_on) {
233 echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."',".$fancy_index_highlite.')" />'."\n";
234 } else {
235 $link = $baseurl . "&amp;startMessage=$pageOffset&amp;&amp;checkall=";
236 if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
237 $link .= ($checkall) ? '0' : '1';
238 } else {
239 $link .= '1';
240 }
241 echo "<a href=\"$link\">"._("All").'</a>';
242 }
243 break;
244 case SQM_COL_FROM: echo _("From")."\n"; break;
245 case SQM_COL_DATE: echo _("Date")."\n"; break;
246 case SQM_COL_SUBJ: echo _("Subject")."\n"; break;
247 case SQM_COL_FLAGS:
248 if ($bIcons) {
249 echo '<img src="' . $sImageLocation. 'msg_new.png" border="0" height="12" width="18" alt="!" title="'. _("Message Flags") . '" />'."\n";
250 } else {
251 echo '&nbsp;'."\n";
252 }
253 break;
254 case SQM_COL_SIZE: echo _("Size")."\n"; break;
255 case SQM_COL_PRIO:
256 if ($bIcons) {
257 echo '<img src="' . $sImageLocation. 'prio_high.png" border="0" height="10" width="5" alt="!" title="'. _("Priority") . '" />'."\n";
258 } else {
259 echo '!'."\n";
260 }
261 break;
262 case SQM_COL_ATTACHMENT:
263 if ($bIcons) {
264 echo '<img src="' . $sImageLocation. 'attach.png" border="0" height="10" width="6" alt="+" title="' . _("Attachment") . '"/>'."\n";
265 } else {
266 echo '+'."\n";
267 }
268 break;
269 case SQM_COL_INT_DATE: echo _("Received")."\n"; break;
270 case SQM_COL_TO: echo _("To")."\n"; break;
271 case SQM_COL_CC: echo _("Cc")."\n"; break;
272 case SQM_COL_BCC: echo _("Bcc")."\n"; break;
273 default: break;
274 }
275 // add the sort buttons
276 if (isset($aSortSupported[$iCol])) {
277 if ($sort == $aSortSupported[$iCol][0]) {
278 $newsort = $aSortSupported[$iCol][1];
279 $img = 'up_pointer.png';
280 } else if ($sort == $aSortSupported[$iCol][1]) {
281 $newsort = 0;
282 $img = 'down_pointer.png';
283 } else {
284 $newsort = $aSortSupported[$iCol][0];
285 $img = 'sort_none.png';
286 }
287 /* Now that we have everything figured out, show the actual button. */
288 echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\">";
289 echo '<img src="../images/' . $img
290 . '" border="0" width="12" height="10" alt="sort" title="'
291 . _("Click here to change the sorting of the message list") .'" /></a>'."\n";
292 }
293 ?>
294 </td>
295 <?php
296 }
297 ?>
298 </tr>
299 <!-- end table header -->
300
301 <!-- Message headers start -->
302 <?php
303 $i = 0;
304 $iColCnt = count($aOrder);
305 $sLine = '';
306
307 // this stuff does the auto row highlighting on mouseover
308 //
309 if ($javascript_on && $fancy_index_highlite) {
310
311 $mouseoverColor = $color[5];
312
313 // set this to an empty string to turn off extra
314 // highlighting of checked rows
315 //
316 //$clickedColor = '';
317 $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
318
319 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
320 } else {
321 $checkbox_javascript = '';
322 }
323 foreach ($aMessages as $iUid => $aMsg) {
324 echo $sLine;
325
326 /**
327 * Display message header row in messages list
328 *
329 */
330
331 $aColumns = $aMsg['columns'];
332
333
334 /**
335 * Check the flags and set a class var.
336 */
337 if (isset($aColumns[SQM_COL_FLAGS])) {
338 $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
339 if ($bIcons) {
340
341 $sFlags = getFlagIcon($aFlags, $sImageLocation);
342 } else {
343 $sFlags = getFlagText($aFlags);
344 }
345 /* add the flag string to the value index */
346 $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
347 }
348 /**
349 * Check the priority column
350 */
351 if (isset($aColumns[SQM_COL_PRIO])) {
352 /* FIX ME, we should use separate templates for icons */
353 if ($bIcons) {
354 $sValue = '<img src="' . $sImageLocation;
355 switch ($aColumns[SQM_COL_PRIO]['value']) {
356 case 1:
357 case 2: $sValue .= 'prio_high.png" border="0" height="10" width="5" alt="" /> ' ; break;
358 case 5: $sValue .= 'prio_low.png" border="0" height="10" width="5" alt="" /> ' ; break;
359 default: $sValue .= 'transparent.png" border="0" width="5" alt="" /> ' ; break;
360 }
361 } else {
362 $sValue = '';
363 switch ($aColumns[SQM_COL_PRIO]['value']) {
364 case 1:
365 case 2: $sValue .= '<span class="high_priority">!</span>'; break;
366 // use downwards arrow for low priority emails
367 case 5: $sValue .= '<span class="low_priority">&#8595;</span>'; break;
368 default: break;
369 }
370 }
371 $aColumns[SQM_COL_PRIO]['value'] = $sValue;
372 }
373
374 /**
375 * Check the attachment column
376 */
377 if (isset($aColumns[SQM_COL_ATTACHMENT])) {
378 /* FIX ME, we should use separate templates for icons */
379 if ($bIcons) {
380 $sValue = '<img src="' . $sImageLocation;
381 $sValue .= ($aColumns[SQM_COL_ATTACHMENT]['value'])
382 ? 'attach.png" border="0" height="10" width="6" alt=""/>'
383 : 'transparent.png" border="0" width="6" alt="" />';
384 } else {
385 $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
386 }
387 $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
388 }
389
390 $class = 'even';
391 /**
392 * If alternating row colors is set, adapt the CSS class
393 */
394 if (isset($alt_index_colors) && $alt_index_colors) {
395 if (!($i % 2)) {
396 $class = 'odd';
397 }
398
399 }
400 if (isset($aMsg['row']['color']))
401 {
402 $bgcolor = $aMsg['row']['color'];
403 $class = 'misc'.$i;
404 }
405 else $bgcolor = '';
406
407 $row_extra = '';
408
409 // this stuff does the auto row highlighting on mouseover
410 //
411 if ($javascript_on && $fancy_index_highlite) {
412 $row_extra .= ' onmouseover="rowOver(\''.$form_id . '_msg' . $i.'\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $class . '\', \'mouse_over\', \'clicked\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $class . '\', \'mouse_over\', \'clicked\');"';
413 }
414 // this does the auto-checking of the checkbox no matter
415 // where on the row you click
416 //
417 $javascript_auto_click = '';
418 if ($javascript_on && $fancy_index_highlite) {
419 // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
420 $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
421 }
422
423 /*
424 * Message Highlighting requires a unique CSS class declaration for proper
425 * mouseover functionality. There is no harm in doing this when the mouseover
426 * functionality is disabled
427 */
428 if ($class != 'even' && $class != 'odd')
429 {
430 ?>
431 <style type="text/css">
432 <!--
433 .table_messageList tr.<?php echo $class; ?> { background:<?php echo $bgcolor; ?> }
434 -->
435 </style>
436 <?php
437 }
438 ?>
439 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" '); echo $row_extra;?>>
440 <?php
441 // flag style mumbo jumbo
442 $sPre = $sEnd = '';
443 if (isset($aColumns[SQM_COL_FLAGS])) {
444 if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
445 $sPre = '<span class="unread">'; $sEnd = '</span>';
446 }
447 if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
448 $sPre = '<span class="deleted">' . $sPre;
449 $sEnd .= '</span>';
450 } else {
451 if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
452 $sPre = '<span class="flagged">' . $sPre;
453 $sEnd .= '</span>';
454 }
455 }
456 }
457 /**
458 * Because the order of the columns and which columns to show is a user preference
459 * we have to do some php coding to display the columns in the right order
460 */
461 foreach ($aOrder as $iCol) {
462 if (in_array($iCol, $show_label_columns)) {
463 $sLabelStart = '<label for="'.$form_id."_msg$i\">";
464 $sLabelEnd = '</label>';
465 } else {
466 $sLabelStart = '';
467 $sLabelEnd = '';
468 }
469 $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : array();
470 $title = (isset($aCol['title'])) ? $aCol['title'] : '';
471 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
472 $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
473 $onclick = (isset($aCol['onclick'])) ? $aCol['onclick'] : '';
474 $link = (isset($aCol['link'])) ? $aCol['link'] : '';
475 $value = (isset($aCol['value'])) ? $aCol['value'] : '';
476 $target = (isset($aCol['target'])) ? $aCol['target'] : '';
477 if ($iCol !== SQM_COL_CHECK) {
478 $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
479 }
480
481
482 switch ($iCol) {
483 case SQM_COL_CHECK:
484 echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
485 <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
486 <?php
487 break;
488 case SQM_COL_SUBJ:
489 $indent = $aCol['indent'];
490 $sText = " <td class=\"col_subject\" $javascript_auto_click>";
491 if ($align['left'] == 'left') {
492 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
493 }
494 $sText .= "<a href=\"$link\"";
495 if ($target) { $sText .= " target=\"$target\""; }
496 if ($title) { $sText .= " title=\"$title\""; }
497 if ($onclick) { $sText .= " onclick=\"$onclick\""; }
498 if ($link_extra) { $sText .= " $link_extra"; }
499 if ($javascript_on && $fancy_index_highlite) {
500 $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
501 'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
502 $clickedColor .'\');"';
503 }
504 $sText .= ">";
505 $sText .= $value . '</a>';
506 if ($align['left'] == 'right') {
507 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
508 }
509 echo $sText."</td>\n";
510 break;
511 case SQM_COL_SIZE:
512 case SQM_COL_FLAGS:
513 $sText = " <td class=\"col_flags\" $javascript_auto_click>";
514 $sText .= "$value</td>\n";
515 echo $sText;
516 break;
517 case SQM_COL_INT_DATE:
518 case SQM_COL_DATE:
519 $sText = " <td class=\"col_date\" $javascript_auto_click>";
520 $sText .= $value. "</td>\n";
521 echo $sText;
522 break;
523 default:
524 $sText = " <td class=\"col_text\" $javascript_auto_click";
525 if ($link) {
526 $sText .= "><a href=\"$link\"";
527 if ($target) { $sText .= " target=\"$target\"";}
528 if ($title) { $sText .= " title=\"$title\"" ;}
529 $sText .= ">";
530 } else {
531 if ($title) {$sText .= " title=\"$title\"";}
532 $sText .= ">";
533 }
534 $sText .= $value;
535 if ($link) { $sText .= '</a>';}
536 echo $sText."</td>\n";
537 break;
538 }
539 }
540 ?>
541 </tr>
542 <?php
543 $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
544 ++$i;
545
546 /*
547 * End displaying row part
548 */
549 }
550
551 ?>
552 <!-- Message headers end -->
553 </table>
554 </td>
555 </tr>
556 </table>
557 </td>
558 </tr>
559 <tr><td class="spacer"></td></tr>
560 <tr>
561 <td>
562 <table class="table_standard" cellspacing="0">
563 <tr>
564 <td>
565 <table class="table_empty" cellspacing="0">
566 <tr>
567 <td class="links_paginator"><?php echo $paginator_str; ?></td>
568 <td class="message_count"><?php echo $msg_cnt_str; ?></td>
569 </tr>
570 </table>
571 </td>
572 </tr>
573 </table>
574 </td>
575 </tr>
576 <tr>
577 <td>
578 <?php do_hook('mailbox_index_after');?>
579 </td>
580 </tr>
581 </table>
582 </form>
583 </div>