📄 func.inc
字号:
<?php/* +-----------------------------------------------------------------------+ | program/steps/mail/func.inc | | | | This file is part of the RoundCube Webmail client | | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | | Licensed under the GNU GPL | | | | PURPOSE: | | Provide webmail functionality and GUI objects | | | +-----------------------------------------------------------------------+ | Author: Thomas Bruederli <roundcube@gmail.com> | +-----------------------------------------------------------------------+ $Id: func.inc 1494 2008-06-09 12:22:54Z alec $*/require_once('lib/enriched.inc');require_once('include/rcube_smtp.inc');$EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i';if (empty($_SESSION['mbox'])) $_SESSION['mbox'] = $IMAP->get_mailbox_name();// set imap properties and session varsif ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC)) $IMAP->set_mailbox(($_SESSION['mbox'] = $mbox));if (!empty($_GET['_page'])) $IMAP->set_page(($_SESSION['page'] = intval($_GET['_page'])));// set mailbox to INBOX if not setif (empty($_SESSION['mbox'])) $_SESSION['mbox'] = $IMAP->get_mailbox_name();// set default sort col/order to sessionif (!isset($_SESSION['sort_col'])) $_SESSION['sort_col'] = $CONFIG['message_sort_col'];if (!isset($_SESSION['sort_order'])) $_SESSION['sort_order'] = $CONFIG['message_sort_order'];// set message set for search resultif (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) { $IMAP->set_search_set($_SESSION['search'][$_REQUEST['_search']]); $OUTPUT->set_env('search_request', $_REQUEST['_search']); $OUTPUT->set_env('search_text', $_SESSION['last_text_search']); }// set current mailbox in client environment$OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name());$OUTPUT->set_env('quota', $IMAP->get_capability('quota'));if ($CONFIG['trash_mbox']) $OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']);if ($CONFIG['drafts_mbox']) $OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']);if ($CONFIG['junk_mbox']) $OUTPUT->set_env('junk_mailbox', $CONFIG['junk_mbox']);if (!$OUTPUT->ajax_call) rcube_add_label('checkingmail', 'deletemessage', 'movemessagetotrash', 'movingmessage');// set page titleif (empty($RCMAIL->action) || $RCMAIL->action == 'list') $OUTPUT->set_pagetitle(rcmail_localize_foldername($IMAP->get_mailbox_name()));/** * return the message list as HTML table */function rcmail_message_list($attrib) { global $IMAP, $CONFIG, $COMM_PATH, $OUTPUT; $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 = $_SESSION['sort_col']; $sort_order = $_SESSION['sort_order']; // add some labels to client rcube_add_label('from', 'to'); // get message headers $a_headers = $IMAP->list_headers('', '', $sort_col, $sort_order); // add id to message list table if not specified if (!strlen($attrib['id'])) $attrib['id'] = 'rcubemessagelist'; // allow the following attributes to be added to the <table> tag $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); $out = '<table' . $attrib_str . ">\n"; // 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', 'size'); $mbox = $IMAP->get_mailbox_name(); // show 'to' instead of from in sent messages if (($mbox==$CONFIG['sent_mbox'] || $mbox==$CONFIG['drafts_mbox']) && ($f = array_search('from', $a_show_cols)) && !array_search('to', $a_show_cols)) $a_show_cols[$f] = 'to'; // add col definition $out .= '<colgroup>'; $out .= '<col class="icon" />'; foreach ($a_show_cols as $col) $out .= sprintf('<col class="%s" />', $col); $out .= '<col class="icon" />'; $out .= "</colgroup>\n"; // add table title $out .= "<thead><tr>\n<td class=\"icon\"> </td>\n"; $javascript = ''; foreach ($a_show_cols as $col) { // get column name $col_name = Q(rcube_label($col)); // make sort links $sort = ''; if (in_array($col, $a_sort_cols)) { // have buttons configured if (!empty($attrib['sortdescbutton']) || !empty($attrib['sortascbutton'])) { $sort = ' '; // asc link if (!empty($attrib['sortascbutton'])) { $sort .= $OUTPUT->button(array( 'command' => 'sort', 'prop' => $col.'_ASC', 'image' => $attrib['sortascbutton'], 'align' => 'absmiddle', 'title' => 'sortasc')); } // desc link if (!empty($attrib['sortdescbutton'])) { $sort .= $OUTPUT->button(array( 'command' => 'sort', 'prop' => $col.'_DESC', 'image' => $attrib['sortdescbutton'], 'align' => 'absmiddle', 'title' => 'sortdesc')); } } // just add a link tag to the header else { $col_name = sprintf( '<a href="./#sort" onclick="return %s.command(\'sort\',\'%s\',this)" title="%s">%s</a>', JS_OBJECT_NAME, $col, rcube_label('sortby'), $col_name); } } $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"; // no messages in this mailbox if (!sizeof($a_headers)) $OUTPUT->show_message('nomessagesfound', 'notice'); $a_js_message_arr = array(); // create row for each message foreach ($a_headers as $i => $header) //while (list($i, $header) = each($a_headers)) { $message_icon = $attach_icon = ''; $js_row_arr = array(); $zebra_class = $i%2 ? 'even' : 'odd'; // set messag attributes to javascript array if ($header->deleted) $js_row_arr['deleted'] = true; if (!$header->seen) $js_row_arr['unread'] = true; if ($header->answered) $js_row_arr['replied'] = true; // set message icon if ($attrib['deletedicon'] && $header->deleted) $message_icon = $attrib['deletedicon']; else if ($attrib['unreadicon'] && !$header->seen) $message_icon = $attrib['unreadicon']; else if ($attrib['repliedicon'] && $header->answered) $message_icon = $attrib['repliedicon']; else if ($attrib['messageicon']) $message_icon = $attrib['messageicon']; // set attachment icon if ($attrib['attachmenticon'] && preg_match("/multipart\/[mr]/i", $header->ctype)) $attach_icon = $attrib['attachmenticon']; $out .= sprintf('<tr id="rcmrow%d" class="message%s%s %s">'."\n", $header->uid, $header->seen ? '' : ' unread', $header->deleted ? ' deleted' : '', $zebra_class); $out .= sprintf("<td class=\"icon\">%s</td>\n", $message_icon ? sprintf($image_tag, $skin_path, $message_icon, '') : ''); if (!empty($header->charset)) $IMAP->set_charset($header->charset); // format each col foreach ($a_show_cols as $col) { if ($col=='from' || $col=='to') $cont = Q(rcmail_address_string($header->$col, 3, $attrib['addicon']), 'show'); else if ($col=='subject') { $action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; $uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draft_uid' : '_uid'; $cont = Q($IMAP->decode_header($header->$col)); if (empty($cont)) $cont = Q(rcube_label('nosubject')); $cont = sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont); } else if ($col=='size') $cont = show_bytes($header->$col); else if ($col=='date') $cont = format_date($header->date); else $cont = Q($header->$col); $out .= '<td class="'.$col.'">' . $cont . "</td>\n"; } $out .= sprintf("<td class=\"icon\">%s</td>\n", $attach_icon ? sprintf($image_tag, $skin_path, $attach_icon, '') : ''); $out .= "</tr>\n"; if (sizeof($js_row_arr)) $a_js_message_arr[$header->uid] = $js_row_arr; } // complete message table $out .= "</tbody></table>\n"; $message_count = $IMAP->messagecount(); // set client env $OUTPUT->add_gui_object('mailcontframe', 'mailcontframe'); $OUTPUT->add_gui_object('messagelist', $attrib['id']); $OUTPUT->set_env('messagecount', $message_count); $OUTPUT->set_env('current_page', $IMAP->list_page); $OUTPUT->set_env('pagecount', ceil($message_count/$IMAP->page_size)); $OUTPUT->set_env('sort_col', $sort_col); $OUTPUT->set_env('sort_order', $sort_order); if ($attrib['messageicon']) $OUTPUT->set_env('messageicon', $skin_path . $attrib['messageicon']); if ($attrib['deletedicon']) $OUTPUT->set_env('deletedicon', $skin_path . $attrib['deletedicon']); if ($attrib['unreadicon']) $OUTPUT->set_env('unreadicon', $skin_path . $attrib['unreadicon']); if ($attrib['repliedicon']) $OUTPUT->set_env('repliedicon', $skin_path . $attrib['repliedicon']); if ($attrib['attachmenticon']) $OUTPUT->set_env('attachmenticon', $skin_path . $attrib['attachmenticon']); $OUTPUT->set_env('messages', $a_js_message_arr); $OUTPUT->set_env('coltypes', $a_show_cols); $OUTPUT->include_script('list.js'); return $out; }/** * return javascript commands to add rows to the message list */function rcmail_js_message_list($a_headers, $insert_top=FALSE) { global $CONFIG, $IMAP, $OUTPUT; $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); $mbox = $IMAP->get_mailbox_name(); // show 'to' instead of from in sent messages if (($mbox == $CONFIG['sent_mbox'] || $mbox == $CONFIG['drafts_mbox']) && (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false) $a_show_cols[$f] = 'to'; $OUTPUT->command('set_message_coltypes', $a_show_cols); // loop through message headers foreach ($a_headers as $n => $header) { $a_msg_cols = array(); $a_msg_flags = array(); if (empty($header)) continue; if (!empty($header->charset)) $IMAP->set_charset($header->charset); // format each col; similar as in rcmail_message_list() foreach ($a_show_cols as $col) { if ($col=='from' || $col=='to') $cont = Q(rcmail_address_string($header->$col, 3), 'show'); else if ($col=='subject') { $action = $mbox==$CONFIG['drafts_mbox'] ? 'compose' : 'show'; $uid_param = $mbox==$CONFIG['drafts_mbox'] ? '_draft_uid' : '_uid'; $cont = Q($IMAP->decode_header($header->$col)); if (!$cont) $cont = Q(rcube_label('nosubject')); $cont = sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), $cont); } else if ($col=='size') $cont = show_bytes($header->$col); else if ($col=='date') $cont = format_date($header->date); else $cont = Q($header->$col); $a_msg_cols[$col] = $cont; } $a_msg_flags['deleted'] = $header->deleted ? 1 : 0; $a_msg_flags['unread'] = $header->seen ? 0 : 1; $a_msg_flags['replied'] = $header->answered ? 1 : 0; $OUTPUT->command('add_message_row', $header->uid, $a_msg_cols, $a_msg_flags, preg_match("/multipart\/m/i", $header->ctype), $insert_top); } }/** * return an HTML iframe for loading mail content */function rcmail_messagecontent_frame($attrib) { global $OUTPUT; if (empty($attrib['id'])) $attrib['id'] = 'rcmailcontentwindow'; // allow the following attributes to be added to the <iframe> tag $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style', 'src', 'width', 'height', 'frameborder'));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -