diff --git a/program/include/main.inc b/program/include/main.inc index bbfba07fc..48e485ce2 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -712,7 +712,7 @@ function show_message($message, $type='notice', $vars=NULL) return 'this.'.$command; else - $OUTPUT->add_script(sprintf("%s%s.%s", + $OUTPUT->add_script(sprintf("%s%s.%s\n", $framed ? sprintf('if(parent.%s)parent.', $JS_OBJECT_NAME) : '', $JS_OBJECT_NAME, $command)); @@ -789,6 +789,19 @@ function rcube_remote_response($js_code, $flush=FALSE) } +// send correctly formatted response for a request posted to an iframe +function rcube_iframe_response($js_code='') + { + global $OUTPUT, $JS_OBJECT_NAME; + + if (!empty($js_code)) + $OUTPUT->add_script("if(parent.$JS_OBJECT_NAME){\n" . $js_code . "\n}"); + + $OUTPUT->write(); + exit; + } + + // read directory program/localization/ and return a list of available languages function rcube_list_languages() { diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc index dad64261e..630d2fb8b 100644 --- a/program/include/rcube_imap.inc +++ b/program/include/rcube_imap.inc @@ -1678,7 +1678,7 @@ function gethdrids($hdr) { $a = $this->_parse_address_list($input); $out = array(); - + if (!is_array($a)) return $out; @@ -2018,12 +2018,13 @@ function gethdrids($hdr) { $a = $this->_explode_quoted_string(',', $str); $result = array(); - + foreach ($a as $key => $val) { $val = str_replace("\"<", "\" <", $val); - $sub_a = $this->_explode_quoted_string(' ', $val); - + $sub_a = $this->_explode_quoted_string(' ', $this->decode_header($val)); + $result[$key]['name'] = ''; + foreach ($sub_a as $k => $v) { if ((strpos($v, '@') > 0) && (strpos($v, '.') > 0)) @@ -2033,9 +2034,7 @@ function gethdrids($hdr) } if (empty($result[$key]['name'])) - $result[$key]['name'] = $result[$key]['address']; - - $result[$key]['name'] = $this->decode_header($result[$key]['name']); + $result[$key]['name'] = $result[$key]['address']; } return $result; diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc index 8f4efdb07..eab175b65 100644 --- a/program/include/rcube_shared.inc +++ b/program/include/rcube_shared.inc @@ -33,6 +33,7 @@ class rcube_html_page var $script_tag_file = "\n"; var $script_tag = "\n"; + var $default_template = "\n
\n"; var $title = ''; var $header = ''; @@ -78,11 +79,12 @@ class rcube_html_page } - function set_title() + function set_title($t) { - + $this->title = $t; } + function set_charset($charset) { global $MBSTRING; @@ -95,16 +97,25 @@ class rcube_html_page $MBSTRING = FALSE; } } - + function get_charset() { return $this->charset; } + function reset() + { + $this->css = new rcube_css(); + $this->script_files = array(); + $this->scripts = array(); + $this->title = ''; + } + + function write($templ='', $base_path='') { - $output = trim($templ); + $output = empty($templ) ? $this->default_template : trim($templ); // set default page title if (!strlen($this->title)) diff --git a/program/js/app.js b/program/js/app.js index 51d9f8570..734241465 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -18,10 +18,9 @@ var CONTROL_KEY = 1; var SHIFT_KEY = 2; var CONTROL_SHIFT_KEY = 3; -var DRAFT_AUTOSAVE = 10; // Minutes +var DRAFT_AUTOSAVE = 5; // Minutes var rcube_webmail_client; -var rcube_save_timer; function rcube_webmail() { @@ -149,8 +148,8 @@ function rcube_webmail() this.enable_command('add-attachment', 'send-attachment', 'remove-attachment', 'send', true); if (this.env.spellcheck) this.enable_command('spellcheck', true); - if (this.env.drafts_mailbox) - this.enable_command('savedraft', true); + if (this.env.drafts_mailbox) + this.enable_command('savedraft', true); } if (this.env.messagecount) @@ -455,7 +454,6 @@ function rcube_webmail() // start the auto-save timer this.auto_save_start(); - }; this.init_address_input_events = function(obj) @@ -704,17 +702,15 @@ function rcube_webmail() { var uid = this.get_single_uid(); if (uid && (!this.env.uid || uid != this.env.uid)) - { + { if (this.env.mailbox==this.env.drafts_mailbox) { this.set_busy(true); location.href = this.env.comm_path+'&_action=compose&_draft_uid='+uid+'&_mbox='+escape(this.env.mailbox); } else - { this.show_message(uid); - } - } + } } else if (this.task=='addressbook') { @@ -933,33 +929,34 @@ function rcube_webmail() break; case 'savedraft': - // Reset the auto-save timer - self.clearTimeout(rcube_save_timer); + // Reset the auto-save timer + self.clearTimeout(this.save_timer); if (!this.gui_objects.messageform) break; - // if saving Drafts is disabled in main.inc.php - if (!this.env.drafts_mailbox) - break; + // if saving Drafts is disabled in main.inc.php + if (!this.env.drafts_mailbox) + break; this.set_busy(true, 'savingmessage'); var form = this.gui_objects.messageform; - form.target = "savetarget"; + form.target = "savetarget"; form.submit(); break; case 'send': if (!this.gui_objects.messageform) break; - + if (!this.check_compose_input()) break; // all checks passed, send message this.set_busy(true, 'sendingmessage'); var form = this.gui_objects.messageform; - form._draft.value=''; + form.target = "savetarget"; + form._draft.value = ''; form.submit(); break; @@ -968,7 +965,7 @@ function rcube_webmail() case 'send-attachment': // Reset the auto-save timer - self.clearTimeout(rcube_save_timer); + self.clearTimeout(this.save_timer); this.upload_file(props) break; @@ -2014,12 +2011,14 @@ function rcube_webmail() return true; }; - + + this.auto_save_start = function() { - rcube_save_timer = self.setTimeout('rcmail.command("savedraft","",this)',DRAFT_AUTOSAVE * 60000); - } - + this.save_timer = self.setTimeout('rcmail.command("savedraft","",this)', DRAFT_AUTOSAVE * 60000); + }; + + this.compose_field_hash = function() { // check input fields @@ -2190,7 +2189,7 @@ function rcube_webmail() for (i=0;i