[2517] | 1 | // Tempo do auto refresh (em milisegundos) |
---|
| 2 | var time_refresh = 300000; |
---|
| 3 | // tempo do auto save (em milisegundos) |
---|
| 4 | // 20000 = 20 segundos |
---|
| 5 | var autosave_time = 20000; |
---|
| 6 | |
---|
| 7 | function init(){ |
---|
[2642] | 8 | BordersArray[0] = new setBorderAttributes(0); |
---|
| 9 | wfolders = new cWFolders(); |
---|
| 10 | |
---|
[2517] | 11 | current_folder = "INBOX"; |
---|
| 12 | if (!is_ie) |
---|
[2519] | 13 | if ( Element('tableDivAppbox') ) |
---|
[2520] | 14 | Element('tableDivAppbox').width = '100%'; |
---|
[2517] | 15 | |
---|
| 16 | var save_contacts = function(data){ |
---|
[2578] | 17 | contacts = expresso.connector.unserialize( data ); |
---|
[2517] | 18 | if (preferences.use_local_messages == 1 && window.google && google.gears) |
---|
| 19 | if (expresso_local_messages.is_offline_installed()) |
---|
| 20 | expresso_local_messages.capt_url('controller.php?action=expressoMail1_2.db_functions.get_dropdown_contacts_to_cache'); |
---|
| 21 | |
---|
[2556] | 22 | }; |
---|
[2578] | 23 | var save_preferences = function(data) |
---|
| 24 | { |
---|
[2656] | 25 | preferences = data.JSON( ); |
---|
[2645] | 26 | _connector.cache(); |
---|
[2578] | 27 | _connector.go( { |
---|
| 28 | "access" : "expressoMail1_2.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end=" |
---|
| 29 | + preferences.max_email_per_page + "&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", |
---|
[2628] | 30 | "cache" : true, |
---|
[2578] | 31 | "handler" : handler_draw_box |
---|
| 32 | } ); |
---|
[2517] | 33 | |
---|
| 34 | if(preferences.hide_folders == "1") |
---|
| 35 | Element('divAppboxHeader').innerHTML = title_app_menu; |
---|
| 36 | |
---|
| 37 | if (preferences.delete_trash_messages_after_n_days != 0) |
---|
[2603] | 38 | _connector.go( { |
---|
| 39 | "access" : "expressoMail1_2.imap_functions.automatic_trash_cleanness&before_date=" |
---|
| 40 | + preferences.delete_trash_messages_after_n_days + "&cyrus_delimiter=" + cyrus_delimiter, |
---|
[2929] | 41 | "handler" : _hand_automtrash_clean |
---|
[2603] | 42 | } ); |
---|
[2517] | 43 | |
---|
| 44 | if(preferences.outoffice == "1") |
---|
| 45 | write_msg(get_lang("Attention, you are in out of office mode."), true); |
---|
| 46 | |
---|
| 47 | if ((preferences.use_local_messages==1) && (!window.google || !google.gears)) { |
---|
| 48 | temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?")); |
---|
| 49 | if (temp) { |
---|
| 50 | location.href = "http://gears.google.com/?action=install&message="+ |
---|
| 51 | "Para utilizar o recurso de mensagens locais, instale o google gears&return=" + document.location.href; |
---|
| 52 | } |
---|
| 53 | else { |
---|
| 54 | preferences.use_local_messages=0; |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | ConstructMenuTools(); |
---|
| 59 | |
---|
| 60 | if (preferences.use_local_messages==1) { |
---|
| 61 | expresso.connector.loadScript('jscode/mail_sync'); |
---|
| 62 | if (is_ie) |
---|
| 63 | expresso.connector.loadScript('jscode/TreeShow'); |
---|
| 64 | setTimeout('auto_archiving()', 30000); |
---|
| 65 | if (expresso_local_messages.is_offline_installed()) { |
---|
| 66 | check_mail_in_queue(); |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | // Insere a applet de criptografia |
---|
| 71 | if (preferences.use_signature_digital_cripto == '1'){ |
---|
| 72 | loadApplet(); |
---|
| 73 | } |
---|
| 74 | // Fim da inserção da applet |
---|
| 75 | |
---|
[2645] | 76 | _connector.cache(); |
---|
[2578] | 77 | _connector.go( { //Save contacts needs preferences. |
---|
| 78 | "access" : "expressoMail1_2.db_functions.get_dropdown_contacts", |
---|
[2628] | 79 | "cache" : true, |
---|
[2578] | 80 | "handler" : save_contacts |
---|
| 81 | } ); |
---|
[2645] | 82 | _connector.cache(); |
---|
[2603] | 83 | _connector.go( { |
---|
| 84 | "access" : "expressoMail1_2.imap_functions.get_folders_list&onload=true", |
---|
[2628] | 85 | "cache" : true, |
---|
[2603] | 86 | "handler" : function( data ) |
---|
| 87 | { |
---|
| 88 | update_menu( expresso.connector.unserialize( data ) ); |
---|
| 89 | } |
---|
| 90 | } ); |
---|
[2517] | 91 | |
---|
[2556] | 92 | }; |
---|
[2929] | 93 | var _hand_automtrash_clean = function(data){ |
---|
[2603] | 94 | data = expresso.connector.unserialize( data ); |
---|
[2517] | 95 | if (data != false){ |
---|
| 96 | write_msg(data.length +' '+ Element('txt_clear_trash').value); |
---|
| 97 | } |
---|
[2556] | 98 | }; |
---|
[2517] | 99 | |
---|
| 100 | // Versão |
---|
[2561] | 101 | if ( Element('divAppboxHeader') ) |
---|
| 102 | Element('divAppboxHeader').innerHTML = title_app; |
---|
[2645] | 103 | _connector.cache(); |
---|
[2578] | 104 | _connector.go( { |
---|
| 105 | "access" : "expressoMail1_2.functions.get_preferences", |
---|
| 106 | "handler" : save_preferences |
---|
| 107 | } ); |
---|
[2517] | 108 | setTimeout('auto_refresh()', time_refresh); |
---|
| 109 | |
---|
[2628] | 110 | refresh(preferences.alert_new_msg); |
---|
[2517] | 111 | } |
---|
| 112 | |
---|
| 113 | function init_offline(){ |
---|
| 114 | if (account_id != null) { |
---|
| 115 | if (!is_ie) |
---|
| 116 | Element('tableDivAppbox').width = '100%'; |
---|
| 117 | else |
---|
| 118 | expresso.connector.createXMLHTTP(); |
---|
| 119 | Element('divStatusBar').innerHTML = '<table height="16px" border=0 width=100% cellspacing=0 cellpadding=2>' + |
---|
| 120 | '<tr>' + |
---|
| 121 | '<td style="padding-left:17px" width=33% id="content_quota" align=left></td>' + |
---|
| 122 | '<td width=33% height=16px align=center nowrap><font face=Verdana, Arial, Helvetica, sans-serif color=#000066 size=2>' + |
---|
| 123 | '<b>ExpressoMail Offline</b><font size=1><b> - Versão 1.0</b></font></td>' + |
---|
| 124 | '<td width=33% id="div_menu_c3" align=right></td>' + |
---|
| 125 | '</tr></table>'; |
---|
| 126 | |
---|
| 127 | ConstructMenuTools(); |
---|
| 128 | |
---|
| 129 | draw_tree_folders(); |
---|
| 130 | |
---|
| 131 | proxy_mensagens.messages_list('local_Inbox', 1, preferences.max_email_per_page, 'SORTARRIVAL', null, 1,1,1, function handler(data){ |
---|
[2743] | 132 | draw_box.draw_newBox(data, 'local_Inbox'); |
---|
[2556] | 133 | }); |
---|
[2517] | 134 | |
---|
| 135 | // Get cyrus delimiter |
---|
| 136 | cyrus_delimiter = Element('cyrus_delimiter').value; |
---|
| 137 | |
---|
| 138 | cExecute ("expressoMail1_2.db_functions.get_dropdown_contacts_to_cache", function(data) {contacts = data;}); |
---|
| 139 | //cExecute ("expressoMail1_2.functions.get_preferences", save_preferences); |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | /** |
---|
| 143 | * Carrega a applet java no objeto search_div |
---|
| 144 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 145 | */ |
---|
| 146 | |
---|
| 147 | function loadApplet(){ |
---|
| 148 | |
---|
| 149 | var search_div = Element('search_div'); |
---|
| 150 | var applet = null; |
---|
| 151 | if (navigator.userAgent.match('MSIE')){ |
---|
| 152 | applet = document.createElement('<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" ' + |
---|
| 153 | 'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"></object>'); |
---|
| 154 | |
---|
| 155 | //applet = document.createElement('object'); |
---|
| 156 | //var attributes = { |
---|
| 157 | // style:'display:yes;width:0;height:0;vertical-align:bottom;', |
---|
| 158 | // id:'cert_applet', |
---|
| 159 | // classid:'clsid:8AD9C840-044E-11D1-B3E9-00805F499D93' |
---|
| 160 | //} |
---|
| 161 | |
---|
| 162 | var parameters = { |
---|
| 163 | type:'application/x-java-applet;version=1.5', |
---|
| 164 | code:'ExpressoSmimeApplet', |
---|
| 165 | codebase:'/security/', |
---|
| 166 | mayscript:'true', |
---|
| 167 | token: token_param, |
---|
| 168 | locale: locale, |
---|
| 169 | archive:'ExpressoCertMail.jar,' + |
---|
| 170 | 'ExpressoCert.jar,' + |
---|
| 171 | 'bcmail-jdk15-142.jar,' + |
---|
| 172 | 'mail.jar,' + |
---|
| 173 | 'activation.jar,' + |
---|
| 174 | 'bcprov-jdk15-142.jar,' + |
---|
| 175 | 'commons-codec-1.3.jar,' + |
---|
| 176 | 'commons-httpclient-3.1.jar,' + |
---|
| 177 | 'commons-logging-1.1.1.jar' |
---|
| 178 | //debug:'true' |
---|
[2556] | 179 | }; |
---|
[2517] | 180 | |
---|
| 181 | //for (var attribute in attributes){ |
---|
| 182 | // applet.setAttribute(attribute, attributes[attribute]); |
---|
| 183 | //} |
---|
| 184 | |
---|
| 185 | if (parameters != 'undefined' && parameters != null){ |
---|
| 186 | for (var parameter in parameters) { |
---|
| 187 | var param = document.createElement("PARAM"); |
---|
| 188 | param.setAttribute("name",parameter); |
---|
| 189 | param.setAttribute("value",parameters[parameter]); |
---|
| 190 | applet.appendChild(param); |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | search_div.appendChild(applet); |
---|
| 194 | //alert(search_div.innerHTML); |
---|
| 195 | //alert(window.); |
---|
| 196 | } |
---|
| 197 | else { |
---|
| 198 | applet = document.createElement('embed'); |
---|
| 199 | applet.innerHTML = '<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" code="ExpressoSmimeApplet.class" ' + |
---|
| 200 | 'codebase="/security/" locale="'+locale+'"'+ |
---|
| 201 | '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" ' + |
---|
| 202 | 'token="' + token_param + '" ' + |
---|
| 203 | 'type="application/x-java-applet;version=1.5" mayscript > ' + |
---|
| 204 | //'type="application/x-java-applet;version=1.5" debug="true" mayscript > ' + |
---|
| 205 | '<noembed> ' + |
---|
| 206 | 'No Java Support. ' + |
---|
| 207 | '</noembed> ' + |
---|
| 208 | '</embed> '; |
---|
| 209 | search_div.appendChild(applet); |
---|
| 210 | } |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | function disable_field(field,condition) { |
---|
| 214 | var comando = "if ("+condition+") { document.getElementById('"+field.id+"').disabled=true;} else { document.getElementById('"+field.id+"').disabled=false; }"; |
---|
| 215 | eval(comando); |
---|
| 216 | } |
---|
| 217 | /* |
---|
| 218 | função que remove todos os anexos... |
---|
| 219 | */ |
---|
| 220 | function remove_all_attachments(folder,msg_num) { |
---|
| 221 | |
---|
| 222 | var call_back = function(data) { |
---|
| 223 | if(!data.status) { |
---|
| 224 | alert(data.msg); |
---|
| 225 | } |
---|
| 226 | else { |
---|
| 227 | msg_to_delete = Element(msg_num); |
---|
| 228 | change_tr_properties(msg_to_delete, data.msg_no); |
---|
| 229 | msg_to_delete.childNodes[1].innerHTML = ""; |
---|
| 230 | write_msg(get_lang("Attachments removed")); |
---|
| 231 | delete_border(msg_num+'_r','false'); //close email tab |
---|
| 232 | } |
---|
| 233 | }; |
---|
| 234 | if (confirm(get_lang("delete all attachments confirmation"))) |
---|
| 235 | cExecute ("expressoMail1_2.imap_functions.remove_attachments&folder=" |
---|
| 236 | +folder+"&msg_num="+msg_num, call_back); |
---|
| 237 | } |
---|
| 238 | function watch_changes_in_msg(border_id) |
---|
| 239 | { |
---|
| 240 | if (document.getElementById('border_id_'+border_id)) |
---|
| 241 | { |
---|
| 242 | function keypress_handler () |
---|
| 243 | { |
---|
| 244 | away=false; |
---|
| 245 | var save_link = Element("save_message_options_"+border_id); |
---|
| 246 | save_link.onclick = function onclick(event) { openTab.toPreserve[border_id] = true; save_msg(border_id); } ; |
---|
| 247 | save_link.className = 'message_options'; |
---|
| 248 | }; |
---|
| 249 | |
---|
| 250 | var obj = document.getElementById('body_'+border_id).contentWindow.document; |
---|
| 251 | if ( obj.addEventListener ) |
---|
| 252 | obj.addEventListener('keypress', keypress_handler, false); |
---|
| 253 | else if ( obj.attachEvent ) |
---|
| 254 | obj.attachEvent('onkeypress', keypress_handler); |
---|
| 255 | |
---|
| 256 | var subject_obj = document.getElementById('subject_'+border_id); |
---|
| 257 | if ( subject_obj.addEventListener ) |
---|
| 258 | subject_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 259 | else if ( subject_obj.attachEvent ) |
---|
| 260 | subject_obj.attachEvent('onkeypress', keypress_handler); |
---|
| 261 | |
---|
| 262 | var to_obj = document.getElementById('to_'+border_id); |
---|
| 263 | if ( to_obj.addEventListener ) |
---|
| 264 | to_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 265 | else if ( to_obj.attachEvent ) |
---|
| 266 | to_obj.attachEvent('onkeypress', keypress_handler); |
---|
| 267 | |
---|
| 268 | } |
---|
| 269 | } |
---|
| 270 | |
---|
| 271 | function show_msg_img(msg_number,folder){ |
---|
| 272 | var call_back = function(data){ |
---|
| 273 | data.showImg = true; |
---|
[2801] | 274 | var table_message = Element('table_message_'+data.msg_number+'_r'); |
---|
| 275 | var tbody_message = table_message.childNodes[0]; |
---|
| 276 | if(tbody_message.childNodes.length > 1) |
---|
| 277 | tbody_message.removeChild(tbody_message.lastChild); |
---|
| 278 | |
---|
[2517] | 279 | if (!Element(data.msg_number)){ |
---|
| 280 | trElement = document.createElement('DIV'); |
---|
| 281 | trElement.id = data.msg_number; |
---|
| 282 | Element("tbody_box").appendChild(trElement); |
---|
| 283 | } |
---|
| 284 | show_msg(data); |
---|
[2556] | 285 | }; |
---|
[2753] | 286 | for (var i=0; i < draw_box.headers_msgs.length; i++) |
---|
| 287 | if (draw_box.headers_msgs[i].msg_number == msg_number){ |
---|
| 288 | var info_msg = draw_box.headers_msgs[i]; |
---|
| 289 | break; |
---|
| 290 | } |
---|
| 291 | proxy_mensagens.get_msg(info_msg,folder,null,call_back); |
---|
[2517] | 292 | } |
---|
| 293 | |
---|
| 294 | function show_msg(msg_info){ |
---|
| 295 | if (typeof(msg_info) != 'object') |
---|
| 296 | alert(get_lang("Error in show_msg param is not object")); |
---|
[2714] | 297 | |
---|
[2517] | 298 | if (msg_info.status_get_msg_info == 'false') |
---|
| 299 | { |
---|
| 300 | write_msg(get_lang("Problems reading your message")+ "."); |
---|
| 301 | return; |
---|
| 302 | } |
---|
[2930] | 303 | var _hand_sendnotif = function(data){ |
---|
[2517] | 304 | if (data) |
---|
| 305 | write_msg(get_lang("A read confirmation was sent.")); |
---|
| 306 | else |
---|
| 307 | write_msg(get_lang("Error in SMTP sending read confirmation.")); |
---|
[2556] | 308 | }; |
---|
[2714] | 309 | |
---|
[2517] | 310 | if(msg_info.source) |
---|
| 311 | { |
---|
[2714] | 312 | // Abrindo um e-mail criptografado |
---|
| 313 | // Verifica se existe o objeto applet |
---|
| 314 | if (!Element('cert_applet')){ |
---|
| 315 | // se não existir, mostra mensagem de erro. |
---|
| 316 | write_msg(get_lang('The preference "%1" isn\'t enabled.', get_lang('Enable digitally sign/cipher the message?'))); |
---|
| 317 | } else { |
---|
| 318 | // se existir prepara os dados para serem enviados e chama a |
---|
| 319 | // operação na applet |
---|
[2517] | 320 | |
---|
[2714] | 321 | expresso.connector.showProgressBar(); |
---|
[2517] | 322 | |
---|
[2714] | 323 | // if ((msg_info.DispositionNotificationTo) && ((msg_info.Unseen == 'U') || (msg_info.Recent == 'N'))){ |
---|
| 324 | /* var confNotification = confirm(get_lang("The sender waits your notification of reading. Do you want to confirm this?"), ""); |
---|
| 325 | if (confNotification)*/ |
---|
[2930] | 326 | // cExecute ("expressoMail1_2.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), _hand_sendnotif); |
---|
[2714] | 327 | // } |
---|
[2517] | 328 | |
---|
[2714] | 329 | Element('cert_applet').doButtonClickAction('decript', |
---|
| 330 | msg_info.msg_number, |
---|
| 331 | msg_info.source, |
---|
| 332 | msg_info.msg_folder); // Passa os dados para a applet |
---|
| 333 | } |
---|
[2517] | 334 | return; |
---|
| 335 | |
---|
| 336 | } |
---|
| 337 | |
---|
| 338 | if (msg_info.status == 'false'){ |
---|
[2714] | 339 | delete_border(msg_info.reuse_border); |
---|
[2517] | 340 | } |
---|
| 341 | else{ |
---|
[2714] | 342 | var ID = msg_info.original_ID ? msg_info.original_ID : msg_info.msg_number; |
---|
| 343 | var id_msg_read = ID+"_r"; |
---|
[2517] | 344 | |
---|
| 345 | if (preferences.use_shortcuts == '1') |
---|
| 346 | select_msg(ID, 'null'); |
---|
| 347 | // Call function to draw message |
---|
| 348 | // If needed, delete old border |
---|
[2714] | 349 | if(currentTab) |
---|
| 350 | { |
---|
[2715] | 351 | draw_msg.draw_message_body(msg_info,currentTab); |
---|
[2714] | 352 | var unseen_sort = document.getElementById('span_flag_UNSEEN').getAttribute('onclick'); |
---|
| 353 | unseen_sort = unseen_sort.toString(); |
---|
| 354 | if ( !(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'") < 0) ) |
---|
[2517] | 355 | { |
---|
[2714] | 356 | var sort_type = sort_box_type; |
---|
| 357 | sort_box_type = null; |
---|
| 358 | sort_box('UNSEEN', sort_type); |
---|
[2517] | 359 | } |
---|
| 360 | } |
---|
[2718] | 361 | else{ |
---|
| 362 | /* No tab avaliable, the draw_message_header hasn't finished?! */ |
---|
[2752] | 363 | setTimeout('expresso.connector.cacheNextRequest(); cExecute("expressoMail1_2.imap_functions.get_info_msg&msg_number='+ ID +'&msg_folder=' + current_folder+'", show_msg)',100); |
---|
[2718] | 364 | } |
---|
[2517] | 365 | |
---|
| 366 | var domains = ""; |
---|
| 367 | if ((msg_info.DispositionNotificationTo) && (!msg_is_read(ID) || (msg_info.Recent == 'N'))) |
---|
[2714] | 368 | { |
---|
[2517] | 369 | if (preferences.notification_domains != undefined && preferences.notification_domains != "") |
---|
[2714] | 370 | { |
---|
[2517] | 371 | domains = preferences.notification_domains.split(','); |
---|
[2714] | 372 | } |
---|
[2517] | 373 | else |
---|
[2714] | 374 | { |
---|
[2517] | 375 | var confNotification = true; |
---|
[2714] | 376 | } |
---|
[2517] | 377 | for (var i = 0; i < domains.length; i++) |
---|
| 378 | if (msg_info.DispositionNotificationTo.match(domains[i]+">")) |
---|
| 379 | { |
---|
| 380 | var confNotification = true; |
---|
| 381 | break; |
---|
| 382 | } |
---|
[2714] | 383 | if (confNotification == undefined) |
---|
| 384 | var confNotification = confirm(get_lang("The sender:\n%1\nwaits your notification of reading. Do you want to confirm this?",msg_info.DispositionNotificationTo), ""); |
---|
[2517] | 385 | if (confNotification) |
---|
[2930] | 386 | cExecute ("expressoMail1_2.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), _hand_sendnotif); |
---|
[2517] | 387 | } |
---|
| 388 | //Change msg class to read. |
---|
| 389 | if (!msg_is_read(ID)) |
---|
| 390 | { |
---|
[2714] | 391 | set_msg_as_read(ID, true); |
---|
[2517] | 392 | if (msg_info.cacheHit || (!proxy_mensagens.is_local_folder(get_current_folder()) && msg_info.original_ID)) |
---|
[2714] | 393 | { |
---|
[2517] | 394 | set_message_flag(ID, "seen"); // avoid caducous (lazy) data |
---|
[2714] | 395 | } |
---|
| 396 | } |
---|
[2517] | 397 | } |
---|
[2798] | 398 | resizeWindow(); |
---|
[2517] | 399 | } |
---|
| 400 | |
---|
| 401 | function auto_refresh(){ |
---|
| 402 | refresh(preferences.alert_new_msg); |
---|
| 403 | setTimeout('auto_refresh()', time_refresh); |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | function auto_archiving() { |
---|
| 407 | expresso_mail_sync.start_sync(); |
---|
| 408 | setTimeout('auto_archiving()',600000); |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | function refresh(alert_new_msg){ |
---|
| 412 | var handler_refresh = function(data){ |
---|
| 413 | var box = Element("tbody_box"); |
---|
| 414 | if (box.childNodes.length == 0) |
---|
| 415 | { |
---|
[2525] | 416 | var tr_info = document.createElement("TR"); |
---|
| 417 | var td_info = document.createElement("TD"); |
---|
| 418 | td_info.setAttribute("colspan", "10"); |
---|
[2517] | 419 | td_info.setAttribute("background", "#FFF"); |
---|
[2525] | 420 | tr_info.setAttribute("id", "msg_info"); |
---|
[2517] | 421 | td_info.align = "center"; |
---|
[2525] | 422 | td_info.style.padding = "25px"; |
---|
| 423 | td_info.style.fontWeight = "bold"; |
---|
| 424 | td_info.style.fontSize = "11pt"; |
---|
[2517] | 425 | td_info.innerHTML = get_lang("This mail box is empty"); |
---|
[2525] | 426 | tr_info.appendChild(td_info); |
---|
| 427 | box.appendChild(tr_info); |
---|
[2517] | 428 | } |
---|
| 429 | |
---|
| 430 | if (data.length > 0){ |
---|
[2556] | 431 | var msg_info = document.getElementById('msg_info'); |
---|
[2517] | 432 | if (msg_info != null) |
---|
| 433 | main.removeChild(msg_info); |
---|
| 434 | |
---|
| 435 | table_element = Element("table_box"); |
---|
| 436 | var box = Element("tbody_box"); |
---|
| 437 | table_element.appendChild(box); |
---|
| 438 | |
---|
| 439 | if (data[0].msg_folder != current_folder) // Bad request |
---|
| 440 | return false; |
---|
| 441 | |
---|
| 442 | for (var i=0; i<data.length; i++){ |
---|
| 443 | var existent = document.getElementById(data[i].msg_number); |
---|
| 444 | if (!existent) |
---|
| 445 | { |
---|
[2801] | 446 | var new_msg = this.make_tr_message(data[i], current_folder); |
---|
[2517] | 447 | _dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true); |
---|
| 448 | eval(data[i].command); |
---|
| 449 | } |
---|
| 450 | } |
---|
| 451 | if (! typeof(data.msgs_to_delete) == 'undefined') |
---|
| 452 | for (var i=0; i<data.msgs_to_delete.length; i++){ |
---|
| 453 | var remove_msg = document.getElementById(data.msgs_to_delete[i]); |
---|
| 454 | if (remove_msg) |
---|
| 455 | remove_msg.parentNode.removeChild(remove_msg); |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | if(parseInt(alert_new_msg) && data.new_msgs > 0) |
---|
| 459 | alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!"); |
---|
| 460 | if(data.new_msgs > 0){ |
---|
| 461 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) + parseInt(data.new_msgs); //refresh tab title |
---|
| 462 | update_quota(get_current_folder()); |
---|
| 463 | } |
---|
[2556] | 464 | }; |
---|
[2517] | 465 | // Update Box BgColor |
---|
| 466 | var box = Element("tbody_box"); |
---|
| 467 | if(box.childNodes.length > 1){ |
---|
| 468 | updateBoxBgColor(box.childNodes); |
---|
| 469 | } |
---|
| 470 | update_menu(); |
---|
[2556] | 471 | }; |
---|
[2517] | 472 | |
---|
| 473 | msg_range_end = (current_page*preferences.max_email_per_page); |
---|
| 474 | msg_range_begin = (msg_range_end-(preferences.max_email_per_page)+1); |
---|
| 475 | |
---|
| 476 | |
---|
| 477 | //Get element tBody. |
---|
| 478 | main = Element("tbody_box"); |
---|
| 479 | if(!main) |
---|
| 480 | return; |
---|
| 481 | |
---|
| 482 | // Get all TR (messages) in tBody. |
---|
| 483 | main_list = main.childNodes; |
---|
| 484 | var tmp = ''; |
---|
| 485 | var string_msgs_in_main = ''; |
---|
| 486 | |
---|
| 487 | var len = main_list.length; |
---|
| 488 | for (var j=0; j < len; j++) |
---|
| 489 | tmp += main_list[j].id + ','; |
---|
| 490 | |
---|
| 491 | string_msgs_in_main = tmp.substring(0,(tmp.length-1)); |
---|
| 492 | if(!expresso_offline) |
---|
| 493 | cExecute ("expressoMail1_2.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); |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | function delete_msgs(folder, msgs_number, border_ID, show_success_msg,archive) |
---|
| 497 | { |
---|
| 498 | if (arguments.length < 4){ |
---|
| 499 | show_success_msg = true; |
---|
| 500 | } |
---|
| 501 | |
---|
| 502 | if (folder == 'null') |
---|
| 503 | folder = current_folder; |
---|
| 504 | |
---|
| 505 | if(openTab.type[currentTab] == 1) |
---|
| 506 | return move_search_msgs('content_id_'+currentTab,'INBOX'+cyrus_delimiter+trashfolder,trashfolder); |
---|
| 507 | |
---|
| 508 | if(currentTab.toString().indexOf("_r") != -1){ |
---|
| 509 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
| 510 | } |
---|
| 511 | |
---|
| 512 | if (!archive && (parseInt(preferences.save_deleted_msg)) && (folder!='INBOX'+cyrus_delimiter+trashfolder)){ |
---|
| 513 | move_msgs2(folder, msgs_number, border_ID, 'INBOX'+cyrus_delimiter+trashfolder,trashfolder,show_success_msg ); |
---|
| 514 | return; |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | var handler_delete_msgs = function(data){ |
---|
| 518 | |
---|
[2929] | 519 | Element('chkbox_sel_allmsg').checked = false; |
---|
[2517] | 520 | if (currentTab) |
---|
| 521 | mail_msg = Element("tbody_box_"+currentTab); |
---|
| 522 | else |
---|
| 523 | mail_msg = Element("tbody_box"); |
---|
| 524 | |
---|
| 525 | if ( preferences.use_shortcuts == '1') { |
---|
| 526 | //Last msg is selected |
---|
| 527 | if (mail_msg && exist_className(mail_msg.childNodes[mail_msg.childNodes.length-1], 'selected_shortcut_msg') ) { |
---|
| 528 | select_msg('null', 'up', true); |
---|
| 529 | } |
---|
| 530 | else { |
---|
| 531 | if (!select_msg('null', 'down', true)) { |
---|
| 532 | select_msg('null', 'up', true); |
---|
| 533 | } |
---|
| 534 | } |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | if (show_success_msg) { |
---|
| 538 | if (data.msgs_number.length == 1) |
---|
| 539 | write_msg(get_lang("The message was deleted.")); |
---|
| 540 | else |
---|
| 541 | write_msg(get_lang("The messages were deleted.")); |
---|
| 542 | } |
---|
| 543 | if (openTab.type[currentTab] > 1){ |
---|
| 544 | var msg_to_delete = Element(msgs_number); |
---|
| 545 | if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) { |
---|
| 546 | if (msg_to_delete.previousSibling){ |
---|
[2556] | 547 | var previous_msg = msg_to_delete.previousSibling.id; |
---|
| 548 | expresso.connector.cacheNextRequest(); |
---|
| 549 | cExecute("expressoMail1_2.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + url_encode(current_folder), show_msg); |
---|
| 550 | } |
---|
[2517] | 551 | else |
---|
| 552 | delete_border(currentTab,'false'); |
---|
| 553 | } |
---|
| 554 | else |
---|
| 555 | delete_border(currentTab,'false'); |
---|
| 556 | } |
---|
| 557 | for (var i=0; i<data.msgs_number.length; i++){ |
---|
| 558 | var msg_to_delete = Element(data.msgs_number[i]); |
---|
| 559 | if (msg_to_delete){ |
---|
| 560 | removeAll(msg_to_delete.id); |
---|
| 561 | } |
---|
| 562 | } |
---|
[2556] | 563 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length; |
---|
| 564 | refresh(); |
---|
| 565 | }; |
---|
[2517] | 566 | |
---|
| 567 | if (msgs_number == 'selected') |
---|
| 568 | msgs_number = get_selected_messages(); |
---|
| 569 | if (msgs_number.length > 0 || parseInt(msgs_number) > 0) |
---|
| 570 | { |
---|
| 571 | cExecute ("expressoMail1_2.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); |
---|
| 572 | } |
---|
| 573 | else |
---|
| 574 | write_msg(get_lang('No selected message.')); |
---|
| 575 | } |
---|
| 576 | |
---|
| 577 | |
---|
| 578 | function move_search_msgs(border_id, new_folder, new_folder_name){ |
---|
| 579 | var selected_messages = ''; |
---|
| 580 | var temp_msg; |
---|
| 581 | var main_list = Element("tbody_box_"+currentTab.substr(7)).childNodes; |
---|
| 582 | for (j = 0; j < main_list.length; j++) { |
---|
| 583 | var check_box = main_list[j].firstChild.firstChild; |
---|
| 584 | if(check_box && check_box.checked) { |
---|
| 585 | if (proxy_mensagens.is_local_folder(main_list[j].getAttribute('name'))) { |
---|
| 586 | alert(get_lang("You cant manipulate local messages on search")); |
---|
| 587 | return; |
---|
| 588 | } |
---|
| 589 | selected_messages += main_list[j].id + ','; |
---|
| 590 | } |
---|
| 591 | } |
---|
| 592 | selected_messages = selected_messages.substring(0,(selected_messages.length-1)); |
---|
[2930] | 593 | var _hand_mvsearchmsg = function(data){ |
---|
[2517] | 594 | if(!data || !data.msgs_number) |
---|
| 595 | return; |
---|
| 596 | else if(data.deleted) { |
---|
| 597 | if (data.msgs_number.length == 1) |
---|
| 598 | write_msg(get_lang("The message was deleted.")); |
---|
| 599 | else |
---|
| 600 | write_msg(get_lang("The messages were deleted.")); |
---|
| 601 | } |
---|
| 602 | else{ |
---|
| 603 | if (data.msgs_number.length == 1) |
---|
| 604 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 605 | else |
---|
| 606 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 607 | } |
---|
| 608 | |
---|
| 609 | selected_messages = selected_messages.split(","); |
---|
| 610 | for (i = 0; i < selected_messages.length; i++){ |
---|
| 611 | removeAll(selected_messages[i]); |
---|
| 612 | } |
---|
| 613 | // Update Box BgColor |
---|
| 614 | var box = Element("tbody_box_"+currentTab.substr(7)).childNodes; |
---|
| 615 | if(main_list.length > 1){ |
---|
| 616 | updateBoxBgColor(box); |
---|
| 617 | } |
---|
[2556] | 618 | }; |
---|
[2517] | 619 | |
---|
| 620 | if (selected_messages){ |
---|
| 621 | var selected_param = ""; |
---|
| 622 | if (selected_messages.indexOf(',') != -1) |
---|
| 623 | { |
---|
| 624 | selected_msg_array = selected_messages.split(","); |
---|
| 625 | for (i = 0; i < selected_msg_array.length; i++){ |
---|
| 626 | var tr = Element(selected_msg_array[i]); |
---|
| 627 | if (tr.getAttribute('name') == new_folder) |
---|
| 628 | { |
---|
| 629 | write_msg(get_lang('At least one message have the same origin')); |
---|
| 630 | return false; |
---|
| 631 | } |
---|
| 632 | trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 633 | selected_param += ','+trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 634 | } |
---|
| 635 | } |
---|
| 636 | else |
---|
| 637 | { |
---|
| 638 | var tr=Element(selected_messages); |
---|
| 639 | if (tr.getAttribute('name') == new_folder) |
---|
| 640 | { |
---|
| 641 | write_msg(get_lang('The origin folder and the destination folder are the same.')); |
---|
| 642 | return false; |
---|
| 643 | } |
---|
| 644 | trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 645 | selected_param=trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 646 | } |
---|
| 647 | var params = ""; |
---|
| 648 | if (!new_folder && parseInt(preferences.save_deleted_msg)){ |
---|
| 649 | new_folder = 'INBOX'+cyrus_delimiter+trashfolder; |
---|
| 650 | new_folder_name = trashfolder; |
---|
| 651 | params = "&delete=true"; |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | params += "&selected_messages="+url_encode(selected_param); |
---|
| 655 | if(new_folder) { |
---|
| 656 | params += "&new_folder="+url_encode(new_folder); |
---|
| 657 | params += "&new_folder_name="+url_encode(new_folder_name); |
---|
| 658 | } |
---|
[2930] | 659 | cExecute ("expressoMail1_2.imap_functions.move_search_messages", _hand_mvsearchmsg, params); |
---|
[2517] | 660 | } |
---|
| 661 | else |
---|
| 662 | write_msg(get_lang('No selected message.')); |
---|
| 663 | } |
---|
| 664 | |
---|
| 665 | function move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,show_success_msg){ |
---|
| 666 | |
---|
| 667 | if (! folder || folder == 'null') |
---|
| 668 | folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder()); |
---|
| 669 | |
---|
| 670 | if(openTab.type[currentTab] == 1) |
---|
| 671 | return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name); |
---|
| 672 | |
---|
| 673 | var handler_move_msgs = function(data){ |
---|
| 674 | if(typeof(data) == 'string') |
---|
| 675 | if (data.match(/^(.*)TRYCREATE(.*)$/)){ |
---|
| 676 | expresso.connector.loadScript('jscode/TreeS'); |
---|
| 677 | var move_to_folder = data.match(/^(.*)Spam(.*)$/) ? "Spam" : trashfolder; |
---|
| 678 | alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.', move_to_folder)); |
---|
| 679 | expresso.connector.loadScript('jscode/TreeShow'); |
---|
| 680 | ttree.FOLDER = 'root'; |
---|
| 681 | ttreeBox.new_past(move_to_folder); |
---|
| 682 | return false; |
---|
| 683 | }else{ |
---|
| 684 | alert(get_lang('Error moving message.')+":\n"+data); |
---|
| 685 | return false; |
---|
| 686 | } |
---|
| 687 | //Este bloco verifica as permissoes ACL sobre pastas compartilhadas |
---|
| 688 | if(data.status == false){ |
---|
| 689 | alert(get_lang("You don't have permission for this operation in this shared folder!")); |
---|
| 690 | return false; |
---|
| 691 | } |
---|
| 692 | mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild; |
---|
| 693 | if (data.msgs_number.length == 1) |
---|
| 694 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 695 | else |
---|
| 696 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 697 | |
---|
| 698 | if (openTab.type[currentTab] > 1){ |
---|
| 699 | msg_to_delete = Element(msgs_number); |
---|
| 700 | if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) |
---|
| 701 | { |
---|
| 702 | if (msg_to_delete.previousSibling){ |
---|
| 703 | var previous_msg = msg_to_delete.previousSibling.id; |
---|
| 704 | //cExecute("expressoMail1_2.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg); |
---|
| 705 | expresso.connector.cacheNextRequest(); |
---|
| 706 | cExecute("expressoMail1_2.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + url_encode(folder), show_msg); |
---|
| 707 | } |
---|
| 708 | else |
---|
| 709 | delete_border(currentTab,'false'); |
---|
| 710 | } |
---|
| 711 | else |
---|
| 712 | delete_border(currentTab,'false'); |
---|
| 713 | if(msg_to_delete) |
---|
| 714 | mail_msg.removeChild(msg_to_delete); |
---|
| 715 | |
---|
| 716 | // Update Box BgColor |
---|
| 717 | var box = Element("tbody_box"); |
---|
| 718 | if(box.childNodes.length > 0){ |
---|
| 719 | updateBoxBgColor(box.childNodes); |
---|
| 720 | } |
---|
| 721 | return; |
---|
| 722 | } |
---|
| 723 | |
---|
[2929] | 724 | Element('chkbox_sel_allmsg').checked = false; |
---|
[2517] | 725 | if (! mail_msg) |
---|
| 726 | mail_msg = Element("tbody_box"); |
---|
| 727 | data.msgs_number = data.msgs_number.split(","); |
---|
| 728 | |
---|
| 729 | var msg_to_delete; |
---|
| 730 | if( typeof(msgs_number) == 'string' ) |
---|
| 731 | all_search_msg = msgs_number.split(','); |
---|
| 732 | else if( typeof(msgs_number) == 'number') |
---|
| 733 | all_search_msg = msgs_number; |
---|
| 734 | |
---|
| 735 | for (var i=0; i <= all_search_msg.length; i++) |
---|
| 736 | { |
---|
| 737 | msg_to_delete = Element(folder+';'+all_search_msg[i]); |
---|
| 738 | if (msg_to_delete) |
---|
| 739 | msg_to_delete.parentNode.removeChild(msg_to_delete); |
---|
| 740 | } |
---|
| 741 | |
---|
| 742 | if ( preferences.use_shortcuts == '1') { |
---|
| 743 | var all_messages = Element('tbody_box').childNodes; |
---|
| 744 | |
---|
| 745 | //Last msg is selected |
---|
| 746 | if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) { |
---|
| 747 | select_msg('null', 'up', true); |
---|
| 748 | } |
---|
| 749 | else { |
---|
| 750 | if (!select_msg('null', 'down', true)) { |
---|
| 751 | select_msg('null', 'up', true); |
---|
| 752 | } |
---|
| 753 | } |
---|
| 754 | } |
---|
| 755 | for (var i=0; i<data.msgs_number.length; i++) |
---|
| 756 | { |
---|
| 757 | msg_to_delete = Element(data.msgs_number[i]); |
---|
| 758 | if (msg_to_delete) |
---|
| 759 | mail_msg.removeChild(msg_to_delete); |
---|
| 760 | } |
---|
| 761 | |
---|
| 762 | |
---|
| 763 | if (data.msgs_number.length == 1) |
---|
| 764 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 765 | else |
---|
| 766 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 767 | if (data.border_ID.indexOf('r') != -1){ |
---|
| 768 | if (parseInt(preferences.delete_and_show_previous_message) && folder == get_current_folder()){ |
---|
| 769 | delete_border(data.border_ID,'false'); |
---|
| 770 | show_msg(data.previous_msg); |
---|
| 771 | } |
---|
| 772 | else |
---|
| 773 | delete_border(data.border_ID,'false'); |
---|
| 774 | } |
---|
| 775 | if(folder == get_current_folder()) |
---|
| 776 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length; |
---|
| 777 | |
---|
| 778 | refresh(); |
---|
[2556] | 779 | }; |
---|
[2517] | 780 | |
---|
| 781 | if (folder == new_folder){ |
---|
| 782 | write_msg(get_lang('The origin folder and the destination folder are the same.')); |
---|
| 783 | return; |
---|
| 784 | } |
---|
| 785 | |
---|
| 786 | if (msgs_number == 'selected'){ |
---|
| 787 | msgs_number = get_selected_messages(); |
---|
| 788 | } |
---|
| 789 | |
---|
| 790 | if(openTab.type[currentTab] == 1){ |
---|
| 791 | return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name); |
---|
| 792 | } |
---|
| 793 | |
---|
| 794 | if(currentTab.toString().indexOf("_r") != -1){ |
---|
| 795 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
| 796 | } |
---|
| 797 | |
---|
| 798 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0) |
---|
| 799 | { |
---|
[3117] | 800 | cExecute ("expressoMail1_2.imap_functions.move_messages&folder="+current_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); |
---|
[2517] | 801 | } |
---|
| 802 | else |
---|
| 803 | write_msg(get_lang('No selected message.')); |
---|
| 804 | |
---|
| 805 | } |
---|
| 806 | |
---|
| 807 | function move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name) { |
---|
| 808 | move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,true); |
---|
| 809 | } |
---|
| 810 | |
---|
| 811 | function archive_msgs(folder,folder_dest,id_msgs) { |
---|
| 812 | if(proxy_mensagens.is_local_folder(folder)) { |
---|
| 813 | write_msg(get_lang("You cant archive local mails")); |
---|
| 814 | return; |
---|
| 815 | } |
---|
| 816 | |
---|
| 817 | if(!id_msgs) |
---|
| 818 | id_msgs = get_selected_messages(); |
---|
| 819 | |
---|
| 820 | if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento... |
---|
| 821 | folder_dest = 'local_Inbox'; |
---|
| 822 | |
---|
| 823 | if (parseInt(id_msgs) > 0 || id_msgs.length > 0) |
---|
| 824 | expresso_mail_sync.archive_msgs(folder,folder_dest,id_msgs); |
---|
[2930] | 825 | //cExecute("expressoMail1_2.imap_functions.get_info_msgs&folder=" + folder + "&msgs_number=" + id_msgs , _hand_arqmsg); |
---|
[2517] | 826 | else |
---|
| 827 | write_msg(get_lang('No selected message.')); |
---|
| 828 | /*var has_local_messages_before = expresso_local_messages.has_local_mails(); //vejo se já tinha mensagens locais |
---|
[2930] | 829 | var _hand_arqmsg = function(data) { |
---|
[2517] | 830 | var sucess = true; |
---|
| 831 | var temp; |
---|
| 832 | var msgs_to_remove = new Array(); |
---|
| 833 | var update_tree; |
---|
| 834 | for (var i = 0; i < data.length; i++) { |
---|
| 835 | msg_info = expresso.connector.unserialize(data[i]); |
---|
| 836 | if ( folder == 'INBOX/Lixeira/tmpMoveToLocal' ){ |
---|
| 837 | msg_info.msg_folder += (Date.parse(new Date)); |
---|
| 838 | } |
---|
| 839 | temp = expresso_local_messages.insert_mail(msg_info, msg_info['header'],msg_info['array_attach'],folder_dest ); |
---|
| 840 | if ( Element("check_box_message_" + msg_info.msg_number) ) |
---|
| 841 | Element("check_box_message_" + msg_info.msg_number).checked = false; |
---|
| 842 | |
---|
| 843 | if(!temp) |
---|
| 844 | sucess = false; |
---|
| 845 | else |
---|
| 846 | msgs_to_remove.push(msg_info.msg_number);//As mensagens arquivadas devem ser removidas, caso o usuario tenha isso configurado. |
---|
| 847 | |
---|
| 848 | if ( Element(msg_info.msg_number) ) |
---|
| 849 | remove_className(Element(msg_info.msg_number), 'selected_msg'); |
---|
| 850 | if ( tree_folders._selected.id.indexOf( 'local_' ) == 0 || folder.indexOf( 'INBOX/Lixeira/tmpMoveToLocal' ) == 0 ) |
---|
| 851 | { |
---|
| 852 | openTab.imapBox[0] = ''; |
---|
| 853 | tree_folders.getNodeById( 'local_Inbox' )._select( ); |
---|
| 854 | change_folder('local_Inbox','Inbox') |
---|
| 855 | } |
---|
| 856 | |
---|
| 857 | } |
---|
| 858 | |
---|
| 859 | if (preferences.keep_archived_messages == 0) { //Remove as mensagens |
---|
| 860 | delete_msgs(folder,msgs_to_remove,'null',false,true); |
---|
| 861 | } |
---|
| 862 | update_tree=(!has_local_messages_before) && expresso_local_messages.has_local_mails(); |
---|
| 863 | |
---|
[2929] | 864 | Element('chkbox_sel_allmsg').checked = false; |
---|
[2517] | 865 | if(update_tree) |
---|
| 866 | ttreeBox.update_folder(); |
---|
| 867 | else |
---|
| 868 | update_menu(); |
---|
| 869 | if(sucess) |
---|
| 870 | write_msg(get_lang("selected messages have been archived")); |
---|
| 871 | else |
---|
| 872 | write_msg(get_lang("at least, one of selected mails is already archived, expresso tried to archive the others, check them later")); |
---|
| 873 | |
---|
| 874 | } |
---|
| 875 | if(!id_msgs) |
---|
| 876 | id_msgs = get_selected_messages(); |
---|
| 877 | if (parseInt(id_msgs) > 0 || id_msgs.length > 0) |
---|
[2930] | 878 | cExecute("expressoMail1_2.imap_functions.get_info_msgs&folder=" + folder + "&msgs_number=" + id_msgs , _hand_arqmsg); |
---|
[2517] | 879 | else |
---|
| 880 | write_msg(get_lang('No selected message.'));*/ |
---|
| 881 | |
---|
| 882 | } |
---|
| 883 | |
---|
| 884 | function get_selected_messages(){ |
---|
[3063] | 885 | try { main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; |
---|
| 886 | }catch(e){ |
---|
| 887 | }; |
---|
[2517] | 888 | if (! main) |
---|
| 889 | main = Element("tbody_box"); |
---|
| 890 | |
---|
| 891 | // Get all TR (messages) in tBody. |
---|
| 892 | main_list = main.childNodes; |
---|
| 893 | |
---|
| 894 | var selected_messages = ''; |
---|
[2929] | 895 | var _sel_msgbyshrtcut = ''; |
---|
[2517] | 896 | var j = 0; |
---|
| 897 | for (j; j<(main_list.length); j++) |
---|
| 898 | { |
---|
| 899 | check_box = Element("check_box_message_"+main_list[j].id); |
---|
| 900 | if ( (check_box) && (check_box.checked) ) |
---|
| 901 | selected_messages += main_list[j].id + ','; |
---|
| 902 | |
---|
| 903 | if (preferences.use_shortcuts == '1') |
---|
| 904 | { |
---|
| 905 | if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') ) |
---|
| 906 | { |
---|
[2929] | 907 | _sel_msgbyshrtcut += main_list[j].id + ','; |
---|
[2517] | 908 | } |
---|
| 909 | } |
---|
| 910 | } |
---|
| 911 | selected_messages = selected_messages.substring(0,(selected_messages.length-1)); |
---|
| 912 | |
---|
| 913 | if (preferences.use_shortcuts == '1') |
---|
| 914 | { |
---|
[2929] | 915 | _sel_msgbyshrtcut = _sel_msgbyshrtcut.substring(0,(_sel_msgbyshrtcut.length-1)); |
---|
[2517] | 916 | |
---|
[2929] | 917 | var _arr_sel_msgbyshrtcut = _sel_msgbyshrtcut.split(","); |
---|
| 918 | var _arr_selected_messages = selected_messages.split(","); |
---|
[2517] | 919 | |
---|
[2929] | 920 | if ((_arr_selected_messages.length <= 1) && (_arr_sel_msgbyshrtcut.length > 1)) |
---|
[2517] | 921 | { |
---|
[2929] | 922 | return _sel_msgbyshrtcut; |
---|
[2517] | 923 | } |
---|
| 924 | } |
---|
| 925 | |
---|
| 926 | if (selected_messages == '') |
---|
| 927 | return false; |
---|
| 928 | else |
---|
| 929 | return selected_messages; |
---|
| 930 | } |
---|
| 931 | |
---|
| 932 | function new_message_to(email) { |
---|
| 933 | var new_border_ID = new_message('new','null'); |
---|
| 934 | document.getElementById("to_" + new_border_ID).value=email; |
---|
| 935 | } |
---|
| 936 | |
---|
| 937 | function new_message(type, border_ID){ |
---|
[2561] | 938 | |
---|
[2517] | 939 | if (Element('show_img_link_'+border_ID)) |
---|
| 940 | { |
---|
| 941 | show_msg_img(border_ID.match(/^\d*/)[0], Element('input_folder_'+border_ID).value); |
---|
| 942 | } |
---|
| 943 | var new_border_ID = draw_new_message(parseInt(border_ID)); |
---|
[3144] | 944 | |
---|
| 945 | if(typeof(openTab.type[new_border_ID]) != "undefined") { |
---|
| 946 | if(tabTypes[type] == openTab.type[new_border_ID]) { |
---|
| 947 | return new_border_ID; |
---|
| 948 | } else { |
---|
[3148] | 949 | var a_types = { 6 : get_lang("Forward"),7 : get_lang("Reply"), |
---|
| 950 | 8 : get_lang("Reply to all with history"), |
---|
| 951 | 9 : get_lang("Reply without history"), |
---|
| 952 | 10: get_lang("Reply to all without history")}; |
---|
| 953 | |
---|
| 954 | if(!confirm(get_lang("Your message to %1 has not been saved or sent. "+ |
---|
| 955 | "To %2 will be necessary open it again. Discard your message?", |
---|
| 956 | a_types[openTab.type[new_border_ID]].toUpperCase(), |
---|
| 957 | a_types[tabTypes[type]].toUpperCase()))){ |
---|
| 958 | return new_border_ID; |
---|
| 959 | } else { |
---|
| 960 | delete_border(currentTab); |
---|
| 961 | new_border_ID = draw_new_message(parseInt(border_ID)); |
---|
| 962 | } |
---|
[3144] | 963 | } |
---|
| 964 | } |
---|
| 965 | |
---|
[3077] | 966 | if (new_border_ID == false){ |
---|
| 967 | setTimeout('new_message(\''+type+'\',\''+border_ID+'\');',500); |
---|
| 968 | return false; |
---|
| 969 | } |
---|
| 970 | if ( RichTextEditor == null ) |
---|
| 971 | RichTextEditor = new cRichTextEditor( ); |
---|
[2517] | 972 | openTab.type[new_border_ID] = tabTypes[type]; |
---|
| 973 | |
---|
| 974 | // Salva a pasta da mensagem respondida ou encaminhada: |
---|
| 975 | var folder_message = Element("input_folder_"+border_ID); |
---|
| 976 | if(folder_message) { |
---|
| 977 | var input_current_folder = document.createElement('input'); |
---|
| 978 | input_current_folder.id = "new_input_folder_"+border_ID; |
---|
| 979 | input_current_folder.name = "input_folder"; |
---|
| 980 | input_current_folder.type = "hidden"; |
---|
| 981 | input_current_folder.value = folder_message.value; |
---|
| 982 | Element("content_id_" + new_border_ID).appendChild(input_current_folder); |
---|
| 983 | }//Fim. |
---|
| 984 | var title = ''; |
---|
| 985 | data = []; |
---|
| 986 | if (Element("from_" + border_ID)){ |
---|
| 987 | if (document.getElementById("reply_to_" + border_ID)){ |
---|
| 988 | data.to = document.getElementById("reply_to_values_" + border_ID).value; |
---|
| 989 | data.to = data.to.replace(/</gi,"<"); |
---|
| 990 | data.to = data.to.replace(/>/gi,">"); |
---|
| 991 | } |
---|
| 992 | else { |
---|
| 993 | if (document.getElementById("from_values_" + border_ID)) |
---|
| 994 | { |
---|
| 995 | data.to = document.getElementById("from_values_" + border_ID).value; |
---|
| 996 | data.to = data.to.replace(/</gi,"<"); |
---|
| 997 | data.to = data.to.replace(/>/gi,">"); |
---|
| 998 | } |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | if (document.getElementById("to_values_" + border_ID)){ |
---|
| 1002 | data.to_all = document.getElementById("to_values_" + border_ID).value; |
---|
| 1003 | data.to_all = data.to_all.replace(/\n/gi," "); |
---|
| 1004 | data.to_all = data.to_all.replace(/</gi,"<"); |
---|
| 1005 | data.to_all = data.to_all.replace(/>/gi,">"); |
---|
| 1006 | var _array_to_all = data.to_all.split(","); |
---|
| 1007 | } |
---|
| 1008 | } |
---|
| 1009 | |
---|
| 1010 | if (document.getElementById("cc_" + border_ID)){ |
---|
| 1011 | data.cc = document.getElementById("cc_values_" + border_ID).value; |
---|
| 1012 | data.cc = data.cc.replace(/</gi,"<"); |
---|
| 1013 | data.cc = data.cc.replace(/>/gi,">"); |
---|
| 1014 | } |
---|
| 1015 | if (document.getElementById("cco_" + border_ID)){ |
---|
| 1016 | data.cco = document.getElementById("cco_values_" + border_ID).value; |
---|
| 1017 | data.cco = data.cco.replace(/</gi,"<"); |
---|
| 1018 | data.cco = data.cco.replace(/>/gi,">"); |
---|
| 1019 | } |
---|
| 1020 | if (document.getElementById("subject_" + border_ID)) |
---|
| 1021 | data.subject = document.getElementById("subject_" + border_ID).innerHTML; |
---|
| 1022 | if (document.getElementById("body_" + border_ID)) |
---|
| 1023 | data.body = document.getElementById("body_" + border_ID).innerHTML; |
---|
| 1024 | |
---|
| 1025 | if (Element('date_' + border_ID)){ |
---|
| 1026 | data.date = Element('date_' + border_ID).innerHTML; |
---|
| 1027 | } |
---|
| 1028 | |
---|
| 1029 | if (Element('date_day_' + border_ID)){ |
---|
| 1030 | data.date_day = Element('date_day_' + border_ID).value; |
---|
| 1031 | } |
---|
| 1032 | if (Element('date_hour_' + border_ID)){ |
---|
| 1033 | data.date_hour = Element('date_hour_' + border_ID).value; |
---|
| 1034 | } |
---|
| 1035 | if(typeof(preferences.signature) == 'undefined') |
---|
| 1036 | preferences.signature = ""; |
---|
| 1037 | var signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "<br>"); |
---|
| 1038 | switch(type){ |
---|
| 1039 | case "reply_without_history": |
---|
| 1040 | Element("to_" + new_border_ID).value = data.to; |
---|
| 1041 | title = "Re: " + data.subject; |
---|
| 1042 | Element("subject_" + new_border_ID).value = "Re: " + data.subject; |
---|
| 1043 | useOriginalAttachments(new_border_ID,border_ID); |
---|
| 1044 | var body = Element("body_" + new_border_ID); |
---|
| 1045 | body.contentWindow.document.open(); |
---|
| 1046 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 1047 | if (preferences.use_signature == "1"){ |
---|
| 1048 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>"); |
---|
| 1049 | } |
---|
| 1050 | else{ |
---|
| 1051 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); |
---|
| 1052 | } |
---|
| 1053 | body.contentWindow.document.close(); |
---|
| 1054 | body.contentWindow.document.designMode = "on"; |
---|
| 1055 | //Focus |
---|
| 1056 | if (is_ie) |
---|
| 1057 | window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); |
---|
| 1058 | else |
---|
| 1059 | body.contentWindow.focus(); |
---|
| 1060 | config_events( body.contentWindow.document, 'onkeyup', function( e ) |
---|
| 1061 | { |
---|
| 1062 | if ( e.keyCode == 13 ) |
---|
| 1063 | { |
---|
| 1064 | var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); |
---|
| 1065 | for ( p = 0; p < paragraphs.length; p++ ) |
---|
| 1066 | paragraphs.item( p ).style.margin = '0px'; |
---|
| 1067 | } |
---|
| 1068 | }); |
---|
| 1069 | msg_reply_from = document.createElement('input'); |
---|
| 1070 | msg_reply_from.id = "msg_reply_from_" + new_border_ID; |
---|
| 1071 | msg_reply_from.type = "hidden"; |
---|
| 1072 | msg_reply_from.value = Element("msg_number_" + border_ID).value; |
---|
| 1073 | Element("content_id_" + new_border_ID).appendChild(msg_reply_from); |
---|
| 1074 | break; |
---|
| 1075 | case "reply_with_history": |
---|
| 1076 | title = "Re: " + data.subject; |
---|
| 1077 | Element("subject_" + new_border_ID).value = "Re: " + data.subject; |
---|
| 1078 | Element("to_" + new_border_ID).value = data.to; |
---|
| 1079 | useOriginalAttachments(new_border_ID,border_ID); |
---|
| 1080 | block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); |
---|
| 1081 | var body = Element("body_" + new_border_ID); |
---|
| 1082 | body.contentWindow.document.open(); |
---|
| 1083 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 1084 | if (preferences.use_signature == "1") { |
---|
| 1085 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>" + block_quoted_body + "</body></html>"); |
---|
| 1086 | } |
---|
| 1087 | else { |
---|
| 1088 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+block_quoted_body+"</body></html>"); |
---|
| 1089 | } |
---|
| 1090 | body.contentWindow.document.close(); |
---|
| 1091 | body.contentWindow.document.designMode = "on"; |
---|
| 1092 | //Focus |
---|
| 1093 | if (is_ie) |
---|
| 1094 | window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); |
---|
| 1095 | else |
---|
| 1096 | body.contentWindow.focus(); |
---|
| 1097 | config_events( body.contentWindow.document, 'onkeyup', function( e ) |
---|
| 1098 | { |
---|
| 1099 | if ( e.keyCode == 13 ) |
---|
| 1100 | { |
---|
| 1101 | var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); |
---|
| 1102 | for ( p = 0; p < paragraphs.length; p++ ) |
---|
| 1103 | paragraphs.item( p ).style.margin = '0px'; |
---|
| 1104 | } |
---|
| 1105 | }); |
---|
| 1106 | msg_reply_from = document.createElement('input'); |
---|
| 1107 | msg_reply_from.id = "msg_reply_from_" + new_border_ID; |
---|
| 1108 | msg_reply_from.type = "hidden"; |
---|
| 1109 | msg_reply_from.value = Element("msg_number_" + border_ID).value; |
---|
| 1110 | Element("content_id_" + new_border_ID).appendChild(msg_reply_from); |
---|
| 1111 | break; |
---|
| 1112 | case "reply_to_all_without_history": |
---|
| 1113 | // delete user email from to_all array. |
---|
| 1114 | data.to_all = new Array(); |
---|
| 1115 | var j = 0; |
---|
| 1116 | for(i = 0; i < _array_to_all.length; i++) { |
---|
| 1117 | if(_array_to_all[i].lastIndexOf(Element("user_email").value) == "-1"){ |
---|
| 1118 | data.to_all[j++] = _array_to_all[i]; |
---|
| 1119 | } |
---|
| 1120 | } |
---|
| 1121 | data.to_all = data.to_all.join(","); |
---|
| 1122 | |
---|
| 1123 | title = "Re: " + data.subject; |
---|
| 1124 | Element("subject_" + new_border_ID).value = "Re: " + data.subject; |
---|
| 1125 | Element("to_" + new_border_ID).value = data.to; |
---|
| 1126 | Element("to_" + new_border_ID).value += ', ' + data.to_all; |
---|
| 1127 | if (data.cc){ |
---|
| 1128 | Element("cc_" + new_border_ID).value = data.cc; |
---|
| 1129 | Element("a_cc_link_" + new_border_ID).style.display='none'; |
---|
| 1130 | Element("tr_cc_" + new_border_ID).style.display=''; |
---|
| 1131 | Element('space_link_' + new_border_ID).style.display='none'; |
---|
| 1132 | } |
---|
| 1133 | useOriginalAttachments(new_border_ID,border_ID); |
---|
| 1134 | var body = Element("body_" + new_border_ID); |
---|
| 1135 | body.contentWindow.document.open(); |
---|
| 1136 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 1137 | if (preferences.use_signature == "1") { |
---|
| 1138 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>"); |
---|
| 1139 | } |
---|
| 1140 | else { |
---|
| 1141 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); |
---|
| 1142 | } |
---|
| 1143 | body.contentWindow.document.close(); |
---|
| 1144 | body.contentWindow.document.designMode = "on"; |
---|
| 1145 | //Focus |
---|
| 1146 | if (is_ie) |
---|
| 1147 | window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); |
---|
| 1148 | else |
---|
| 1149 | body.contentWindow.focus(); |
---|
| 1150 | config_events( body.contentWindow.document, 'onkeyup', function( e ) |
---|
| 1151 | { |
---|
| 1152 | if ( e.keyCode == 13 ) |
---|
| 1153 | { |
---|
| 1154 | var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); |
---|
| 1155 | for ( p = 0; p < paragraphs.length; p++ ) |
---|
| 1156 | paragraphs.item( p ).style.margin = '0px'; |
---|
| 1157 | } |
---|
| 1158 | }); |
---|
| 1159 | msg_reply_from = document.createElement('input'); |
---|
| 1160 | msg_reply_from.id = "msg_reply_from_" + new_border_ID; |
---|
| 1161 | msg_reply_from.type = "hidden"; |
---|
| 1162 | msg_reply_from.value = Element("msg_number_" + border_ID).value; |
---|
| 1163 | Element("content_id_" + new_border_ID).appendChild(msg_reply_from); |
---|
| 1164 | break; |
---|
| 1165 | case "reply_to_all_with_history": |
---|
| 1166 | // delete user email from to_all array. |
---|
| 1167 | data.to_all = new Array(); |
---|
| 1168 | var j = 0; |
---|
| 1169 | for(i = 0; i < _array_to_all.length; i++) { |
---|
| 1170 | if(_array_to_all[i].lastIndexOf(Element("user_email").value) == "-1"){ |
---|
| 1171 | data.to_all[j++] = _array_to_all[i]; |
---|
| 1172 | } |
---|
| 1173 | } |
---|
| 1174 | data.to_all = data.to_all.join(","); |
---|
| 1175 | title = "Re: " + data.subject; |
---|
| 1176 | Element("to_" + new_border_ID).value = data.to; |
---|
| 1177 | Element("to_" + new_border_ID).value += ', ' + data.to_all; |
---|
| 1178 | if (data.cc){ |
---|
| 1179 | document.getElementById("cc_" + new_border_ID).value = data.cc; |
---|
| 1180 | document.getElementById("a_cc_link_" + new_border_ID).style.display='none'; |
---|
| 1181 | document.getElementById("tr_cc_" + new_border_ID).style.display=''; |
---|
| 1182 | document.getElementById('space_link_' + new_border_ID).style.display='none'; |
---|
| 1183 | } |
---|
| 1184 | document.getElementById("subject_" + new_border_ID).value = "Re: " + data.subject; |
---|
| 1185 | useOriginalAttachments(new_border_ID,border_ID); |
---|
| 1186 | block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); |
---|
| 1187 | var body = document.getElementById("body_" + new_border_ID); |
---|
| 1188 | body.contentWindow.document.open(); |
---|
| 1189 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 1190 | if (preferences.use_signature == "1") { |
---|
| 1191 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>" + block_quoted_body + "</body></html>"); |
---|
| 1192 | } |
---|
| 1193 | else { |
---|
| 1194 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+block_quoted_body+"</body></html>"); |
---|
| 1195 | } |
---|
| 1196 | body.contentWindow.document.close(); |
---|
| 1197 | body.contentWindow.document.designMode = "on"; |
---|
| 1198 | //Focus |
---|
| 1199 | if (is_ie) |
---|
| 1200 | window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); |
---|
| 1201 | else |
---|
| 1202 | body.contentWindow.focus(); |
---|
| 1203 | config_events( body.contentWindow.document, 'onkeyup', function( e ) |
---|
| 1204 | { |
---|
| 1205 | if ( e.keyCode == 13 ) |
---|
| 1206 | { |
---|
| 1207 | var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); |
---|
| 1208 | for ( p = 0; p < paragraphs.length; p++ ) |
---|
| 1209 | paragraphs.item( p ).style.margin = '0px'; |
---|
| 1210 | } |
---|
| 1211 | }); |
---|
| 1212 | msg_reply_from = document.createElement('input'); |
---|
| 1213 | msg_reply_from.id = "msg_reply_from_" + new_border_ID; |
---|
| 1214 | msg_reply_from.type = "hidden"; |
---|
| 1215 | msg_reply_from.value = Element("msg_number_" + border_ID).value; |
---|
| 1216 | Element("content_id_" + new_border_ID).appendChild(msg_reply_from); |
---|
| 1217 | break; |
---|
| 1218 | case "forward": |
---|
[3095] | 1219 | try{ |
---|
| 1220 | data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false; |
---|
| 1221 | } |
---|
| 1222 | catch (e) { |
---|
| 1223 | data.is_local_message = false; |
---|
| 1224 | } |
---|
[2517] | 1225 | msg_forward_from = document.createElement('input'); |
---|
| 1226 | msg_forward_from.id = "msg_forward_from_" + new_border_ID; |
---|
| 1227 | msg_forward_from.type = "hidden"; |
---|
| 1228 | msg_forward_from.value = Element("msg_number_" + border_ID).value; |
---|
| 1229 | Element("content_id_" + new_border_ID).appendChild(msg_forward_from); |
---|
| 1230 | title = "Fw: " + data.subject; |
---|
| 1231 | document.getElementById("subject_" + new_border_ID).value = "Fw: " + data.subject; |
---|
| 1232 | var divFiles = Element("divFiles_"+new_border_ID); |
---|
| 1233 | var campo_arquivo; |
---|
| 1234 | if (Element("attachments_" + border_ID)){ |
---|
| 1235 | var attachments = document.getElementById("attachments_" + border_ID).childNodes; |
---|
| 1236 | for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){ |
---|
| 1237 | if((attachments[i].tagName=="SPAN") || (attachments[i].tagName=="IMG") || |
---|
| 1238 | ((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1))) |
---|
| 1239 | continue; |
---|
| 1240 | var link_attachment = document.createElement("A"); |
---|
| 1241 | link_attachment.setAttribute("href", attachments[i].href); |
---|
| 1242 | link_attachment.innerHTML = attachments[i].innerHTML; |
---|
| 1243 | if (data.is_local_message) {//Local messages |
---|
| 1244 | document.getElementById("is_local_forward"+new_border_ID).value = "1"; |
---|
| 1245 | var tmp = link_attachment.href.substring(link_attachment.href.indexOf("(") + 2);//Pula o parenteses e a aspas |
---|
| 1246 | tmp = tmp.substring(0, tmp.length - 2);//corta a aspas e o parenteses |
---|
| 1247 | tmp = replaceAll(tmp,"%20"," "); |
---|
| 1248 | var tempNomeArquivo = tmp.split("/"); |
---|
| 1249 | var nomeArquivo = tempNomeArquivo[tempNomeArquivo.length-1]; |
---|
| 1250 | nomeArquivo = nomeArquivo.substring(0,nomeArquivo.length - 4); //Anexos no gears são todos com extensão .php. tenho que tirar a extensão para ficar o nome real do arquivo. |
---|
| 1251 | campo_arquivo = addForwardedFile(new_border_ID,nomeArquivo,link_attachment.href); |
---|
| 1252 | if(!expresso_offline) |
---|
| 1253 | expresso_local_messages.getInputFileFromAnexo(campo_arquivo, tmp); |
---|
| 1254 | else //To offline, you just set the url on value of a hidden input. |
---|
| 1255 | campo_arquivo.value = tmp; |
---|
| 1256 | |
---|
| 1257 | } |
---|
| 1258 | else { |
---|
| 1259 | var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); |
---|
| 1260 | var a_tmp = tmp.split(','); |
---|
| 1261 | tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); |
---|
| 1262 | a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; |
---|
| 1263 | s_tmp = escape(expresso.connector.serialize(a_tmp)); |
---|
| 1264 | |
---|
| 1265 | divFiles.innerHTML += "<input style='border:0' type='CHECKBOX' name='forwarding_attachments[]' checked value=\""+s_tmp+"\"/>"; |
---|
| 1266 | divFiles.innerHTML += "<link style='border:0' name='file_"+i+"' id='inputFile_"+border_ID+i+"'/>"; |
---|
| 1267 | divFiles.appendChild(link_attachment); |
---|
| 1268 | } |
---|
| 1269 | } |
---|
| 1270 | } |
---|
| 1271 | var body = Element("body_" + new_border_ID); |
---|
| 1272 | body.contentWindow.document.open(); |
---|
| 1273 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 1274 | if (preferences.use_signature == "1") { |
---|
| 1275 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>" + make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc) + "</body></html>"); |
---|
| 1276 | } |
---|
| 1277 | else { |
---|
| 1278 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)+"</body></html>"); |
---|
| 1279 | } |
---|
| 1280 | body.contentWindow.document.close(); |
---|
| 1281 | body.contentWindow.document.designMode = "on"; |
---|
| 1282 | config_events( body.contentWindow.document, 'onkeyup', function( e ) |
---|
| 1283 | { |
---|
| 1284 | if ( e.keyCode == 13 ) |
---|
| 1285 | { |
---|
| 1286 | var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); |
---|
| 1287 | for ( p = 0; p < paragraphs.length; p++ ) |
---|
| 1288 | paragraphs.item( p ).style.margin = '0px'; |
---|
| 1289 | } |
---|
| 1290 | }); |
---|
| 1291 | Element("to_" + new_border_ID).focus(); |
---|
| 1292 | break; |
---|
| 1293 | case "new": |
---|
| 1294 | title = get_lang("New Message"); |
---|
| 1295 | if(Element('msg_number').value) { |
---|
| 1296 | var _to = Element('msg_number').value; |
---|
| 1297 | 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}\])$/; |
---|
| 1298 | if(!reEmail.test(_to)){ |
---|
| 1299 | var array_contacts = contacts.split(','); |
---|
| 1300 | for(i = 0; i < array_contacts.length;i++) { |
---|
| 1301 | if(array_contacts[i].lastIndexOf(_to) != "-1"){ |
---|
| 1302 | var _group = array_contacts[i].split(";"); |
---|
| 1303 | _to = '"'+_group[0]+'" <'+_group[1]+'>'; |
---|
| 1304 | break; |
---|
| 1305 | } |
---|
| 1306 | } |
---|
| 1307 | } |
---|
| 1308 | Element("to_" + new_border_ID).value = _to +','; |
---|
| 1309 | Element('msg_number').value = ''; |
---|
| 1310 | } |
---|
| 1311 | var body = document.getElementById("body_" + new_border_ID); |
---|
| 1312 | body.contentWindow.document.open(); |
---|
| 1313 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 1314 | if (preferences.use_signature == "1") { |
---|
| 1315 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>" + "<br>" + signature + "</body></html>"); |
---|
| 1316 | } |
---|
| 1317 | else { |
---|
| 1318 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'></body></html>"); |
---|
| 1319 | } |
---|
| 1320 | body.contentWindow.document.close(); |
---|
| 1321 | body.contentWindow.document.designMode = "on"; |
---|
| 1322 | config_events( body.contentWindow.document, 'onkeyup', function( e ) |
---|
| 1323 | { |
---|
| 1324 | if ( e.keyCode == 13 ) |
---|
| 1325 | { |
---|
| 1326 | var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); |
---|
| 1327 | for ( p = 0; p < paragraphs.length; p++ ) |
---|
| 1328 | paragraphs.item( p ).style.margin = '0px'; |
---|
| 1329 | } |
---|
| 1330 | }); |
---|
| 1331 | Element("to_" + new_border_ID).focus(); |
---|
| 1332 | break; |
---|
| 1333 | case "edit": |
---|
| 1334 | openTab.imapBox[new_border_ID] = folder_message.value; |
---|
| 1335 | openTab.toPreserve[new_border_ID] = true; |
---|
| 1336 | openTab.imapUid[new_border_ID] = parseInt(border_ID.substr(0,border_ID.indexOf("_"))); |
---|
| 1337 | document.getElementById('font_border_id_'+new_border_ID).innerHTML = data.subject; |
---|
| 1338 | data.to = Element("to_values_" + border_ID).value; |
---|
| 1339 | data.to = data.to.replace(/</gi,"<"); |
---|
| 1340 | data.to = data.to.replace(/>/gi,">"); |
---|
| 1341 | title = "Edição: "+data.subject; |
---|
| 1342 | |
---|
| 1343 | Element("to_" + new_border_ID).value = data.to; |
---|
| 1344 | if (data.cc){ |
---|
| 1345 | Element("cc_" + new_border_ID).value = data.cc; |
---|
| 1346 | Element("space_link_" + new_border_ID).style.display = 'none'; |
---|
| 1347 | Element("a_cc_link_" + new_border_ID).style.display = 'none'; |
---|
| 1348 | Element("tr_cc_"+ new_border_ID).style.display = ''; |
---|
| 1349 | } |
---|
| 1350 | if (data.cco){ |
---|
| 1351 | Element("cco_" + new_border_ID).value = data.cco; |
---|
| 1352 | Element("space_link_" + new_border_ID).style.display = 'none'; |
---|
| 1353 | Element("a_cco_link_" + new_border_ID).style.display = 'none'; |
---|
| 1354 | Element("tr_cco_"+ new_border_ID).style.display = ''; |
---|
| 1355 | } |
---|
| 1356 | Element("subject_" + new_border_ID).value = data.subject; |
---|
| 1357 | |
---|
| 1358 | var divFiles = Element("divFiles_"+new_border_ID); |
---|
| 1359 | if (Element("attachments_" + border_ID)){ |
---|
| 1360 | var attachments = document.getElementById("attachments_" + border_ID).childNodes; |
---|
| 1361 | for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){ |
---|
| 1362 | var link_attachment = document.createElement("A"); |
---|
| 1363 | link_attachment.setAttribute("href", attachments[i].href); |
---|
| 1364 | link_attachment.innerHTML = attachments[i].innerHTML; |
---|
| 1365 | var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); |
---|
| 1366 | var a_tmp = tmp.split(','); |
---|
| 1367 | tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); |
---|
| 1368 | a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; |
---|
| 1369 | s_tmp = escape(expresso.connector.serialize(a_tmp)); |
---|
| 1370 | divFiles.innerHTML += "<input style='border:0' type='CHECKBOX' name='forwarding_attachments[]' checked value=\""+s_tmp+"\"/>"; |
---|
| 1371 | divFiles.appendChild(link_attachment); |
---|
| 1372 | } |
---|
| 1373 | } |
---|
| 1374 | var body = Element("body_" + new_border_ID); |
---|
| 1375 | body.contentWindow.document.open(); |
---|
| 1376 | body.contentWindow.document.write("<html><body bgcolor='#FFFFFF'>"+data.body+"</body></html>"); |
---|
| 1377 | body.contentWindow.document.close(); |
---|
| 1378 | body.contentWindow.document.designMode = "on"; |
---|
| 1379 | //Focus |
---|
| 1380 | if (is_ie) |
---|
| 1381 | window.setTimeout('document.getElementById("body_'+new_border_ID+'").contentWindow.focus();', 300); |
---|
| 1382 | else |
---|
| 1383 | body.contentWindow.focus(); |
---|
| 1384 | config_events( body.contentWindow.document, 'onkeyup', function( e ) |
---|
| 1385 | { |
---|
| 1386 | if ( e.keyCode == 13 ) |
---|
| 1387 | { |
---|
| 1388 | var paragraphs = body.contentWindow.document.getElementsByTagName( 'p' ); |
---|
| 1389 | for ( p = 0; p < paragraphs.length; p++ ) |
---|
| 1390 | paragraphs.item( p ).style.margin = '0px'; |
---|
| 1391 | } |
---|
| 1392 | }); |
---|
| 1393 | break; |
---|
| 1394 | default: |
---|
| 1395 | } |
---|
| 1396 | |
---|
| 1397 | // IM Module Enabled |
---|
[2952] | 1398 | if( window.parent.loadscript && loadscript.autoStatusIM ) |
---|
[2517] | 1399 | { |
---|
| 1400 | config_events( body.contentWindow.document, "onkeypress", loadscript.autoStatusIM ); |
---|
| 1401 | } |
---|
| 1402 | |
---|
| 1403 | if (preferences.auto_save_draft == 1) |
---|
| 1404 | { |
---|
| 1405 | openTab.autosave_timer[new_border_ID] = false; |
---|
| 1406 | var save_link = document.getElementById("save_message_options"+new_border_ID); |
---|
| 1407 | |
---|
| 1408 | function auto_sav() |
---|
| 1409 | { |
---|
| 1410 | if (openTab.autosave_timer[new_border_ID]) |
---|
| 1411 | clearTimeout(openTab.autosave_timer[new_border_ID]); |
---|
| 1412 | |
---|
| 1413 | openTab.autosave_timer[new_border_ID] = setTimeout("save_msg("+new_border_ID+")", autosave_time); |
---|
| 1414 | } |
---|
| 1415 | config_events(body.contentWindow.document,'keypress', auto_sav); |
---|
| 1416 | } |
---|
| 1417 | |
---|
| 1418 | //BEGIN Tab event |
---|
| 1419 | if (preferences.use_shortcuts == '1') |
---|
| 1420 | { |
---|
| 1421 | if (is_ie) |
---|
| 1422 | { |
---|
| 1423 | 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); |
---|
| 1424 | } |
---|
| 1425 | else |
---|
| 1426 | { |
---|
| 1427 | 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); |
---|
| 1428 | } |
---|
| 1429 | } |
---|
| 1430 | // END Tab event |
---|
| 1431 | |
---|
| 1432 | var offWidth = Element('border_blank').offsetWidth ? Element('border_blank').offsetWidth : Element('border_blank').clientWidth; |
---|
| 1433 | var resize = false; |
---|
| 1434 | |
---|
| 1435 | if (offWidth < 200) { |
---|
| 1436 | resize = Element("border_id_" + new_border_ID).style.width; |
---|
| 1437 | } |
---|
| 1438 | |
---|
| 1439 | if (title.length > 21){ |
---|
| 1440 | title = title.substring(0,21) + "..."; |
---|
| 1441 | } |
---|
| 1442 | |
---|
| 1443 | if(resize) |
---|
| 1444 | title = title.substring(0, parseInt(resize)*0.08); |
---|
| 1445 | |
---|
[3131] | 1446 | // Load default style for <PRE> tag, inside RichTextEditor. |
---|
| 1447 | RichTextEditor.loadStyle("pre","main.css"); |
---|
[3081] | 1448 | Element("border_id_" + new_border_ID).innerHTML = "<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td id=font_border_id_" + new_border_ID +" class='font-menu' width=*>" +title + "</td><td width=1px><img onmousedown='javascript:return false' style='cursor:pointer' onclick=delete_border('" + new_border_ID + "','false') src='"+URL_SERVER+"expressoMail1_2/templates/"+template+"/images/close_button.png'></td></tr></table>"; |
---|
[3079] | 1449 | expresso.connector.loadScript('wfolders'); |
---|
[2517] | 1450 | return new_border_ID; //Preciso retornar o ID da nova mensagem. |
---|
| 1451 | } |
---|
| 1452 | |
---|
| 1453 | function useOriginalAttachments(new_id_border,old_id_border) |
---|
| 1454 | { |
---|
| 1455 | var divFiles = Element("divFiles_"+new_id_border); |
---|
| 1456 | if (Element("attachments_" + old_id_border)) { |
---|
| 1457 | var areaOldAttachments = document.createElement("DIV"); |
---|
| 1458 | areaOldAttachments.id = "area_div_attachments_"+new_id_border; |
---|
| 1459 | divFiles.appendChild(areaOldAttachments); |
---|
| 1460 | var optAttachments = document.createElement("A"); |
---|
| 1461 | optAttachments.setAttribute("href","javascript:void(0)"); |
---|
| 1462 | optAttachments.tabIndex = -1; |
---|
| 1463 | optAttachments.innerHTML = get_lang("Original attachments: add")+"</br>"; |
---|
| 1464 | areaOldAttachments.appendChild(optAttachments); |
---|
| 1465 | var divOriginalAttachments = document.createElement("DIV"); |
---|
| 1466 | divOriginalAttachments.id = "div_attachments_"+new_id_border; |
---|
| 1467 | optAttachments.onclick = function(){ |
---|
| 1468 | if(document.getElementById('div_attachments_'+new_id_border)) |
---|
| 1469 | { |
---|
| 1470 | areaOldAttachments.removeChild(document.getElementById('div_attachments_'+new_id_border)); |
---|
| 1471 | optAttachments.innerHTML = get_lang("Original attachments: add")+"</br>"; |
---|
| 1472 | } |
---|
| 1473 | else |
---|
| 1474 | { |
---|
| 1475 | areaOldAttachments.appendChild(divOriginalAttachments); |
---|
| 1476 | optAttachments.innerHTML = get_lang("Original attachments: remove")+"</br>"; |
---|
| 1477 | } |
---|
[2556] | 1478 | return false; |
---|
| 1479 | }; |
---|
[2517] | 1480 | var attachments = document.getElementById("attachments_" + old_id_border).childNodes; |
---|
| 1481 | for (var i = (attachments.length > 1 ? 1 : 0); i < attachments.length; i++){ |
---|
| 1482 | var link_attachment = document.createElement("A"); |
---|
| 1483 | link_attachment.setAttribute("href", attachments[i].href); |
---|
| 1484 | link_attachment.innerHTML = attachments[i].innerHTML; |
---|
| 1485 | var tmp = link_attachment.href.replace("javascript:download_attachments(", "").replace(")", ""); |
---|
| 1486 | var a_tmp = tmp.split(','); |
---|
| 1487 | tmp = link_attachment.innerHTML.substring(0,link_attachment.innerHTML.lastIndexOf("(")); |
---|
| 1488 | a_tmp[2] = "'"+tmp.substring(0,tmp.length-1)+"'"; |
---|
| 1489 | s_tmp = escape(expresso.connector.serialize(a_tmp)); |
---|
| 1490 | divOriginalAttachments.innerHTML += "<input style='border:0' type='CHECKBOX' name='forwarding_attachments[]' checked value=\""+s_tmp+"\"/>"; |
---|
| 1491 | divOriginalAttachments.appendChild(link_attachment); |
---|
| 1492 | } |
---|
[2556] | 1493 | }; |
---|
[2517] | 1494 | } |
---|
| 1495 | |
---|
| 1496 | function send_message_return(data, ID){ |
---|
[2968] | 1497 | watch_changes_in_msg(ID); |
---|
[2517] | 1498 | |
---|
| 1499 | var sign = false; |
---|
| 1500 | var crypt = false; |
---|
| 1501 | if ((preferences.use_assinar_criptografar != '0') && (preferences.use_signature_digital_cripto != '0')){ |
---|
[2556] | 1502 | var checkSign = document.getElementById('return_digital_'+ID); |
---|
[2517] | 1503 | if (checkSign.checked){ |
---|
| 1504 | sign = true; |
---|
| 1505 | } |
---|
| 1506 | |
---|
| 1507 | var checkCript = document.getElementById('return_cripto_'+ID); |
---|
| 1508 | if (checkCript.checked){ |
---|
| 1509 | crypt = true; |
---|
| 1510 | } |
---|
| 1511 | } |
---|
| 1512 | |
---|
| 1513 | if (typeof(data) == 'object' && !data.success) |
---|
| 1514 | { |
---|
| 1515 | connector = expresso.connector; |
---|
| 1516 | expresso.connector.showProgressBar(); |
---|
| 1517 | |
---|
| 1518 | if (sign || crypt){ |
---|
| 1519 | var operation = ''; |
---|
| 1520 | if (sign){ |
---|
| 1521 | operation = 'sign'; |
---|
| 1522 | } |
---|
| 1523 | else { // crypt |
---|
| 1524 | //TODO: Colocar mensagem de erro, e finalizar o método. |
---|
| 1525 | operation = 'nop'; |
---|
| 1526 | } |
---|
| 1527 | } |
---|
| 1528 | |
---|
| 1529 | if (data.body){ |
---|
| 1530 | Element('cert_applet').doButtonClickAction(operation, ID, data.body); |
---|
| 1531 | } |
---|
| 1532 | else { |
---|
| 1533 | alert(data.error); |
---|
| 1534 | } |
---|
| 1535 | |
---|
| 1536 | return; |
---|
| 1537 | } |
---|
| 1538 | if(data && data.success == true ){ |
---|
| 1539 | // if send ok, set a flag as answered or forwarded |
---|
| 1540 | var msg_number_replied = Element('msg_reply_from_'+ID); |
---|
| 1541 | var msg_number_forwarded = Element('msg_forward_from_'+ID); |
---|
| 1542 | |
---|
| 1543 | if (msg_number_replied){ |
---|
| 1544 | proxy_mensagens.proxy_set_message_flag(msg_number_replied.value, 'answered'); |
---|
| 1545 | } |
---|
| 1546 | else if (msg_number_forwarded){ |
---|
| 1547 | proxy_mensagens.proxy_set_message_flag(msg_number_forwarded.value, 'forwarded'); |
---|
| 1548 | } |
---|
| 1549 | if(expresso_offline){ |
---|
| 1550 | write_msg(get_lang('Your message was sent to queue')); |
---|
| 1551 | delete_border(ID,'true'); |
---|
| 1552 | return; |
---|
| 1553 | }else{ |
---|
| 1554 | if (wfolders.alert) { |
---|
| 1555 | write_msg(get_lang('Your message was sent and save.')); |
---|
| 1556 | wfolders.alert = false; |
---|
| 1557 | } |
---|
| 1558 | else { |
---|
| 1559 | write_msg(get_lang('Your message was sent.')); |
---|
| 1560 | } |
---|
| 1561 | } |
---|
| 1562 | // If new dynamic contacts were added, update the autocomplete .... |
---|
| 1563 | if(data.new_contacts){ |
---|
| 1564 | var ar_contacts = data.new_contacts.split(',;'); |
---|
| 1565 | for(var j in ar_contacts){ |
---|
| 1566 | // If the dynamic contact don't exist, update the autocomplete.... |
---|
| 1567 | if((contacts+",").indexOf(";"+ar_contacts[j]+",") == -1) |
---|
| 1568 | contacts += ",;" + ar_contacts[j]; |
---|
| 1569 | } |
---|
| 1570 | } |
---|
| 1571 | if ((! openTab.toPreserve[ID]) && (openTab.imapUid[ID] != 0)) |
---|
| 1572 | { |
---|
[2556] | 1573 | cExecute ("expressoMail1_2.imap_functions.delete_msgs&folder="+openTab.imapBox[ID]+"&msgs_number="+openTab.imapUid[ID],function(data){ return; }); |
---|
[2517] | 1574 | } |
---|
| 1575 | delete_border(ID,'true'); // Becarefull: email saved automatically should be deleted. delete_border erase information about openTab |
---|
| 1576 | } |
---|
| 1577 | else{ |
---|
| 1578 | if(data == 'Post-Content-Length') |
---|
[2866] | 1579 | 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)); |
---|
[2517] | 1580 | else if(data) |
---|
| 1581 | write_msg(data); |
---|
| 1582 | else |
---|
| 1583 | write_msg(get_lang("Connection failed with %1 Server. Try later.", "Web")); |
---|
| 1584 | } |
---|
| 1585 | if(!expresso_offline) |
---|
| 1586 | expresso.connector.hideProgressBar(); |
---|
| 1587 | } |
---|
| 1588 | |
---|
| 1589 | /** |
---|
| 1590 | * Método chamado pela applet para retornar o resultado da assinatura/decifragem do e-mail. |
---|
| 1591 | * para posterior envio ao servidor. |
---|
| 1592 | * @author Mário César Kolling <mario.kolling@serpro.gov.br>, Bruno Vieira da Costa <bruno.vieira-costa@serpro.gov.br> |
---|
| 1593 | * @param smime O e-mail decifrado/assinado |
---|
| 1594 | * @param ID O ID do e-mail, para saber em que aba esse e-mail será mostrado. |
---|
| 1595 | * @param operation A operação que foi realizada pela applet (assinatura ou decifragem) |
---|
| 1596 | */ |
---|
| 1597 | function appletReturn(smime, ID, operation, folder){ |
---|
| 1598 | |
---|
| 1599 | if (!smime){ // Erro aconteceu ao assinar ou decifrar e-mail |
---|
| 1600 | connector = expresso.connector; |
---|
| 1601 | expresso.connector.hideProgressBar(); |
---|
| 1602 | return; |
---|
| 1603 | } |
---|
| 1604 | |
---|
| 1605 | if(operation=='decript') |
---|
| 1606 | { |
---|
| 1607 | var handler = function(data){ |
---|
| 1608 | |
---|
| 1609 | if(data.msg_day == '') |
---|
| 1610 | { |
---|
| 1611 | header=expresso_local_messages.get_msg_date(data.original_ID, proxy_mensagens.is_local_folder(get_current_folder())); |
---|
| 1612 | |
---|
| 1613 | data.fulldate=header.fulldate; |
---|
| 1614 | data.smalldate=header.smalldate; |
---|
| 1615 | data.msg_day = header.msg_day; |
---|
| 1616 | data.msg_hour = header.msg_hour; |
---|
| 1617 | |
---|
| 1618 | } |
---|
| 1619 | this.show_msg(data); |
---|
[2556] | 1620 | }; |
---|
[2517] | 1621 | para="&source="+smime+"&ID="+ID+"&folder="+folder; |
---|
| 1622 | cExecute ("expressoMail1_2.imap_functions.show_decript&", handler, para); |
---|
| 1623 | }else |
---|
| 1624 | { |
---|
| 1625 | ID_tmp = ID; |
---|
| 1626 | // Lê a variável e chama a nova função cExecuteForm |
---|
| 1627 | // Processa e envia para o servidor web |
---|
| 1628 | // Faz o request do connector novamente. Talvez implementar no connector |
---|
| 1629 | // para manter coerência. |
---|
| 1630 | |
---|
| 1631 | var handler_send_smime = function(data){ |
---|
| 1632 | send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug |
---|
| 1633 | }; |
---|
| 1634 | |
---|
| 1635 | var textArea = document.createElement("TEXTAREA"); |
---|
| 1636 | textArea.style.display='none'; |
---|
| 1637 | textArea.id = 'smime'; |
---|
| 1638 | textArea.name = "smime"; |
---|
| 1639 | textArea.value += smime; |
---|
| 1640 | |
---|
| 1641 | // Lê a variável e chama a nova função cExecuteForm |
---|
| 1642 | // Processa e envia para o servidor web |
---|
| 1643 | // Faz o request do connector novamente. Talvez implementar no connector |
---|
| 1644 | // para manter coerência. |
---|
| 1645 | if (is_ie){ |
---|
| 1646 | var i = 0; |
---|
[2556] | 1647 | while (document.forms(i).name != "form_message_"+ID) { i++; } |
---|
[2517] | 1648 | form = document.forms(i); |
---|
| 1649 | } |
---|
| 1650 | else |
---|
| 1651 | form = document.forms["form_message_"+ID]; |
---|
| 1652 | |
---|
| 1653 | form.appendChild(textArea); |
---|
| 1654 | |
---|
| 1655 | cExecuteForm ("expressoMail1_2.imap_functions.send_mail", form, handler_send_smime, ID); |
---|
| 1656 | } |
---|
| 1657 | } |
---|
| 1658 | |
---|
| 1659 | function send_message(ID, folder, folder_name){ |
---|
| 1660 | |
---|
| 1661 | //limpa autosave_timer[ID]; havia conflito quando uma mensagem ia ser enviada e nesse exato momento o autosave |
---|
| 1662 | //entrava em execucao (a aba de edicao da mensagem continuava aberta e a mensagem exibida era a de que a mensagem foi |
---|
| 1663 | //salva na pasta Rascunhos e nao que tinha sido enviada, como deveria); |
---|
| 1664 | if (preferences.auto_save_draft == 1) |
---|
| 1665 | { |
---|
| 1666 | if (openTab.autosave_timer[ID]) |
---|
| 1667 | { |
---|
| 1668 | clearTimeout(openTab.autosave_timer[ID]); |
---|
| 1669 | } |
---|
| 1670 | } |
---|
| 1671 | |
---|
| 1672 | if ( document.getElementById('viewsource_rt_checkbox').checked == true ) |
---|
| 1673 | document.getElementById('viewsource_rt_checkbox').click(); |
---|
| 1674 | |
---|
| 1675 | var save_link = Element("save_message_options_"+ID); |
---|
| 1676 | save_link.onclick = ''; |
---|
| 1677 | save_link.className = 'message_options_inactive'; |
---|
| 1678 | |
---|
| 1679 | ID_tmp = ID; |
---|
| 1680 | |
---|
| 1681 | var handler_send_message = function(data){ |
---|
| 1682 | send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug |
---|
| 1683 | }; |
---|
| 1684 | |
---|
| 1685 | var textArea = document.createElement("TEXTAREA"); |
---|
| 1686 | textArea.style.display='none'; |
---|
| 1687 | textArea.name = "body"; |
---|
| 1688 | body = document.getElementById("body_"+ID); |
---|
| 1689 | textArea.value += '<body>\r\n'; |
---|
| 1690 | textArea.value += body.contentWindow.document.body.innerHTML; |
---|
| 1691 | textArea.value += '\r\n</body>'; |
---|
| 1692 | var input_folder = document.createElement("INPUT"); |
---|
| 1693 | input_folder.style.display='none'; |
---|
| 1694 | input_folder.name = "folder"; |
---|
| 1695 | input_folder.value = folder; |
---|
| 1696 | var msg_id = document.createElement("INPUT"); |
---|
| 1697 | msg_id.style.display='none'; |
---|
| 1698 | msg_id.name = "msg_id"; |
---|
| 1699 | msg_id.value = openTab.imapUid[ID]; |
---|
| 1700 | |
---|
| 1701 | if (is_ie){ |
---|
| 1702 | var i = 0; |
---|
[2556] | 1703 | while (document.forms(i).name != "form_message_"+ID) { i++; } |
---|
[2517] | 1704 | form = document.forms(i); |
---|
| 1705 | } |
---|
| 1706 | else |
---|
| 1707 | form = document.forms["form_message_"+ID]; |
---|
| 1708 | |
---|
| 1709 | // Evita que e-mails assinados sejam enviados quando o usuário tenta enviar um e-mail |
---|
| 1710 | // não assinado (desmarcou a opção) após tentar enviar um e-mail assinado que não passou |
---|
| 1711 | // no teste de validação. |
---|
| 1712 | var checkSign = document.getElementById('return_digital_'+ID); |
---|
| 1713 | if (checkSign && !checkSign.checked){ |
---|
| 1714 | var smime = Element('smime'); |
---|
| 1715 | if (smime) |
---|
| 1716 | { |
---|
| 1717 | var parent = smime.parentNode; |
---|
| 1718 | parent.removeChild(smime); |
---|
| 1719 | } |
---|
| 1720 | } |
---|
| 1721 | |
---|
| 1722 | form.appendChild(textArea); |
---|
| 1723 | form.appendChild(input_folder); |
---|
| 1724 | form.appendChild(msg_id); |
---|
| 1725 | |
---|
| 1726 | var _subject = trim(Element("subject_"+ID).value); |
---|
| 1727 | if((_subject.length == 0) && !confirm(get_lang("Send this message without a subject?"))) { |
---|
| 1728 | Element("subject_"+ID).focus(); |
---|
| 1729 | return; |
---|
| 1730 | } |
---|
| 1731 | |
---|
| 1732 | if (expresso_offline) { |
---|
| 1733 | stringEmail = Element("to_"+ID).value; |
---|
| 1734 | stringEmail += Element("cco_"+ID).value =='' ? "":", "+Element("cco_"+ID).value; |
---|
| 1735 | stringEmail += Element("cc_"+ID).value =='' ? "":", "+Element("cc_"+ID).value; |
---|
| 1736 | var invalidEmail = searchEmail(stringEmail); |
---|
| 1737 | if(Element("to_"+ID).value=="" && Element("cco_"+ID).value=="" && Element("cc_"+ID).value=="") { |
---|
| 1738 | write_msg(get_lang("message without receiver.")); |
---|
| 1739 | return; |
---|
| 1740 | }else if(invalidEmail[0] == true){ |
---|
| 1741 | write_msg("Os endereços de destinatário a seguir estão incorretos: "+invalidEmail[1]); |
---|
| 1742 | return; |
---|
| 1743 | } |
---|
| 1744 | |
---|
| 1745 | sucess = expresso_local_messages.send_to_queue(form); |
---|
| 1746 | var data_return = new Array(); |
---|
| 1747 | data_return.success = sucess; |
---|
| 1748 | handler_send_message(data_return,ID); |
---|
| 1749 | } |
---|
| 1750 | else |
---|
| 1751 | cExecuteForm("expressoMail1_2.imap_functions.send_mail", form, handler_send_message, ID); |
---|
| 1752 | } |
---|
| 1753 | function change_tr_properties(tr_element, newUid, newSubject){ |
---|
| 1754 | if (tr_element == null) |
---|
| 1755 | return false; |
---|
| 1756 | message_id=tr_element.id; |
---|
| 1757 | var td_who = document.getElementById('td_who_'+message_id); |
---|
| 1758 | if (typeof(newSubject) != 'undefined') |
---|
| 1759 | td_who.nextSibling.innerHTML = newSubject; |
---|
| 1760 | tr_element.id = newUid; |
---|
| 1761 | |
---|
| 1762 | var openNewMessage = function () { |
---|
| 1763 | expresso.connector.cacheNextRequest(); |
---|
| 1764 | cExecute("expressoMail1_2.imap_functions.get_info_msg&msg_number="+newUid |
---|
| 1765 | +"&msg_folder="+url_encode(current_folder),show_msg); |
---|
| 1766 | }; |
---|
| 1767 | for (var i=2; i < 10; i++){ |
---|
| 1768 | if (typeof(tr_element.childNodes[i].id) != "undefined") |
---|
| 1769 | tr_element.childNodes[i].id = tr_element.childNodes[i].id.replace(message_id,newUid); |
---|
| 1770 | tr_element.childNodes[i].onclick = openNewMessage; |
---|
| 1771 | } |
---|
| 1772 | } |
---|
| 1773 | |
---|
| 1774 | function return_save(data,border_id,folder_name,folder_id,message_id) |
---|
| 1775 | { |
---|
[2968] | 1776 | Element("send_button_"+border_id).style.visibility="visible"; |
---|
[2517] | 1777 | var handler_delete_msg = function(data){ refresh(preferences.alert_new_msg); }; |
---|
| 1778 | |
---|
| 1779 | if (data.append != true || !data) |
---|
| 1780 | { |
---|
| 1781 | RichTextEditor.saveFlag = -1; |
---|
| 1782 | if (! data.append) |
---|
| 1783 | write_msg('ERROR saving your message.'); |
---|
| 1784 | else |
---|
| 1785 | { |
---|
| 1786 | if (data.append.match(/^(.*)TRYCREATE(.*)$/)) |
---|
| 1787 | { |
---|
| 1788 | expresso.connector.loadScript('jscode/TreeS'); |
---|
| 1789 | alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.',draftsfolder)); |
---|
| 1790 | expresso.connector.loadScript('jscode/TreeShow'); |
---|
| 1791 | ttree.FOLDER = 'root'; |
---|
| 1792 | ttreeBox.new_past(draftsfolder); |
---|
| 1793 | setTimeout('save_msg('+border_id+')',3000); |
---|
| 1794 | } |
---|
| 1795 | else |
---|
| 1796 | write_msg(data.append); |
---|
| 1797 | } |
---|
| 1798 | } |
---|
| 1799 | else |
---|
| 1800 | { |
---|
| 1801 | RichTextEditor.saveFlag = 1; |
---|
| 1802 | openTab.imapUid[border_id] = data.msg_no; |
---|
| 1803 | openTab.imapBox[border_id] = data.folder_id; |
---|
| 1804 | |
---|
| 1805 | var newTitle = document.getElementById('subject_'+border_id).value; |
---|
| 1806 | if (newTitle.length > 18) |
---|
| 1807 | newTitle = newTitle.substr(18) + '...'; |
---|
| 1808 | else if (newTitle == '') |
---|
| 1809 | newTitle = get_lang("No subject"); |
---|
| 1810 | document.getElementById('font_border_id_'+border_id).innerHTML = newTitle; |
---|
| 1811 | |
---|
| 1812 | // Replace the embedded images for new uids |
---|
| 1813 | var mainField = document.getElementById('body_'+border_id).contentWindow; |
---|
| 1814 | var content_body = mainField.document.getElementsByTagName('body').item(0).innerHTML; |
---|
| 1815 | var body_images = content_body.match(/msg_num=\d*/g); |
---|
| 1816 | var images_part = content_body.match(/msg_part=\d*/g); |
---|
| 1817 | if (body_images) |
---|
| 1818 | { |
---|
| 1819 | for (var i=0; i<body_images.length; i++){ |
---|
| 1820 | content_body = content_body.replace(body_images[i],"msg_num="+openTab.imapUid[border_id]); |
---|
| 1821 | } |
---|
| 1822 | var allImgs = new Array (images_part.length); |
---|
| 1823 | var j=-1; |
---|
| 1824 | for (var i in images_part){ |
---|
| 1825 | |
---|
| 1826 | if (is_ie) |
---|
| 1827 | if (i == 0) |
---|
| 1828 | var image_number = parseInt(images_part[i].substr(9)); |
---|
| 1829 | else |
---|
| 1830 | image_number = "null"; |
---|
| 1831 | else |
---|
| 1832 | var image_number = parseInt(images_part[i].substr(9)); |
---|
| 1833 | |
---|
| 1834 | if (! isNaN(image_number)) |
---|
| 1835 | { |
---|
| 1836 | if (! allImgs[image_number]) |
---|
| 1837 | { |
---|
| 1838 | allImgs[image_number] = true; |
---|
| 1839 | j--; |
---|
| 1840 | } |
---|
| 1841 | content_body = content_body.replace(images_part[i],'msg_part='+j); |
---|
| 1842 | } |
---|
| 1843 | } |
---|
| 1844 | content_body = content_body.replace(/msg_part=-/g,'msg_part='); |
---|
| 1845 | |
---|
| 1846 | mainField.document.getElementsByTagName('body').item(0).innerHTML = content_body; |
---|
| 1847 | } |
---|
| 1848 | |
---|
| 1849 | //Replace all files to new files |
---|
| 1850 | var divFiles = Element("divFiles_"+border_id); |
---|
| 1851 | elFiles = divFiles.getElementsByTagName("input"); |
---|
| 1852 | var countCheck =0; |
---|
| 1853 | for (var i=0; i<elFiles.length; i++) { |
---|
| 1854 | if(elFiles[i].value !=""){ |
---|
| 1855 | if (elFiles[i].type == "checkbox") { |
---|
| 1856 | countCheck++; |
---|
| 1857 | } |
---|
| 1858 | else { |
---|
| 1859 | elFiles[i].value =""; |
---|
| 1860 | parantNodeFile = elFiles[i].parentNode.parentNode; |
---|
| 1861 | parantNodeFile.removeChild(elFiles[i].parentNode); |
---|
| 1862 | i--; |
---|
| 1863 | } |
---|
| 1864 | |
---|
| 1865 | } |
---|
| 1866 | }; |
---|
| 1867 | |
---|
| 1868 | var attach_files = expresso.connector.unserialize(data.files); |
---|
| 1869 | if (attach_files != null) { |
---|
| 1870 | openTab.countFile[border_id] = attach_files.length; |
---|
| 1871 | att_index = countCheck; |
---|
| 1872 | for (att_index; att_index < attach_files.length; att_index++){ |
---|
| 1873 | |
---|
| 1874 | var link_attachment = document.createElement("A"); |
---|
| 1875 | var fileName = attach_files[att_index].substr(0,attach_files[att_index].indexOf('_SIZE_')); |
---|
[2556] | 1876 | var fileSize = parseInt(attach_files[att_index].substr(attach_files[att_index].indexOf('_SIZE_')+6))/1024; |
---|
[2517] | 1877 | link_attachment.innerHTML = fileName + " ("+borkb((parseInt(fileSize)*1024))+")"; |
---|
| 1878 | |
---|
| 1879 | var href = "'"+folder_id+"','"+data.msg_no+"','"+(att_index)+"','"+(att_index+2)+"','base64'"; |
---|
| 1880 | |
---|
| 1881 | link_attachment.setAttribute("href", "javascript:download_attachments("+href+")"); |
---|
| 1882 | |
---|
| 1883 | var a_tmp = href.split(','); |
---|
| 1884 | a_tmp[2] = fileName; |
---|
| 1885 | s_tmp = escape(expresso.connector.serialize(a_tmp)); |
---|
| 1886 | |
---|
| 1887 | var check_attachment = document.createElement("INPUT"); |
---|
| 1888 | check_attachment.type = 'CHECKBOX'; |
---|
| 1889 | check_attachment.name = 'forwarding_attachments[]'; |
---|
| 1890 | check_attachment.value = s_tmp; |
---|
| 1891 | |
---|
| 1892 | divFiles.insertBefore(document.createElement("BR"),divFiles.childNodes[0]); |
---|
| 1893 | divFiles.insertBefore(link_attachment,divFiles.childNodes[0]); |
---|
| 1894 | divFiles.insertBefore(check_attachment,divFiles.childNodes[0]); |
---|
| 1895 | |
---|
| 1896 | check_attachment.checked = true; |
---|
| 1897 | } |
---|
| 1898 | } |
---|
| 1899 | if (message_id) |
---|
| 1900 | { |
---|
| 1901 | cExecute ("expressoMail1_2.imap_functions.delete_msgs&folder="+openTab.imapBox[border_id]+"&msgs_number="+message_id,handler_delete_msg); |
---|
| 1902 | if (openTab.imapBox[0] == "INBOX/"+draftsfolder) |
---|
| 1903 | { |
---|
| 1904 | //Update mailbox |
---|
| 1905 | var tr_msg = document.getElementById(message_id); |
---|
| 1906 | change_tr_properties(tr_msg, data.msg_no, data.subject); |
---|
| 1907 | } |
---|
| 1908 | |
---|
| 1909 | } |
---|
| 1910 | var save_link = Element("save_message_options_"+border_id); |
---|
| 1911 | save_link.onclick = ''; |
---|
| 1912 | save_link.className = 'message_options_inactive'; |
---|
| 1913 | watch_changes_in_msg(border_id); |
---|
| 1914 | write_msg(get_lang('Your message was save as draft in folder %1.', lang_folder(folder_name))); |
---|
| 1915 | } |
---|
| 1916 | } |
---|
| 1917 | |
---|
| 1918 | function save_msg(border_id,withImage){ |
---|
| 1919 | if (typeof(withImage) == 'undefined') |
---|
| 1920 | withImage = false; |
---|
| 1921 | |
---|
| 1922 | var rt_checkbox = Element('viewsource_rt_checkbox'); |
---|
| 1923 | if (rt_checkbox == null) |
---|
| 1924 | return false; |
---|
| 1925 | if (rt_checkbox.checked == true) |
---|
| 1926 | rt_checkbox.click(); |
---|
| 1927 | |
---|
| 1928 | var sendButton = Element("send_button_"+border_id); |
---|
| 1929 | if (sendButton) |
---|
| 1930 | sendButton.style.visibility="hidden"; |
---|
| 1931 | |
---|
[3144] | 1932 | if (openTab.imapBox[border_id] && openTab.type[border_id] < 6) //Gets the imap folder |
---|
[2517] | 1933 | var folder_id = openTab.imapBox[border_id]; |
---|
| 1934 | else |
---|
| 1935 | var folder_id = "INBOX/"+draftsfolder; |
---|
| 1936 | |
---|
| 1937 | if (folder_id == 'INBOX') // and folder name from border |
---|
| 1938 | var folder_name = get_lang(folder_id); |
---|
| 1939 | else |
---|
| 1940 | var folder_name = folder_id.substr(6); |
---|
| 1941 | |
---|
| 1942 | // hack to avoid form connector bug, escapes quotation. Please see #179 |
---|
| 1943 | tmp_border_id=border_id; |
---|
| 1944 | tmp_folder_name=folder_name; |
---|
| 1945 | tmp_folder_id=folder_id; |
---|
| 1946 | message_id = openTab.imapUid[border_id]; |
---|
[2556] | 1947 | var handler_save_msg = function(data){ return_save(data,this.tmp_border_id,this.tmp_folder_name,this.tmp_folder_id,this.message_id); }; |
---|
[2517] | 1948 | |
---|
| 1949 | var textArea = document.createElement("TEXTAREA"); |
---|
| 1950 | textArea.style.display='none'; |
---|
| 1951 | textArea.name = "body"; |
---|
| 1952 | body = document.getElementById("body_"+border_id); |
---|
| 1953 | if (! body) |
---|
| 1954 | return; |
---|
| 1955 | textArea.value += '<body>\r\n'; |
---|
| 1956 | textArea.value += body.contentWindow.document.body.innerHTML; |
---|
| 1957 | textArea.value += '\r\n</body>'; |
---|
| 1958 | var input_folder = document.createElement("INPUT"); |
---|
| 1959 | input_folder.style.display='none'; |
---|
| 1960 | input_folder.name = "folder"; |
---|
| 1961 | input_folder.value = folder_id; |
---|
| 1962 | var input_msgid = document.createElement("INPUT"); |
---|
| 1963 | input_msgid.style.display='none'; |
---|
| 1964 | input_msgid.name = "msg_id"; |
---|
| 1965 | input_msgid.value = message_id; |
---|
| 1966 | var input_insertImg = document.createElement("INPUT"); |
---|
| 1967 | input_insertImg.style.display='none'; |
---|
| 1968 | input_insertImg.name = "insertImg"; |
---|
| 1969 | input_insertImg.value = withImage; |
---|
| 1970 | |
---|
| 1971 | |
---|
| 1972 | if (is_ie){ |
---|
| 1973 | var i = 0; |
---|
[2556] | 1974 | while (document.forms(i).name != "form_message_"+border_id) { i++; } |
---|
[2517] | 1975 | form = document.forms(i); |
---|
| 1976 | } |
---|
| 1977 | else |
---|
| 1978 | form = document.forms["form_message_"+border_id]; |
---|
| 1979 | form.appendChild(textArea); |
---|
| 1980 | form.appendChild(input_folder); |
---|
| 1981 | form.appendChild(input_msgid); |
---|
| 1982 | form.appendChild(input_insertImg); |
---|
| 1983 | |
---|
| 1984 | cExecuteForm ("expressoMail1_2.imap_functions.save_msg", form, handler_save_msg,border_id); |
---|
| 1985 | } |
---|
| 1986 | |
---|
| 1987 | function return_saveas(data,border_id,folder_name) |
---|
| 1988 | { |
---|
| 1989 | if (data.append) |
---|
| 1990 | { |
---|
| 1991 | delete_border(border_id,null); |
---|
| 1992 | write_msg(get_lang('Your message was save as draft in folder %1.', folder_name)); |
---|
| 1993 | } |
---|
| 1994 | else |
---|
| 1995 | write_msg('ERROR saving your message.'); |
---|
| 1996 | } |
---|
| 1997 | |
---|
| 1998 | function save_as_msg(border_id, folder_id, folder_name){ |
---|
| 1999 | // hack to avoid form connector bug, escapes quotation. Please see #179 |
---|
| 2000 | tmp_border_id=border_id; |
---|
| 2001 | tmp_folder_name=folder_name; |
---|
[2556] | 2002 | var handler_save_msg = function(data){ return_saveas(data,this.tmp_border_id,this.tmp_folder_name); }; |
---|
[2517] | 2003 | var textArea = document.createElement("TEXTAREA"); |
---|
| 2004 | textArea.style.display='none'; |
---|
| 2005 | textArea.name = "body"; |
---|
| 2006 | body = document.getElementById("body_"+border_id); |
---|
| 2007 | textArea.value += '<body>\r\n'; |
---|
| 2008 | textArea.value += body.contentWindow.document.body.innerHTML; |
---|
| 2009 | textArea.value += '\r\n</body>'; |
---|
| 2010 | |
---|
| 2011 | var input_folder = document.createElement("INPUT"); |
---|
| 2012 | input_folder.style.display='none'; |
---|
| 2013 | input_folder.name = "folder"; |
---|
| 2014 | input_folder.value = folder_id; |
---|
| 2015 | |
---|
| 2016 | if (is_ie){ |
---|
| 2017 | var i = 0; |
---|
| 2018 | while (document.forms(i).name != "form_message_"+border_id){i++} |
---|
| 2019 | form = document.forms(i); |
---|
| 2020 | } |
---|
| 2021 | else |
---|
| 2022 | form = document.forms["form_message_"+border_id]; |
---|
| 2023 | form.appendChild(textArea); |
---|
| 2024 | form.appendChild(input_folder); |
---|
| 2025 | |
---|
| 2026 | cExecuteForm ("expressoMail1_2.imap_functions.save_msg", form, handler_save_msg,border_id); |
---|
| 2027 | } |
---|
| 2028 | |
---|
| 2029 | |
---|
| 2030 | // Get checked messages |
---|
| 2031 | function set_messages_flag(flag, msgs_to_set){ |
---|
[2929] | 2032 | var _hand_setmsgflag = function (data){ |
---|
[2517] | 2033 | |
---|
| 2034 | var msgs_to_set = data.msgs_to_set.split(","); |
---|
| 2035 | |
---|
| 2036 | if(!data.status) { |
---|
| 2037 | alert(data.msg); |
---|
[2929] | 2038 | Element('chkbox_sel_allmsg').checked = false; |
---|
[2517] | 2039 | for (var i = 0; i < msgs_to_set.length; i++) { |
---|
| 2040 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
| 2041 | remove_className(Element(msgs_to_set[i]), 'selected_msg'); |
---|
| 2042 | } |
---|
| 2043 | if(!data.msgs_unflageds) |
---|
| 2044 | return; |
---|
| 2045 | else |
---|
| 2046 | msgs_to_set = data.msgs_unflageds.split(","); |
---|
| 2047 | } |
---|
| 2048 | |
---|
| 2049 | |
---|
| 2050 | for (var i=0; i<msgs_to_set.length; i++){ |
---|
| 2051 | if(Element("check_box_message_" + msgs_to_set[i])){ |
---|
| 2052 | switch(data.flag){ |
---|
| 2053 | case "unseen": |
---|
| 2054 | set_msg_as_unread(msgs_to_set[i]); |
---|
| 2055 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
| 2056 | break; |
---|
| 2057 | case "seen": |
---|
| 2058 | set_msg_as_read(msgs_to_set[i], false); |
---|
| 2059 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
| 2060 | break; |
---|
| 2061 | case "flagged": |
---|
| 2062 | set_msg_as_flagged(msgs_to_set[i]); |
---|
| 2063 | document.getElementById("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
| 2064 | break; |
---|
| 2065 | case "unflagged": |
---|
| 2066 | set_msg_as_unflagged(msgs_to_set[i]); |
---|
| 2067 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
| 2068 | break; |
---|
| 2069 | } |
---|
| 2070 | } |
---|
| 2071 | } |
---|
[2929] | 2072 | Element('chkbox_sel_allmsg').checked = false; |
---|
[2556] | 2073 | }; |
---|
[2517] | 2074 | |
---|
| 2075 | var folder = get_current_folder(); |
---|
| 2076 | if (msgs_to_set == 'get_selected_messages') |
---|
| 2077 | var msgs_to_set = this.get_selected_messages(); |
---|
| 2078 | else |
---|
| 2079 | folder = Element("input_folder_"+msgs_to_set+"_r").value; |
---|
| 2080 | |
---|
| 2081 | if (msgs_to_set) |
---|
| 2082 | { |
---|
[2929] | 2083 | cExecute ("expressoMail1_2.imap_functions.set_messages_flag&folder="+folder+"&msgs_to_set="+msgs_to_set+"&flag="+flag, _hand_setmsgflag); |
---|
[2517] | 2084 | } |
---|
| 2085 | else |
---|
| 2086 | write_msg(get_lang('No selected message.')); |
---|
| 2087 | } |
---|
| 2088 | |
---|
| 2089 | // By message number |
---|
| 2090 | function set_message_flag(msg_number, flag){ |
---|
| 2091 | var msg_number_folder = Element("new_input_folder_"+msg_number+"_r"); |
---|
[2929] | 2092 | var _hand_setmsgflag = function (data){ |
---|
[2517] | 2093 | if (data.status && Element("td_message_answered_"+msg_number)) { |
---|
| 2094 | if(flag == 'answered') |
---|
[2630] | 2095 | Element("td_message_answered_"+msg_number).innerHTML = '<img src="'+URL_SERVER+'expressoMail1_2/templates/'+template+'/images/answered.gif" title="Respondida">'; |
---|
[2517] | 2096 | else if(flag == 'forwarded') |
---|
[2630] | 2097 | Element("td_message_answered_"+msg_number).innerHTML = '<img src="'+URL_SERVER+'expressoMail1_2/templates/'+template+'/images/forwarded.gif" title="Encaminhada">'; |
---|
[2517] | 2098 | } |
---|
[2556] | 2099 | }; |
---|
[2929] | 2100 | cExecute ("expressoMail1_2.imap_functions.set_messages_flag&folder="+( msg_number_folder ? msg_number_folder.value : get_current_folder() )+"&msgs_to_set="+msg_number+"&flag="+flag, _hand_setmsgflag); |
---|
[2517] | 2101 | } |
---|
| 2102 | |
---|
| 2103 | function print_all(){ |
---|
| 2104 | if (openTab.type[currentTab] == 2) |
---|
| 2105 | return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab); |
---|
| 2106 | |
---|
| 2107 | var folder= Element('border_id_0').innerHTML; |
---|
| 2108 | var body = Element('divScrollMain_'+numBox).innerHTML; |
---|
| 2109 | var print_width = screen.width - 200; |
---|
| 2110 | var x = ((screen.width - print_width) / 2); |
---|
| 2111 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 2112 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
| 2113 | var seekDot = /\<img /gi; |
---|
| 2114 | body = body.replace(seekDot, "<img style='display:none' "); |
---|
| 2115 | seekDot = /\<input /gi; |
---|
| 2116 | body = body.replace(seekDot, "<input style='display:none' "); |
---|
| 2117 | |
---|
| 2118 | while (1){ |
---|
| 2119 | try{ |
---|
| 2120 | var html = '<br>'; |
---|
| 2121 | html += "<h4>ExpressoLivre - ExpressoMail</h4>"; |
---|
| 2122 | html += folder+"<hr>"; |
---|
| 2123 | |
---|
| 2124 | window_print.document.body.innerHTML = html + '<blockquote><font size="2">' + |
---|
| 2125 | '<table style="font-size:12" width="'+(is_ie ? "85%" : "99%" )+'"><TR><TD align="center" width="5%"> </TD><TD width="30%" align="center">'+get_lang("Who")+'</TD><TD align="center" width="45%">'+get_lang("Subject")+'</TD><TD align="center" width="10%">'+get_lang("Date")+'</TD><TD width="10%">'+get_lang("Size")+'</TD></TR></table>' |
---|
| 2126 | + body + '</font></blockquote>'; |
---|
| 2127 | break; |
---|
| 2128 | } |
---|
| 2129 | catch(e){ |
---|
| 2130 | //alert(e.message); |
---|
| 2131 | } |
---|
| 2132 | } |
---|
| 2133 | window_print.document.close(); |
---|
| 2134 | window_print.print(); |
---|
| 2135 | } |
---|
| 2136 | |
---|
| 2137 | |
---|
| 2138 | function print_msg(msg_folder, msg_number, border_ID){ |
---|
| 2139 | var div_toaddress_full = Element("div_toaddress_full_"+border_ID); |
---|
| 2140 | var div_ccaddress_full = Element("div_ccaddress_full_"+border_ID); |
---|
| 2141 | var printListTO = (div_toaddress_full && div_toaddress_full.style.display != 'none') || toaddress_array[border_ID].length == 1 ? true : false; |
---|
| 2142 | var printListCC = (div_ccaddress_full && div_ccaddress_full.style.display != 'none') || !div_ccaddress_full ? true : false; |
---|
| 2143 | var sender = Element('sender_values_'+border_ID) ? Element('sender_values_'+border_ID).value : null; |
---|
| 2144 | var from = Element('from_values_'+border_ID) ? Element('from_values_'+border_ID).value : null; |
---|
| 2145 | var to = Element('to_values_'+border_ID) ? Element('to_values_'+border_ID).value :null; |
---|
| 2146 | var cc = Element('cc_values_'+border_ID) ? Element('cc_values_'+border_ID).value : null; |
---|
| 2147 | var date = Element('date_'+border_ID); |
---|
| 2148 | var subject = Element('subject_'+border_ID); |
---|
| 2149 | var attachments = Element('attachments_'+border_ID); |
---|
| 2150 | var body = Element('body_'+border_ID); |
---|
| 2151 | |
---|
| 2152 | if (!is_ie) {//altera o link da imagem para renderização na tela de impressão no firefox |
---|
| 2153 | var link = location.href.replace(/\/expressoMail1_2\/(.*)/, ""); |
---|
| 2154 | link = link.replace(/\/expressoMail1_2\/(.*)/, ""); |
---|
| 2155 | body.innerHTML = body.innerHTML.replace(/\.(\/inc\/show_embedded_attach\.php)/, link + "/expressoMail1_2$1"); |
---|
| 2156 | body.innerHTML = body.innerHTML.replace(/(tmpLclAtt\/)/, link + "/expressoMail1_2/$1"); |
---|
| 2157 | } |
---|
| 2158 | |
---|
| 2159 | var print_width = screen.width - 200; |
---|
| 2160 | var x = ((screen.width - print_width) / 2); |
---|
| 2161 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 2162 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
| 2163 | if(window_print == null) { |
---|
| 2164 | alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname)); |
---|
| 2165 | return; |
---|
| 2166 | } |
---|
| 2167 | |
---|
| 2168 | //needed to get the names of the attachments... only. |
---|
| 2169 | if(attachments != null) |
---|
| 2170 | { |
---|
| 2171 | var a = attachments.childNodes; |
---|
| 2172 | var attachs = ""; |
---|
| 2173 | var show_attachs = ""; |
---|
| 2174 | for(i=0;i<a.length;i++) |
---|
| 2175 | { |
---|
| 2176 | if(a[i].tagName && a[i].tagName == "A") |
---|
| 2177 | { |
---|
| 2178 | attachs += a[i].innerHTML; |
---|
| 2179 | } |
---|
| 2180 | } |
---|
| 2181 | show_attachs = "<tr><td width=7%><font size='2'>" + get_lang('Attachments: ')+ " </font></td><td><font size='2'>"+attachs+"</font></td></tr>"; |
---|
| 2182 | } else{ |
---|
| 2183 | show_attachs = ""; |
---|
| 2184 | } |
---|
[3131] | 2185 | var current_path = window.location.href.substr(0,window.location.href.lastIndexOf("/")); |
---|
| 2186 | var window_print_head = window_print.document.getElementsByTagName("head")[0]; |
---|
| 2187 | // For IE |
---|
| 2188 | if(typeof(window_print_head) == 'undefined'){ |
---|
| 2189 | window_print_head = window_print.document.createElement("head"); |
---|
| 2190 | window_print.document.appendChild(window_print_head); |
---|
| 2191 | } |
---|
| 2192 | var window_print_style = window_print.document.createElement("LINK"); |
---|
| 2193 | window_print_style.href = current_path+'/templates/default/main.css'; |
---|
| 2194 | window_print_style.type = "text/css"; |
---|
| 2195 | window_print_style.rel = "stylesheet"; |
---|
| 2196 | window_print_head.appendChild(window_print_style); |
---|
[2517] | 2197 | |
---|
| 2198 | while (1){ |
---|
| 2199 | try{ |
---|
[3131] | 2200 | var html ='<body>'; |
---|
[2517] | 2201 | html += "<h4>ExpressoLivre - ExpressoMail</h4><hr>"; |
---|
| 2202 | html += '<table><tbody>'; |
---|
| 2203 | if(sender) |
---|
| 2204 | html += "<tr><td width=7% noWrap><font size='2'>" + get_lang('Sent by') + ": </font></td><td><font size='2'>"+sender+"</font></td></tr>"; |
---|
| 2205 | if(from) |
---|
| 2206 | html += "<tr><td width=7%><font size='2'>" + get_lang('From') + ": </font></td><td><font size='2'>"+from+"</font></td></tr>"; |
---|
| 2207 | if(to) { |
---|
| 2208 | if(!printListTO) |
---|
| 2209 | to = 'Os destinatários não estão sendo exibidos para esta impressão'; |
---|
| 2210 | html += "<tr><td width=7%><font size='2'>" + get_lang('To') + ": </font></td><td><font size='2'>"+to+"</font></td></tr>"; |
---|
| 2211 | } |
---|
| 2212 | if (cc) { |
---|
| 2213 | if(!printListCC) |
---|
| 2214 | cc = 'Os destinatários não estão sendo exibidos para esta impressão'; |
---|
| 2215 | html += "<tr><td width=7%><font size='2'>" + get_lang('Cc') + ": </font></td><td><font size='2'>"+cc+"</font></td></tr>"; |
---|
| 2216 | } |
---|
| 2217 | if(date) |
---|
| 2218 | html += "<tr><td width=7%><font size='2'>" + get_lang('Date') + ": </font></td><td><font size='2'>"+date.innerHTML+"</font></td></tr>"; |
---|
| 2219 | html += "<tr><td width=7%><font size='2'>" + get_lang('Subject')+ ": </font></td><td><font size='2'>"+subject.innerHTML+"</font></td></tr>"; |
---|
| 2220 | html += show_attachs; //to show the names of the attachments |
---|
| 2221 | html += "</tbody></table><hr>"; |
---|
[3131] | 2222 | window_print.document.body.innerHTML = html + body.innerHTML; |
---|
[2517] | 2223 | if(!is_ie){ |
---|
| 2224 | var tab_tags = window_print.document.getElementsByTagName("IMG"); |
---|
| 2225 | for(var i = 0; i < tab_tags.length;i++){ |
---|
| 2226 | var _img = document.createElement("IMG"); |
---|
| 2227 | _img.src = tab_tags[i].src; |
---|
| 2228 | tab_tags[i].parentNode.replaceChild(_img,tab_tags[i]); |
---|
| 2229 | } |
---|
| 2230 | } |
---|
| 2231 | break; |
---|
| 2232 | } |
---|
| 2233 | catch(e){ |
---|
| 2234 | //alert(e.message); |
---|
| 2235 | } |
---|
| 2236 | } |
---|
| 2237 | window_print.document.close(); |
---|
| 2238 | window_print.print(); |
---|
| 2239 | } |
---|
| 2240 | |
---|
| 2241 | function empty_trash_imap(){ |
---|
| 2242 | var handler_empty_trash = function(data){ |
---|
[2929] | 2243 | Element('chkbox_sel_allmsg').checked = false; |
---|
[2517] | 2244 | tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder).alter({caption: get_lang("Trash")}); |
---|
| 2245 | tree_folders.getNodeById('INBOX'+cyrus_delimiter+trashfolder)._refresh(); |
---|
| 2246 | update_quota(get_current_folder()); |
---|
| 2247 | if (data) |
---|
| 2248 | { |
---|
| 2249 | write_msg(get_lang('Your Trash folder was empty.')); |
---|
| 2250 | if (get_current_folder() == 'INBOX'+cyrus_delimiter+trashfolder){ |
---|
| 2251 | draw_paging(0); |
---|
| 2252 | kill_current_box(); |
---|
| 2253 | Element('tot_m').innerHTML = 0; |
---|
| 2254 | Element('new_m').innerHTML = 0; |
---|
| 2255 | } |
---|
| 2256 | } |
---|
| 2257 | else |
---|
| 2258 | write_msg(get_lang('ERROR emptying your Trash folder.')); |
---|
[2556] | 2259 | }; |
---|
[2517] | 2260 | var realyEmptyTrash=confirm(get_lang('Do you really want to empty your trash folder?')); |
---|
| 2261 | if (realyEmptyTrash){ |
---|
| 2262 | cExecute ("expressoMail1_2.imap_functions.empty_folder&clean_folder="+"imapDefaultTrashFolder", handler_empty_trash); |
---|
| 2263 | } |
---|
| 2264 | } |
---|
| 2265 | |
---|
| 2266 | function empty_spam_imap(){ |
---|
| 2267 | var handler_empty_spam = function(data){ |
---|
[2929] | 2268 | Element('chkbox_sel_allmsg').checked = false; |
---|
[2517] | 2269 | if (get_current_folder() == 'INBOX'+cyrus_delimiter+spamfolder){ |
---|
| 2270 | draw_paging(0); |
---|
| 2271 | kill_current_box(); |
---|
| 2272 | } |
---|
| 2273 | tree_folders.getNodeById('INBOX'+cyrus_delimiter+spamfolder).alter({caption: get_lang("Spam")}); |
---|
| 2274 | tree_folders.getNodeById('INBOX'+cyrus_delimiter+spamfolder)._refresh(); |
---|
| 2275 | update_quota(get_current_folder()); |
---|
| 2276 | if (data) |
---|
| 2277 | write_msg(get_lang('Your Spam folder was empty.')); |
---|
| 2278 | else |
---|
| 2279 | write_msg(get_lang('ERROR emptying your Spam folder.')); |
---|
[2556] | 2280 | }; |
---|
[2517] | 2281 | var realyEmptySpam=confirm(get_lang('Do you really want to empty your spam folder?')); |
---|
| 2282 | if (realyEmptySpam) |
---|
| 2283 | cExecute ("expressoMail1_2.imap_functions.empty_folder&clean_folder="+"imapDefaultSpamFolder", handler_empty_spam); |
---|
| 2284 | } |
---|
| 2285 | |
---|
| 2286 | |
---|
| 2287 | function export_all_selected_msgs(){ |
---|
| 2288 | if (openTab.type[currentTab] > 1){ |
---|
| 2289 | source_msg(currentTab,current_folder); |
---|
| 2290 | return; |
---|
| 2291 | } |
---|
| 2292 | var msgs_to_export = this.get_selected_messages(); |
---|
| 2293 | |
---|
[2929] | 2294 | var _hand_expallselmsg = function(data){ |
---|
[2517] | 2295 | |
---|
| 2296 | if(!data){ |
---|
| 2297 | write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.')); |
---|
| 2298 | } |
---|
| 2299 | else |
---|
| 2300 | download_attachments(null, null, data, null,null,'mensagens.zip'); |
---|
[2556] | 2301 | }; |
---|
[2517] | 2302 | |
---|
| 2303 | if (msgs_to_export) { |
---|
[2929] | 2304 | cExecute ("expressoMail1_2.exporteml.makeAll", _hand_expallselmsg, "folder="+get_current_folder()+"&msgs_to_export="+msgs_to_export); |
---|
[2517] | 2305 | write_msg(get_lang('You must wait while the messages will be exported...')); |
---|
| 2306 | } |
---|
| 2307 | else |
---|
| 2308 | write_msg(get_lang('No selected message.')); |
---|
| 2309 | } |
---|
| 2310 | |
---|
| 2311 | function select_all_search_messages(select, id){ |
---|
| 2312 | var search_box = Element("table_resultsearch_" + id.substr(18)).firstChild; |
---|
| 2313 | var felement = search_box.firstChild; |
---|
| 2314 | while(felement) |
---|
| 2315 | { |
---|
| 2316 | if (select) |
---|
| 2317 | felement.firstChild.firstChild.checked = true; |
---|
| 2318 | else |
---|
| 2319 | felement.firstChild.firstChild.checked = false; |
---|
| 2320 | felement = felement.nextSibling; |
---|
| 2321 | } |
---|
| 2322 | } |
---|
| 2323 | |
---|
| 2324 | // Save image file. |
---|
| 2325 | function save_image(e,thumb,file_type){ |
---|
| 2326 | file_type = file_type.replace("/","."); |
---|
| 2327 | thumb.oncontextmenu = function(e) { |
---|
| 2328 | return false; |
---|
[2556] | 2329 | }; |
---|
[2517] | 2330 | var _button = is_ie ? window.event.button : e.which; |
---|
| 2331 | var _target = is_ie ? event.srcElement : e.target; |
---|
| 2332 | |
---|
| 2333 | if(_button == 2 || _button == 3) { |
---|
| 2334 | var _params = _target.id.split(";;"); |
---|
| 2335 | download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type); |
---|
| 2336 | } |
---|
| 2337 | } |
---|
| 2338 | |
---|
| 2339 | function nospam(msgs_number, border_ID, folder){ |
---|
| 2340 | if (folder == 'null') |
---|
| 2341 | folder = get_current_folder(); |
---|
| 2342 | var new_folder = 'INBOX'; |
---|
| 2343 | var new_folder_name = get_lang('INBOX'); |
---|
| 2344 | var handler_move_msgs = function(data){ |
---|
| 2345 | if (msgs_number == 'selected') |
---|
| 2346 | set_messages_flag("unseen", "get_selected_messages"); |
---|
| 2347 | else |
---|
| 2348 | proxy_mensagens.proxy_set_message_flag(msgs_number, "unseen"); |
---|
| 2349 | proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name); |
---|
[2556] | 2350 | }; |
---|
[2517] | 2351 | |
---|
| 2352 | if (msgs_number == 'selected') |
---|
| 2353 | msgs_number = get_selected_messages(); |
---|
| 2354 | |
---|
| 2355 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0) |
---|
| 2356 | cExecute ("expressoMail1_2.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); |
---|
| 2357 | else |
---|
| 2358 | write_msg(get_lang('No selected message.')); |
---|
| 2359 | } |
---|
| 2360 | |
---|
| 2361 | function spam(folder, msgs_number, border_ID){ |
---|
| 2362 | if (folder == 'null') |
---|
| 2363 | folder = get_current_folder(); |
---|
| 2364 | var new_folder = 'INBOX'+cyrus_delimiter+'Spam'; |
---|
| 2365 | var new_folder_name = 'Spam'; |
---|
| 2366 | var handler_move_msgs = function(data){ |
---|
| 2367 | // debug |
---|
| 2368 | // alert(data); |
---|
| 2369 | proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name); |
---|
[2556] | 2370 | }; |
---|
[2517] | 2371 | if(msgs_number == 'selected') |
---|
| 2372 | msgs_number = get_selected_messages(); |
---|
| 2373 | if(parseInt(msgs_number) > 0 || msgs_number.length > 0) |
---|
| 2374 | cExecute ("expressoMail1_2.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); |
---|
| 2375 | else |
---|
| 2376 | write_msg(get_lang('No selected message.')); |
---|
| 2377 | } |
---|
| 2378 | |
---|
| 2379 | function import_window(){ |
---|
| 2380 | var win = arrayJSWin["import_window"]; |
---|
| 2381 | var form_upload = Element("form_upload"); |
---|
| 2382 | if(!win) { |
---|
| 2383 | var form = document.createElement("DIV"); |
---|
| 2384 | form.id = "import_window"; |
---|
| 2385 | form.style.visibility = "hidden"; |
---|
| 2386 | form.style.position = "absolute"; |
---|
| 2387 | form.style.background = "#eeeeee"; |
---|
| 2388 | form.style.left = "0px"; |
---|
| 2389 | form.style.top = "0px"; |
---|
| 2390 | form.style.width = "0px"; |
---|
| 2391 | form.style.height = "0px"; |
---|
| 2392 | document.body.appendChild(form); |
---|
| 2393 | form_upload = document.createElement("DIV"); |
---|
| 2394 | form_upload.id = "form_upload"; |
---|
| 2395 | form_upload.style.position = "absolute"; |
---|
| 2396 | form_upload.style.top = "5px"; |
---|
| 2397 | form_upload.style.left = "5px"; |
---|
| 2398 | form_upload.name = get_lang('zip mails to import'); |
---|
| 2399 | form_upload.style.width = "450px"; |
---|
| 2400 | form_upload.style.height = "75px"; |
---|
| 2401 | form.appendChild(form_upload); |
---|
| 2402 | form.style.width = form.firstChild.style.width; |
---|
| 2403 | form.style.height = form.firstChild.style.height; |
---|
| 2404 | form.style.zIndex = "10000"; |
---|
| 2405 | var title = form.firstChild.name; |
---|
| 2406 | var wHeight = form.offsetHeight + "px"; |
---|
| 2407 | var wWidth = form.offsetWidth + "px"; |
---|
| 2408 | form.style.width = form.offsetWidth - 5; |
---|
| 2409 | win = new dJSWin({ |
---|
| 2410 | id: 'win_'+form.id, |
---|
| 2411 | content_id: form.id, |
---|
| 2412 | width: wWidth, |
---|
| 2413 | height: wHeight, |
---|
| 2414 | title_color: '#3978d6', |
---|
| 2415 | bg_color: '#eee', |
---|
| 2416 | title: title, |
---|
| 2417 | title_text_color: 'white', |
---|
| 2418 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
| 2419 | border: true }); |
---|
| 2420 | win.draw(); |
---|
| 2421 | } |
---|
| 2422 | form_upload.innerHTML = '<form method="POST" name="form_import" enctype="multipart/form-data">'+get_lang('zip mails to import')+':<br>'+ |
---|
| 2423 | '<input name="file_1" maxlength="255" size="50" id="file_1" type="file"><br>' + |
---|
| 2424 | '<input title="'+get_lang('Select a folder')+'" value="' + get_lang('Select a folder') + '"' + 'type="button" onclick="javascript:select_import_folder()"> ' + |
---|
| 2425 | '<input title="' + get_lang('Close') + '" value="' + get_lang('Close') + '"' + |
---|
| 2426 | ' type="button" onclick="arrayJSWin[\'import_window\'].close()"></form>'; |
---|
| 2427 | win.open(); |
---|
| 2428 | } |
---|
| 2429 | |
---|
| 2430 | function import_msgs(wfolders_tree){ |
---|
| 2431 | function handler(data){ |
---|
| 2432 | // Its necessary to encapsulate the data returned (IE bugfix) |
---|
| 2433 | return_import_msgs(data,wfolders_tree); |
---|
| 2434 | } |
---|
| 2435 | var countFiles = document.form_import.countFiles; |
---|
| 2436 | if(!countFiles){ |
---|
| 2437 | countFiles = document.createElement("INPUT"); |
---|
| 2438 | countFiles.type = "hidden"; |
---|
| 2439 | countFiles.name = "countFiles"; |
---|
| 2440 | countFiles.value = "1"; |
---|
| 2441 | document.form_import.appendChild(countFiles); |
---|
| 2442 | } |
---|
| 2443 | var folder = document.createElement("INPUT"); |
---|
| 2444 | folder.type = "hidden"; |
---|
| 2445 | folder.name = "folder"; |
---|
| 2446 | folder.value = wfolders_tree._selected.id; |
---|
| 2447 | document.form_import.appendChild(folder); |
---|
| 2448 | write_msg(get_lang('You must wait while the messages will be imported...')); |
---|
| 2449 | |
---|
| 2450 | cExecuteForm('expressoMail1_2.imap_functions.import_msgs', document.form_import, handler); |
---|
| 2451 | } |
---|
| 2452 | function return_import_msgs(data, wfolders_tree){ |
---|
| 2453 | if(data && data.error){ |
---|
| 2454 | write_msg(data.error); |
---|
| 2455 | } |
---|
| 2456 | else{ |
---|
| 2457 | if(data == 'Post-Content-Length') |
---|
| 2458 | write_msg(get_lang('The size of this message has exceeded the limit (%1B).',Element('upload_max_filesize').value)); |
---|
| 2459 | else { /* |
---|
| 2460 | * @author Rommel Cysne (rommel.cysne@serpro.gov.br) |
---|
| 2461 | * @date 2009/05/15 |
---|
| 2462 | * Foi colocado um teste para verificar se a pasta selecionada, passada como parametro, |
---|
| 2463 | * eh uma pasta local (qualquer uma) |
---|
| 2464 | */ |
---|
| 2465 | var er = /^local_/; |
---|
| 2466 | if ( er.test(wfolders_tree._selected.id) ) |
---|
| 2467 | { |
---|
| 2468 | archive_msgs('INBOX/Lixeira/tmpMoveToLocal',wfolders_tree._selected.id,data); |
---|
| 2469 | cExecute('expressoMail1_2.imap_functions.delete_mailbox',function(){},'del_past=INBOX/Lixeira/tmpMoveToLocal'); |
---|
| 2470 | } |
---|
| 2471 | else{ |
---|
| 2472 | write_msg(data); |
---|
| 2473 | arrayJSWin["import_window"].close(); |
---|
| 2474 | if(openTab.imapBox[0] == wfolders_tree._selected.id) |
---|
| 2475 | { |
---|
| 2476 | openTab.imapBox[0] = ''; |
---|
| 2477 | change_folder(wfolders_tree._selected.id, wfolders_tree._selected.caption); |
---|
| 2478 | } else{ |
---|
| 2479 | refresh(); |
---|
| 2480 | } |
---|
| 2481 | } |
---|
| 2482 | } |
---|
| 2483 | } |
---|
| 2484 | |
---|
| 2485 | } |
---|
| 2486 | |
---|
| 2487 | function select_import_folder(){ |
---|
| 2488 | //Begin: Verify if the file extension is allowed. |
---|
| 2489 | var imgExtensions = new Array("eml","zip"); |
---|
| 2490 | var inputFile = document.form_import.file_1; |
---|
| 2491 | if(!inputFile.value){ |
---|
| 2492 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 2493 | return false; |
---|
| 2494 | } |
---|
| 2495 | var fileExtension = inputFile.value.split("."); |
---|
| 2496 | fileExtension = fileExtension[(fileExtension.length-1)]; |
---|
| 2497 | var deniedExtension = true; |
---|
| 2498 | for(var i=0; i<imgExtensions.length; i++) { |
---|
| 2499 | if(imgExtensions[i].toUpperCase() == fileExtension.toUpperCase()) { |
---|
| 2500 | deniedExtension = false; |
---|
| 2501 | break; |
---|
| 2502 | } |
---|
| 2503 | } |
---|
| 2504 | if(deniedExtension) { |
---|
| 2505 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 2506 | return false; |
---|
| 2507 | } |
---|
| 2508 | arrayJSWin['import_window'].close(); |
---|
| 2509 | wfolders.makeWindow('null','import'); |
---|
| 2510 | } |
---|
| 2511 | function import_calendar(data){ |
---|
| 2512 | function handler_import_calendar(data){ |
---|
| 2513 | if(data === true){ |
---|
| 2514 | write_msg(get_lang("The event was imported successfully.")); |
---|
| 2515 | } |
---|
| 2516 | } |
---|
| 2517 | if(confirm(get_lang("Do you confirm this import to your Calendar?"))){ |
---|
| 2518 | cExecute('expressoMail1_2.db_functions.import_vcard&msg_folder='+data,handler_import_calendar); |
---|
| 2519 | } |
---|
| 2520 | } |
---|
| 2521 | function hack_sent_queue(data,rowid_message) { |
---|
| 2522 | |
---|
| 2523 | if (data.success != true) { |
---|
| 2524 | queue_send_errors = true; |
---|
| 2525 | expresso_local_messages.set_problem_on_sent(rowid_message,data); |
---|
| 2526 | } |
---|
| 2527 | else { |
---|
| 2528 | expresso_local_messages.set_as_sent(rowid_message); |
---|
| 2529 | if(document.getElementById('_action')) { //Não posso manter esse elemento, pois o connector irá criar outro com o mesmo id para a próxima mensagem. |
---|
| 2530 | el =document.getElementById('_action'); |
---|
| 2531 | father = el.parentNode; |
---|
| 2532 | father.removeChild(el); |
---|
| 2533 | } |
---|
| 2534 | send_mail_from_queue(false); |
---|
| 2535 | } |
---|
| 2536 | } |
---|
| 2537 | |
---|
| 2538 | function send_mail_from_queue(first_pass) { |
---|
| 2539 | if(first_pass) |
---|
| 2540 | modal('send_queue'); |
---|
| 2541 | var num_msgs = expresso_local_messages.get_num_msgs_to_send(); |
---|
| 2542 | if (num_msgs <= 0) { |
---|
| 2543 | close_lightbox(); |
---|
| 2544 | return; |
---|
| 2545 | } |
---|
| 2546 | document.getElementById('text_send_queue').innerHTML = get_lang('Number of messages to send:')+' '+num_msgs; |
---|
[2929] | 2547 | var _hand_sendqueuemsg = function(data,rowid_message) { |
---|
[2517] | 2548 | hack_sent_queue(data,this.ID_tmp); |
---|
[2556] | 2549 | }; |
---|
[2517] | 2550 | var msg_to_send = expresso_local_messages.get_form_msg_to_send(); |
---|
| 2551 | if(!is_ie) |
---|
| 2552 | ID_tmp = msg_to_send.rowid.value; |
---|
| 2553 | else {//I.E kills me of shame... |
---|
| 2554 | for (var i=0;i<msg_to_send.length;i++) { |
---|
| 2555 | if(msg_to_send.elements[i].name=='rowid') { |
---|
| 2556 | ID_tmp = msg_to_send.elements[i].value; |
---|
| 2557 | break; |
---|
| 2558 | } |
---|
| 2559 | } |
---|
| 2560 | } |
---|
| 2561 | |
---|
[2929] | 2562 | cExecuteForm("expressoMail1_2.imap_functions.send_mail", msg_to_send, _hand_sendqueuemsg,"queue_"+ID_tmp); |
---|
[2517] | 2563 | } |
---|
| 2564 | |
---|
| 2565 | function check_mail_in_queue() { |
---|
| 2566 | var num_msgs = expresso_local_messages.get_num_msgs_to_send(); |
---|
| 2567 | if(num_msgs>0) { |
---|
| 2568 | control = confirm(get_lang('You have messages to send. Want you to send them now?')); |
---|
| 2569 | if(control) { |
---|
| 2570 | send_mail_from_queue(true); |
---|
| 2571 | } |
---|
| 2572 | return true; |
---|
| 2573 | } |
---|
| 2574 | else { |
---|
| 2575 | return false; |
---|
| 2576 | } |
---|
| 2577 | } |
---|
| 2578 | |
---|
| 2579 | function force_check_queue() { |
---|
| 2580 | if(!check_mail_in_queue()) { |
---|
| 2581 | write_msg(get_lang("No messages to send")); |
---|
| 2582 | } |
---|
| 2583 | } |
---|
| 2584 | |
---|
| 2585 | function searchEmail(emailString){ |
---|
| 2586 | var arrayInvalidEmails = new Array(); |
---|
| 2587 | arrayInvalidEmails[1] = ''; |
---|
| 2588 | var email; |
---|
| 2589 | var arrayEmailsFull = new Array(); |
---|
| 2590 | arrayEmailsFull = emailString.split(','); |
---|
| 2591 | var er_Email = new RegExp("<(.*?)>"); |
---|
| 2592 | // TODO Use validateEmail of common functions |
---|
| 2593 | var er_ValidaEmail = new RegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"); |
---|
| 2594 | |
---|
| 2595 | for (i=0; i < arrayEmailsFull.length; i++){ |
---|
| 2596 | email = er_Email.exec(arrayEmailsFull[i]); |
---|
| 2597 | tempEmail = email == null ? arrayEmailsFull[i]:email[1]; |
---|
| 2598 | tempEmail = tempEmail.replace(/^\s+|\s+$/g,""); |
---|
| 2599 | if (tempEmail != '') { |
---|
| 2600 | singleEmail = er_ValidaEmail.exec(tempEmail); |
---|
| 2601 | |
---|
| 2602 | if (singleEmail == null) { |
---|
| 2603 | arrayInvalidEmails[0] = true; |
---|
| 2604 | arrayInvalidEmails[1] += (email == null ? arrayEmailsFull[i] : email[1]) + "; "; |
---|
| 2605 | } |
---|
| 2606 | } |
---|
| 2607 | } |
---|
| 2608 | |
---|
| 2609 | return arrayInvalidEmails; |
---|
[2579] | 2610 | }; |
---|