// Tempo do auto refresh (em milisegundos) var time_refresh = 300000; // tempo do auto save (em milisegundos) // 20000 = 20 segundos var autosave_time = 20000; function init(){ if (!is_ie) Element('tableDivAppbox').width = '100%'; var save_contacts = function(data){ contacts = data; if (preferences.use_local_messages == 1 && window.google && google.gears) if (expresso_local_messages.is_offline_installed()) expresso_local_messages.capt_url('controller.php?action=$this.db_functions.get_dropdown_contacts_to_cache'); } var save_preferences = function(data){ preferences = data; current_folder="INBOX"; if( (window.google && google.gears) && !google.gears.factory.getPermission()) preferences.use_local_messages=0; if ((preferences.use_local_messages==1) && (!window.google || !google.gears)) { temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?")); if (temp) { location.href = "http://gears.google.com/?action=install&message="+ "Para utilizar o recurso de mensagens locais, instale o google gears&return=" + document.location.href; } else { preferences.use_local_messages=0; } } if (preferences.use_local_messages==1) { //O I.E 7 estava se atrapalhando caso esses loads fossem feitos após as chamadas ajax. Antes não apresentou problemas... connector.loadScript('mail_sync'); if (is_ie) connector.loadScript('TreeShow'); setTimeout('auto_archiving()', 30000); } cExecute ("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", handler_draw_box); cExecute ("$this.imap_functions.get_folders_list&onload=true", update_menu); cExecute ("$this.db_functions.get_dropdown_contacts", save_contacts); //Save contacts needs preferences. if(preferences.hide_folders == "1") Element('divAppboxHeader').innerHTML = title_app_menu; if (preferences.delete_trash_messages_after_n_days != 0) cExecute ("$this.imap_functions.automatic_trash_cleanness&before_date="+preferences.delete_trash_messages_after_n_days+"&cyrus_delimiter="+cyrus_delimiter, handler_automatic_trash_cleanness); if(preferences.outoffice == "1") write_msg(get_lang("Attention, you are in out of office mode."), true); ConstructMenuTools(); if ( (preferences.use_local_messages==1) && (expresso_local_messages.is_offline_installed()) ) //Precisa ser feito após a renderização da caixa de emails check_mail_in_queue(); // Insere a applet de criptografia if (preferences.use_signature_digital_cripto == '1'){ loadApplet(); } // Fim da inserção da applet } var handler_automatic_trash_cleanness = function(data){ if (data != false){ write_msg(data.length +' '+ Element('txt_clear_trash').value); } } // Versão Element('divAppboxHeader').innerHTML = title_app; // Get cyrus delimiter cyrus_delimiter = Element('cyrus_delimiter').value; cExecute ("$this.functions.get_preferences", save_preferences); cExecute ("phpgwapi.browser.isMobile", function( data ) { mobile_device = ( ( data.constructor == Boolean ) ? data : ( data === 'true' ) ); } ); setTimeout('auto_refresh()', time_refresh); } function init_offline(){ current_folder = 'local_Inbox'; if (account_id != null) { if (!is_ie) Element('tableDivAppbox').width = '100%'; else connector.createXMLHTTP(); Element('divStatusBar').innerHTML = '' + '' + '' + '' + '' + '
' + 'ExpressoMail Offline - Versão 1.0
'; ConstructMenuTools(); draw_tree_folders(); proxy_mensagens.messages_list('local_Inbox', 1, preferences.max_email_per_page, 'SORTARRIVAL', null, 1,1,1, function handler(data){ draw_box(data, 'local_Inbox'); }) // Get cyrus delimiter cyrus_delimiter = Element('cyrus_delimiter').value; cExecute ("$this.db_functions.get_dropdown_contacts_to_cache", function(data) {contacts = data;}); //cExecute ("$this.functions.get_preferences", save_preferences); } } /** * Carrega a applet java no objeto search_div * @author Mário César Kolling */ function loadApplet(){ var search_div = Element('search_div'); var applet = null; if (navigator.userAgent.match('MSIE')){ applet = document.createElement(''); var parameters = { type:'application/x-java-applet;version=1.5', code:'ExpressoSmimeApplet', codebase:'/security/', mayscript:'true', token: token_param, locale: locale, archive:'ExpressoCertMail.jar,' + 'ExpressoCert.jar,' + 'bcmail-jdk15-142.jar,' + 'mail.jar,' + 'activation.jar,' + 'bcprov-jdk15-142.jar,' + 'commons-codec-1.3.jar,' + 'commons-httpclient-3.1.jar,' + 'commons-logging-1.1.1.jar' //debug:'true' } if (parameters != 'undefined' && parameters != null){ for (var parameter in parameters) { var param = document.createElement("PARAM"); param.setAttribute("name",parameter); param.setAttribute("value",parameters[parameter]); applet.appendChild(param); } } } else { applet = document.createElement('embed'); applet.innerHTML = ' ' + //'type="application/x-java-applet;version=1.5" debug="true" mayscript > ' + ' ' + 'No Java Support. ' + ' ' + ' '; } if( applet != null ) { applet.style.top = "-100px"; applet.style.left = "-100px"; window.document.body.insertBefore( applet, document.body.lastChild ); } } function disable_field(field,condition) { var comando = "if ("+condition+") { document.getElementById('"+field.id+"').disabled=true;} else { document.getElementById('"+field.id+"').disabled=false; }"; eval(comando); } /* função que remove todos os anexos... */ function remove_all_attachments(folder,msg_num) { var call_back = function(data) { if(!data.status) { alert(data.msg); } else { msg_to_delete = Element(msg_num); change_tr_properties(msg_to_delete, data.msg_no); msg_to_delete.childNodes[1].innerHTML = ""; write_msg(get_lang("Attachments removed")); delete_border(msg_num+'_r','false'); //close email tab } }; if (confirm(get_lang("delete all attachments confirmation"))) cExecute ("$this.imap_functions.remove_attachments&folder=" +folder+"&msg_num="+msg_num, call_back); } function watch_changes_in_msg(border_id) { if (document.getElementById('border_id_'+border_id)) { function keypress_handler () { away=false; var save_link = Element("save_message_options_"+border_id); save_link.onclick = function onclick(event) { openTab.toPreserve[border_id] = true; save_msg(border_id); } ; save_link.className = 'message_options'; }; var obj = document.getElementById('body_'+border_id).contentWindow.document; if ( obj.addEventListener ) obj.addEventListener('keypress', keypress_handler, false); else if ( obj.attachEvent ) obj.attachEvent('onkeypress', keypress_handler); var subject_obj = document.getElementById('subject_'+border_id); if ( subject_obj.addEventListener ) subject_obj.addEventListener('keypress', keypress_handler, false); else if ( subject_obj.attachEvent ) subject_obj.attachEvent('onkeypress', keypress_handler); var to_obj = document.getElementById('to_'+border_id); if ( to_obj.addEventListener ) to_obj.addEventListener('keypress', keypress_handler, false); else if ( to_obj.attachEvent ) to_obj.attachEvent('onkeypress', keypress_handler); } } function show_msg_img(msg_number,folder){ var call_back = function(data){ data.showImg = true; if (!Element(data.msg_number)){ trElement = document.createElement('DIV'); trElement.id = data.msg_number; Element("tbody_box").appendChild(trElement); } show_msg(data); } proxy_mensagens.msg_img(msg_number,folder,call_back); } function show_msg(msg_info){ if(!verify_session(msg_info)) return; if (typeof(msg_info) != 'object') alert(get_lang("Error in show_msg param is not object")); if (msg_info.status_get_msg_info == 'false') { write_msg(get_lang("Problems reading your message")+ "."); return; } var handler_sendNotification = function(data){ if (data) write_msg(get_lang("A read confirmation was sent.")); else write_msg(get_lang("Error in SMTP sending read confirmation.")); } if(msg_info.source) { // Abrindo um e-mail criptografado // Verifica se existe o objeto applet if (!Element('cert_applet')){ // se não existir, mostra mensagem de erro. write_msg(get_lang('The preference "%1" isn\'t enabled.', get_lang('Enable digitally sign/cipher the message?'))); } else { // se existir prepara os dados para serem enviados e chama a // operação na applet connector.showProgressBar(); // if ((msg_info.DispositionNotificationTo) && ((msg_info.Unseen == 'U') || (msg_info.Recent == 'N'))){ /* var confNotification = confirm(get_lang("The sender waits your notification of reading. Do you want to confirm this?"), ""); if (confNotification)*/ // cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), handler_sendNotification); // } Element('cert_applet').doButtonClickAction('decript', msg_info.msg_number, msg_info.source, msg_info.msg_folder); // Passa os dados para a applet } return; } if (msg_info.status_get_msg_info == 'false') { write_msg(get_lang("Problems reading your message")+ "."); return; } if (msg_info.status == 'false'){ eval(msg_info.command_to_exec); } else{ var ID = msg_info.original_ID ? msg_info.original_ID : msg_info.msg_number; var id_msg_read = ID+"_r"; if (preferences.use_shortcuts == '1') select_msg(ID, 'null'); // Call function to draw message // If needed, delete old border if (openTab.type[currentTab] == 2 || openTab.type[currentTab] == 3) delete_border(currentTab,'false'); if(Element("border_id_" + id_msg_read)) { alternate_border(id_msg_read); resizeWindow(); } else { var border_id = create_border(msg_info.subject, id_msg_read); if(border_id) { openTab.type[border_id] = 2; draw_message(msg_info,border_id); var unseen_sort = document.getElementById('span_flag_UNSEEN').getAttribute('onclick'); unseen_sort = unseen_sort.toString(); if ( !(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'") < 0) ) { var sort_type = sort_box_type; sort_box_type = null; sort_box('UNSEEN', sort_type); } } else return; } var domains = ""; if ((msg_info.DispositionNotificationTo) && (!msg_is_read(ID) || (msg_info.Recent == 'N'))) { if (preferences.notification_domains != undefined && preferences.notification_domains != "") { domains = preferences.notification_domains.split(','); } else { var confNotification = true; } for (var i = 0; i < domains.length; i++) if (msg_info.DispositionNotificationTo.match(domains[i]+">")) { var confNotification = true; break; } if (confNotification == undefined) var confNotification = confirm(get_lang("The sender:\n%1\nwaits your notification of reading. Do you want to confirm this?",msg_info.DispositionNotificationTo), ""); if (confNotification) cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject), handler_sendNotification); } //Change msg class to read. if (!msg_is_read(ID)) { set_msg_as_read(ID, true); if (msg_info.cacheHit || (!proxy_mensagens.is_local_folder(get_current_folder()) && msg_info.original_ID)) { set_message_flag(ID, "seen"); // avoid caducous (lazy) data } } } } function auto_refresh(){ refresh(preferences.alert_new_msg); setTimeout('auto_refresh()', time_refresh); } function auto_archiving() { expresso_mail_sync.start_sync(); setTimeout('auto_archiving()',600000); } function refresh(alert_new_msg){ var handler_refresh = function(data){ if(!verify_session(data)) return; var box = Element("tbody_box"); if (box.childNodes.length == 0) { var tr_info = document.createElement("TR"); var td_info = document.createElement("TD"); td_info.setAttribute("colspan", "10"); td_info.setAttribute("background", "#FFF"); td_info.setAttribute("id","msg_info"); td_info.id = "msg_info"; td_info.align = "center"; td_info.style.padding = "25px"; td_info.style.fontWeight = "bold"; td_info.style.fontSize = "11pt"; td_info.innerHTML = get_lang("This mail box is empty"); tr_info.appendChild(td_info); box.appendChild(td_info); } if (data.length > 0){ var msg_info = document.getElementById('msg_info'); if (msg_info != null) { var msg_tr = msg_info.parentNode; msg_tr.removeChild(msg_info); } table_element = Element("table_box"); var box = Element("tbody_box"); table_element.appendChild(box); if (data.msgs_to_delete.length > 0) for (var i=0; i 0) alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!"); build_quota(data['quota']); } // Update Box BgColor var box = Element("tbody_box"); if(box.childNodes.length > 1){ updateBoxBgColor(box.childNodes); } connector.purgeCache(); update_menu(); } msg_range_end = (current_page*preferences.max_email_per_page); msg_range_begin = (msg_range_end-(preferences.max_email_per_page)+1); //Get element tBody. main = Element("tbody_box"); if(!main) return; // Get all TR (messages) in tBody. main_list = main.childNodes; var tmp = ''; var string_msgs_in_main = ''; var len = main_list.length; for (var j=0; j < len; j++) tmp += main_list[j].id + ','; string_msgs_in_main = tmp.substring(0,(tmp.length-1)); if(!expresso_offline) cExecute ("$this.imap_functions.refresh&folder="+current_folder+"&msgs_existent="+string_msgs_in_main+"&msg_range_begin="+msg_range_begin+"&msg_range_end="+msg_range_end+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse, handler_refresh); } function delete_msgs(folder, msgs_number, border_ID, show_success_msg,archive) { if (arguments.length < 4){ show_success_msg = true; } if (folder == 'null') folder = current_folder; if(openTab.type[currentTab] == 1) return move_search_msgs('content_id_'+currentTab,'INBOX'+cyrus_delimiter+trashfolder,trashfolder); if(currentTab.toString().indexOf("_r") != -1){ msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); } if (!archive && (parseInt(preferences.save_deleted_msg)) && (folder!='INBOX'+cyrus_delimiter+trashfolder)){ move_msgs2(folder, msgs_number, border_ID, 'INBOX'+cyrus_delimiter+trashfolder,trashfolder,show_success_msg ); return; } var handler_delete_msgs = function(data){ Element('chk_box_select_all_messages').checked = false; if (currentTab) mail_msg = Element("tbody_box_"+currentTab); else mail_msg = Element("tbody_box"); if ( preferences.use_shortcuts == '1') { //Last msg is selected if (mail_msg && exist_className(mail_msg.childNodes[mail_msg.childNodes.length-1], 'selected_shortcut_msg') ) { select_msg('null', 'up', true); } else { if (!select_msg('null', 'down', true)) { select_msg('null', 'up', true); } } } if (show_success_msg) { if (data.msgs_number.length == 1) write_msg(get_lang("The message was deleted.")); else write_msg(get_lang("The messages were deleted.")); } if (openTab.type[currentTab] > 1){ var msg_to_delete = Element(msgs_number); if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) { if (msg_to_delete.previousSibling){ var previous_msg = msg_to_delete.previousSibling.id; cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + url_encode(current_folder), show_msg); } else delete_border(currentTab,'false'); } else delete_border(currentTab,'false'); } for (var i=0; i 0 || parseInt(msgs_number) > 0) cExecute ("$this.imap_functions.delete_msgs&folder="+folder+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse, handler_delete_msgs); else write_msg(get_lang('No selected message.')); } function move_search_msgs(border_id, new_folder, new_folder_name){ var selected_messages = ''; var temp_msg; var main_list = Element("tbody_box_"+currentTab.substr(7)).childNodes; for (j = 0; j < main_list.length; j++) { var check_box = main_list[j].firstChild.firstChild; if(check_box && check_box.checked) { if (proxy_mensagens.is_local_folder(main_list[j].getAttribute('name'))) { alert(get_lang("You cant manipulate local messages on search")); return; } selected_messages += main_list[j].id + ','; } } selected_messages = selected_messages.substring(0,(selected_messages.length-1)); var handler_move_search_msgs = function(data){ if(!data || !data.msgs_number) return; else if(data.deleted) { if (data.msgs_number.length == 1) write_msg(get_lang("The message was deleted.")); else write_msg(get_lang("The messages were deleted.")); } else{ if (data.msgs_number.length == 1) write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); else write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); } selected_messages = selected_messages.split(","); for (i = 0; i < selected_messages.length; i++){ removeAll(selected_messages[i]); } // Update Box BgColor var box = Element("tbody_box_"+currentTab.substr(7)).childNodes; if(main_list.length > 1){ updateBoxBgColor(box); } connector.purgeCache(); } if (selected_messages){ var selected_param = ""; if (selected_messages.indexOf(',') != -1) { selected_msg_array = selected_messages.split(","); for (i = 0; i < selected_msg_array.length; i++){ var tr = Element(selected_msg_array[i]); if (tr.getAttribute('name') == new_folder) { write_msg(get_lang('At least one message have the same origin')); return false; } trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); selected_param += ','+trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); } } else { var tr=Element(selected_messages); if (tr.getAttribute('name') == new_folder) { write_msg(get_lang('The origin folder and the destination folder are the same.')); return false; } trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); selected_param=trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); } var params = ""; if (!new_folder && parseInt(preferences.save_deleted_msg)){ new_folder = 'INBOX'+cyrus_delimiter+trashfolder; new_folder_name = trashfolder; params = "&delete=true"; } params += "&selected_messages="+url_encode(selected_param); if(new_folder) { params += "&new_folder="+url_encode(new_folder); params += "&new_folder_name="+url_encode(new_folder_name); } cExecute ("$this.imap_functions.move_search_messages", handler_move_search_msgs, params); } else write_msg(get_lang('No selected message.')); } function move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,show_success_msg){ if (! folder || folder == 'null') folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder()); if(openTab.type[currentTab] == 1) return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name); var handler_move_msgs = function(data){ if(typeof(data) == 'string') if (data.match(/^(.*)TRYCREATE(.*)$/)){ connector.loadScript('TreeS'); var move_to_folder = data.match(/^(.*)Spam(.*)$/) ? "Spam" : trashfolder; alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.', move_to_folder)); connector.loadScript('TreeShow'); ttree.FOLDER = 'root'; ttreeBox.new_past(move_to_folder); return false; }else{ alert(get_lang('Error moving message.')+":\n"+data); return false; } //Este bloco verifica as permissoes ACL sobre pastas compartilhadas if(data.status == false){ alert(get_lang("You don't have permission for this operation in this shared folder!")); return false; } mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild; if (data.msgs_number.length == 1) write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); else write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); if (openTab.type[currentTab] > 1){ msg_to_delete = Element(msgs_number); if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) { if (msg_to_delete.previousSibling){ var previous_msg = msg_to_delete.previousSibling.id; //cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg); cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + url_encode(folder), show_msg); } else delete_border(currentTab,'false'); } else delete_border(currentTab,'false'); if(msg_to_delete) mail_msg.removeChild(msg_to_delete); // Update Box BgColor var box = Element("tbody_box"); if(box.childNodes.length > 0){ updateBoxBgColor(box.childNodes); } return; } Element('chk_box_select_all_messages').checked = false; if (! mail_msg) mail_msg = Element("tbody_box"); data.msgs_number = data.msgs_number.split(","); var msg_to_delete; if( typeof(msgs_number) == 'string' ) all_search_msg = msgs_number.split(','); else if( typeof(msgs_number) == 'number') all_search_msg = msgs_number; for (var i=0; i <= all_search_msg.length; i++) { msg_to_delete = Element(folder+';'+all_search_msg[i]); if (msg_to_delete) msg_to_delete.parentNode.removeChild(msg_to_delete); } if ( preferences.use_shortcuts == '1') { var all_messages = Element('tbody_box').childNodes; //Last msg is selected if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) { select_msg('null', 'up', true); } else { if (!select_msg('null', 'down', true)) { select_msg('null', 'up', true); } } } for (var i=0; i 0 || msgs_number.length > 0) cExecute ("$this.imap_functions.move_messages&folder="+folder+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+preferences.delete_and_show_previous_message, handler_move_msgs); else write_msg(get_lang('No selected message.')); } function move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name) { move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,true); } function archive_msgs(folder,folder_dest,id_msgs) { if(proxy_mensagens.is_local_folder(folder)) { write_msg(get_lang("You cant archive local mails")); return; } if(currentTab.toString().indexOf("_r") != -1){ id_msgs = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); } if(!id_msgs) id_msgs = get_selected_messages(); if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento... folder_dest = 'local_Inbox'; if (parseInt(id_msgs) > 0 || id_msgs.length > 0) expresso_mail_sync.archive_msgs(folder,folder_dest,id_msgs); //cExecute("$this.imap_functions.get_info_msgs&folder=" + folder + "&msgs_number=" + id_msgs , handler_arquivar_mensagens); else write_msg(get_lang('No selected message.')); } function get_selected_messages(){ try{ main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; }catch(e){ }; if (! main) main = Element("tbody_box"); // Get all TR (messages) in tBody. main_list = main.childNodes; var selected_messages = ''; var selected_messages_by_shortcuts = ''; var j = 0; for (j; j<(main_list.length); j++) { if (numBox > 0) { id_mensagem = main_list[j].id.split('_'); check_box = Element("search_" + numBox + "_check_box_message_" + id_mensagem[0]); } else check_box = Element("check_box_message_" + main_list[j].id); if ( (check_box) && (check_box.checked) ) selected_messages += main_list[j].id + ','; if (preferences.use_shortcuts == '1') { if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') ) { selected_messages_by_shortcuts += main_list[j].id + ','; } } } selected_messages = selected_messages.substring(0,(selected_messages.length-1)); if (preferences.use_shortcuts == '1') { selected_messages_by_shortcuts = selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1)); var array_selected_messages_by_shortcuts = selected_messages_by_shortcuts.split(","); var array_selected_messages = selected_messages.split(","); if ((array_selected_messages.length <= 1) && (array_selected_messages_by_shortcuts.length > 1)) { return selected_messages_by_shortcuts; } } if (selected_messages == '') return false; else return selected_messages; } function replaceAll(string, token, newtoken) { while (string.indexOf(token) != -1) { string = string.replace(token, newtoken); } return string; } function new_message_to(email) { var new_border_ID = new_message('new','null'); document.getElementById("to_" + new_border_ID).value=email; } function new_message(type, border_ID){ if (Element('show_img_link_'+border_ID)) { show_msg_img(border_ID.match(/^\d*/)[0], Element('input_folder_'+border_ID).value); } var new_border_ID = draw_new_message(parseInt(border_ID)); if(typeof(openTab.type[new_border_ID]) != "undefined") { if(tabTypes[type] == openTab.type[new_border_ID]) { return new_border_ID; } else { var a_types = { 6 : get_lang("Forward"),7 : get_lang("Reply"), 8 : get_lang("Reply to all with history"), 9 : get_lang("Reply without history"), 10: get_lang("Reply to all without history")}; if(!confirm(get_lang("Your message to %1 has not been saved or sent. "+ "To %2 will be necessary open it again. Discard your message?", a_types[openTab.type[new_border_ID]].toUpperCase(), a_types[tabTypes[type]].toUpperCase()))){ return new_border_ID; } else { delete_border(currentTab); new_border_ID = draw_new_message(parseInt(border_ID)); } } } if (new_border_ID == false) { setTimeout('new_message(\''+type+'\',\''+border_ID+'\');',500); return false; } openTab.type[new_border_ID] = tabTypes[type]; // Salva a pasta da mensagem respondida ou encaminhada: var folder_message = Element("input_folder_"+border_ID); if(folder_message) { var input_current_folder = document.createElement('input'); input_current_folder.id = "new_input_folder_"+border_ID; input_current_folder.name = "input_folder"; input_current_folder.type = "hidden"; input_current_folder.value = folder_message.value; Element("content_id_" + new_border_ID).appendChild(input_current_folder); }//Fim. var title = ''; data = []; if (Element("from_" + border_ID)){ if (document.getElementById("reply_to_" + border_ID)){ data.to = document.getElementById("reply_to_values_" + border_ID).value; data.to = data.to.replace(/</gi,"<"); data.to = data.to.replace(/>/gi,">"); } else { if (document.getElementById("from_values_" + border_ID)) { data.to = document.getElementById("from_values_" + border_ID).value; data.to = data.to.replace(/</gi,"<"); data.to = data.to.replace(/>/gi,">"); } } if (document.getElementById("to_values_" + border_ID)){ data.to_all = document.getElementById("to_values_" + border_ID).value; data.to_all = data.to_all.replace(/\n/gi," "); data.to_all = data.to_all.replace(/</gi,"<"); data.to_all = data.to_all.replace(/>/gi,">"); var _array_to_all = data.to_all.split(","); } } if (document.getElementById("cc_" + border_ID)){ data.cc = document.getElementById("cc_values_" + border_ID).value; data.cc = data.cc.replace(/</gi,"<"); data.cc = data.cc.replace(/>/gi,">"); } if (document.getElementById("cco_" + border_ID)){ data.cco = document.getElementById("cco_values_" + border_ID).value; data.cco = data.cco.replace(/</gi,"<"); data.cco = data.cco.replace(/>/gi,">"); } if (document.getElementById("subject_" + border_ID)) data.subject = document.getElementById("subject_" + border_ID).innerHTML; if (document.getElementById("body_" + border_ID)) data.body = document.getElementById("body_" + border_ID).innerHTML; if (Element('date_' + border_ID)){ data.date = Element('date_' + border_ID).innerHTML; } if (Element('date_day_' + border_ID)){ data.date_day = Element('date_day_' + border_ID).value; } if (Element('date_hour_' + border_ID)){ data.date_hour = Element('date_hour_' + border_ID).value; } if(typeof(preferences.signature) == 'undefined') preferences.signature = ""; var signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "
"); if(type!="new" && type!="edit") data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false; switch(type){ case "reply_without_history": Element("to_" + new_border_ID).value = data.to; title = "Re: " + data.subject; Element("subject_" + new_border_ID).value = "Re: " + data.subject; useOriginalAttachments(new_border_ID,border_ID,data.is_local_message); var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1"){ body.contentWindow.document.write("" + "
" + signature + ""); } else{ body.contentWindow.document.write(""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); config_events( body.contentWindow.document, 'onkeyup', function( e ) { if ( e.keyCode == 13 ) { var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); for ( p = 0; p < paragraphs.length; p++ ) paragraphs.item( p ).style.margin = '0px'; } }); msg_reply_from = document.createElement('input'); msg_reply_from.id = "msg_reply_from_" + new_border_ID; msg_reply_from.type = "hidden"; msg_reply_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_reply_from); break; case "reply_with_history": title = "Re: " + data.subject; Element("subject_" + new_border_ID).value = "Re: " + data.subject; Element("to_" + new_border_ID).value = data.to; useOriginalAttachments(new_border_ID,border_ID,data.is_local_message); block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + "" + block_quoted_body + ""); } else { body.contentWindow.document.write(""+block_quoted_body+""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); config_events( body.contentWindow.document, 'onkeyup', function( e ) { if ( e.keyCode == 13 ) { var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); for ( p = 0; p < paragraphs.length; p++ ) paragraphs.item( p ).style.margin = '0px'; } }); msg_reply_from = document.createElement('input'); msg_reply_from.id = "msg_reply_from_" + new_border_ID; msg_reply_from.type = "hidden"; msg_reply_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_reply_from); break; case "reply_to_all_without_history": // delete user email from to_all array. data.to_all = new Array(); var j = 0; for(i = 0; i < _array_to_all.length; i++) { if(_array_to_all[i].lastIndexOf(Element("user_email").value) == "-1"){ data.to_all[j++] = _array_to_all[i]; } } data.to_all = data.to_all.join(","); title = "Re: " + data.subject; Element("subject_" + new_border_ID).value = "Re: " + data.subject; Element("to_" + new_border_ID).value = data.to; Element("to_" + new_border_ID).value += ', ' + data.to_all; if (data.cc){ Element("cc_" + new_border_ID).value = data.cc; Element("a_cc_link_" + new_border_ID).style.display='none'; Element("tr_cc_" + new_border_ID).style.display=''; Element('space_link_' + new_border_ID).style.display='none'; } useOriginalAttachments(new_border_ID,border_ID,data.is_local_message); var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + ""); } else { body.contentWindow.document.write(""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); config_events( body.contentWindow.document, 'onkeyup', function( e ) { if ( e.keyCode == 13 ) { var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); for ( p = 0; p < paragraphs.length; p++ ) paragraphs.item( p ).style.margin = '0px'; } }); msg_reply_from = document.createElement('input'); msg_reply_from.id = "msg_reply_from_" + new_border_ID; msg_reply_from.type = "hidden"; msg_reply_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_reply_from); break; case "reply_to_all_with_history": // delete user email from to_all array. data.to_all = new Array(); var j = 0; for(i = 0; i < _array_to_all.length; i++) { if(_array_to_all[i].lastIndexOf(Element("user_email").value) == "-1"){ data.to_all[j++] = _array_to_all[i]; } } if (data.to_all != get_lang("undisclosed-recipient")) data.to_all = data.to_all.join(","); else data.to_all = ""; title = "Re: " + data.subject; Element("to_" + new_border_ID).value = data.to; Element("to_" + new_border_ID).value += ', ' + data.to_all; if (data.cc){ document.getElementById("cc_" + new_border_ID).value = data.cc; document.getElementById("a_cc_link_" + new_border_ID).style.display='none'; document.getElementById("tr_cc_" + new_border_ID).style.display=''; document.getElementById('space_link_' + new_border_ID).style.display='none'; } document.getElementById("subject_" + new_border_ID).value = "Re: " + data.subject; useOriginalAttachments(new_border_ID,border_ID,data.is_local_message); block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); var body = document.getElementById("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + "" + block_quoted_body + ""); } else { body.contentWindow.document.write(""+block_quoted_body+""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); config_events( body.contentWindow.document, 'onkeyup', function( e ) { if ( e.keyCode == 13 ) { var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); for ( p = 0; p < paragraphs.length; p++ ) paragraphs.item( p ).style.margin = '0px'; } }); msg_reply_from = document.createElement('input'); msg_reply_from.id = "msg_reply_from_" + new_border_ID; msg_reply_from.type = "hidden"; msg_reply_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_reply_from); break; case "forward": data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false; msg_forward_from = document.createElement('input'); msg_forward_from.id = "msg_forward_from_" + new_border_ID; msg_forward_from.type = "hidden"; msg_forward_from.value = Element("msg_number_" + border_ID).value; Element("content_id_" + new_border_ID).appendChild(msg_forward_from); title = "Fw: " + data.subject; document.getElementById("subject_" + new_border_ID).value = "Fw: " + data.subject; var divFiles = Element("divFiles_"+new_border_ID); var campo_arquivo; if (Element("attachments_" + border_ID)){ var attachments = document.getElementById("attachments_" + border_ID).getElementsByTagName("a"); for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){ if((attachments[i].tagName=="SPAN") || (attachments[i].tagName=="IMG") || ((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1))) continue; var link_attachment = document.createElement("A"); link_attachment.setAttribute("href", attachments[i].href); link_attachment.innerHTML = attachments[i].firstChild.nodeValue + '
'; if (data.is_local_message) {//Local messages document.getElementById("is_local_forward"+new_border_ID).value = "1"; var tmp = link_attachment.href.substring(link_attachment.href.indexOf("(") + 2);//Pula o parenteses e a aspas tmp = tmp.substring(0, tmp.length - 2);//corta a aspas e o parenteses tmp = replaceAll(tmp,"%20"," "); if (!tmp.match(/inc\/gotodownload.php/)) { //Anexos após ticket #1257 que usa gotodownload var tempNomeArquivo = tmp.split("/"); var nomeArquivo = tempNomeArquivo[tempNomeArquivo.length - 1]; } else { var tempNomeArquivo = tmp.split("&newfilename="); var nomeArquivo = tempNomeArquivo[tempNomeArquivo.length - 1]; } if(nomeArquivo.match(/\.[a-z]{1,3}\.php$/i)!=null) //Anexos no gears podem vir com .php depois de sua extensão. tenho que tirar o .php para ficar o nome real do arquivo. nomeArquivo = nomeArquivo.substring(0, nomeArquivo.length - 4); campo_arquivo = addForwardedFile(new_border_ID, nomeArquivo, link_attachment.href); if(!expresso_offline) expresso_local_messages.getInputFileFromAnexo(campo_arquivo, tmp); else //To offline, you just set the url on value of a hidden input. campo_arquivo.value = tmp; } else { var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); var a_tmp = tmp.split(','); tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; s_tmp = trim(escape(connector.serialize(a_tmp))); divFiles.innerHTML += ""; divFiles.innerHTML += ""; divFiles.appendChild(link_attachment); } } } var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + "" + make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc) + ""); } else { body.contentWindow.document.write(""+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)+""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; config_events( body.contentWindow.document, 'onkeyup', function( e ) { if ( e.keyCode == 13 ) { var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); for ( p = 0; p < paragraphs.length; p++ ) paragraphs.item( p ).style.margin = '0px'; } }); Element("to_" + new_border_ID).focus(); break; case "new": title = get_lang("New Message"); if(Element('msg_number').value) { var _to = Element('msg_number').value; var reEmail = /^[A-Za-z\d_-]+(\.[A-Za-z\d_-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/; if(!reEmail.test(_to)){ var array_contacts = contacts.split(','); for(i = 0; i < array_contacts.length;i++) { if(array_contacts[i].lastIndexOf(_to) != "-1"){ var _group = array_contacts[i].split(";"); _to = '"'+_group[0]+'" <'+_group[1]+'>'; break; } } } Element("to_" + new_border_ID).value = _to +','; Element('msg_number').value = ''; } var body = document.getElementById("body_" + new_border_ID); body.contentWindow.document.open(); // Insert the signature automaticaly at message body if use_signature preference is set if (preferences.use_signature == "1") { body.contentWindow.document.write("" + "
" + signature + ""); } else { body.contentWindow.document.write(""); } body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; config_events( body.contentWindow.document, 'onkeyup', function( e ) { if ( e.keyCode == 13 ) { var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); for ( p = 0; p < paragraphs.length; p++ ) paragraphs.item( p ).style.margin = '0px'; } }); Element("to_" + new_border_ID).focus(); break; case "edit": openTab.imapBox[new_border_ID] = folder_message.value; openTab.toPreserve[new_border_ID] = true; openTab.imapUid[new_border_ID] = parseInt(border_ID.substr(0,border_ID.indexOf("_"))); document.getElementById('font_border_id_'+new_border_ID).innerHTML = data.subject; title = "Edição: "+data.subject; data.to = Element("to_values_" + border_ID).value; if( data.to != get_lang("without destination") ) { data.to = data.to.replace(/</gi,"<"); data.to = data.to.replace(/>/gi,">"); } else { data.to = ""; } Element("to_" + new_border_ID).value = data.to; if (data.cc){ Element("cc_" + new_border_ID).value = data.cc; Element("space_link_" + new_border_ID).style.display = 'none'; Element("a_cc_link_" + new_border_ID).style.display = 'none'; Element("tr_cc_"+ new_border_ID).style.display = ''; } if (data.cco){ Element("cco_" + new_border_ID).value = data.cco; Element("space_link_" + new_border_ID).style.display = 'none'; Element("a_cco_link_" + new_border_ID).style.display = 'none'; Element("tr_cco_"+ new_border_ID).style.display = ''; } Element("subject_" + new_border_ID).value = data.subject; if( Element("disposition_notification_" + border_ID) ) Element("return_receipt_" + new_border_ID).checked = true; var element_important_message = Element("important_message_" + new_border_ID); if(element_important_message) { if(Element("is_important_" + border_ID).value == "1") element_important_message.checked = true; } var divFiles = Element("divFiles_"+new_border_ID); if (Element("attachments_" + border_ID)){ var attachments = document.getElementById("attachments_" + border_ID).childNodes; for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){ var link_attachment = document.createElement("A"); link_attachment.setAttribute("href", attachments[i].href); link_attachment.innerHTML = attachments[i].innerHTML; var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); var a_tmp = tmp.split(','); tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; s_tmp = trim(escape(connector.serialize(a_tmp))); divFiles.innerHTML += ""; divFiles.appendChild(link_attachment); } } var body = Element("body_" + new_border_ID); body.contentWindow.document.open(); body.contentWindow.document.write(""+data.body+""); body.contentWindow.document.close(); body.contentWindow.document.designMode = "on"; //Focus if (is_ie) window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); else body.contentWindow.focus(); config_events( body.contentWindow.document, 'onkeyup', function( e ) { if ( e.keyCode == 13 ) { var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); for ( p = 0; p < paragraphs.length; p++ ) paragraphs.item( p ).style.margin = '0px'; } }); break; default: } // IM Module Enabled if( window.parent.loadscript && loadscript.autoStatusIM ) { config_events( body.contentWindow.document, "onkeypress", loadscript.autoStatusIM ); } if ( ! expresso_offline ) { if ( mobile_device ) { var text_plain = document.getElementById( 'textplain_rt_checkbox_' + new_border_ID ); text_plain.click( ); text_plain.parentNode.style.display = 'none'; } } if (preferences.auto_save_draft == 1) { openTab.autosave_timer[new_border_ID] = false; var save_link = document.getElementById("save_message_options"+new_border_ID); function auto_sav() { if (openTab.autosave_timer[new_border_ID]) clearTimeout(openTab.autosave_timer[new_border_ID]); openTab.autosave_timer[new_border_ID] = setTimeout("save_msg("+new_border_ID+")", autosave_time); } config_events(body.contentWindow.document,'keypress', auto_sav); } //BEGIN Tab event if (preferences.use_shortcuts == '1') { if (is_ie) { body.contentWindow.document.attachEvent('onkeydown', function(event) { if(event.keyCode==27){delete_border(new_border_ID,'false');} if(event.keyCode==9) { Element('to_'+new_border_ID).focus(); Element('send_button_'+new_border_ID).focus(); return false;} }, false); } else { body.contentWindow.document.addEventListener('keypress', function(event) { if(event.keyCode==27){delete_border(new_border_ID,'false');} if(event.keyCode==9) { Element('send_button_'+new_border_ID).focus(); event.preventDefault(); } }, false); } } // END Tab event // Load default style for
 tag, inside RichTextEditor.
	RichTextEditor.loadStyle("pre","main.css");

	Element("border_id_" + new_border_ID).title = title;
	set_border_caption("border_id_" + new_border_ID, title);

        if(!expresso_offline && preferences.use_SpellChecker != '0')
	    setupSpellChecker();

	return new_border_ID; //Preciso retornar o ID da nova mensagem.
}

function useOriginalAttachments(new_id_border,old_id_border,is_local)
{
	var divFiles = Element("divFiles_"+new_id_border);
	if (Element("attachments_" + old_id_border)) {
		var areaOldAttachments = document.createElement("DIV");
		areaOldAttachments.id = "area_div_attachments_"+new_id_border;
		divFiles.appendChild(areaOldAttachments);
		var optAttachments = document.createElement("A");
		optAttachments.setAttribute("href","javascript:void(0)");
		optAttachments.tabIndex = -1;
		optAttachments.innerHTML = get_lang("Original attachments: add")+"
"; areaOldAttachments.appendChild(optAttachments); var divOriginalAttachments = document.createElement("DIV"); divOriginalAttachments.id = "div_attachments_"+new_id_border; optAttachments.onclick = function(){ if(document.getElementById('div_attachments_'+new_id_border)) { areaOldAttachments.removeChild(document.getElementById('div_attachments_'+new_id_border)); optAttachments.innerHTML = get_lang("Original attachments: add")+"
"; } else { areaOldAttachments.appendChild(divOriginalAttachments); optAttachments.innerHTML = get_lang("Original attachments: remove")+"
"; } return false;}; var attachments = document.getElementById("attachments_" + old_id_border).getElementsByTagName("a"); for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){ if (!is_local) { var link_attachment = document.createElement("A"); link_attachment.setAttribute("href", attachments[i].href); link_attachment.innerHTML = attachments[i].firstChild.nodeValue + '
'; var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); var a_tmp = tmp.split(','); tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; s_tmp = trim(escape(connector.serialize(a_tmp))); divOriginalAttachments.innerHTML += ""; divOriginalAttachments.appendChild(link_attachment); } else { document.getElementById("is_local_forward"+new_id_border).value = "1"; var link = attachments[i].href.replace("javascript:download_local_attachment('", "").replace("')", ""); var name = attachments[i].innerHTML.substring(0, attachments[i].innerHTML.lastIndexOf("(")); var campo_arquivo = addForwardedFile(new_id_border, name, attachments[i].href, divOriginalAttachments); expresso_local_messages.getInputFileFromAnexo(campo_arquivo, link); } } } } function send_message_return(data, ID){ watch_changes_in_msg(ID); var sign = false; var crypt = false; if ((preferences.use_assinar_criptografar != '0') && (preferences.use_signature_digital_cripto != '0')){ var checkSign = document.getElementById('return_digital_'+ID) if (checkSign.checked){ sign = true; } var checkCript = document.getElementById('return_cripto_'+ID); if (checkCript.checked){ crypt = true; } } if (typeof(data) == 'object' && !data.success) { connector = new cConnector(); connector.showProgressBar(); if (sign || crypt){ var operation = ''; if (sign){ operation = 'sign'; } else { // crypt //TODO: Colocar mensagem de erro, e finalizar o método. operation = 'nop'; } } if (data.body){ Element('cert_applet').doButtonClickAction(operation, ID, data.body); } else { alert(data.error); } return; } if(data && data.success == true ){ // if send ok, set a flag as answered or forwarded var msg_number_replied = Element('msg_reply_from_'+ID); var msg_number_forwarded = Element('msg_forward_from_'+ID); if (msg_number_replied){ proxy_mensagens.proxy_set_message_flag(msg_number_replied.value, 'answered'); } else if (msg_number_forwarded){ proxy_mensagens.proxy_set_message_flag(msg_number_forwarded.value, 'forwarded'); } if(expresso_offline){ write_msg(get_lang('Your message was sent to queue')); delete_border(ID,'true'); return; }else{ if (wfolders.alert) { write_msg(get_lang('Your message was sent and save.')); wfolders.alert = false; } else { write_msg(get_lang('Your message was sent.')); } } // If new dynamic contacts were added, update the autocomplete .... if(data.new_contacts){ var ar_contacts = data.new_contacts.split(',;'); for(var j in ar_contacts){ // If the dynamic contact don't exist, update the autocomplete.... if((contacts+",").indexOf(";"+ar_contacts[j]+",") == -1) contacts += ",;" + ar_contacts[j]; } } if ((! openTab.toPreserve[ID]) && (openTab.imapUid[ID] != 0)) cExecute ("$this.imap_functions.delete_msgs&folder="+openTab.imapBox[ID]+"&msgs_number="+openTab.imapUid[ID],function(data){ return }); delete_border(ID,'true'); // Becarefull: email saved automatically should be deleted. delete_border erase information about openTab } else{ if(data == 'Post-Content-Length') write_msg(get_lang('The size of this message has exceeded the limit (%1B).',Element('upload_max_filesize').value)); else if(data) write_msg(data); else write_msg(get_lang("Connection failed with %1 Server. Try later.", "Web")); var save_link = Element("save_message_options_"+ID); save_link.onclick = function onclick(event) { openTab.toPreserve[ID] = true; save_msg(ID); } ; save_link.className = 'message_options'; } if(!expresso_offline) connector.hideProgressBar(); } /** * Método chamado pela applet para retornar o resultado da assinatura/decifragem do e-mail. * para posterior envio ao servidor. * @author Mário César Kolling , Bruno Vieira da Costa * @param smime O e-mail decifrado/assinado * @param ID O ID do e-mail, para saber em que aba esse e-mail será mostrado. * @param operation A operação que foi realizada pela applet (assinatura ou decifragem) */ function appletReturn(smime, ID, operation, folder){ if (!smime){ // Erro aconteceu ao assinar ou decifrar e-mail connector = new cConnector(); connector.hideProgressBar(); return; } if(operation=='decript') { var handler = function(data){ if(data.msg_day == '') { header=expresso_local_messages.get_msg_date(data.original_ID, proxy_mensagens.is_local_folder(get_current_folder())); data.fulldate=header.fulldate; data.smalldate=header.smalldate; data.msg_day = header.msg_day; data.msg_hour = header.msg_hour; } this.show_msg(data); } para="&source="+smime+"&ID="+ID+"&folder="+folder; cExecute ("$this.imap_functions.show_decript&", handler, para); }else { ID_tmp = ID; // Lê a variável e chama a nova função cExecuteForm // Processa e envia para o servidor web // Faz o request do connector novamente. Talvez implementar no connector // para manter coerência. var handler_send_smime = function(data){ send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug }; var textArea = document.createElement("TEXTAREA"); textArea.style.display='none'; textArea.id = 'smime'; textArea.name = "smime"; textArea.value += smime; // Lê a variável e chama a nova função cExecuteForm // Processa e envia para o servidor web // Faz o request do connector novamente. Talvez implementar no connector // para manter coerência. if (is_ie){ var i = 0; while (document.forms(i).name != "form_message_"+ID){i++} form = document.forms(i); } else form = document.forms["form_message_"+ID]; form.appendChild(textArea); cExecuteForm ("$this.imap_functions.send_mail", form, handler_send_smime, ID); } } function send_message(ID, folder, folder_name){ //limpa autosave_timer[ID]; havia conflito quando uma mensagem ia ser enviada e nesse exato momento o autosave //entrava em execucao (a aba de edicao da mensagem continuava aberta e a mensagem exibida era a de que a mensagem foi //salva na pasta Rascunhos e nao que tinha sido enviada, como deveria); if (preferences.auto_save_draft == 1) { if (openTab.autosave_timer[ID]) { clearTimeout(openTab.autosave_timer[ID]); } } if ( document.getElementById('viewsource_rt_checkbox_' + ID).checked == true ) document.getElementById('viewsource_rt_checkbox_' + ID).click(); var save_link = Element("save_message_options_"+ID); save_link.onclick = ''; save_link.className = 'message_options_inactive'; ID_tmp = ID; var handler_send_message = function(data){ send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug }; var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + ID ); mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false; var textArea = document.createElement("TEXTAREA"); textArea.style.display='none'; textArea.name = "body"; body = document.getElementById("body_"+ID); textArea.value = ( ( mail_as_plain ) ? body.previousSibling.value : ( '\r\n' + body.contentWindow.document.body.innerHTML + '\r\n' ) ); var input_folder = document.createElement("INPUT"); input_folder.style.display='none'; input_folder.name = "folder"; input_folder.value = folder; var msg_id = document.createElement("INPUT"); msg_id.style.display='none'; msg_id.name = "msg_id"; msg_id.value = openTab.imapUid[ID]; if (is_ie){ var i = 0; while (document.forms(i).name != "form_message_"+ID){i++} form = document.forms(i); } else form = document.forms["form_message_"+ID]; // Evita que e-mails assinados sejam enviados quando o usuário tenta enviar um e-mail // não assinado (desmarcou a opção) após tentar enviar um e-mail assinado que não passou // no teste de validação. var checkSign = document.getElementById('return_digital_'+ID); if (checkSign && !checkSign.checked){ var smime = Element('smime'); if (smime) { var parent = smime.parentNode; parent.removeChild(smime); } } form.appendChild(textArea); form.appendChild(input_folder); form.appendChild(msg_id); var mail_type = document.createElement('input'); mail_type.setAttribute('type', 'hidden'); mail_type.name = 'type'; mail_type.value = ( mail_as_plain ) ? 'plain' : 'html'; form.parentNode.appendChild(mail_type); var _subject = trim(Element("subject_"+ID).value); if((_subject.length == 0) && !confirm(get_lang("Send this message without a subject?"))) { Element("subject_"+ID).focus(); return; } if (expresso_offline) { stringEmail = Element("to_"+ID).value; stringEmail += Element("cco_"+ID).value =='' ? "":", "+Element("cco_"+ID).value; stringEmail += Element("cc_"+ID).value =='' ? "":", "+Element("cc_"+ID).value; var invalidEmail = searchEmail(stringEmail); if(Element("to_"+ID).value=="" && Element("cco_"+ID).value=="" && Element("cc_"+ID).value=="") { write_msg(get_lang("message without receiver.")); return; }else if(invalidEmail[0] == true){ write_msg("Os endereços de destinatário a seguir estão incorretos: "+invalidEmail[1]); return; } sucess = expresso_local_messages.send_to_queue(form); var data_return = new Array(); data_return.success = sucess; handler_send_message(data_return,ID); } else cExecuteForm("$this.imap_functions.send_mail", form, handler_send_message, ID); } function change_tr_properties(tr_element, newUid, newSubject){ message_id=tr_element.id; var td_who = document.getElementById('td_who_'+message_id); if (typeof(newSubject) != 'undefined') td_who.nextSibling.innerHTML = newSubject; tr_element.id = newUid; var openNewMessage = function () { cExecute("$this.imap_functions.get_info_msg&msg_number="+newUid +"&msg_folder="+url_encode(current_folder),show_msg); }; for (var i=2; i < 10; i++){ if (typeof(tr_element.childNodes[i].id) != "undefined") tr_element.childNodes[i].id = tr_element.childNodes[i].id.replace(message_id,newUid); tr_element.childNodes[i].onclick = openNewMessage; } } function return_save(data,border_id,folder_name,folder_id,message_id) { Element("send_button_"+border_id).style.visibility="visible"; var handler_delete_msg = function(data){ refresh(preferences.alert_new_msg); }; if (data.append != true || !data) { RichTextEditor.saveFlag = -1; if (! data.append) if(data == 'Post-Content-Length') write_msg(get_lang('The size of this message has exceeded the limit (%1B).', preferences.max_attachment_size ? preferences.max_attachment_size : Element('upload_max_filesize').value)); else write_msg(get_lang('ERROR saving your message.')); else { if (data.append.match(/^(.*)TRYCREATE(.*)$/)) { connector.loadScript('TreeS'); alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.',draftsfolder)); connector.loadScript('TreeShow'); ttree.FOLDER = 'root'; ttreeBox.new_past(draftsfolder); setTimeout('save_msg('+border_id+')',3000); } else write_msg(data.append); } } else { RichTextEditor.saveFlag = 1; openTab.imapUid[border_id] = data.msg_no; openTab.imapBox[border_id] = data.folder_id; var newTitle = document.getElementById('subject_'+border_id).value; if (newTitle == '') newTitle = get_lang("No subject"); set_border_caption('border_id_'+border_id, newTitle); // Replace the embedded images for new uids var mainField = document.getElementById('body_'+border_id).contentWindow; var content_body = mainField.document.getElementsByTagName('body').item(0).innerHTML; var body_images = content_body.match(/msg_num=\d*/g); var images_part = content_body.match(/msg_part=\d*/g); if (body_images) { for (var i=0; i\r\n' + body.contentWindow.document.body.innerHTML + '\r\n' ) ); var input_folder = document.createElement("INPUT"); input_folder.style.display='none'; input_folder.name = "folder"; input_folder.value = folder_id; var input_msgid = document.createElement("INPUT"); input_msgid.style.display='none'; input_msgid.name = "msg_id"; input_msgid.value = message_id; var input_insertImg = document.createElement("INPUT"); input_insertImg.style.display='none'; input_insertImg.name = "insertImg"; input_insertImg.value = withImage; if (is_ie){ var i = 0; while (document.forms(i).name != "form_message_"+border_id){i++} form = document.forms(i); } else form = document.forms["form_message_"+border_id]; form.appendChild(textArea); form.appendChild(input_folder); form.appendChild(input_msgid); form.appendChild(input_insertImg); var mail_type = document.createElement('input'); mail_type.name = 'type'; mail_type.setAttribute('type', 'hidden'); mail_type.value = ( mail_as_plain ) ? 'plain' : 'html'; form.parentNode.appendChild(mail_type); cExecuteForm ("$this.imap_functions.save_msg", form, handler_save_msg,border_id); } function return_saveas(data,border_id,folder_name) { if(!verify_session(data)) return; if (data.append) { delete_border(border_id,null); write_msg(get_lang('Your message was save as draft in folder %1.', folder_name)); } else write_msg('ERROR saving your message.'); } function save_as_msg(border_id, folder_id, folder_name){ // hack to avoid form connector bug, escapes quotation. Please see #179 tmp_border_id=border_id; tmp_folder_name=folder_name; var handler_save_msg = function(data){ return_saveas(data,this.tmp_border_id,this.tmp_folder_name); } var textArea = document.createElement("TEXTAREA"); textArea.style.display='none'; textArea.name = "body"; body = document.getElementById("body_"+border_id); textArea.value += '\r\n'; textArea.value += body.contentWindow.document.body.innerHTML; textArea.value += '\r\n'; var input_folder = document.createElement("INPUT"); input_folder.style.display='none'; input_folder.name = "folder"; input_folder.value = folder_id; if (is_ie){ var i = 0; while (document.forms(i).name != "form_message_"+border_id){i++} form = document.forms(i); } else form = document.forms["form_message_"+border_id]; form.appendChild(textArea); form.appendChild(input_folder); cExecuteForm ("$this.imap_functions.save_msg", form, handler_save_msg,border_id); } // Get checked messages function set_messages_flag(flag, msgs_to_set){ var handler_set_messages_flag = function (data){ if(!verify_session(data)) return; var msgs_to_set = data.msgs_to_set.split(","); if(!data.status) { write_msg(data.msg); Element('chk_box_select_all_messages').checked = false; for (var i = 0; i < msgs_to_set.length; i++) { Element("check_box_message_" + msgs_to_set[i]).checked = false; remove_className(Element(msgs_to_set[i]), 'selected_msg'); } if(!data.msgs_unflageds) return; else msgs_to_set = data.msgs_unflageds.split(","); } for (var i=0; i'; break; case "forwarded": Element("td_message_answered_"+msg_number).innerHTML = ''; break; } } else { refresh(); } } cExecute ("$this.imap_functions.set_messages_flag&folder="+( msg_number_folder ? msg_number_folder.value : get_current_folder() )+"&msgs_to_set="+msg_number+"&flag="+flag, handler_set_messages_flag); } function print_all(){ if (openTab.type[currentTab] == 2) return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab); var folder= Element('border_id_0').innerHTML; var body = Element('divScrollMain_'+numBox).innerHTML; var print_width = screen.width - 200; var x = ((screen.width - print_width) / 2); var y = ((screen.height - 400) / 2) - 35; var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); var seekDot = /\"; window_print.document.body.innerHTML = html + '
' + '' + '' + '' + '' + '
'+get_lang("Who")+''+get_lang("Subject")+''+get_lang("Date")+''+get_lang("Size")+'
' + body + '
'; break; } catch(e){ //alert(e.message); } } window_print.document.close(); window_print.print(); } function print_msg(msg_folder, msg_number, border_ID){ var div_toaddress_full = Element("div_toaddress_full_"+border_ID); var div_ccaddress_full = Element("div_ccaddress_full_"+border_ID); var div_ccoaddress_full = Element("div_ccoaddress_full_"+border_ID); var printListTO = (div_toaddress_full && div_toaddress_full.style.display != 'none') || toaddress_array[border_ID].length == 1 ? true : false; var printListCC = (div_ccaddress_full && div_ccaddress_full.style.display != 'none') || !div_ccaddress_full ? true : false; var printListCCO = (div_ccoaddress_full && div_ccoaddress_full.style.display != 'none') || !div_ccoaddress_full ? true : false; var sender = Element('sender_values_'+border_ID) ? Element('sender_values_'+border_ID).value : null; var from = Element('from_values_'+border_ID) ? Element('from_values_'+border_ID).value : null; var to = Element('to_values_'+border_ID) ? Element('to_values_'+border_ID).value :null; var cco = Element('cco_values_'+border_ID) ? Element('cco_values_'+border_ID).value : null; var cc = Element('cc_values_'+border_ID) ? Element('cc_values_'+border_ID).value : null; var date = Element('date_'+border_ID); var subject = Element('subject_'+border_ID); var attachments = Element('attachments_'+border_ID); var body = Element('body_'+border_ID); if(!is_ie) { var link = location.href.replace(/\/expressoMail1_2\/(.*)/, ""); var tab_tags = body.getElementsByTagName("IMG"); for(var i = 0; i < tab_tags.length;i++) { var _img = document.createElement("IMG"); _img.src = tab_tags[i].src; if(tab_tags[i].src.toUpperCase().indexOf('/INC/SHOW_EMBEDDED_ATTACH.PHP?MSG_FOLDER=') > -1) { _img.src = link + '/expressoMail1_2'+tab_tags[i].src.substr(tab_tags[i].src.toUpperCase().indexOf('/INC/SHOW_EMBEDDED_ATTACH.PHP?MSG_FOLDER=')); } tab_tags[i].parentNode.replaceChild(_img,tab_tags[i]); } } var print_width = screen.width - 200; var x = ((screen.width - print_width) / 2); var y = ((screen.height - 400) / 2) - 35; var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); if(window_print == null) { alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname)); return; } //needed to get the names of the attachments... only. if(attachments != null) { var a = attachments.childNodes; var attachs = ""; var show_attachs = ""; for(i=3;i"+attachs+""; } else{ show_attachs = ""; } var current_path = window.location.href.substr(0,window.location.href.lastIndexOf("/")); var head = ''; window_print.document.write(head); while (1){ try{ var html =''; html += "

ExpressoLivre - ExpressoMail


"; html += ''; if(sender) html += ""; if(from) html += ""; if(to) { if(!printListTO) to = 'Os destinatários não estão sendo exibidos para esta impressão'; html += ""; } if (cc) { if(!printListCC) cc = 'Os destinatários não estão sendo exibidos para esta impressão'; html += ""; } if (cco) { if(!printListCCO) cco = 'Os destinatários não estão sendo exibidos para esta impressão'; html += ""; } if(date) html += ""; html += ""; html += show_attachs; //to show the names of the attachments html += "
" + get_lang('Sent by') + ": "+sender+"
" + get_lang('From') + ": "+from+"
" + get_lang('To') + ": "+to+"
" + get_lang('Cc') + ": "+cc+"
" + get_lang('Cco') + ": "+cco+"
" + get_lang('Date') + ": "+date.innerHTML+"
" + get_lang('Subject')+ ": "+subject.innerHTML+"

"; window_print.document.write(html + body.innerHTML); if(!is_ie){ var tab_tags = window_print.document.getElementsByTagName("IMG"); for(var i = 0; i < tab_tags.length;i++){ var _img = document.createElement("IMG"); _img.src = tab_tags[i].src; tab_tags[i].parentNode.replaceChild(_img,tab_tags[i]); } } break; } catch(e){ //alert(e.message); } } window_print.document.close(); window_print.print(); } function empty_trash_imap(){ var handler_empty_trash = function(data){ Element('chk_box_select_all_messages').checked = false; if(!verify_session(data)) return; tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder).alter({caption: get_lang("Trash")}); tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder)._refresh(); update_quota(get_current_folder()); if (data){ write_msg(get_lang('Your Trash folder was empty.')); if (get_current_folder() == 'INBOX'+cyrus_delimiter+trashfolder){ draw_paging(0); kill_current_box(); Element('tot_m').innerHTML = 0; Element('new_m').innerHTML = 0; } } else write_msg(get_lang('ERROR emptying your Trash folder.')); } var realyEmptyTrash=confirm(get_lang('Do you really want to empty your trash folder?')); if (realyEmptyTrash) cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultTrashFolder", handler_empty_trash); } function empty_spam_imap(){ var handler_empty_spam = function(data){ Element('chk_box_select_all_messages').checked = false; if(!verify_session(data)) return; if (get_current_folder() == 'INBOX'+cyrus_delimiter+spamfolder){ draw_paging(0); kill_current_box(); } tree_folders.getNodeById('INBOX'+cyrus_delimiter+spamfolder).alter({caption: get_lang("Spam")}); tree_folders.getNodeById('INBOX'+cyrus_delimiter+spamfolder)._refresh(); update_quota(get_current_folder()); if (data) write_msg(get_lang('Your Spam folder was empty.')); else write_msg(get_lang('ERROR emptying your Spam folder.')); } var realyEmptySpam=confirm(get_lang('Do you really want to empty your spam folder?')); if (realyEmptySpam) cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultSpamFolder", handler_empty_spam); } function export_all_selected_msgs(){ if (openTab.type[currentTab] > 1){ source_msg(currentTab,current_folder); return; } var msgs_to_export = this.get_selected_messages(); var handler_export_all_selected_msgs = function(data){ if(!data){ write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.')); } else download_attachments(null, null, data, null,null,'mensagens.zip'); } if (msgs_to_export) { cExecute ("$this.exporteml.makeAll", handler_export_all_selected_msgs, "folder="+get_current_folder()+"&msgs_to_export="+msgs_to_export); write_msg(get_lang('You must wait while the messages will be exported...')); } else write_msg(get_lang('No selected message.')); } function select_all_search_messages(select, id){ var search_box = Element("table_resultsearch_" + id.substr(18)).firstChild; var felement = search_box.firstChild; while(felement) { if (select) felement.firstChild.firstChild.checked = true; else felement.firstChild.firstChild.checked = false; felement = felement.nextSibling; } } function verify_session(data){ if(data && data.imap_error) { if(data.imap_error == "nosession") write_msg(get_lang("your session could not be verified.")); else write_msg(data.imap_error); // Hold sesion for edit message. //if(!hold_session) // location.href="../login.php?cd=10&phpgw_forward=%2FexpressoMail1_2%2Findex.php"; return false; } else return true; } // Save image file. function save_image(e,thumb,file_type){ file_type = file_type.replace("/","."); thumb.oncontextmenu = function(e) { return false; } var _button = is_ie ? window.event.button : e.which; var _target = is_ie ? event.srcElement : e.target; if(_button == 2 || _button == 3) { var _params = _target.id.split(";;"); download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type); } } function nospam(msgs_number, border_ID, folder){ if (folder == 'null') folder = get_current_folder(); var new_folder = 'INBOX'; var new_folder_name = get_lang('INBOX'); var handler_move_msgs = function(data){ if (msgs_number == 'selected') set_messages_flag("unseen", "get_selected_messages"); else proxy_mensagens.proxy_set_message_flag(msgs_number, "unseen"); proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name); if (openTab.type[currentTab] > 1) delete_border(currentTab,'false'); } if(currentTab.toString().indexOf("_r") != -1) msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); else if(msgs_number == 'selected') msgs_number = get_selected_messages(); if (parseInt(msgs_number) > 0 || msgs_number.length > 0) cExecute ("$this.imap_functions.spam&folder="+folder+"&spam=false"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+preferences.delete_and_show_previous_message+"&cyrus_delimiter="+cyrus_delimiter, handler_move_msgs); else write_msg(get_lang('No selected message.')); } function spam(folder, msgs_number, border_ID){ if (folder == 'null') folder = get_current_folder(); var new_folder = 'INBOX'+cyrus_delimiter+'Spam'; var new_folder_name = 'Spam'; var handler_move_msgs = function(data){ proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name); if (openTab.type[currentTab] > 1) delete_border(currentTab,'false'); } if(currentTab.toString().indexOf("_r") != -1) msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); else if(msgs_number == 'selected') msgs_number = get_selected_messages(); if(parseInt(msgs_number) > 0 || msgs_number.length > 0) cExecute ("$this.imap_functions.spam&folder="+folder+"&spam=true"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+preferences.delete_and_show_previous_message+"&cyrus_delimiter="+cyrus_delimiter, handler_move_msgs); else write_msg(get_lang('No selected message.')); } function import_window(){ var win = arrayJSWin["import_window"]; var form_upload = Element("form_upload"); if(!win) { var form = document.createElement("DIV"); form.id = "import_window"; form.style.visibility = "hidden"; form.style.position = "absolute"; form.style.background = "#eeeeee"; form.style.left = "0px"; form.style.top = "0px"; form.style.width = "0px"; form.style.height = "0px"; document.body.appendChild(form); form_upload = document.createElement("DIV"); form_upload.id = "form_upload"; form_upload.style.position = "absolute"; form_upload.style.top = "5px"; form_upload.style.left = "5px"; form_upload.name = get_lang('zip mails to import'); form_upload.style.width = "450px"; form_upload.style.height = "75px"; form.appendChild(form_upload); form.style.width = form.firstChild.style.width; form.style.height = form.firstChild.style.height; form.style.zIndex = "10000"; var title = form.firstChild.name; var wHeight = form.offsetHeight + "px"; var wWidth = form.offsetWidth + "px"; form.style.width = form.offsetWidth - 5; win = new dJSWin({ id: 'win_'+form.id, content_id: form.id, width: wWidth, height: wHeight, title_color: '#3978d6', bg_color: '#eee', title: title, title_text_color: 'white', button_x_img: '../phpgwapi/images/winclose.gif', border: true }); win.draw(); } form_upload.innerHTML = '
'+get_lang('zip mails to import')+':
'+ '
' + ' ' + '
'; win.open(); } function import_msgs(wfolders_tree){ function handler(data){ // Its necessary to encapsulate the data returned (IE bugfix) return_import_msgs(data,wfolders_tree); } var countFiles = document.form_import.countFiles; if(!countFiles){ countFiles = document.createElement("INPUT"); countFiles.type = "hidden"; countFiles.name = "countFiles"; countFiles.value = "1"; document.form_import.appendChild(countFiles); } var folder = document.createElement("INPUT"); folder.type = "hidden"; folder.name = "folder"; folder.value = wfolders_tree._selected.id; document.form_import.appendChild(folder); write_msg(get_lang('You must wait while the messages will be imported...')); cExecuteForm('$this.imap_functions.import_msgs', document.form_import, handler); } function return_import_msgs(data, wfolders_tree){ if(data && data.error){ write_msg(data.error); } else{ if(data == 'Post-Content-Length') write_msg(get_lang('The size of this message has exceeded the limit (%1B).', preferences.max_attachment_size ? preferences.max_attachment_size : Element('upload_max_filesize').value)); else { /* * @author Rommel Cysne (rommel.cysne@serpro.gov.br) * @date 2009/05/15 * Foi colocado um teste para verificar se a pasta selecionada, passada como parametro, * eh uma pasta local (qualquer uma) */ var er = /^local_/; if ( er.test(wfolders_tree._selected.id) ) { archive_msgs('INBOX/Lixeira/tmpMoveToLocal',wfolders_tree._selected.id,data); cExecute('$this.imap_functions.delete_mailbox',function(){},'del_past=INBOX/Lixeira/tmpMoveToLocal'); } else{ write_msg(get_lang(data)); arrayJSWin["import_window"].close(); if(openTab.imapBox[0] == wfolders_tree._selected.id) { openTab.imapBox[0] = ''; change_folder(wfolders_tree._selected.id, wfolders_tree._selected.caption); } else{ refresh(); } } } } } function select_import_folder(){ //Begin: Verify if the file extension is allowed. var imgExtensions = new Array("eml","zip"); var inputFile = document.form_import.file_1; if(!inputFile.value){ alert(get_lang('File extension forbidden or invalid file') + '.'); return false; } var fileExtension = inputFile.value.split("."); fileExtension = fileExtension[(fileExtension.length-1)]; var deniedExtension = true; for(var i=0; i0) { control = confirm(get_lang('You have messages to send. Want you to send them now?')); if(control) { send_mail_from_queue(true); } return true; } else { return false; } } function force_check_queue() { if(!check_mail_in_queue()) { write_msg(get_lang("No messages to send")); } } function searchEmail(emailString){ var arrayInvalidEmails = new Array(); arrayInvalidEmails[1] = ''; var email; var arrayEmailsFull = new Array(); arrayEmailsFull = emailString.split(','); var er_Email = new RegExp("<(.*?)>"); // TODO Use validateEmail of common functions ! var er_ValidaEmail = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"); for (i=0; i < arrayEmailsFull.length; i++){ email = er_Email.exec(arrayEmailsFull[i]); tempEmail = email == null ? arrayEmailsFull[i]:email[1]; tempEmail = tempEmail.replace(/^\s+|\s+$/g,""); if (tempEmail != '') { singleEmail = er_ValidaEmail.exec(tempEmail); if (singleEmail == null) { arrayInvalidEmails[0] = true; arrayInvalidEmails[1] += (email == null ? arrayEmailsFull[i] : email[1]) + "; "; } } } return arrayInvalidEmails; }