| | |
| | | function rcmail_message_list($attrib) |
| | | { |
| | | global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT, $JS_OBJECT_NAME; |
| | | |
| | | |
| | | $skin_path = $CONFIG['skin_path']; |
| | | $image_tag = '<img src="%s%s" alt="%s" border="0" />'; |
| | | |
| | | |
| | | // check to see if we have some settings for sorting |
| | | $sort_col = isset($_SESSION['sort_col']) ? $_SESSION['sort_col'] : $CONFIG['message_sort_col']; |
| | | $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order']; |
| | | |
| | | // get message headers |
| | | $a_headers = $IMAP->list_headers(); |
| | | $a_headers = $IMAP->list_headers('', '', $sort_col, $sort_order); |
| | | |
| | | // add id to message list table if not specified |
| | | if (!strlen($attrib['id'])) |
| | |
| | | |
| | | // define list of cols to be displayed |
| | | $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); |
| | | $a_sort_cols = array('subject', 'date', 'from', 'to'); |
| | | |
| | | // show 'to' instead of from in sent messages |
| | | if (strtolower($IMAP->get_mailbox_name())=='sent' && ($f = array_search('from', $a_show_cols))) |
| | |
| | | |
| | | // add table title |
| | | $out .= "<thead><tr>\n<td class=\"icon\"> </td>\n"; |
| | | |
| | | |
| | | $javascript = ''; |
| | | foreach ($a_show_cols as $col) |
| | | $out .= '<td class="'.$col.'">' . rep_specialchars_output(rcube_label($col)) . "</td>\n"; |
| | | { |
| | | // get column name |
| | | $col_name = rep_specialchars_output(rcube_label($col)); |
| | | |
| | | // make sort links |
| | | $sort = ''; |
| | | if (in_array($col, $a_sort_cols) && (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton']))) |
| | | { |
| | | $sort = ' '; |
| | | |
| | | // asc link |
| | | if (!empty($attrib['sortascbutton'])) |
| | | { |
| | | $sort .= rcube_button(array('command' => 'sort', |
| | | 'prop' => $col.'_ASC', |
| | | 'image' => $attrib['sortascbutton'], |
| | | 'title' => 'sortasc')); |
| | | } |
| | | |
| | | // desc link |
| | | if (!empty($attrib['sortdescbutton'])) |
| | | { |
| | | $sort .= rcube_button(array('command' => 'sort', |
| | | 'prop' => $col.'_DESC', |
| | | 'image' => $attrib['sortdescbutton'], |
| | | 'title' => 'sortdesc')); |
| | | } |
| | | } |
| | | |
| | | $sort_class = $col==$sort_col ? " sorted$sort_order" : ''; |
| | | |
| | | // put it all together |
| | | $out .= '<td class="'.$col.$sort_class.'" id="rcmHead'.$col.'">' . "$col_name$sort</td>\n"; |
| | | } |
| | | |
| | | $out .= '<td class="icon">'.($attrib['attachmenticon'] ? sprintf($image_tag, $skin_path, $attrib['attachmenticon'], '') : '')."</td>\n"; |
| | | $out .= "</tr></thead>\n<tbody>\n"; |
| | |
| | | $message_count = $IMAP->messagecount(); |
| | | |
| | | // set client env |
| | | $javascript = sprintf("%s.gui_object('messagelist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']); |
| | | $javascript .= sprintf("%s.gui_object('messagelist', '%s');\n", $JS_OBJECT_NAME, $attrib['id']); |
| | | $javascript .= sprintf("%s.set_env('messagecount', %d);\n", $JS_OBJECT_NAME, $message_count); |
| | | $javascript .= sprintf("%s.set_env('current_page', %d);\n", $JS_OBJECT_NAME, $IMAP->list_page); |
| | | $javascript .= sprintf("%s.set_env('pagecount', %d);\n", $JS_OBJECT_NAME, ceil($message_count/$IMAP->page_size)); |
| | | $javascript .= sprintf("%s.set_env('sort_col', '%s');\n", $JS_OBJECT_NAME, $sort_col); |
| | | $javascript .= sprintf("%s.set_env('sort_order', '%s');\n", $JS_OBJECT_NAME, $sort_order); |
| | | |
| | | if ($attrib['messageicon']) |
| | | $javascript .= sprintf("%s.set_env('messageicon', '%s%s');\n", $JS_OBJECT_NAME, $skin_path, $attrib['messageicon']); |
| | |
| | | if (!$headers[$hkey]) |
| | | continue; |
| | | |
| | | if ($hkey=='date') |
| | | if ($hkey=='date' && !empty($headers[$hkey])) |
| | | $header_value = format_date(strtotime($headers[$hkey])); |
| | | else if (in_array($hkey, array('from', 'to', 'cc', 'reply-to'))) |
| | | $header_value = rep_specialchars_output(rcmail_address_string($IMAP->decode_header($headers[$hkey]), NULL, $attrib['addicon'])); |