| | |
| | | |
| | | */ |
| | | |
| | | // setup some global vars used by mail steps |
| | | $SENT_MBOX = $RCMAIL->config->get('sent_mbox'); |
| | | $DRAFTS_MBOX = $RCMAIL->config->get('drafts_mbox'); |
| | | $SEARCH_MODS_DEFAULT = array('*' => array('subject'=>1, 'from'=>1), $SENT_MBOX => array('subject'=>1, 'to'=>1), $DRAFTS_MBOX => array('subject'=>1, 'to'=>1)); |
| | | |
| | | $EMAIL_ADDRESS_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9][a-z0-9\-\.]*\\.[a-z]{2,5})'; |
| | | |
| | | // actions that do not require imap connection |
| | |
| | | $OUTPUT->set_env('search_request', $search_request); |
| | | } |
| | | |
| | | $OUTPUT->set_env('search_mods', $_SESSION['search_mods'] ? $_SESSION['search_mods'] : array('subject'=>'subject')); |
| | | $search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT); |
| | | $OUTPUT->set_env('search_mods', $search_mods); |
| | | |
| | | // make sure the message count is refreshed (for default view) |
| | | $IMAP->messagecount($mbox_name, 'ALL', true); |
| | | } |
| | |
| | | |
| | | // show 'to' instead of 'from' in sent/draft messages |
| | | if ((strpos($mbox.$delim, $CONFIG['sent_mbox'].$delim)===0 || strpos($mbox.$delim, $CONFIG['drafts_mbox'].$delim)===0) |
| | | && ($f = array_search('from', $a_show_cols)) && !array_search('to', $a_show_cols)) |
| | | && (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false) |
| | | $a_show_cols[$f] = 'to'; |
| | | |
| | | // add col definition |
| | |
| | | $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 = abbreviate_string(trim($IMAP->decode_header($header->$col)), 160); |
| | | if (!$cont) $cont = rcube_label('nosubject'); |
| | | $cont = $browser->ie ? Q($cont) : sprintf('<a href="%s" onclick="return rcube_event.cancel(event)">%s</a>', Q(rcmail_url($action, array($uid_param=>$header->uid, '_mbox'=>$mbox))), Q($cont)); |
| | | $cont = Q($cont); |
| | | $a_msg_cols['mbox'] = $mbox; |
| | | } |
| | | else if ($col=='size') |
| | | $cont = show_bytes($header->$col); |
| | |
| | | function rcmail_wash_html($html, $p = array(), $cid_replaces) |
| | | { |
| | | global $REMOTE_OBJECTS; |
| | | |
| | | |
| | | $p += array('safe' => false, 'inline_html' => true); |
| | | |
| | | // special replacements (not properly handled by washtml class) |
| | | $html_search = array( |
| | | '/(<\/nobr>)(\s+)(<nobr>)/i', // space(s) between <NOBR> |
| | | '/<title[^>]*>.*<\/title>/i', // PHP bug #32547 workaround: remove title tag |
| | | '/<title[^>]*>.*<\/title>/i', // PHP bug #32547 workaround: remove title tag |
| | | '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', // byte-order mark (only outlook?) |
| | | '/<html\s[^>]+>/i', // washtml/DOMDocument cannot handle xml namespaces |
| | | ); |
| | |
| | | |
| | | // charset was converted to UTF-8 in rcube_imap::get_message_part(), |
| | | // -> change charset specification in HTML accordingly |
| | | $charset_pattern = '(<meta\s+[^>]*)(content=[\'"]?\w+\/\w+;\s*charset)=([a-z0-9-_]+)'; |
| | | $charset_pattern = '(<meta\s+[^>]* content=)[\'"]?(\w+\/\w+;\s*charset=)([a-z0-9-_]+[\'"]?)'; |
| | | if (preg_match("/$charset_pattern/Ui", $html)) { |
| | | $html = preg_replace("/$charset_pattern/i", '\\1\\2='.RCMAIL_CHARSET, $html); |
| | | $html = preg_replace("/$charset_pattern/i", '\\1"\\2'.RCMAIL_CHARSET.'"', $html); |
| | | } |
| | | else { |
| | | // add meta content-type to malformed messages, washtml cannot work without that |
| | |
| | | */ |
| | | function rcmail_address_string($input, $max=null, $linked=false, $addicon=null) |
| | | { |
| | | global $IMAP, $PRINT_MODE, $CONFIG, $OUTPUT, $EMAIL_ADDRESS_PATTERN; |
| | | global $IMAP, $RCMAIL, $PRINT_MODE, $CONFIG, $OUTPUT, $EMAIL_ADDRESS_PATTERN; |
| | | static $got_writable_abook = null; |
| | | |
| | | $a_parts = $IMAP->decode_address_list($input); |
| | | |
| | |
| | | $j = 0; |
| | | $out = ''; |
| | | |
| | | if ($got_writable_abook === null && $books = $RCMAIL->get_address_sources(true)) { |
| | | $got_writable_abook = true; |
| | | } |
| | | |
| | | foreach ($a_parts as $part) { |
| | | $j++; |
| | | if ($PRINT_MODE) { |
| | | $out .= sprintf('%s <%s>', Q($part['name']), $part['mailto']); |
| | | } |
| | | else if (preg_match("/$EMAIL_ADDRESS_PATTERN/i", $part['mailto'])) { |
| | | else if (check_email($part['mailto'], false)) { |
| | | if ($linked) { |
| | | $out .= html::a(array( |
| | | 'href' => 'mailto:'.$part['mailto'], |
| | |
| | | $out .= html::span(array('title' => $part['mailto'], 'class' => "rcmContactAddress"), Q($part['name'])); |
| | | } |
| | | |
| | | if ($addicon) { |
| | | if ($addicon && $got_writable_abook) { |
| | | $out .= ' ' . html::a(array( |
| | | 'href' => "#add", |
| | | 'onclick' => sprintf("return %s.command('add-contact','%s',this)", JS_OBJECT_NAME, urlencode($part['string'])), |
| | |
| | | } |
| | | |
| | | |
| | | function rcmail_draftinfo_encode($p) |
| | | { |
| | | $parts = array(); |
| | | foreach ($p as $key => $val) |
| | | $parts[] = $key . '=' . ($key == 'folder' ? base64_encode($val) : $val); |
| | | |
| | | return join('; ', $parts); |
| | | } |
| | | |
| | | |
| | | function rcmail_draftinfo_decode($str) |
| | | { |
| | | $info = array(); |
| | | foreach (preg_split('/;\s+/', $str) as $part) { |
| | | list($key, $val) = explode('=', $part, 2); |
| | | if ($key == 'folder') |
| | | $val = base64_decode($val); |
| | | $info[$key] = $val; |
| | | } |
| | | |
| | | return $info; |
| | | } |
| | | |
| | | |
| | | function rcmail_message_part_controls() |
| | | { |
| | | global $MESSAGE; |
| | |
| | | if (!isset($_SESSION['compose'])) |
| | | return; |
| | | |
| | | rcmail::get_instance()->plugins->exec_hook('cleanup_attachments',array()); |
| | | |
| | | rcube_sess_unset('compose'); |
| | | $rcmail = rcmail::get_instance(); |
| | | $rcmail->plugins->exec_hook('cleanup_attachments',array()); |
| | | $rcmail->session->remove('compose'); |
| | | } |
| | | |
| | | |