[2] | 1 | // Tempo do auto refresh (em milisegundos) |
---|
| 2 | var time_refresh = 300000; |
---|
[320] | 3 | // tempo do auto save (em milisegundos) |
---|
| 4 | // 20000 = 20 segundos |
---|
[5459] | 5 | var autosave_time = 40000; |
---|
[5134] | 6 | var results_search_messages = ""; |
---|
| 7 | var cabecalho = '<h4>ExpressoLivre - ExpressoMail</h4>'; |
---|
[6487] | 8 | // Variavel para controle de atualização das mensagens listadas na modal de alerta de filtro por remetente |
---|
| 9 | var checkAlarmsFilter = false; |
---|
[6031] | 10 | |
---|
| 11 | //Os IE's < 9 não possui suporte a trim() introduzida no JavaScript 1.8.1 |
---|
| 12 | if(!String.prototype.trim){ |
---|
| 13 | String.prototype.trim = function(){ |
---|
| 14 | return this.replace(/^\s+|\s+$/g,''); |
---|
| 15 | } |
---|
| 16 | } |
---|
[5302] | 17 | |
---|
[6031] | 18 | |
---|
| 19 | |
---|
[5302] | 20 | function mount_url_folder(folders){ |
---|
[5306] | 21 | return folders.join(cyrus_delimiter); |
---|
[5486] | 22 | } |
---|
[2] | 23 | function init(){ |
---|
| 24 | if (!is_ie) |
---|
| 25 | Element('tableDivAppbox').width = '100%'; |
---|
[3035] | 26 | |
---|
[5923] | 27 | var save_contacts = function(data){ |
---|
[2] | 28 | contacts = data; |
---|
[3035] | 29 | if (preferences.use_local_messages == 1 && window.google && google.gears) |
---|
| 30 | if (expresso_local_messages.is_offline_installed()) |
---|
[1982] | 31 | expresso_local_messages.capt_url('controller.php?action=$this.db_functions.get_dropdown_contacts_to_cache'); |
---|
| 32 | |
---|
[2] | 33 | } |
---|
| 34 | var save_preferences = function(data){ |
---|
[3035] | 35 | |
---|
[3405] | 36 | |
---|
[2] | 37 | preferences = data; |
---|
[4994] | 38 | |
---|
[3730] | 39 | |
---|
[5134] | 40 | if(preferences.show_name_print_messages == "1") { |
---|
| 41 | var getUserName = document.getElementById("user_info"); |
---|
| 42 | var userName = getUserName.innerHTML; |
---|
| 43 | var position = userName.indexOf("-"); |
---|
| 44 | var userName = userName.substring(3, position); |
---|
| 45 | cabecalho = '<h4>' + userName; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | current_folder="INBOX"; |
---|
| 50 | |
---|
[3417] | 51 | if( (window.google && google.gears) && !google.gears.factory.getPermission()) |
---|
[3405] | 52 | preferences.use_local_messages=0; |
---|
[4994] | 53 | |
---|
[3405] | 54 | if ((preferences.use_local_messages==1) && (!window.google || !google.gears)) { |
---|
| 55 | temp = confirm(get_lang("To use local messages you have to install google gears. Would you like to be redirected to gears installation page?")); |
---|
| 56 | if (temp) { |
---|
| 57 | location.href = "http://gears.google.com/?action=install&message="+ |
---|
| 58 | "Para utilizar o recurso de mensagens locais, instale o google gears&return=" + document.location.href; |
---|
| 59 | } |
---|
| 60 | else { |
---|
| 61 | preferences.use_local_messages=0; |
---|
| 62 | } |
---|
| 63 | } |
---|
[3730] | 64 | if (preferences.use_local_messages==1) { //O I.E 7 estava se atrapalhando caso esses loads fossem feitos após as chamadas ajax. Antes não apresentou problemas... |
---|
| 65 | connector.loadScript('mail_sync'); |
---|
| 66 | if (is_ie) |
---|
| 67 | connector.loadScript('TreeShow'); |
---|
| 68 | setTimeout('auto_archiving()', 30000); |
---|
| 69 | |
---|
| 70 | } |
---|
[5486] | 71 | //Substituido por padrão Jquery |
---|
[3066] | 72 | cExecute ("$this.imap_functions.get_range_msgs2&folder=INBOX&msg_range_begin=1&msg_range_end="+preferences.max_email_per_page+"&sort_box_type=SORTARRIVAL&search_box_type=ALL&sort_box_reverse=1", handler_draw_box); |
---|
| 73 | cExecute ("$this.db_functions.get_dropdown_contacts", save_contacts); //Save contacts needs preferences. |
---|
[2] | 74 | if(preferences.hide_folders == "1") |
---|
| 75 | Element('divAppboxHeader').innerHTML = title_app_menu; |
---|
[3035] | 76 | |
---|
[2] | 77 | if (preferences.delete_trash_messages_after_n_days != 0) |
---|
| 78 | cExecute ("$this.imap_functions.automatic_trash_cleanness&before_date="+preferences.delete_trash_messages_after_n_days+"&cyrus_delimiter="+cyrus_delimiter, handler_automatic_trash_cleanness); |
---|
[5663] | 79 | |
---|
| 80 | //if(preferences.outoffice == "1") |
---|
| 81 | // |
---|
[3035] | 82 | |
---|
[5497] | 83 | //Troca da forma de construção de menu para o plugin jquery.contextMenu |
---|
| 84 | //ConstructMenuTools(); |
---|
[3730] | 85 | |
---|
| 86 | if ( (preferences.use_local_messages==1) && (expresso_local_messages.is_offline_installed()) ) //Precisa ser feito após a renderização da caixa de emails |
---|
| 87 | check_mail_in_queue(); |
---|
| 88 | |
---|
[3035] | 89 | // Insere a applet de criptografia |
---|
| 90 | if (preferences.use_signature_digital_cripto == '1'){ |
---|
| 91 | loadApplet(); |
---|
| 92 | } |
---|
[5486] | 93 | // Fim da inserção da applet |
---|
[5718] | 94 | DataLayer.get("folder", true); |
---|
| 95 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
[5486] | 96 | |
---|
| 97 | if($.cookie('collapse_folders') == "true"){ |
---|
[5703] | 98 | if(!is_ie) |
---|
| 99 | $("#folderscol").addClass( "hidden"); |
---|
| 100 | else |
---|
| 101 | $("#folderscol").hide(); |
---|
[5486] | 102 | $(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-e").children().attr('title', "Expandir"); |
---|
| 103 | refresh(); |
---|
| 104 | resizeWindow(); |
---|
| 105 | } |
---|
| 106 | else{ |
---|
| 107 | $(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-w").children().attr('title', "Ocultar"); |
---|
| 108 | refresh(); |
---|
| 109 | resizeWindow(); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | $(".collapse_folders_td").attr('title', "Ocultar/Expandir").click(function(){ |
---|
| 113 | if($("#folderscol").css("display") != "none"){ |
---|
[5703] | 114 | if(!is_ie) |
---|
| 115 | $("#folderscol").addClass( "hidden"); |
---|
| 116 | else |
---|
| 117 | $("#folderscol").hide(); |
---|
| 118 | |
---|
[5486] | 119 | $(".collapse_folders").removeClass("ui-icon-triangle-1-w"); |
---|
| 120 | $(".collapse_folders").addClass("ui-icon-triangle-1-e").attr('title', "Expandir"); |
---|
| 121 | $.cookie('collapse_folders', "true"); |
---|
| 122 | refresh(); |
---|
| 123 | resizeWindow(); |
---|
| 124 | }else{ |
---|
[5703] | 125 | if(!is_ie) |
---|
| 126 | $("#folderscol").removeClass( "hidden"); |
---|
| 127 | else |
---|
| 128 | $("#folderscol").show(); |
---|
[5486] | 129 | $(".collapse_folders").removeClass("ui-icon-triangle-1-e"); |
---|
| 130 | $(".collapse_folders").addClass("ui-icon-triangle-1-w").attr('title', "Ocultar"); |
---|
| 131 | $.cookie('collapse_folders', "false"); |
---|
| 132 | refresh(); |
---|
| 133 | resizeWindow(); |
---|
| 134 | } |
---|
| 135 | resizeWindow(); |
---|
| 136 | |
---|
| 137 | }).hover( |
---|
| 138 | function(){ |
---|
| 139 | $(this).addClass("collapse_folders_td_over"); |
---|
| 140 | }, |
---|
| 141 | function(){ |
---|
| 142 | $(this).removeClass("collapse_folders_td_over"); |
---|
| 143 | } |
---|
| 144 | ); |
---|
[2] | 145 | } |
---|
| 146 | var handler_automatic_trash_cleanness = function(data){ |
---|
| 147 | if (data != false){ |
---|
| 148 | write_msg(data.length +' '+ Element('txt_clear_trash').value); |
---|
| 149 | } |
---|
| 150 | } |
---|
[3035] | 151 | |
---|
[2] | 152 | // Versão |
---|
| 153 | Element('divAppboxHeader').innerHTML = title_app; |
---|
[3035] | 154 | |
---|
[2] | 155 | // Get cyrus delimiter |
---|
| 156 | cyrus_delimiter = Element('cyrus_delimiter').value; |
---|
[1035] | 157 | |
---|
[51] | 158 | cExecute ("$this.functions.get_preferences", save_preferences); |
---|
[5486] | 159 | cExecute ("phpgwapi.browser.isMobile", function( data ){ |
---|
[4757] | 160 | mobile_device = ( ( data.constructor == Boolean ) ? data : ( data === 'true' ) ); |
---|
[5486] | 161 | }); |
---|
[6487] | 162 | |
---|
[2] | 163 | setTimeout('auto_refresh()', time_refresh); |
---|
[5486] | 164 | |
---|
| 165 | $("#divAppbox").css("padding-left", "0px"); |
---|
[2] | 166 | } |
---|
[1035] | 167 | |
---|
[1121] | 168 | function init_offline(){ |
---|
[3570] | 169 | current_folder = 'local_Inbox'; |
---|
[1121] | 170 | if (account_id != null) { |
---|
[3035] | 171 | if (!is_ie) |
---|
[1121] | 172 | Element('tableDivAppbox').width = '100%'; |
---|
| 173 | else |
---|
| 174 | connector.createXMLHTTP(); |
---|
| 175 | Element('divStatusBar').innerHTML = '<table height="16px" border=0 width=100% cellspacing=0 cellpadding=2>' + |
---|
| 176 | '<tr>' + |
---|
| 177 | '<td style="padding-left:17px" width=33% id="content_quota" align=left></td>' + |
---|
| 178 | '<td width=33% height=16px align=center nowrap><font face=Verdana, Arial, Helvetica, sans-serif color=#000066 size=2>' + |
---|
| 179 | '<b>ExpressoMail Offline</b><font size=1><b> - Versão 1.0</b></font></td>' + |
---|
| 180 | '<td width=33% id="div_menu_c3" align=right></td>' + |
---|
| 181 | '</tr></table>'; |
---|
[3035] | 182 | |
---|
[5497] | 183 | //Troca da forma de construção de menu para o plugin jquery.contextMenu |
---|
| 184 | //ConstructMenuTools(); |
---|
[1121] | 185 | |
---|
| 186 | draw_tree_folders(); |
---|
[3035] | 187 | |
---|
[1814] | 188 | proxy_mensagens.messages_list('local_Inbox', 1, preferences.max_email_per_page, 'SORTARRIVAL', null, 1,1,1, function handler(data){ |
---|
[1121] | 189 | draw_box(data, 'local_Inbox'); |
---|
| 190 | }) |
---|
[3035] | 191 | |
---|
[1121] | 192 | // Get cyrus delimiter |
---|
| 193 | cyrus_delimiter = Element('cyrus_delimiter').value; |
---|
[3035] | 194 | |
---|
[1939] | 195 | cExecute ("$this.db_functions.get_dropdown_contacts_to_cache", function(data) {contacts = data;}); |
---|
[1121] | 196 | //cExecute ("$this.functions.get_preferences", save_preferences); |
---|
| 197 | } |
---|
| 198 | } |
---|
[1035] | 199 | /** |
---|
| 200 | * Carrega a applet java no objeto search_div |
---|
| 201 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 202 | */ |
---|
| 203 | |
---|
| 204 | function loadApplet(){ |
---|
| 205 | |
---|
[3035] | 206 | var search_div = Element('search_div'); |
---|
| 207 | var applet = null; |
---|
| 208 | if (navigator.userAgent.match('MSIE')){ |
---|
| 209 | applet = document.createElement('<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" ' + |
---|
| 210 | 'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"></object>'); |
---|
[1035] | 211 | |
---|
[3035] | 212 | var parameters = { |
---|
| 213 | type:'application/x-java-applet;version=1.5', |
---|
| 214 | code:'ExpressoSmimeApplet', |
---|
| 215 | codebase:'/security/', |
---|
| 216 | mayscript:'true', |
---|
| 217 | token: token_param, |
---|
| 218 | locale: locale, |
---|
| 219 | archive:'ExpressoCertMail.jar,' + |
---|
| 220 | 'ExpressoCert.jar,' + |
---|
| 221 | 'bcmail-jdk15-142.jar,' + |
---|
| 222 | 'mail.jar,' + |
---|
| 223 | 'activation.jar,' + |
---|
| 224 | 'bcprov-jdk15-142.jar,' + |
---|
| 225 | 'commons-codec-1.3.jar,' + |
---|
| 226 | 'commons-httpclient-3.1.jar,' + |
---|
| 227 | 'commons-logging-1.1.1.jar' |
---|
| 228 | //debug:'true' |
---|
| 229 | } |
---|
[1035] | 230 | |
---|
[3035] | 231 | if (parameters != 'undefined' && parameters != null){ |
---|
| 232 | for (var parameter in parameters) { |
---|
| 233 | var param = document.createElement("PARAM"); |
---|
| 234 | param.setAttribute("name",parameter); |
---|
| 235 | param.setAttribute("value",parameters[parameter]); |
---|
| 236 | applet.appendChild(param); |
---|
| 237 | } |
---|
| 238 | } |
---|
| 239 | } |
---|
[3781] | 240 | else |
---|
| 241 | { |
---|
[3035] | 242 | applet = document.createElement('embed'); |
---|
| 243 | applet.innerHTML = '<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" code="ExpressoSmimeApplet.class" ' + |
---|
| 244 | 'codebase="/security/" locale="'+locale+'"'+ |
---|
| 245 | '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" ' + |
---|
| 246 | 'token="' + token_param + '" ' + |
---|
| 247 | 'type="application/x-java-applet;version=1.5" mayscript > ' + |
---|
| 248 | //'type="application/x-java-applet;version=1.5" debug="true" mayscript > ' + |
---|
| 249 | '<noembed> ' + |
---|
| 250 | 'No Java Support. ' + |
---|
| 251 | '</noembed> ' + |
---|
| 252 | '</embed> '; |
---|
| 253 | } |
---|
[3781] | 254 | |
---|
| 255 | if( applet != null ) |
---|
| 256 | { |
---|
| 257 | applet.style.top = "-100px"; |
---|
| 258 | applet.style.left = "-100px"; |
---|
| 259 | window.document.body.insertBefore( applet, document.body.lastChild ); |
---|
| 260 | } |
---|
| 261 | |
---|
[1035] | 262 | } |
---|
| 263 | |
---|
[689] | 264 | function disable_field(field,condition) { |
---|
| 265 | var comando = "if ("+condition+") { document.getElementById('"+field.id+"').disabled=true;} else { document.getElementById('"+field.id+"').disabled=false; }"; |
---|
| 266 | eval(comando); |
---|
| 267 | } |
---|
[613] | 268 | /* |
---|
| 269 | função que remove todos os anexos... |
---|
| 270 | */ |
---|
| 271 | function remove_all_attachments(folder,msg_num) { |
---|
[649] | 272 | |
---|
[613] | 273 | var call_back = function(data) { |
---|
[1319] | 274 | if(!data.status) { |
---|
| 275 | alert(data.msg); |
---|
| 276 | } |
---|
| 277 | else { |
---|
| 278 | msg_to_delete = Element(msg_num); |
---|
| 279 | change_tr_properties(msg_to_delete, data.msg_no); |
---|
| 280 | msg_to_delete.childNodes[1].innerHTML = ""; |
---|
| 281 | write_msg(get_lang("Attachments removed")); |
---|
| 282 | delete_border(msg_num+'_r','false'); //close email tab |
---|
| 283 | } |
---|
| 284 | }; |
---|
[613] | 285 | if (confirm(get_lang("delete all attachments confirmation"))) |
---|
[1319] | 286 | cExecute ("$this.imap_functions.remove_attachments&folder=" |
---|
| 287 | +folder+"&msg_num="+msg_num, call_back); |
---|
[613] | 288 | } |
---|
[271] | 289 | function watch_changes_in_msg(border_id) |
---|
| 290 | { |
---|
| 291 | if (document.getElementById('border_id_'+border_id)) |
---|
[3035] | 292 | { |
---|
[271] | 293 | function keypress_handler () |
---|
| 294 | { |
---|
| 295 | away=false; |
---|
[5911] | 296 | var save_link = content.find(".save"); |
---|
[4803] | 297 | save_link.onclick = function onclick(event) {openTab.toPreserve[border_id] = true;save_msg(border_id);} ; |
---|
[5911] | 298 | save_link.button({disabled: false}); |
---|
[5417] | 299 | $(".header-button").button(); |
---|
[271] | 300 | }; |
---|
[5911] | 301 | var content = $("#content_id_"+border_id); |
---|
| 302 | |
---|
| 303 | var subject_obj = content.find(".subject"); |
---|
[271] | 304 | if ( subject_obj.addEventListener ) |
---|
| 305 | subject_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 306 | else if ( subject_obj.attachEvent ) |
---|
| 307 | subject_obj.attachEvent('onkeypress', keypress_handler); |
---|
[3035] | 308 | |
---|
[5911] | 309 | var to_obj = content.find('[name="input_to"]'); |
---|
[271] | 310 | if ( to_obj.addEventListener ) |
---|
| 311 | to_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 312 | else if ( to_obj.attachEvent ) |
---|
| 313 | to_obj.attachEvent('onkeypress', keypress_handler); |
---|
[5417] | 314 | |
---|
[5911] | 315 | var cc_obj = content.find('[name="input_cc"]'); |
---|
[5417] | 316 | if ( cc_obj.addEventListener ) |
---|
| 317 | cc_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 318 | else if ( cc_obj.attachEvent ) |
---|
| 319 | cc_obj.attachEvent('onkeypress', keypress_handler); |
---|
| 320 | |
---|
[5911] | 321 | if(content.find('[name="input_cco"]').length){ |
---|
| 322 | var cco_obj = content.find('[name="input_cco"]'); |
---|
[5423] | 323 | if ( cco_obj.addEventListener ) |
---|
[5417] | 324 | cco_obj.addEventListener('keypress', keypress_handler, false); |
---|
[5423] | 325 | else if ( cco_obj.attachEvent ) |
---|
| 326 | cco_obj.attachEvent('onkeypress', keypress_handler); |
---|
| 327 | } |
---|
[5417] | 328 | //var important_obj = $("important_message_options_"+border_id).bind('click',keypress_handler); |
---|
| 329 | //important_obj.addEventListener('click', keypress_handler, false); |
---|
| 330 | |
---|
[5194] | 331 | var txtarea_obj = Element('body_'+border_id); |
---|
| 332 | if (txtarea_obj){ |
---|
| 333 | if ((preferences.plain_text_editor == 1)||(Element('body_')+border_id).checked){ |
---|
| 334 | if ( txtarea_obj.addEventListener ) |
---|
| 335 | txtarea_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 336 | else if ( txtarea_obj.attachEvent ) |
---|
| 337 | txtarea_obj.attachEvent('onkeypress', keypress_handler); |
---|
| 338 | } |
---|
| 339 | } |
---|
[271] | 340 | } |
---|
| 341 | } |
---|
| 342 | |
---|
[1000] | 343 | function show_msg_img(msg_number,folder){ |
---|
[3035] | 344 | var call_back = function(data){ |
---|
| 345 | data.showImg = true; |
---|
| 346 | if (!Element(data.msg_number)){ |
---|
| 347 | trElement = document.createElement('DIV'); |
---|
| 348 | trElement.id = data.msg_number; |
---|
| 349 | Element("tbody_box").appendChild(trElement); |
---|
| 350 | } |
---|
| 351 | show_msg(data); |
---|
| 352 | } |
---|
[1000] | 353 | |
---|
[3035] | 354 | proxy_mensagens.msg_img(msg_number,folder,call_back); |
---|
[1000] | 355 | |
---|
[800] | 356 | } |
---|
[271] | 357 | |
---|
[827] | 358 | function show_msg(msg_info){ |
---|
[2] | 359 | if(!verify_session(msg_info)) |
---|
| 360 | return; |
---|
[800] | 361 | if (typeof(msg_info) != 'object') |
---|
| 362 | alert(get_lang("Error in show_msg param is not object")); |
---|
[3035] | 363 | |
---|
[206] | 364 | if (msg_info.status_get_msg_info == 'false') |
---|
| 365 | { |
---|
| 366 | write_msg(get_lang("Problems reading your message")+ "."); |
---|
| 367 | return; |
---|
| 368 | } |
---|
[3035] | 369 | |
---|
[2] | 370 | var handler_sendNotification = function(data){ |
---|
| 371 | if (data) |
---|
| 372 | write_msg(get_lang("A read confirmation was sent.")); |
---|
| 373 | else |
---|
| 374 | write_msg(get_lang("Error in SMTP sending read confirmation.")); |
---|
| 375 | } |
---|
[3035] | 376 | |
---|
[1035] | 377 | if(msg_info.source) |
---|
| 378 | { |
---|
[3035] | 379 | // Abrindo um e-mail criptografado |
---|
| 380 | // Verifica se existe o objeto applet |
---|
| 381 | if (!Element('cert_applet')){ |
---|
| 382 | // se não existir, mostra mensagem de erro. |
---|
| 383 | write_msg(get_lang('The preference "%1" isn\'t enabled.', get_lang('Enable digitally sign/cipher the message?'))); |
---|
| 384 | } else { |
---|
| 385 | // se existir prepara os dados para serem enviados e chama a |
---|
| 386 | // operação na applet |
---|
[847] | 387 | |
---|
[3035] | 388 | connector.showProgressBar(); |
---|
[1035] | 389 | |
---|
[3035] | 390 | // if ((msg_info.DispositionNotificationTo) && ((msg_info.Unseen == 'U') || (msg_info.Recent == 'N'))){ |
---|
| 391 | /* var confNotification = confirm(get_lang("The sender waits your notification of reading. Do you want to confirm this?"), ""); |
---|
| 392 | if (confNotification)*/ |
---|
| 393 | // cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), handler_sendNotification); |
---|
| 394 | // } |
---|
[1035] | 395 | |
---|
[3035] | 396 | Element('cert_applet').doButtonClickAction('decript', |
---|
| 397 | msg_info.msg_number, |
---|
| 398 | msg_info.source, |
---|
| 399 | msg_info.msg_folder); // Passa os dados para a applet |
---|
| 400 | } |
---|
[1035] | 401 | return; |
---|
| 402 | |
---|
| 403 | } |
---|
| 404 | |
---|
| 405 | |
---|
| 406 | if (msg_info.status_get_msg_info == 'false') |
---|
| 407 | { |
---|
| 408 | write_msg(get_lang("Problems reading your message")+ "."); |
---|
| 409 | return; |
---|
| 410 | } |
---|
| 411 | |
---|
[2] | 412 | if (msg_info.status == 'false'){ |
---|
| 413 | eval(msg_info.command_to_exec); |
---|
| 414 | } |
---|
| 415 | else{ |
---|
[3035] | 416 | var ID = msg_info.original_ID ? msg_info.original_ID : msg_info.msg_number; |
---|
[6330] | 417 | |
---|
[6349] | 418 | var folderName = msg_info.msg_folder; |
---|
| 419 | folderName = Base64.encode(folderName); |
---|
| 420 | folderName = folderName.replace(/=/gi, ''); |
---|
| 421 | var id_msg_read = ID+"_r_"+folderName; |
---|
[5284] | 422 | |
---|
| 423 | //Evita a tentativa de criação de uma aba cujo ID já existe |
---|
[5614] | 424 | if (Element("border_id_"+id_msg_read) && currentTab > 0) |
---|
[5284] | 425 | id_msg_read += "n"; |
---|
[5936] | 426 | |
---|
[6337] | 427 | if (preferences.use_shortcuts == '1') |
---|
| 428 | select_msg(ID, 'null'); |
---|
| 429 | |
---|
[2] | 430 | // Call function to draw message |
---|
[59] | 431 | // If needed, delete old border |
---|
[5134] | 432 | var isPartMsg = false; |
---|
| 433 | for(var ii = 0; ii < partMsgs.length; ii++) |
---|
[5689] | 434 | if(partMsgs[ii] == ID) isPartMsg = true; |
---|
| 435 | |
---|
| 436 | if(msg_info.alarm == false){ |
---|
| 437 | if ((openTab.type[currentTab] == 2 || openTab.type[currentTab] == 3) && isPartMsg === false) |
---|
| 438 | delete_border(currentTab,'false'); |
---|
| 439 | } |
---|
| 440 | |
---|
[3018] | 441 | if(Element("border_id_" + id_msg_read)) { |
---|
[3035] | 442 | alternate_border(id_msg_read); |
---|
| 443 | resizeWindow(); |
---|
[3018] | 444 | } |
---|
[2] | 445 | else { |
---|
| 446 | var border_id = create_border(msg_info.subject, id_msg_read); |
---|
| 447 | if(border_id) |
---|
[827] | 448 | { |
---|
| 449 | openTab.type[border_id] = 2; |
---|
[6283] | 450 | openTab.imapBox[border_id] = msg_info.msg_folder; |
---|
[2] | 451 | draw_message(msg_info,border_id); |
---|
[827] | 452 | var unseen_sort = document.getElementById('span_flag_UNSEEN').getAttribute('onclick'); |
---|
| 453 | unseen_sort = unseen_sort.toString(); |
---|
| 454 | if ( !(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'") < 0) ) |
---|
| 455 | { |
---|
| 456 | var sort_type = sort_box_type; |
---|
| 457 | sort_box_type = null; |
---|
| 458 | sort_box('UNSEEN', sort_type); |
---|
| 459 | } |
---|
| 460 | } |
---|
[2] | 461 | else |
---|
| 462 | return; |
---|
| 463 | } |
---|
| 464 | |
---|
[605] | 465 | var domains = ""; |
---|
[1035] | 466 | if ((msg_info.DispositionNotificationTo) && (!msg_is_read(ID) || (msg_info.Recent == 'N'))) |
---|
[3035] | 467 | { |
---|
[605] | 468 | if (preferences.notification_domains != undefined && preferences.notification_domains != "") |
---|
[3035] | 469 | { |
---|
[605] | 470 | domains = preferences.notification_domains.split(','); |
---|
[3035] | 471 | } |
---|
[605] | 472 | else |
---|
[3035] | 473 | { |
---|
[605] | 474 | var confNotification = true; |
---|
| 475 | } |
---|
| 476 | for (var i = 0; i < domains.length; i++) |
---|
| 477 | if (msg_info.DispositionNotificationTo.match(domains[i]+">")) |
---|
| 478 | { |
---|
| 479 | var confNotification = true; |
---|
| 480 | break; |
---|
| 481 | } |
---|
| 482 | if (confNotification == undefined) |
---|
| 483 | var confNotification = confirm(get_lang("The sender:\n%1\nwaits your notification of reading. Do you want to confirm this?",msg_info.DispositionNotificationTo), ""); |
---|
| 484 | |
---|
| 485 | if (confNotification) |
---|
[3231] | 486 | cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject), handler_sendNotification); |
---|
[605] | 487 | } |
---|
[163] | 488 | //Change msg class to read. |
---|
[1035] | 489 | if (!msg_is_read(ID)) |
---|
[605] | 490 | { |
---|
[3035] | 491 | set_msg_as_read(ID, true); |
---|
[1035] | 492 | if (msg_info.cacheHit || (!proxy_mensagens.is_local_folder(get_current_folder()) && msg_info.original_ID)) |
---|
[3035] | 493 | { |
---|
[1035] | 494 | set_message_flag(ID, "seen"); // avoid caducous (lazy) data |
---|
[3035] | 495 | } |
---|
| 496 | } |
---|
[2] | 497 | } |
---|
[5339] | 498 | setTimeout('resizeWindow()',300); |
---|
[2] | 499 | } |
---|
| 500 | |
---|
| 501 | function auto_refresh(){ |
---|
| 502 | refresh(preferences.alert_new_msg); |
---|
| 503 | setTimeout('auto_refresh()', time_refresh); |
---|
| 504 | } |
---|
| 505 | |
---|
[1518] | 506 | function auto_archiving() { |
---|
| 507 | expresso_mail_sync.start_sync(); |
---|
| 508 | setTimeout('auto_archiving()',600000); |
---|
| 509 | } |
---|
| 510 | |
---|
[2] | 511 | function refresh(alert_new_msg){ |
---|
[6487] | 512 | getFromAlertRules(); |
---|
[2] | 513 | var handler_refresh = function(data){ |
---|
[6487] | 514 | if(checkAlarmsFilter){ |
---|
| 515 | handlerMessageFilter = function (data) { |
---|
| 516 | alarmFollowupflagged('filtersAlarms', data); |
---|
| 517 | } |
---|
| 518 | /* Busca nas pastas indexadas para ver se há novas mensagens com a flag $FilteredMessage */ |
---|
| 519 | cExecute ("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules, handlerMessageFilter); |
---|
| 520 | } |
---|
| 521 | checkAlarmsFilter = true; |
---|
[5158] | 522 | if(data['msg_range_end']) |
---|
| 523 | if(data['msg_range_end'] > 0) |
---|
| 524 | current_page = data['msg_range_end']/preferences.max_email_per_page; |
---|
[2] | 525 | if(!verify_session(data)) |
---|
| 526 | return; |
---|
[5134] | 527 | var total_messages_element = Element('tot_m'); |
---|
[3955] | 528 | |
---|
[833] | 529 | var box = Element("tbody_box"); |
---|
| 530 | if (box.childNodes.length == 0) |
---|
[4189] | 531 | showEmptyBoxMsg(box); |
---|
[833] | 532 | |
---|
[2] | 533 | if (data.length > 0){ |
---|
[6426] | 534 | for(var i=0;i< data.length;i++){ |
---|
| 535 | if (!onceOpenedHeadersMessages[current_folder]) |
---|
| 536 | onceOpenedHeadersMessages[current_folder] = {}; |
---|
| 537 | onceOpenedHeadersMessages[current_folder][data[i].msg_number] = data[i]; |
---|
| 538 | } |
---|
[4814] | 539 | Element("table_message_header_box_"+numBox).emptyBody = false; |
---|
[4189] | 540 | table_element = Element("table_box"); |
---|
[3145] | 541 | var msg_info = document.getElementById('msg_info'); |
---|
[3265] | 542 | if (msg_info != null) |
---|
| 543 | { |
---|
[4189] | 544 | var msg_tr = msg_info.parentNode.parentNode; |
---|
| 545 | msg_tr.removeChild(msg_info.parentNode); |
---|
[4814] | 546 | if (!Element("colgroup_main_"+numBox)) { |
---|
| 547 | var colgr_element = buildColGroup(); |
---|
| 548 | colgr_element.setAttribute("id","colgroup_main_"+numBox); |
---|
| 549 | table_element.appendChild(colgr_element); |
---|
| 550 | } |
---|
[3265] | 551 | } |
---|
[139] | 552 | |
---|
[2] | 553 | var box = Element("tbody_box"); |
---|
[5134] | 554 | //table_element.insertBefore(box, Element("colgroup_main_"+numBox)); // keeps colgroup as the last child |
---|
| 555 | //table_element.appendChild(Element("colgroup_main_"+numBox)); |
---|
| 556 | |
---|
| 557 | $(table_element).append(Element("colgroup_main_"+numBox)); |
---|
[3265] | 558 | |
---|
[5134] | 559 | if (data.msgs_to_delete.length > 0){ |
---|
[3265] | 560 | for (var i=0; i<data.msgs_to_delete.length; i++){ |
---|
[4110] | 561 | if ( (data.msgs_to_delete[i] != undefined) && (data.msgs_to_delete[i] != "")){ |
---|
[3265] | 562 | removeAll(data.msgs_to_delete[i]); |
---|
| 563 | } |
---|
| 564 | } |
---|
[5134] | 565 | } |
---|
[3035] | 566 | if (data[0].msg_folder != current_folder) // Bad request |
---|
[3140] | 567 | return false; |
---|
[271] | 568 | for (var i=0; i<data.length; i++){ |
---|
[3035] | 569 | var existent = document.getElementById(data[i].msg_number); |
---|
| 570 | if (!existent) |
---|
| 571 | { |
---|
[3493] | 572 | var new_msg = this.make_tr_message(data[i], current_folder, data.offsetToGMT); |
---|
[5486] | 573 | $(new_msg).draggable({ |
---|
| 574 | start : function(){ |
---|
[5499] | 575 | if($(".shared-folders").length){ |
---|
| 576 | $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({ |
---|
| 577 | over : function(a, b){ |
---|
| 578 | //SETA BORDA EM VOLTA DA PASTA |
---|
[5765] | 579 | over = $(this); |
---|
| 580 | $(this).addClass("folder-over"); |
---|
| 581 | if(($(this)[0] != $(this).parent().find(".head_folder")[0])) |
---|
| 582 | if($(this).prev()[0]) |
---|
| 583 | if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){ |
---|
| 584 | setTimeout(function(){ |
---|
| 585 | if(over.hasClass("folder-over")) |
---|
| 586 | over.prev().trigger("click"); |
---|
| 587 | }, 500); |
---|
| 588 | |
---|
| 589 | } |
---|
[5499] | 590 | }, |
---|
| 591 | out : function(){ |
---|
| 592 | //RETIRA BORDA EM VOLTA DA PASTA |
---|
[5765] | 593 | $(this).removeClass("folder-over"); |
---|
[5499] | 594 | }, |
---|
| 595 | //accept: ".draggin_mail", |
---|
| 596 | drop : function(event, ui){ |
---|
| 597 | $(this).css("border", ""); |
---|
| 598 | if($(this).parent().attr('id') == undefined){ |
---|
| 599 | var folder_to = 'INBOX'; |
---|
| 600 | var to_folder_title = get_lang("Inbox"); |
---|
| 601 | }else{ |
---|
| 602 | var folder_to = $(this).parent().attr('id'); |
---|
| 603 | var to_folder_title = $(this).attr('title'); |
---|
| 604 | } |
---|
| 605 | var folder_to_move = ui.draggable.parent().attr('id'); |
---|
| 606 | var border_id = ui.draggable.find("input[type=hidden]").attr("name"); |
---|
| 607 | // Mensagens : SE O DROP VIER DA LISTA DE MENSAGENS : |
---|
| 608 | if(folder_to_move == "tbody_box"){ |
---|
| 609 | move_msgs2(get_current_folder(), 'selected', 0, folder_to, to_folder_title,true); |
---|
| 610 | return refresh(); |
---|
| 611 | } |
---|
| 612 | } |
---|
| 613 | }); |
---|
| 614 | } |
---|
[5486] | 615 | }, |
---|
[5499] | 616 | stop :function(){ |
---|
| 617 | $(".shared-folders").parent().find(".folder").droppable("destroy"); |
---|
[5486] | 618 | }, |
---|
| 619 | helper: function(event){ |
---|
[5754] | 620 | if($(this).find("input:checkbox").attr("checked") != "checked"){ |
---|
| 621 | $(this).find("input:checkbox").trigger('click'); |
---|
| 622 | $(this).addClass("selected_msg"); |
---|
| 623 | } |
---|
| 624 | if($("#table_box").find("tr input:checked").length > 1) |
---|
| 625 | return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : (($("#table_box").find("tr input:checked")).length+" mensagens selecionadas"), type: "messages"})+"</td></tr>"); |
---|
| 626 | if( $(this).find(".td_msg_subject").text().length > 18 ) |
---|
| 627 | return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : $(this).find(".td_msg_subject").text().substring(0,18) + "...", type: "messages"})+"</td></tr>"); |
---|
| 628 | else |
---|
| 629 | return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : $(this).find(".td_msg_subject").text(), type: "messages"})+"</td></tr>"); |
---|
[5486] | 630 | }, |
---|
[5754] | 631 | iframeFix: true, |
---|
| 632 | delay: 150, |
---|
| 633 | cursorAt: {top: 5, left: 56}, |
---|
| 634 | refreshPositions: true, |
---|
[5486] | 635 | containment: "#divAppbox" |
---|
[5506] | 636 | }).bind("contextmenu", function(){ |
---|
| 637 | if($(this).find("input:checkbox").attr("checked") != "checked"){ |
---|
| 638 | $(this).find("input:checkbox").trigger('click'); |
---|
| 639 | $(this).addClass("selected_msg"); |
---|
| 640 | } |
---|
[5486] | 641 | }); |
---|
| 642 | //_dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true); |
---|
[3955] | 643 | |
---|
[4764] | 644 | if( data[i].next_msg_number != undefined && data[i].next_msg_number != null ){ |
---|
[5134] | 645 | try { |
---|
[5891] | 646 | box.insertBefore(new_msg, box.childNodes[data[i].msg_key_position]); |
---|
[5134] | 647 | } |
---|
| 648 | catch (e){ |
---|
[5292] | 649 | box.insertBefore(new_msg, box.firstChild); |
---|
[5134] | 650 | } |
---|
[4764] | 651 | } |
---|
| 652 | else if (data[i].Recent == 'N'){ |
---|
[3265] | 653 | box.insertBefore(new_msg,box.firstChild); |
---|
[4764] | 654 | } |
---|
| 655 | else { |
---|
[3265] | 656 | box.appendChild(new_msg); |
---|
[4764] | 657 | } |
---|
[3035] | 658 | } |
---|
[2] | 659 | } |
---|
[6188] | 660 | if(parseInt(preferences.use_shortcuts)) |
---|
| 661 | select_msg("null","reload_msg","null"); |
---|
[827] | 662 | |
---|
[2] | 663 | if(parseInt(alert_new_msg) && data.new_msgs > 0) |
---|
[1951] | 664 | alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!"); |
---|
[3265] | 665 | build_quota(data['quota']); |
---|
[2] | 666 | } |
---|
[5134] | 667 | if(data.new_msgs){ |
---|
| 668 | total_messages_element.innerHTML = parseInt( total_messages_element.innerHTML ) + data.new_msgs; |
---|
| 669 | }else if(data.tot_msgs){ |
---|
| 670 | total_messages_element.innerHTML = data.tot_msgs; |
---|
| 671 | } |
---|
[976] | 672 | // Update Box BgColor |
---|
| 673 | var box = Element("tbody_box"); |
---|
| 674 | if(box.childNodes.length > 1){ |
---|
| 675 | updateBoxBgColor(box.childNodes); |
---|
| 676 | } |
---|
[1443] | 677 | connector.purgeCache(); |
---|
[2] | 678 | update_menu(); |
---|
[4189] | 679 | resizeMailList(); |
---|
[5754] | 680 | |
---|
[2] | 681 | } |
---|
[5936] | 682 | |
---|
[2] | 683 | msg_range_end = (current_page*preferences.max_email_per_page); |
---|
| 684 | msg_range_begin = (msg_range_end-(preferences.max_email_per_page)+1); |
---|
[3035] | 685 | |
---|
| 686 | |
---|
[2] | 687 | //Get element tBody. |
---|
| 688 | main = Element("tbody_box"); |
---|
| 689 | if(!main) |
---|
[3035] | 690 | return; |
---|
[139] | 691 | |
---|
[2] | 692 | // Get all TR (messages) in tBody. |
---|
| 693 | main_list = main.childNodes; |
---|
| 694 | var tmp = ''; |
---|
| 695 | var string_msgs_in_main = ''; |
---|
[139] | 696 | |
---|
[3035] | 697 | var len = main_list.length; |
---|
[2] | 698 | for (var j=0; j < len; j++) |
---|
| 699 | tmp += main_list[j].id + ','; |
---|
[3035] | 700 | |
---|
[2] | 701 | string_msgs_in_main = tmp.substring(0,(tmp.length-1)); |
---|
[1121] | 702 | if(!expresso_offline) |
---|
[6287] | 703 | $.ajax({ |
---|
| 704 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.refresh', |
---|
| 705 | folder: current_folder, |
---|
| 706 | msgs_existent: string_msgs_in_main, |
---|
| 707 | msg_range_begin: msg_range_begin, |
---|
| 708 | msg_range_end: msg_range_end, |
---|
| 709 | sort_box_type: sort_box_type, |
---|
| 710 | search_box_type: search_box_type, |
---|
| 711 | sort_box_reverse: sort_box_reverse } ), |
---|
| 712 | success: function( data ){ |
---|
| 713 | data = connector.unserialize( data ); |
---|
| 714 | |
---|
| 715 | if( data ) |
---|
| 716 | handler_refresh( data ); |
---|
[6469] | 717 | }, |
---|
| 718 | beforeSend: function( jqXHR, settings ){ |
---|
| 719 | connector.showProgressBar(); |
---|
| 720 | }, |
---|
| 721 | complete: function( jqXHR, settings ){ |
---|
| 722 | connector.hideProgressBar(); |
---|
[6287] | 723 | } |
---|
| 724 | |
---|
| 725 | }); |
---|
[2] | 726 | } |
---|
| 727 | |
---|
[5844] | 728 | function delete_msgs(folder, msgs_number, border_ID, show_success_msg,archive){ |
---|
[5134] | 729 | if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){ |
---|
| 730 | alert( "Impossivel deletar mensagens que estão ainda estão sendo arquivadas." ); |
---|
| 731 | return; |
---|
| 732 | } |
---|
| 733 | |
---|
[4840] | 734 | var userTrashFolder = ''; |
---|
| 735 | |
---|
| 736 | if (arguments.length < 4) show_success_msg = true; |
---|
| 737 | if (folder == 'null') folder = current_folder; |
---|
| 738 | |
---|
| 739 | if(folder.substr(0,4) == 'user') |
---|
| 740 | { |
---|
[5844] | 741 | var arrayFolder = folder.split(cyrus_delimiter); |
---|
| 742 | userTrashFolder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Trash']; |
---|
| 743 | /** TODO Mudar quando melhorias forem implementadas na API de atualização do cache */ |
---|
| 744 | DataLayer.remove('folder', false); |
---|
| 745 | DataLayer.get('folder'); |
---|
| 746 | |
---|
| 747 | var has_folder = DataLayer.get('folder', userTrashFolder); |
---|
| 748 | if(!has_folder){ |
---|
| 749 | create_new_folder(special_folders['Trash'], 'user'+cyrus_delimiter+arrayFolder[1]); |
---|
| 750 | } |
---|
| 751 | |
---|
[4840] | 752 | } |
---|
[5306] | 753 | else userTrashFolder = mount_url_folder(["INBOX",special_folders["Trash"]]); |
---|
[4840] | 754 | |
---|
[5134] | 755 | if(openTab.type[currentTab] == 1) |
---|
[5211] | 756 | return move_search_msgs('content_id_'+currentTab,userTrashFolder,special_folders['Trash']); |
---|
[5134] | 757 | |
---|
| 758 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 759 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
[4840] | 760 | |
---|
| 761 | if (!archive && (parseInt(preferences.save_deleted_msg)) && (folder != userTrashFolder)){ |
---|
[5211] | 762 | move_msgs2(folder, msgs_number, border_ID, userTrashFolder,special_folders['Trash'],show_success_msg ); |
---|
[4840] | 763 | return; |
---|
[827] | 764 | } |
---|
| 765 | |
---|
[2] | 766 | var handler_delete_msgs = function(data){ |
---|
[3035] | 767 | |
---|
[2] | 768 | Element('chk_box_select_all_messages').checked = false; |
---|
[827] | 769 | if (currentTab) |
---|
| 770 | mail_msg = Element("tbody_box_"+currentTab); |
---|
| 771 | else |
---|
| 772 | mail_msg = Element("tbody_box"); |
---|
[3035] | 773 | |
---|
[214] | 774 | if ( preferences.use_shortcuts == '1') { |
---|
[1658] | 775 | //Last msg is selected |
---|
| 776 | if (mail_msg && exist_className(mail_msg.childNodes[mail_msg.childNodes.length-1], 'selected_shortcut_msg') ) { |
---|
[214] | 777 | select_msg('null', 'up', true); |
---|
| 778 | } |
---|
[1658] | 779 | else { |
---|
| 780 | if (!select_msg('null', 'down', true)) { |
---|
| 781 | select_msg('null', 'up', true); |
---|
| 782 | } |
---|
| 783 | } |
---|
[214] | 784 | } |
---|
[3035] | 785 | |
---|
[689] | 786 | if (show_success_msg) { |
---|
[827] | 787 | if (data.msgs_number.length == 1) |
---|
[689] | 788 | write_msg(get_lang("The message was deleted.")); |
---|
[827] | 789 | else |
---|
[689] | 790 | write_msg(get_lang("The messages were deleted.")); |
---|
| 791 | } |
---|
[827] | 792 | if (openTab.type[currentTab] > 1){ |
---|
[1658] | 793 | var msg_to_delete = Element(msgs_number); |
---|
| 794 | if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) { |
---|
| 795 | if (msg_to_delete.previousSibling){ |
---|
[3035] | 796 | var previous_msg = msg_to_delete.previousSibling.id; |
---|
[6275] | 797 | $.ajax({ |
---|
| 798 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 799 | msg_number: previous_msg, |
---|
| 800 | msg_folder: current_folder, |
---|
| 801 | decoded: true } ), |
---|
| 802 | success: function( data ){ |
---|
| 803 | data = connector.unserialize( data ); |
---|
| 804 | |
---|
| 805 | if( data ) |
---|
| 806 | show_msg( data ); |
---|
[6469] | 807 | }, |
---|
| 808 | beforeSend: function( jqXHR, settings ){ |
---|
| 809 | connector.showProgressBar(); |
---|
| 810 | }, |
---|
| 811 | complete: function( jqXHR, settings ){ |
---|
| 812 | connector.hideProgressBar(); |
---|
[6275] | 813 | } |
---|
| 814 | |
---|
| 815 | }); |
---|
[3035] | 816 | } |
---|
[1658] | 817 | else |
---|
| 818 | delete_border(currentTab,'false'); |
---|
[827] | 819 | } |
---|
[2] | 820 | else |
---|
[827] | 821 | delete_border(currentTab,'false'); |
---|
[2] | 822 | } |
---|
[3035] | 823 | for (var i=0; i<data.msgs_number.length; i++){ |
---|
| 824 | var msg_to_delete = Element(data.msgs_number[i]); |
---|
| 825 | if (msg_to_delete){ |
---|
| 826 | removeAll(msg_to_delete.id); |
---|
| 827 | } |
---|
| 828 | } |
---|
[2] | 829 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length; |
---|
[3035] | 830 | refresh(); |
---|
[2] | 831 | } |
---|
| 832 | |
---|
| 833 | if (msgs_number == 'selected') |
---|
| 834 | msgs_number = get_selected_messages(); |
---|
| 835 | if (msgs_number.length > 0 || parseInt(msgs_number) > 0) |
---|
[1226] | 836 | cExecute ("$this.imap_functions.delete_msgs&folder="+folder+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&search_box_type="+search_box_type+"&sort_box_reverse="+sort_box_reverse, handler_delete_msgs); |
---|
[2] | 837 | else |
---|
[3035] | 838 | write_msg(get_lang('No selected message.')); |
---|
[2] | 839 | } |
---|
| 840 | |
---|
[5134] | 841 | |
---|
[5172] | 842 | function move_search_msgs(border_id, new_folder, new_folder_name, action){ |
---|
[5134] | 843 | |
---|
[5172] | 844 | var msg_to_delete = ""; |
---|
| 845 | var msg_to_move = ""; |
---|
[163] | 846 | var selected_messages = ''; |
---|
[689] | 847 | var temp_msg; |
---|
[5172] | 848 | var remove_currente_folder = ""; |
---|
| 849 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 850 | |
---|
| 851 | var delete_msg = false; |
---|
| 852 | |
---|
| 853 | if(new_folder_name == special_folders['Trash']){ |
---|
| 854 | delete_msg = true; |
---|
[163] | 855 | } |
---|
[5172] | 856 | selected_messages = get_selected_messages_search(); |
---|
| 857 | |
---|
| 858 | if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( selected_messages, folder ) ){ |
---|
| 859 | alert( "Impossivel mover mensagens que estão ainda estão sendo arquivadas." ); |
---|
| 860 | return; |
---|
[163] | 861 | } |
---|
| 862 | var handler_move_search_msgs = function(data){ |
---|
| 863 | if(!data || !data.msgs_number) |
---|
| 864 | return; |
---|
[3035] | 865 | else if(data.deleted) { |
---|
[5172] | 866 | if(data.no_move && data.move) |
---|
| 867 | alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission.")); |
---|
| 868 | else if (data.msgs_number.length == 1) |
---|
[163] | 869 | write_msg(get_lang("The message was deleted.")); |
---|
| 870 | else |
---|
[3035] | 871 | write_msg(get_lang("The messages were deleted.")); |
---|
[5172] | 872 | }else if(data.status == false && data.move ){ |
---|
| 873 | alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission.")); |
---|
| 874 | }else if(data.status == false){ |
---|
| 875 | alert(get_lang("You don't have permission for this operation in this shared folder!")); |
---|
| 876 | return false; |
---|
| 877 | }else{ |
---|
[163] | 878 | if (data.msgs_number.length == 1) |
---|
| 879 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 880 | else |
---|
| 881 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 882 | } |
---|
[569] | 883 | |
---|
[5172] | 884 | if(data.no_move){ |
---|
| 885 | var no_remove = data.no_move.split(','); |
---|
| 886 | var continua = true; |
---|
| 887 | |
---|
[163] | 888 | selected_messages = selected_messages.split(","); |
---|
| 889 | for (i = 0; i < selected_messages.length; i++){ |
---|
[5172] | 890 | for(j = 0; j < no_remove.length; j++) |
---|
| 891 | if(selected_messages[i] == no_remove[j]) |
---|
| 892 | continua = false; |
---|
| 893 | if(continua) |
---|
| 894 | removeAll(selected_messages[i]+'_s'+id_border); |
---|
| 895 | continua = true; |
---|
[827] | 896 | } |
---|
[5172] | 897 | }else{ |
---|
| 898 | selected_messages = selected_messages.split(","); |
---|
| 899 | for (i = 0; i < selected_messages.length; i++){ |
---|
| 900 | removeAll(selected_messages[i]+'_s'+id_border); |
---|
| 901 | |
---|
| 902 | } |
---|
| 903 | } |
---|
| 904 | |
---|
[976] | 905 | // Update Box BgColor |
---|
[4810] | 906 | var box = Element("tbody_box_"+getNumBoxFromTabId(currentTab)).childNodes; |
---|
[5172] | 907 | if(box.length > 1){ |
---|
[976] | 908 | updateBoxBgColor(box); |
---|
| 909 | } |
---|
[1443] | 910 | connector.purgeCache(); |
---|
[4821] | 911 | |
---|
[5172] | 912 | |
---|
| 913 | if(remove_currente_folder != ""){ |
---|
| 914 | var mail_msg = Element('tbody_box').childNodes; |
---|
| 915 | remove_currente_folder = remove_currente_folder.substring(0,(remove_currente_folder.length-1)); |
---|
| 916 | remove_currente_folder = remove_currente_folder.split(","); |
---|
| 917 | for(i = 0; i < remove_currente_folder.length; i++) |
---|
| 918 | removeAll(remove_currente_folder[i]); |
---|
| 919 | |
---|
| 920 | // Update Box BgColor |
---|
| 921 | var box = Element("tbody_box"); |
---|
| 922 | if(box.childNodes.length > 0){ |
---|
| 923 | updateBoxBgColor(box.childNodes); |
---|
| 924 | } |
---|
| 925 | if(folder == get_current_folder()){ |
---|
| 926 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - remove_currente_folder.length; |
---|
| 927 | } |
---|
| 928 | } |
---|
| 929 | |
---|
| 930 | draw_tree_folders(); |
---|
[4821] | 931 | EsearchE.refresh(); |
---|
[827] | 932 | } |
---|
[163] | 933 | |
---|
| 934 | if (selected_messages){ |
---|
[5306] | 935 | |
---|
[569] | 936 | var selected_param = ""; |
---|
| 937 | if (selected_messages.indexOf(',') != -1) |
---|
| 938 | { |
---|
| 939 | selected_msg_array = selected_messages.split(","); |
---|
| 940 | for (i = 0; i < selected_msg_array.length; i++){ |
---|
[5172] | 941 | var tr = Element(selected_msg_array[i]+'_s'+id_border); |
---|
| 942 | if(tr.getAttribute('name') == current_folder) |
---|
| 943 | remove_currente_folder += tr.id.replace(/_[a-zA-Z0-9]+/,"")+','; |
---|
[5306] | 944 | |
---|
| 945 | if ((action == 'delete' && tr.getAttribute('name') == mount_url_folder(["INBOX",special_folders["Trash"]])) || !(parseInt(preferences.save_deleted_msg))) |
---|
[829] | 946 | { |
---|
[5172] | 947 | msg_to_delete += ','+special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 948 | } |
---|
| 949 | else if (!(tr.getAttribute('name') == new_folder && action != 'delete')) |
---|
| 950 | { |
---|
| 951 | msg_to_move = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 952 | selected_param += ','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 953 | }else{ |
---|
[829] | 954 | write_msg(get_lang('At least one message have the same origin')); |
---|
| 955 | return false; |
---|
| 956 | } |
---|
[569] | 957 | } |
---|
| 958 | } |
---|
| 959 | else |
---|
| 960 | { |
---|
[5172] | 961 | var tr=Element(selected_messages+'_s'+id_border); |
---|
| 962 | if(tr.getAttribute('name') == current_folder) |
---|
| 963 | remove_currente_folder += tr.id.replace(/_[a-zA-Z0-9]+/,"")+','; |
---|
[5306] | 964 | if((action == 'delete' && tr.getAttribute('name') == mount_url_folder(["INBOX",special_folders["Trash"]])) || !(parseInt(preferences.save_deleted_msg))){ |
---|
[5172] | 965 | msg_to_delete = special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 966 | }else if (!(tr.getAttribute('name') == new_folder && action != 'delete')){ |
---|
| 967 | trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 968 | selected_param=trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 969 | }else{ |
---|
[829] | 970 | write_msg(get_lang('The origin folder and the destination folder are the same.')); |
---|
| 971 | return false; |
---|
| 972 | } |
---|
[569] | 973 | } |
---|
[163] | 974 | var params = ""; |
---|
[5172] | 975 | if(msg_to_delete != "" && msg_to_move != ""){ |
---|
| 976 | params += "&selected_messages_move="+url_encode(selected_param); |
---|
| 977 | params += "&new_folder_move="+url_encode(new_folder); |
---|
| 978 | params += "&new_folder_name_move="+url_encode(new_folder_name); |
---|
| 979 | |
---|
[5306] | 980 | new_folder = mount_url_folder(["INBOX",special_folders["Trash"]]); |
---|
[5211] | 981 | new_folder_name = special_folders['Trash']; |
---|
[5172] | 982 | params += "&selected_messages_delete="+url_encode(msg_to_delete); |
---|
| 983 | params += "&new_folder_delete="+url_encode(new_folder); |
---|
| 984 | cExecute ("$this.imap_functions.move_delete_search_messages", handler_move_search_msgs, params); |
---|
| 985 | }else if(msg_to_delete != ""){ |
---|
[5306] | 986 | new_folder = mount_url_folder(["INBOX",special_folders["Trash"]]); |
---|
[5211] | 987 | new_folder_name = special_folders['Trash']; |
---|
[5172] | 988 | params += "&delete=true"; |
---|
| 989 | params += "&selected_messages="+url_encode(msg_to_delete); |
---|
[163] | 990 | params += "&new_folder="+url_encode(new_folder); |
---|
[5172] | 991 | cExecute ("$this.imap_functions.move_search_messages", handler_move_search_msgs, params); |
---|
| 992 | }else{ |
---|
| 993 | params = "&selected_messages="+url_encode(selected_param); |
---|
| 994 | params += "&delete=false"; |
---|
| 995 | params += "&new_folder="+url_encode(new_folder); |
---|
[163] | 996 | params += "&new_folder_name="+url_encode(new_folder_name); |
---|
| 997 | cExecute ("$this.imap_functions.move_search_messages", handler_move_search_msgs, params); |
---|
| 998 | } |
---|
[5172] | 999 | } |
---|
[163] | 1000 | else |
---|
[3035] | 1001 | write_msg(get_lang('No selected message.')); |
---|
[163] | 1002 | } |
---|
| 1003 | |
---|
[5134] | 1004 | function move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,show_success_msg, not_opem_previus){ |
---|
| 1005 | not_opem_previus = typeof(not_opem_previus) != 'undefined' ? not_opem_previus : false; |
---|
[5211] | 1006 | var folder_error = new_folder_name; |
---|
| 1007 | if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){ |
---|
[5134] | 1008 | alert( "Impossivel mover mensagens que estão ainda estão sendo arquivadas." ); |
---|
| 1009 | return; |
---|
| 1010 | } |
---|
| 1011 | |
---|
[320] | 1012 | if (! folder || folder == 'null') |
---|
[3018] | 1013 | folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder()); |
---|
[845] | 1014 | if(openTab.type[currentTab] == 1) |
---|
| 1015 | return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name); |
---|
| 1016 | |
---|
[2] | 1017 | var handler_move_msgs = function(data){ |
---|
[320] | 1018 | if(typeof(data) == 'string') |
---|
| 1019 | if (data.match(/^(.*)TRYCREATE(.*)$/)){ |
---|
| 1020 | connector.loadScript('TreeS'); |
---|
[5211] | 1021 | var move_to_folder = data.match(/^(.*)Spam(.*)$/) ? "Spam" : special_folders['Trash']; |
---|
| 1022 | alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.', folder_error)); |
---|
[320] | 1023 | connector.loadScript('TreeShow'); |
---|
| 1024 | ttree.FOLDER = 'root'; |
---|
| 1025 | ttreeBox.new_past(move_to_folder); |
---|
| 1026 | return false; |
---|
| 1027 | }else{ |
---|
[827] | 1028 | alert(get_lang('Error moving message.')+":\n"+data); |
---|
[320] | 1029 | return false; |
---|
| 1030 | } |
---|
[325] | 1031 | //Este bloco verifica as permissoes ACL sobre pastas compartilhadas |
---|
| 1032 | if(data.status == false){ |
---|
| 1033 | alert(get_lang("You don't have permission for this operation in this shared folder!")); |
---|
| 1034 | return false; |
---|
| 1035 | } |
---|
[827] | 1036 | mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild; |
---|
[5134] | 1037 | if (data.msgs_number.length == 1){ |
---|
[827] | 1038 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
[5134] | 1039 | } |
---|
| 1040 | else{ |
---|
[827] | 1041 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
[5134] | 1042 | } |
---|
[827] | 1043 | |
---|
| 1044 | if (openTab.type[currentTab] > 1){ |
---|
| 1045 | msg_to_delete = Element(msgs_number); |
---|
| 1046 | if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) |
---|
| 1047 | { |
---|
| 1048 | if (msg_to_delete.previousSibling){ |
---|
| 1049 | var previous_msg = msg_to_delete.previousSibling.id; |
---|
[1635] | 1050 | //cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg); |
---|
[5134] | 1051 | if(!not_opem_previus){ |
---|
[6275] | 1052 | $.ajax({ |
---|
| 1053 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 1054 | msg_number: previous_msg, |
---|
| 1055 | msg_folder: folder, |
---|
| 1056 | decoded: true } ), |
---|
| 1057 | success: function( data ){ |
---|
| 1058 | data = connector.unserialize( data ); |
---|
| 1059 | |
---|
| 1060 | if( data ) |
---|
| 1061 | show_msg( data ); |
---|
| 1062 | } |
---|
| 1063 | |
---|
| 1064 | }); |
---|
[5486] | 1065 | } |
---|
[827] | 1066 | } |
---|
[5524] | 1067 | //se houver pagina anterior a paginação deve ser refeita |
---|
| 1068 | else if (current_page > 1){ |
---|
| 1069 | $('#msg_opt_previous_'+msg_to_delete.getAttribute('id') + '_r').trigger('click'); |
---|
| 1070 | } |
---|
[827] | 1071 | else |
---|
| 1072 | delete_border(currentTab,'false'); |
---|
| 1073 | } |
---|
[5134] | 1074 | else{ |
---|
[827] | 1075 | delete_border(currentTab,'false'); |
---|
[5134] | 1076 | } |
---|
[827] | 1077 | if(msg_to_delete) |
---|
| 1078 | mail_msg.removeChild(msg_to_delete); |
---|
[1652] | 1079 | |
---|
| 1080 | // Update Box BgColor |
---|
| 1081 | var box = Element("tbody_box"); |
---|
| 1082 | if(box.childNodes.length > 0){ |
---|
| 1083 | updateBoxBgColor(box.childNodes); |
---|
| 1084 | } |
---|
[5134] | 1085 | if(folder == get_current_folder()){ |
---|
| 1086 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - 1; |
---|
| 1087 | } |
---|
[827] | 1088 | return; |
---|
| 1089 | } |
---|
| 1090 | |
---|
[2] | 1091 | Element('chk_box_select_all_messages').checked = false; |
---|
[345] | 1092 | if (! mail_msg) |
---|
| 1093 | mail_msg = Element("tbody_box"); |
---|
[2] | 1094 | data.msgs_number = data.msgs_number.split(","); |
---|
[320] | 1095 | |
---|
[345] | 1096 | var msg_to_delete; |
---|
| 1097 | if( typeof(msgs_number) == 'string' ) |
---|
| 1098 | all_search_msg = msgs_number.split(','); |
---|
[827] | 1099 | else if( typeof(msgs_number) == 'number') |
---|
[345] | 1100 | all_search_msg = msgs_number; |
---|
[3035] | 1101 | |
---|
[320] | 1102 | for (var i=0; i <= all_search_msg.length; i++) |
---|
| 1103 | { |
---|
[3035] | 1104 | msg_to_delete = Element(folder+';'+all_search_msg[i]); |
---|
[320] | 1105 | if (msg_to_delete) |
---|
| 1106 | msg_to_delete.parentNode.removeChild(msg_to_delete); |
---|
| 1107 | } |
---|
| 1108 | |
---|
[214] | 1109 | if ( preferences.use_shortcuts == '1') { |
---|
| 1110 | var all_messages = Element('tbody_box').childNodes; |
---|
[5922] | 1111 | // verificar se a msg selecionada com o checkbox é a mesma selecionada com o shortcut |
---|
| 1112 | var msg_list_shortcut = get_selected_messages_shortcut().split(','); |
---|
| 1113 | if(data.msgs_number.length > 0 && msg_list_shortcut.length > 0 && data.msgs_number.toString() == msg_list_shortcut.toString()){ |
---|
| 1114 | //Last msg is selected |
---|
| 1115 | if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) { |
---|
[214] | 1116 | select_msg('null', 'up', true); |
---|
[135] | 1117 | } |
---|
[5922] | 1118 | else { |
---|
| 1119 | if (!select_msg('null', 'down', true)) { |
---|
| 1120 | select_msg('null', 'up', true); |
---|
| 1121 | } |
---|
| 1122 | } |
---|
[2] | 1123 | } |
---|
| 1124 | } |
---|
[214] | 1125 | for (var i=0; i<data.msgs_number.length; i++) |
---|
| 1126 | { |
---|
| 1127 | msg_to_delete = Element(data.msgs_number[i]); |
---|
| 1128 | if (msg_to_delete) |
---|
[5936] | 1129 | mail_msg.removeChild(msg_to_delete); |
---|
[3035] | 1130 | } |
---|
| 1131 | |
---|
[673] | 1132 | if (data.msgs_number.length == 1) |
---|
| 1133 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 1134 | else |
---|
| 1135 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
[320] | 1136 | if (data.border_ID.indexOf('r') != -1){ |
---|
[605] | 1137 | if (parseInt(preferences.delete_and_show_previous_message) && folder == get_current_folder()){ |
---|
| 1138 | delete_border(data.border_ID,'false'); |
---|
[2] | 1139 | show_msg(data.previous_msg); |
---|
[605] | 1140 | } |
---|
[2] | 1141 | else |
---|
| 1142 | delete_border(data.border_ID,'false'); |
---|
| 1143 | } |
---|
[5134] | 1144 | if(folder == get_current_folder()){ |
---|
[5771] | 1145 | var n_total_msg = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length; |
---|
| 1146 | draw_paging(n_total_msg); |
---|
| 1147 | Element('tot_m').innerHTML = n_total_msg; |
---|
[5134] | 1148 | } |
---|
[2] | 1149 | refresh(); |
---|
| 1150 | } |
---|
| 1151 | |
---|
| 1152 | if (folder == new_folder){ |
---|
[53] | 1153 | write_msg(get_lang('The origin folder and the destination folder are the same.')); |
---|
[2] | 1154 | return; |
---|
| 1155 | } |
---|
| 1156 | |
---|
[4836] | 1157 | try{ |
---|
| 1158 | if (proxy_mensagens.is_local_folder(Element('input_folder_'+currentTab).getAttribute('value'))) { |
---|
| 1159 | alert(get_lang("You cant manipulate local messages on search")); |
---|
| 1160 | return; |
---|
| 1161 | } |
---|
| 1162 | } catch (e) {} |
---|
[4825] | 1163 | |
---|
[827] | 1164 | if (msgs_number == 'selected'){ |
---|
[2] | 1165 | msgs_number = get_selected_messages(); |
---|
[827] | 1166 | } |
---|
[2] | 1167 | |
---|
[827] | 1168 | if(openTab.type[currentTab] == 1){ |
---|
| 1169 | return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name); |
---|
| 1170 | } |
---|
| 1171 | |
---|
[5134] | 1172 | // se a aba estiver aberta e selecionada, apenas a msg da aba é movida |
---|
[6458] | 1173 | if(currentTab.toString().indexOf("_r") != -1 && currentTab == border_ID) |
---|
[5134] | 1174 | { |
---|
| 1175 | //se a aba for aberta atraves de uma pesquisa |
---|
| 1176 | if(currentTab.toString().indexOf('_s') != -1) |
---|
| 1177 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf('_s')); |
---|
| 1178 | else |
---|
| 1179 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf('_r')); |
---|
[827] | 1180 | } |
---|
[5158] | 1181 | refresh(); |
---|
[4997] | 1182 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0){ |
---|
[6487] | 1183 | // remove a flag $FilteredMessage da mensagem, depois move |
---|
| 1184 | var handler_removeFlag = function(){ |
---|
| 1185 | $.ajax({ |
---|
[6287] | 1186 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.move_messages', |
---|
| 1187 | folder: folder, |
---|
| 1188 | msgs_number: msgs_number, |
---|
| 1189 | border_ID: border_ID, |
---|
| 1190 | sort_box_type: sort_box_type, |
---|
| 1191 | search_box_type: search_box_type, |
---|
| 1192 | sort_box_reverse: sort_box_reverse, |
---|
| 1193 | reuse_border: border_ID, |
---|
| 1194 | new_folder: new_folder, |
---|
| 1195 | new_folder_name: new_folder_name, |
---|
| 1196 | get_previous_msg: ( !not_opem_previus ? preferences.delete_and_show_previous_message : false ), |
---|
| 1197 | decoded: true } ), |
---|
| 1198 | |
---|
| 1199 | success: function( data ){ |
---|
| 1200 | data = connector.unserialize( data ); |
---|
| 1201 | |
---|
| 1202 | if( data ) |
---|
| 1203 | handler_move_msgs( data ); |
---|
| 1204 | } |
---|
| 1205 | |
---|
[6487] | 1206 | }); |
---|
| 1207 | } |
---|
| 1208 | var hasFolder = false; |
---|
| 1209 | $.each(fromRules, function(index, value) { |
---|
| 1210 | if(value == folder){ |
---|
| 1211 | hasFolder = true; |
---|
| 1212 | cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_number, handler_removeFlag); |
---|
| 1213 | return false; |
---|
| 1214 | } |
---|
| 1215 | }); |
---|
| 1216 | if(!hasFolder){ |
---|
| 1217 | handler_removeFlag(); |
---|
| 1218 | } |
---|
| 1219 | |
---|
[5134] | 1220 | }else |
---|
[3035] | 1221 | write_msg(get_lang('No selected message.')); |
---|
[2] | 1222 | } |
---|
| 1223 | |
---|
[5134] | 1224 | function move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name, not_opem_previus) { |
---|
| 1225 | move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,true, not_opem_previus); |
---|
[689] | 1226 | } |
---|
| 1227 | |
---|
[5134] | 1228 | //Caso deseja-se que não se abra a mensagem anterior independente da |
---|
| 1229 | //preferencia do usuario |
---|
| 1230 | function move_msgs_not_previus(folder, msgs_number, border_ID, new_folder, new_folder_name) { |
---|
| 1231 | move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,true, true); |
---|
| 1232 | } |
---|
| 1233 | |
---|
| 1234 | function normalizeMsgNumber( msgNumber ){ |
---|
| 1235 | |
---|
| 1236 | if (msgNumber || msgNumber == 'selected') |
---|
| 1237 | msgNumber = get_selected_messages(); |
---|
| 1238 | |
---|
| 1239 | |
---|
| 1240 | // se a aba estiver aberta e selecionada, apenas a msg da aba é movida |
---|
| 1241 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 1242 | { |
---|
| 1243 | //se a aba for aberta atraves de uma pesquisa |
---|
| 1244 | if(currentTab.toString().indexOf('_s') != -1) |
---|
| 1245 | msgNumber = currentTab.toString().substr(0,currentTab.toString().indexOf('_s')); |
---|
| 1246 | else |
---|
| 1247 | msgNumber = currentTab.toString().substr(0,currentTab.toString().indexOf('_r')); |
---|
| 1248 | } |
---|
| 1249 | |
---|
| 1250 | if (parseInt(msgNumber) <= 0 || msgNumber.length <= 0){ |
---|
| 1251 | write_msg(get_lang('No selected message.')); |
---|
| 1252 | return( false ); |
---|
| 1253 | } |
---|
| 1254 | |
---|
| 1255 | return( msgNumber ); |
---|
| 1256 | |
---|
| 1257 | } |
---|
| 1258 | |
---|
[5172] | 1259 | function archive_search_msgs(folder_dest) { |
---|
| 1260 | |
---|
| 1261 | var id_msgs = ""; |
---|
| 1262 | id_msgs = get_selected_messages_search(); |
---|
| 1263 | var msg_to_arquive = ""; |
---|
| 1264 | var messages = ""; |
---|
| 1265 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 1266 | |
---|
| 1267 | if ( parseInt(id_msgs) <= 0 || id_msgs.length <= 0 ) |
---|
| 1268 | return write_msg(get_lang('No selected message.')); |
---|
| 1269 | |
---|
| 1270 | if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento... |
---|
| 1271 | folder_dest = 'local_Inbox'; |
---|
| 1272 | |
---|
| 1273 | id_msgs = expresso_local_messages.checkArchived( id_msgs, folder_dest ); |
---|
| 1274 | |
---|
| 1275 | if( !id_msgs ){ |
---|
| 1276 | write_msg( "Todas as mensagens já foram arquivadas anteriormente." ); |
---|
| 1277 | return; |
---|
| 1278 | } |
---|
| 1279 | |
---|
| 1280 | document.getElementById("overlay").style.visibility = "visible"; |
---|
| 1281 | |
---|
| 1282 | var handler_arquivar_mensagens = function(data) { |
---|
| 1283 | |
---|
| 1284 | var msgs_info = []; |
---|
| 1285 | |
---|
| 1286 | for( var i = 0; i < data.length; i++ ) |
---|
| 1287 | msgs_info[i] = connector.unserialize( data[i] ); |
---|
| 1288 | |
---|
| 1289 | //vejo se já tinha mensagens locais |
---|
| 1290 | var h = expresso_local_messages.has_local_mails(); |
---|
| 1291 | |
---|
| 1292 | expresso_local_messages.insert_mails( msgs_info, folder_dest, function( s, f ){complete_archiving( s, f, h )} ); |
---|
| 1293 | |
---|
| 1294 | document.getElementById("overlay").style.visibility = "hidden"; |
---|
| 1295 | } |
---|
| 1296 | |
---|
| 1297 | id_msgs = id_msgs.split(','); |
---|
| 1298 | for (i = 0; i < id_msgs.length; i++){ |
---|
| 1299 | var tr = Element(id_msgs[i]+'_s'+id_border); |
---|
| 1300 | msg_to_arquive = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 1301 | messages += ','+msg_to_arquive+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 1302 | } |
---|
| 1303 | |
---|
[6275] | 1304 | $.ajax({ |
---|
| 1305 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 1306 | msg_number: messages, |
---|
| 1307 | msg_folder: folder_dest, |
---|
| 1308 | decoded: true } ), |
---|
| 1309 | success: function( data ){ |
---|
| 1310 | data = connector.unserialize( data ); |
---|
| 1311 | |
---|
| 1312 | if( data ) |
---|
| 1313 | handler_arquivar_mensagens( data ); |
---|
[6469] | 1314 | }, |
---|
| 1315 | beforeSend: function( jqXHR, settings ){ |
---|
| 1316 | connector.showProgressBar(); |
---|
| 1317 | }, |
---|
| 1318 | complete: function( jqXHR, settings ){ |
---|
| 1319 | connector.hideProgressBar(); |
---|
[6275] | 1320 | } |
---|
| 1321 | |
---|
| 1322 | }); |
---|
[5172] | 1323 | } |
---|
| 1324 | |
---|
| 1325 | |
---|
[689] | 1326 | function archive_msgs(folder,folder_dest,id_msgs) { |
---|
| 1327 | if(proxy_mensagens.is_local_folder(folder)) { |
---|
| 1328 | write_msg(get_lang("You cant archive local mails")); |
---|
| 1329 | return; |
---|
| 1330 | } |
---|
[1595] | 1331 | |
---|
[5200] | 1332 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 1333 | id_msgs = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
| 1334 | |
---|
| 1335 | if(currentTab.toString().indexOf("_s") != -1) |
---|
| 1336 | id_msgs = currentTab.toString().substr(0,currentTab.toString().indexOf("_s")); |
---|
[3411] | 1337 | |
---|
[5172] | 1338 | if(!id_msgs){ |
---|
| 1339 | if (currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
| 1340 | archive_search_msgs(folder_dest); |
---|
| 1341 | return; |
---|
| 1342 | }else |
---|
[5200] | 1343 | id_msgs = get_selected_messages(); |
---|
[5172] | 1344 | } |
---|
[3035] | 1345 | |
---|
[5134] | 1346 | if ( parseInt(id_msgs) <= 0 || id_msgs.length <= 0 ) |
---|
| 1347 | return write_msg(get_lang('No selected message.')); |
---|
| 1348 | |
---|
[1595] | 1349 | if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento... |
---|
| 1350 | folder_dest = 'local_Inbox'; |
---|
[3035] | 1351 | |
---|
[5134] | 1352 | id_msgs = expresso_local_messages.checkArchived( id_msgs, folder_dest ); |
---|
[827] | 1353 | |
---|
[5134] | 1354 | if( !id_msgs ){ |
---|
| 1355 | write_msg( "Todas as mensagens já foram arquivadas anteriormente." ); |
---|
| 1356 | return; |
---|
| 1357 | } |
---|
| 1358 | |
---|
| 1359 | document.getElementById("overlay").style.visibility = "visible"; |
---|
| 1360 | |
---|
| 1361 | var handler_arquivar_mensagens = function(data) { |
---|
| 1362 | |
---|
| 1363 | var msgs_info = []; |
---|
| 1364 | |
---|
| 1365 | for( var i = 0; i < data.length; i++ ) |
---|
| 1366 | msgs_info[i] = connector.unserialize( data[i] ); |
---|
| 1367 | |
---|
| 1368 | //vejo se já tinha mensagens locais |
---|
| 1369 | var h = expresso_local_messages.has_local_mails(); |
---|
| 1370 | |
---|
| 1371 | expresso_local_messages.insert_mails( msgs_info, folder_dest, function( s, f ){complete_archiving( s, f, h )} ); |
---|
| 1372 | |
---|
| 1373 | document.getElementById("overlay").style.visibility = "hidden"; |
---|
| 1374 | } |
---|
| 1375 | |
---|
[6275] | 1376 | $.ajax({ |
---|
| 1377 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 1378 | msg_number: id_msgs, |
---|
| 1379 | msg_folder: folder, |
---|
| 1380 | decoded: true } ), |
---|
| 1381 | success: function( data ){ |
---|
| 1382 | data = connector.unserialize( data ); |
---|
| 1383 | |
---|
| 1384 | if( data ) |
---|
| 1385 | handler_arquivar_mensagens( data ); |
---|
[6469] | 1386 | }, |
---|
| 1387 | beforeSend: function( jqXHR, settings ){ |
---|
| 1388 | connector.showProgressBar(); |
---|
| 1389 | }, |
---|
| 1390 | complete: function( jqXHR, settings ){ |
---|
| 1391 | connector.hideProgressBar(); |
---|
[6275] | 1392 | } |
---|
| 1393 | |
---|
| 1394 | }); |
---|
[689] | 1395 | } |
---|
| 1396 | |
---|
[5134] | 1397 | function complete_archiving( success, fails, has_local_messages_before ) |
---|
| 1398 | { |
---|
| 1399 | var msgs_to_remove = {}; |
---|
[5306] | 1400 | var target = mount_url_folder(["INBOX",special_folders["Trash"],'tmpMoveToLocal']); |
---|
[5134] | 1401 | |
---|
| 1402 | success = expresso_local_messages.select_mail( [ 'original_id', 'original_folder' ], success ); |
---|
| 1403 | |
---|
| 1404 | for (var i = 0; i < success.length; i++) { |
---|
| 1405 | |
---|
| 1406 | var msg_info = success[i]; |
---|
| 1407 | |
---|
| 1408 | // if ( msg_info.dest_folder == target ) |
---|
| 1409 | // { |
---|
| 1410 | // msg_info.msg_folder += (Date.parse(new Date)); |
---|
| 1411 | // } |
---|
| 1412 | |
---|
| 1413 | //////////////// deselecionando //////////////// |
---|
| 1414 | Element('chk_box_select_all_messages').checked = false; |
---|
| 1415 | |
---|
| 1416 | if ( Element("check_box_message_" + msg_info.original_id) ) |
---|
| 1417 | { |
---|
| 1418 | Element("check_box_message_" + msg_info.original_id).checked = false; |
---|
| 1419 | } |
---|
| 1420 | if ( Element(msg_info.original_id) ) |
---|
| 1421 | { |
---|
| 1422 | remove_className(Element(msg_info.original_id), 'selected_msg'); |
---|
| 1423 | } |
---|
| 1424 | |
---|
| 1425 | // if ( tree_folders._selected.id.indexOf( 'local_' ) == 0 || msg_info.dest_folder.indexOf( target ) == 0 ) |
---|
| 1426 | // { |
---|
| 1427 | // openTab.imapBox[0] = ''; |
---|
| 1428 | // tree_folders.getNodeById( 'local_Inbox' )._select( ); |
---|
| 1429 | // change_folder('local_Inbox','Inbox'); |
---|
| 1430 | // } |
---|
| 1431 | ///////////////////////////////////////////////// |
---|
| 1432 | |
---|
| 1433 | //As mensagens arquivadas devem ser removidas, caso o usuario tenha isso configurado. |
---|
| 1434 | msgs_to_remove[ msg_info.original_folder ] = msgs_to_remove[ msg_info.original_folder ] || []; |
---|
| 1435 | msgs_to_remove[ msg_info.original_folder ].push( msg_info.original_id ); |
---|
| 1436 | } |
---|
| 1437 | |
---|
| 1438 | if (preferences.keep_archived_messages == 0) { |
---|
| 1439 | //Remove as mensagens |
---|
| 1440 | for( var folder in msgs_to_remove ){ |
---|
| 1441 | if(folder != 'undefined') |
---|
| 1442 | delete_msgs(folder, msgs_to_remove[folder],'null',false,true); |
---|
| 1443 | } |
---|
| 1444 | } |
---|
| 1445 | |
---|
| 1446 | if( !has_local_messages_before && expresso_local_messages.has_local_mails() ) |
---|
| 1447 | ttreeBox.update_folder(); |
---|
| 1448 | else |
---|
| 1449 | update_menu(); |
---|
| 1450 | } |
---|
| 1451 | |
---|
[5172] | 1452 | function action_msg_selected_from_search(aba, evento){ |
---|
| 1453 | if(evento == "delete") |
---|
| 1454 | move_search_msgs(aba,'INBOX/Trash', 'Trash', 'delete'); |
---|
| 1455 | } |
---|
| 1456 | |
---|
| 1457 | function get_all_messages_search(){ |
---|
| 1458 | var aba = document.getElementById('content_id_'+currentTab); |
---|
| 1459 | var messages = ""; |
---|
| 1460 | jQuery(function() { |
---|
| 1461 | jQuery("#"+aba.id+" tr").each(function(i, main_list) { |
---|
| 1462 | messages += main_list.id.replace(/_[a-zA-Z0-9]+/,"") + ',' ; |
---|
| 1463 | }); |
---|
| 1464 | |
---|
| 1465 | }); |
---|
| 1466 | if(messages.indexOf(',') == 0) |
---|
| 1467 | messages = messages.substring(1,(messages.length)); |
---|
| 1468 | return messages.substring(0,(messages.length-1)); |
---|
| 1469 | } |
---|
| 1470 | |
---|
| 1471 | function get_selected_messages_search(){ |
---|
| 1472 | var aba = document.getElementById('content_id_'+currentTab); |
---|
| 1473 | var selected_messages = ""; |
---|
| 1474 | jQuery("#"+aba.id+" tr").each(function(i, main_list) { |
---|
| 1475 | var check_box = main_list.firstChild.firstChild; |
---|
| 1476 | if(check_box && check_box.checked) { |
---|
| 1477 | selected_messages += main_list.id.replace(/_[a-zA-Z0-9]+/,"") + ',' ; |
---|
| 1478 | }; |
---|
| 1479 | }); |
---|
| 1480 | |
---|
| 1481 | if (selected_messages != ""){ |
---|
| 1482 | if(selected_messages.indexOf(',') == 0) |
---|
| 1483 | selected_messages = selected_messages.substring(1,(selected_messages.length)); |
---|
| 1484 | selected_messages = selected_messages.substring(0,(selected_messages.length-1)); |
---|
| 1485 | return selected_messages; |
---|
| 1486 | }else{ |
---|
| 1487 | return false; |
---|
| 1488 | } |
---|
| 1489 | } |
---|
| 1490 | |
---|
[5584] | 1491 | function get_selected_messages_search_role(){ |
---|
| 1492 | var aba = document.getElementById('content_id_'+currentTab); |
---|
| 1493 | var selected_messages = ""; |
---|
[5588] | 1494 | jQuery("#"+aba.id+" tr").each(function(i, main_list) { |
---|
| 1495 | var check_box = main_list.firstChild.firstChild; |
---|
[6033] | 1496 | if(check_box && check_box.checked && check_box.id != 'chk_box_select_all_messages_search') { |
---|
[5588] | 1497 | selected_messages += main_list.role + ',' ; |
---|
| 1498 | }; |
---|
| 1499 | }); |
---|
| 1500 | |
---|
[5584] | 1501 | if (selected_messages != ""){ |
---|
| 1502 | if(selected_messages.indexOf(',') == 0) |
---|
| 1503 | selected_messages = selected_messages.substring(1,(selected_messages.length)); |
---|
| 1504 | selected_messages = selected_messages.substring(0,(selected_messages.length-1)); |
---|
| 1505 | return selected_messages; |
---|
| 1506 | }else{ |
---|
| 1507 | return false; |
---|
| 1508 | } |
---|
| 1509 | } |
---|
[5172] | 1510 | |
---|
[5922] | 1511 | function get_selected_messages_shortcut(){ |
---|
| 1512 | var main; |
---|
| 1513 | try{ |
---|
| 1514 | main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; |
---|
| 1515 | }catch(e){ |
---|
| 1516 | }; |
---|
| 1517 | |
---|
| 1518 | if (! main) |
---|
| 1519 | main = Element("tbody_box_"+numBox); |
---|
| 1520 | |
---|
| 1521 | if (! main) |
---|
| 1522 | main = Element("tbody_box"); |
---|
| 1523 | |
---|
| 1524 | // Get all TR (messages) in tBody. |
---|
| 1525 | var main_list = main.childNodes; |
---|
| 1526 | var selected_messages_by_shortcuts = ''; |
---|
| 1527 | var j = 0; |
---|
| 1528 | for (j; j<(main_list.length); j++) |
---|
| 1529 | { |
---|
| 1530 | |
---|
| 1531 | if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') ) |
---|
| 1532 | { |
---|
| 1533 | selected_messages_by_shortcuts += main_list[j].id + ','; |
---|
| 1534 | } |
---|
| 1535 | |
---|
| 1536 | } |
---|
| 1537 | selected_messages_by_shortcuts = selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1)); |
---|
| 1538 | |
---|
| 1539 | return selected_messages_by_shortcuts; |
---|
| 1540 | |
---|
| 1541 | } |
---|
| 1542 | |
---|
[2] | 1543 | function get_selected_messages(){ |
---|
[4812] | 1544 | var main; |
---|
[3062] | 1545 | try{ |
---|
| 1546 | main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; |
---|
| 1547 | }catch(e){ |
---|
| 1548 | }; |
---|
| 1549 | |
---|
[345] | 1550 | if (! main) |
---|
[4810] | 1551 | main = Element("tbody_box_"+numBox); |
---|
| 1552 | |
---|
| 1553 | if (! main) |
---|
[345] | 1554 | main = Element("tbody_box"); |
---|
[320] | 1555 | |
---|
[2] | 1556 | // Get all TR (messages) in tBody. |
---|
[4812] | 1557 | var main_list = main.childNodes; |
---|
[320] | 1558 | |
---|
[5134] | 1559 | var _tab_prefix = getTabPrefix(); |
---|
[2] | 1560 | var selected_messages = ''; |
---|
[163] | 1561 | var selected_messages_by_shortcuts = ''; |
---|
[2] | 1562 | var j = 0; |
---|
[163] | 1563 | for (j; j<(main_list.length); j++) |
---|
| 1564 | { |
---|
[3724] | 1565 | |
---|
[5922] | 1566 | if ( (!isNaN(parseInt(numBox))) && (numBox == 0)) { |
---|
| 1567 | check_box = Element("check_box_message_" + main_list[j].id); |
---|
| 1568 | } else { |
---|
| 1569 | id_mensagem = main_list[j].id.split('_'); |
---|
| 1570 | check_box = Element("search_" + numBox + "_check_box_message_" + id_mensagem[0]); |
---|
| 1571 | } |
---|
[5134] | 1572 | |
---|
[5922] | 1573 | if ( (check_box) && (check_box.checked) ) |
---|
| 1574 | selected_messages += main_list[j].id + ','; |
---|
[3035] | 1575 | |
---|
[163] | 1576 | if (preferences.use_shortcuts == '1') |
---|
| 1577 | { |
---|
| 1578 | if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') ) |
---|
| 1579 | { |
---|
| 1580 | selected_messages_by_shortcuts += main_list[j].id + ','; |
---|
| 1581 | } |
---|
| 1582 | } |
---|
[2] | 1583 | } |
---|
| 1584 | selected_messages = selected_messages.substring(0,(selected_messages.length-1)); |
---|
[3035] | 1585 | |
---|
[5134] | 1586 | |
---|
| 1587 | /* Verifica se está na tela de pesquisa. */ |
---|
| 1588 | if(selected_messages.indexOf("_") != -1) |
---|
| 1589 | { |
---|
| 1590 | results_search_messages = selected_messages; |
---|
| 1591 | /* Retira a informação da aba */ |
---|
| 1592 | selected_messages = selected_messages.substring(0,selected_messages.indexOf("_")); |
---|
| 1593 | } |
---|
| 1594 | |
---|
| 1595 | |
---|
[163] | 1596 | if (preferences.use_shortcuts == '1') |
---|
| 1597 | { |
---|
| 1598 | selected_messages_by_shortcuts = selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1)); |
---|
[3035] | 1599 | |
---|
[163] | 1600 | var array_selected_messages_by_shortcuts = selected_messages_by_shortcuts.split(","); |
---|
| 1601 | var array_selected_messages = selected_messages.split(","); |
---|
[3035] | 1602 | |
---|
[5922] | 1603 | if ((array_selected_messages.length == 0) && (array_selected_messages_by_shortcuts.length > 0)) |
---|
[163] | 1604 | { |
---|
| 1605 | return selected_messages_by_shortcuts; |
---|
| 1606 | } |
---|
| 1607 | } |
---|
[3035] | 1608 | |
---|
[2] | 1609 | if (selected_messages == '') |
---|
| 1610 | return false; |
---|
| 1611 | else |
---|
| 1612 | return selected_messages; |
---|
| 1613 | } |
---|
| 1614 | |
---|
[689] | 1615 | function replaceAll(string, token, newtoken) { |
---|
| 1616 | while (string.indexOf(token) != -1) { |
---|
| 1617 | string = string.replace(token, newtoken); |
---|
| 1618 | } |
---|
| 1619 | return string; |
---|
| 1620 | } |
---|
| 1621 | |
---|
[603] | 1622 | function new_message_to(email) { |
---|
| 1623 | var new_border_ID = new_message('new','null'); |
---|
| 1624 | document.getElementById("to_" + new_border_ID).value=email; |
---|
| 1625 | } |
---|
| 1626 | |
---|
[2] | 1627 | function new_message(type, border_ID){ |
---|
[5083] | 1628 | if(RichTextEditor.editorReady === false) return false; |
---|
| 1629 | |
---|
| 1630 | RichTextEditor.editorReady = false; |
---|
| 1631 | |
---|
[5229] | 1632 | |
---|
[3035] | 1633 | if (Element('show_img_link_'+border_ID)) |
---|
| 1634 | { |
---|
| 1635 | show_msg_img(border_ID.match(/^\d*/)[0], Element('input_folder_'+border_ID).value); |
---|
| 1636 | } |
---|
[5211] | 1637 | var new_border_ID = draw_new_message(parseInt(border_ID.replace('_r',''))); |
---|
| 1638 | |
---|
| 1639 | if(typeof(openTab.type[new_border_ID]) != "undefined") { |
---|
[3143] | 1640 | if(tabTypes[type] == openTab.type[new_border_ID]) { |
---|
[4757] | 1641 | if (type != 'edit') |
---|
| 1642 | { |
---|
[5911] | 1643 | delete_border(currentTab); |
---|
| 1644 | new_border_ID = draw_new_message(parseInt(border_ID)); |
---|
[4757] | 1645 | } |
---|
[3143] | 1646 | } else { |
---|
[4803] | 1647 | var a_types = {6 : get_lang("Forward"),7 : get_lang("Reply"), |
---|
[3147] | 1648 | 8 : get_lang("Reply to all with history"), |
---|
| 1649 | 9 : get_lang("Reply without history"), |
---|
| 1650 | 10: get_lang("Reply to all without history")}; |
---|
[5134] | 1651 | if(new_border_ID != 0) |
---|
[3147] | 1652 | if(!confirm(get_lang("Your message to %1 has not been saved or sent. "+ |
---|
| 1653 | "To %2 will be necessary open it again. Discard your message?", |
---|
| 1654 | a_types[openTab.type[new_border_ID]].toUpperCase(), |
---|
| 1655 | a_types[tabTypes[type]].toUpperCase()))){ |
---|
| 1656 | return new_border_ID; |
---|
| 1657 | } else { |
---|
| 1658 | delete_border(currentTab); |
---|
| 1659 | new_border_ID = draw_new_message(parseInt(border_ID)); |
---|
| 1660 | } |
---|
[3143] | 1661 | } |
---|
| 1662 | } |
---|
[5134] | 1663 | if (new_border_ID == 'maximo'){ |
---|
| 1664 | RichTextEditor.editorReady = true; |
---|
| 1665 | return false; |
---|
| 1666 | } |
---|
[352] | 1667 | if (new_border_ID == false) |
---|
[3075] | 1668 | { |
---|
[5083] | 1669 | RichTextEditor.editorReady = true; |
---|
| 1670 | setTimeout('new_message(\''+type+'\',\''+border_ID+'\');',500); |
---|
[3035] | 1671 | return false; |
---|
[3075] | 1672 | } |
---|
| 1673 | openTab.type[new_border_ID] = tabTypes[type]; |
---|
[605] | 1674 | |
---|
[63] | 1675 | // Salva a pasta da mensagem respondida ou encaminhada: |
---|
| 1676 | var folder_message = Element("input_folder_"+border_ID); |
---|
| 1677 | if(folder_message) { |
---|
[3035] | 1678 | var input_current_folder = document.createElement('input'); |
---|
[63] | 1679 | input_current_folder.id = "new_input_folder_"+border_ID; |
---|
| 1680 | input_current_folder.name = "input_folder"; |
---|
| 1681 | input_current_folder.type = "hidden"; |
---|
| 1682 | input_current_folder.value = folder_message.value; |
---|
| 1683 | Element("content_id_" + new_border_ID).appendChild(input_current_folder); |
---|
| 1684 | }//Fim. |
---|
[2] | 1685 | var title = ''; |
---|
| 1686 | data = []; |
---|
[5193] | 1687 | |
---|
[5221] | 1688 | |
---|
[5949] | 1689 | if (Element("from_" + border_ID)){ |
---|
| 1690 | if (document.getElementById("reply_to_" + border_ID)){ |
---|
[320] | 1691 | data.to = document.getElementById("reply_to_values_" + border_ID).value; |
---|
| 1692 | data.to = data.to.replace(/</gi,"<"); |
---|
| 1693 | data.to = data.to.replace(/>/gi,">"); |
---|
[2] | 1694 | } |
---|
| 1695 | else { |
---|
[5193] | 1696 | if (document.getElementById("sender_values_"+border_ID)) |
---|
[320] | 1697 | { |
---|
[5193] | 1698 | data.to = document.getElementById("sender_values_"+border_ID).value; |
---|
[320] | 1699 | data.to = data.to.replace(/</gi,"<"); |
---|
| 1700 | data.to = data.to.replace(/>/gi,">"); |
---|
| 1701 | } |
---|
[5221] | 1702 | else if(document.getElementById("from_values_"+border_ID)) { |
---|
| 1703 | data.to = document.getElementById("from_values_"+border_ID).value; |
---|
| 1704 | data.to = data.to.replace(/</gi,"<"); |
---|
| 1705 | data.to = data.to.replace(/>/gi,">"); |
---|
| 1706 | } |
---|
[3035] | 1707 | } |
---|
[320] | 1708 | if (document.getElementById("to_values_" + border_ID)){ |
---|
| 1709 | data.to_all = document.getElementById("to_values_" + border_ID).value; |
---|
[5229] | 1710 | data.to_all_alternative = document.getElementById("user_email_alternative").value; |
---|
[3035] | 1711 | data.to_all = data.to_all.replace(/\n/gi," "); |
---|
[320] | 1712 | data.to_all = data.to_all.replace(/</gi,"<"); |
---|
| 1713 | data.to_all = data.to_all.replace(/>/gi,">"); |
---|
| 1714 | var _array_to_all = data.to_all.split(","); |
---|
[5229] | 1715 | var _array_to_alternative = data.to_all_alternative.split(","); |
---|
[3035] | 1716 | } |
---|
[2] | 1717 | } |
---|
| 1718 | if (document.getElementById("cc_" + border_ID)){ |
---|
| 1719 | data.cc = document.getElementById("cc_values_" + border_ID).value; |
---|
| 1720 | data.cc = data.cc.replace(/</gi,"<"); |
---|
| 1721 | data.cc = data.cc.replace(/>/gi,">"); |
---|
[5158] | 1722 | var _array_cc = data.cc.split(","); |
---|
[2] | 1723 | } |
---|
[1638] | 1724 | if (document.getElementById("cco_" + border_ID)){ |
---|
| 1725 | data.cco = document.getElementById("cco_values_" + border_ID).value; |
---|
| 1726 | data.cco = data.cco.replace(/</gi,"<"); |
---|
| 1727 | data.cco = data.cco.replace(/>/gi,">"); |
---|
| 1728 | } |
---|
[5389] | 1729 | if ($("#subject_" + border_ID)) |
---|
| 1730 | data.subject = $("#subject_" + border_ID).text(); |
---|
[5134] | 1731 | if(data.subject == get_lang("(no subject) ")) |
---|
| 1732 | data.subject = ''; |
---|
[2] | 1733 | if (document.getElementById("body_" + border_ID)) |
---|
| 1734 | data.body = document.getElementById("body_" + border_ID).innerHTML; |
---|
| 1735 | if (Element('date_' + border_ID)){ |
---|
| 1736 | data.date = Element('date_' + border_ID).innerHTML; |
---|
| 1737 | } |
---|
| 1738 | if (Element('date_day_' + border_ID)){ |
---|
| 1739 | data.date_day = Element('date_day_' + border_ID).value; |
---|
| 1740 | } |
---|
| 1741 | if (Element('date_hour_' + border_ID)){ |
---|
| 1742 | data.date_hour = Element('date_hour_' + border_ID).value; |
---|
| 1743 | } |
---|
[5134] | 1744 | |
---|
[5083] | 1745 | var signature = RichTextEditor.getSignatureDefault(); |
---|
[5134] | 1746 | |
---|
| 1747 | if(type!="new" && type!="edit" && document.getElementById("is_local_"+border_ID) != null) |
---|
[3387] | 1748 | data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false; |
---|
[5911] | 1749 | |
---|
| 1750 | if(typeof($.fn.elastic) == "undefined"){ |
---|
| 1751 | $.lazy({ |
---|
| 1752 | src: '../prototype/plugins/jquery-elastic/jquery.elastic.source.js', |
---|
| 1753 | name: 'elastic' |
---|
| 1754 | }); |
---|
| 1755 | } |
---|
| 1756 | var content = $("#content_id_"+new_border_ID); |
---|
[6060] | 1757 | |
---|
[5911] | 1758 | |
---|
| 1759 | switch(type){ |
---|
[3035] | 1760 | case "reply_without_history": |
---|
[5083] | 1761 | RichTextEditor.replyController = true; //Seta o editor como modo reply |
---|
[5911] | 1762 | content.find('[name="input_to"]').val(data.to); |
---|
[6135] | 1763 | title = "Re: " + html_entities(data.subject); |
---|
[5911] | 1764 | content.find(".subject").val("Re: " + data.subject); |
---|
[6060] | 1765 | useOriginalAttachments(new_border_ID,border_ID); |
---|
| 1766 | content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); |
---|
[5134] | 1767 | |
---|
[325] | 1768 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
[5083] | 1769 | if (preferences.use_signature == "1"){ |
---|
[5911] | 1770 | RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature ,true) ; |
---|
| 1771 | } |
---|
[2] | 1772 | break; |
---|
| 1773 | case "reply_with_history": |
---|
[5193] | 1774 | |
---|
[5083] | 1775 | RichTextEditor.replyController = true; //Seta o editor como modo reply |
---|
[6135] | 1776 | title = "Re: " + html_entities(data.subject); |
---|
[5911] | 1777 | content.find(".subject").val("Re: " + data.subject); |
---|
| 1778 | content.find('[name="input_to"]').val(data.to); |
---|
[6060] | 1779 | content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); |
---|
[5620] | 1780 | |
---|
[6056] | 1781 | block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); |
---|
| 1782 | |
---|
[5620] | 1783 | useOriginalAttachments(new_border_ID,border_ID); |
---|
| 1784 | |
---|
[325] | 1785 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
[5962] | 1786 | if (preferences.use_signature == "1"){ |
---|
| 1787 | RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>' + block_quoted_body,true); |
---|
| 1788 | }else{ |
---|
[5083] | 1789 | RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+ block_quoted_body,true); |
---|
[5962] | 1790 | } |
---|
[2] | 1791 | break; |
---|
| 1792 | case "reply_to_all_without_history": |
---|
[5083] | 1793 | RichTextEditor.replyController = true; //Seta o editor como modo reply |
---|
[320] | 1794 | // delete user email from to_all array. |
---|
| 1795 | data.to_all = new Array(); |
---|
[5408] | 1796 | data.to_all = removeUserEmail(_array_to_all); |
---|
[5257] | 1797 | data.to_all = removeAlternative(data.to_all,_array_to_alternative); |
---|
[6060] | 1798 | content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); |
---|
[5257] | 1799 | |
---|
[320] | 1800 | data.to_all = data.to_all.join(","); |
---|
| 1801 | |
---|
[6135] | 1802 | title = "Re: " + html_entities(data.subject); |
---|
[5911] | 1803 | content.find(".subject").val("Re: " + data.subject); |
---|
[5408] | 1804 | |
---|
| 1805 | if (data.to.indexOf(Element("user_email").value) > 0 ) |
---|
[5911] | 1806 | content.find('[name="input_to"]').val(data.to_all); |
---|
[5408] | 1807 | else |
---|
[5911] | 1808 | content.find('[name="input_to"]').val(data.to + ',' + data.to_all); |
---|
| 1809 | |
---|
[2] | 1810 | if (data.cc){ |
---|
[5229] | 1811 | data.cc = new Array(); |
---|
[5408] | 1812 | data.cc = removeUserEmail(_array_cc); |
---|
[5257] | 1813 | data.cc = removeAlternative(data.cc,_array_to_alternative); |
---|
[5417] | 1814 | if (data.cc != get_lang("undisclosed-recipient")) |
---|
| 1815 | data.cc = data.cc.join(","); |
---|
| 1816 | else |
---|
[5911] | 1817 | data.cc = ""; |
---|
| 1818 | if(data.cc != ""){ |
---|
| 1819 | content.find('[name="input_cc"]').val(data.cc); |
---|
[6129] | 1820 | input_binds(content.find('[name="input_cc"]'), new_border_ID); |
---|
[5931] | 1821 | content.find(".cc-tr").show();//cc-button |
---|
[5417] | 1822 | //document.getElementById("a_cc_link" + new_border_ID).value = data.cc; |
---|
[5911] | 1823 | content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); |
---|
| 1824 | content.find(".cc-button").find("span").html("Remover CC"); |
---|
| 1825 | content.find('[name="input_cc"]').elastic().unbind('blur'); |
---|
| 1826 | content.find('[name="input_cc"]').trigger("update"); |
---|
[5417] | 1827 | } |
---|
[2] | 1828 | } |
---|
[5620] | 1829 | |
---|
[5911] | 1830 | useOriginalAttachments(new_border_ID,border_ID); |
---|
[5962] | 1831 | if (preferences.use_signature == "1"){ |
---|
[5911] | 1832 | RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature,true); |
---|
[5962] | 1833 | } |
---|
[5911] | 1834 | |
---|
[2] | 1835 | break; |
---|
| 1836 | case "reply_to_all_with_history": |
---|
[5083] | 1837 | RichTextEditor.replyController = true; //Seta o editor como modo reply |
---|
[5408] | 1838 | //delete user email from to_all array. |
---|
[320] | 1839 | data.to_all = new Array(); |
---|
[5408] | 1840 | data.to_all = removeUserEmail(_array_to_all); |
---|
[5257] | 1841 | data.to_all = removeAlternative(data.to_all,_array_to_alternative); |
---|
[6060] | 1842 | content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); |
---|
[5408] | 1843 | |
---|
[5229] | 1844 | if (data.to_all != get_lang("undisclosed-recipient")) |
---|
| 1845 | data.to_all = data.to_all.join(","); |
---|
| 1846 | else |
---|
[4122] | 1847 | data.to_all = ""; |
---|
[6135] | 1848 | title = "Re: " + html_entities(data.subject); |
---|
[5229] | 1849 | |
---|
[5408] | 1850 | if (data.to.indexOf(Element("user_email").value) > 0 ) |
---|
[5911] | 1851 | content.find('[name="input_to"]').val(data.to_all); |
---|
[5408] | 1852 | else |
---|
[5911] | 1853 | content.find('[name="input_to"]').val(data.to + ',' + data.to_all); |
---|
[2] | 1854 | if (data.cc){ |
---|
[5408] | 1855 | data.cc = new Array(); |
---|
| 1856 | data.cc = removeUserEmail(_array_cc); |
---|
[5257] | 1857 | data.cc = removeAlternative(data.cc,_array_to_alternative); |
---|
[5408] | 1858 | if (data.cc != get_lang("undisclosed-recipient")) |
---|
[5229] | 1859 | data.cc = data.cc.join(","); |
---|
[5408] | 1860 | else |
---|
[5229] | 1861 | data.cc = ""; |
---|
[5911] | 1862 | if(data.cc != ""){ |
---|
| 1863 | content.find('[name="input_cc"]').val(data.cc); |
---|
[6106] | 1864 | input_binds(content.find('[name="input_cc"]'), new_border_ID); |
---|
[5911] | 1865 | content.find(".cc-tr").show(); |
---|
| 1866 | content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); |
---|
| 1867 | content.find(".cc-button").find("span").html("Remover CC"); |
---|
| 1868 | content.find('[name="input_cc"]').elastic().unbind('blur'); |
---|
| 1869 | content.find('[name="input_cc"]').trigger("update"); |
---|
[5417] | 1870 | } |
---|
[2] | 1871 | } |
---|
[5911] | 1872 | content.find(".subject").val("Re: " + data.subject); |
---|
[6056] | 1873 | |
---|
[2] | 1874 | block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); |
---|
[5911] | 1875 | |
---|
[6056] | 1876 | useOriginalAttachments(new_border_ID,border_ID); |
---|
| 1877 | |
---|
[5962] | 1878 | if (preferences.use_signature == "1"){ |
---|
[5973] | 1879 | RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div><div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ block_quoted_body,true); |
---|
[5962] | 1880 | }else{ |
---|
[5911] | 1881 | RichTextEditor.setInitData(new_border_ID,block_quoted_body,true); |
---|
[5962] | 1882 | } |
---|
[5911] | 1883 | |
---|
[2] | 1884 | break; |
---|
| 1885 | case "forward": |
---|
[6135] | 1886 | title = "Fw: " + html_entities(data.subject); |
---|
[5911] | 1887 | content.find(".subject").val("Fw: " + data.subject); |
---|
[2] | 1888 | var divFiles = Element("divFiles_"+new_border_ID); |
---|
[1711] | 1889 | var campo_arquivo; |
---|
[6060] | 1890 | content.find('[name="msg_forward_from"]').val($("#msg_number_" + border_ID).val()); |
---|
[5620] | 1891 | |
---|
| 1892 | if (Element("attachments_" + border_ID)) |
---|
[5626] | 1893 | addOriginalAttachments(new_border_ID,border_ID); |
---|
[5620] | 1894 | |
---|
[325] | 1895 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
[5962] | 1896 | if (preferences.use_signature == "1"){ |
---|
[5973] | 1897 | $("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)); |
---|
[5962] | 1898 | RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)); |
---|
| 1899 | content.find(".to").focus(); |
---|
| 1900 | } |
---|
| 1901 | else{ |
---|
| 1902 | RichTextEditor.setInitData(new_border_ID,make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)); |
---|
[5976] | 1903 | $("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>'+make_forward_body(data.body, data.to, data.date, data.subject, data.to_all, data.cc)); |
---|
[5962] | 1904 | content.find(".to").focus(); |
---|
| 1905 | } |
---|
[5485] | 1906 | |
---|
[2] | 1907 | break; |
---|
| 1908 | case "new": |
---|
| 1909 | title = get_lang("New Message"); |
---|
| 1910 | if(Element('msg_number').value) { |
---|
| 1911 | var _to = Element('msg_number').value; |
---|
[3035] | 1912 | 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}\])$/; |
---|
[2] | 1913 | if(!reEmail.test(_to)){ |
---|
| 1914 | var array_contacts = contacts.split(','); |
---|
| 1915 | for(i = 0; i < array_contacts.length;i++) { |
---|
| 1916 | if(array_contacts[i].lastIndexOf(_to) != "-1"){ |
---|
| 1917 | var _group = array_contacts[i].split(";"); |
---|
| 1918 | _to = '"'+_group[0]+'" <'+_group[1]+'>'; |
---|
| 1919 | break; |
---|
| 1920 | } |
---|
| 1921 | } |
---|
| 1922 | } |
---|
[5911] | 1923 | content.find('[name="input_to"]').val(_to +','); |
---|
[2] | 1924 | Element('msg_number').value = ''; |
---|
| 1925 | } |
---|
[5083] | 1926 | |
---|
[325] | 1927 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
[5962] | 1928 | if (preferences.use_signature == "1"){ |
---|
[5973] | 1929 | $("#body_"+new_border_ID).val('<div><br type="_moz"></div><div><br type="_moz"></div>' + signature); |
---|
[5083] | 1930 | RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature); |
---|
[5962] | 1931 | content.find(".to").focus(); |
---|
| 1932 | } |
---|
[5485] | 1933 | else |
---|
[5911] | 1934 | content.find('[name="input_to"]').focus(); |
---|
[2] | 1935 | break; |
---|
| 1936 | case "edit": |
---|
[605] | 1937 | openTab.imapBox[new_border_ID] = folder_message.value; |
---|
[271] | 1938 | document.getElementById('font_border_id_'+new_border_ID).innerHTML = data.subject; |
---|
[6135] | 1939 | title = "Edição: "+ html_entities(data.subject); |
---|
[3770] | 1940 | |
---|
[2] | 1941 | data.to = Element("to_values_" + border_ID).value; |
---|
[3770] | 1942 | if( data.to != get_lang("without destination") ) { |
---|
| 1943 | data.to = data.to.replace(/</gi,"<"); |
---|
| 1944 | data.to = data.to.replace(/>/gi,">"); |
---|
| 1945 | } else { |
---|
| 1946 | data.to = ""; |
---|
| 1947 | } |
---|
[3035] | 1948 | |
---|
[5911] | 1949 | content.find('[name="input_to"]').val(data.to); |
---|
[2] | 1950 | if (data.cc){ |
---|
[5134] | 1951 | data.cc = data.cc.replace(/</gi,"<"); |
---|
| 1952 | data.cc = data.cc.replace(/>/gi,">"); |
---|
[5911] | 1953 | content.find('[name="input_cc"]').val(data.cc); |
---|
[6129] | 1954 | input_binds(content.find('[name="input_cc"]'), new_border_ID); |
---|
[5911] | 1955 | content.find(".cc-tr").show(); |
---|
| 1956 | content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); |
---|
| 1957 | content.find(".cc-button").find("span").html(get_lang('Remove CC')); |
---|
| 1958 | content.find('[name="input_cc"]').elastic().unbind('blur'); |
---|
| 1959 | content.find('[name="input_cc"]').trigger("update"); |
---|
[2] | 1960 | } |
---|
[1638] | 1961 | if (data.cco){ |
---|
[5911] | 1962 | if(content.find('[name="input_cco"]').length){ |
---|
| 1963 | content.find('[name="input_cco"]').val(data.cco); |
---|
| 1964 | content.find(".cco-tr").show(); |
---|
| 1965 | content.find(".cco-button").toggleClass("expressomail-button-icon-ative"); |
---|
| 1966 | content.find(".cco-button").find("span").html(get_lang('Remove CCo')); |
---|
| 1967 | content.find('[name="input_cco"]').elastic().unbind('blur'); |
---|
| 1968 | content.find('[name="input_cco"]').trigger("update"); |
---|
| 1969 | } |
---|
[1638] | 1970 | } |
---|
[5911] | 1971 | content.find(".subject").val(data.subject); |
---|
[3798] | 1972 | |
---|
[5911] | 1973 | if( $("#disposition_notification_" + border_ID).length ){ |
---|
| 1974 | content.find('[name="input_return_receipt"]').attr("checked", true); |
---|
| 1975 | content.find(".return-recept").toggleClass("expressomail-button-icon-ative"); |
---|
[5417] | 1976 | //Element("return_receipt_" + new_border_ID).checked = true; |
---|
| 1977 | } |
---|
[3035] | 1978 | |
---|
[3798] | 1979 | var element_important_message = Element("important_message_" + new_border_ID); |
---|
| 1980 | if(element_important_message) { |
---|
[5134] | 1981 | |
---|
[5911] | 1982 | if($("#disposition_important_" + border_ID).length){ |
---|
| 1983 | content.find('[name="input_important_message"]').attr("checked", true); |
---|
| 1984 | content.find(".important").toggleClass("expressomail-button-icon-ative"); |
---|
[5417] | 1985 | } |
---|
[3798] | 1986 | } |
---|
| 1987 | |
---|
[5620] | 1988 | if (Element("attachments_" + border_ID)) |
---|
[5911] | 1989 | addOriginalAttachments(new_border_ID,border_ID); |
---|
[5172] | 1990 | RichTextEditor.setInitData(new_border_ID, data.body, 'edit'); |
---|
[6194] | 1991 | |
---|
| 1992 | uidsSave[new_border_ID].push(new_border_ID); |
---|
| 1993 | close_delete(border_ID); |
---|
| 1994 | |
---|
[2] | 1995 | break; |
---|
| 1996 | default: |
---|
| 1997 | } |
---|
[5428] | 1998 | |
---|
[5911] | 1999 | content.find('[name="input_to"]').trigger("update"); |
---|
| 2000 | var txtarea = $('#body_'+new_border_ID); |
---|
[5470] | 2001 | var height = document.body.scrollHeight - 330; |
---|
[5911] | 2002 | txtarea.css("overflowY","auto"); |
---|
| 2003 | txtarea.css("height",height); |
---|
[5992] | 2004 | $("#border_id_" + new_border_ID).attr("title", title); |
---|
[3372] | 2005 | set_border_caption("border_id_" + new_border_ID, title); |
---|
[5134] | 2006 | resizeWindow(); |
---|
[603] | 2007 | return new_border_ID; //Preciso retornar o ID da nova mensagem. |
---|
[2] | 2008 | } |
---|
| 2009 | |
---|
[5408] | 2010 | //Remove o email do usuario ao responder a todos |
---|
| 2011 | function removeUserEmail(emailList){ |
---|
| 2012 | var userEmail = Element("user_email").value; |
---|
| 2013 | var array_emails = Array(); |
---|
| 2014 | var j = 0; |
---|
| 2015 | for (var i=0;i<emailList.length;i++){ |
---|
| 2016 | if (emailList[i].indexOf(userEmail) < 0){ |
---|
| 2017 | array_emails[j++] = emailList[i]; |
---|
| 2018 | } |
---|
| 2019 | } |
---|
| 2020 | return array_emails; |
---|
| 2021 | } |
---|
| 2022 | |
---|
| 2023 | //Remove os emails alternativos ao responder a todos |
---|
[5257] | 2024 | function removeAlternative(value_to_all, _array_to_alternative){ |
---|
| 2025 | for(i = 0; i < _array_to_alternative.length; i++) { |
---|
| 2026 | for(k = 0; k < value_to_all.length; k++){ |
---|
| 2027 | if(value_to_all[k].match(/<([^<]*)>[\s]*$/)){ |
---|
| 2028 | if(value_to_all[k].match(/<([^<]*)>[\s]*$/)[1].toLowerCase() == _array_to_alternative[i].toLowerCase()){ |
---|
| 2029 | value_to_all.splice( k , 1); |
---|
| 2030 | k--; |
---|
| 2031 | } |
---|
| 2032 | }else if(value_to_all[k].replace(/^\s+|\s+$/g,"").toLowerCase() == _array_to_alternative[i].toLowerCase()){ |
---|
| 2033 | value_to_all.splice( k , 1); |
---|
| 2034 | k--; |
---|
| 2035 | } |
---|
| 2036 | } |
---|
| 2037 | } |
---|
| 2038 | return value_to_all; |
---|
| 2039 | } |
---|
| 2040 | |
---|
[5620] | 2041 | function useOriginalAttachments(new_border_ID,old_id_border) |
---|
[5626] | 2042 | { |
---|
[5620] | 2043 | if (Element("attachments_" + old_id_border)) |
---|
| 2044 | { |
---|
[5626] | 2045 | var fileUploadMSG = $('#fileupload_msg'+new_border_ID); |
---|
| 2046 | var attachments = document.getElementById("attachments_" + old_id_border).getElementsByTagName("a"); |
---|
[6056] | 2047 | var imagens = block_quoted_body.match(/<img[^>]*>/g); |
---|
| 2048 | var arrayAttachments = []; |
---|
| 2049 | var arrayAttachmentsA = []; |
---|
[5626] | 2050 | |
---|
[6056] | 2051 | //------------------- |
---|
| 2052 | for (var i = 0; i < attachments.length; i++){ |
---|
[5626] | 2053 | if((attachments[i].tagName=="SPAN") || (attachments[i].tagName=="IMG") || ((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1))) |
---|
| 2054 | continue; |
---|
[5620] | 2055 | |
---|
[5626] | 2056 | var arrayAtt = attachments[i].href.replace("javascript:download_attachments(", "").replace(")", "").split(','); |
---|
| 2057 | var att = new Object(); |
---|
| 2058 | var regex = new RegExp( "'", "g" ); |
---|
| 2059 | att.folder = arrayAtt[0].replace(regex,""); |
---|
| 2060 | att.uid = arrayAtt[1].replace(regex,""); |
---|
| 2061 | att.part = arrayAtt[3].replace(regex,""); |
---|
| 2062 | att.type = 'imapPart'; |
---|
[6056] | 2063 | var idATT = JSON.stringify(att); |
---|
| 2064 | |
---|
| 2065 | if(block_quoted_body.indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&msgNumber='+att.uid+'&indexPart='+att.part+'"') !== -1) |
---|
| 2066 | { |
---|
| 2067 | addAttachment( new_border_ID , idATT); |
---|
[5620] | 2068 | |
---|
[6056] | 2069 | var attach = {}; |
---|
| 2070 | attach.fileName = attachments[i].text.substring(0, attachments[i].text.lastIndexOf('(')); |
---|
[5620] | 2071 | |
---|
[6056] | 2072 | if(attach.fileName.length > 45) |
---|
| 2073 | attach.fileName = attach.fileName.substr(0, 32) + " ... " + attach.fileName.substr(attach.fileName.length-9, attach.fileName.length); |
---|
[5620] | 2074 | |
---|
[6056] | 2075 | attach.fileSize = attachments[i].text.substring(( attachments[i].text.lastIndexOf('(')+1), attachments[i].text.lastIndexOf(')')); |
---|
[5620] | 2076 | |
---|
[6056] | 2077 | var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); |
---|
| 2078 | upload.find('.status-upload').remove(); |
---|
| 2079 | upload.find('.in-progress').remove(); |
---|
| 2080 | upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>'); |
---|
| 2081 | upload.find('.button.close').button({ |
---|
| 2082 | icons: { |
---|
| 2083 | primary: "ui-icon-close" |
---|
| 2084 | }, |
---|
| 2085 | text: false |
---|
[5620] | 2086 | |
---|
[6056] | 2087 | }).click(function(){ |
---|
| 2088 | var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); |
---|
| 2089 | var content_body = RichTextEditor.getData('body_'+new_border_ID); |
---|
| 2090 | var imagens = content_body.match(/<img[^>]*>/g); |
---|
| 2091 | var att = JSON.parse(idAttach); |
---|
| 2092 | if(imagens != null) |
---|
| 2093 | { |
---|
| 2094 | for (var x = 0; x < imagens.length; x++) |
---|
| 2095 | if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&msgNumber='+att.uid+'&indexPart='+att.part) !== -1) |
---|
| 2096 | content_body = content_body.replace(imagens[x],''); |
---|
[5626] | 2097 | |
---|
[6056] | 2098 | RichTextEditor.setData('body_'+new_border_ID,content_body); |
---|
| 2099 | } |
---|
[5626] | 2100 | |
---|
[6056] | 2101 | fileUploadMSG.find('.attachments-list').find('input[value="'+idAttach+'"]'); |
---|
| 2102 | delAttachment(new_border_ID,idAttach); |
---|
| 2103 | $(this).parent().remove(); |
---|
| 2104 | }); |
---|
| 2105 | |
---|
| 2106 | fileUploadMSG.find('.attachments-list').append(upload); |
---|
| 2107 | } |
---|
| 2108 | else |
---|
| 2109 | { |
---|
| 2110 | arrayAttachments.push(idATT); |
---|
| 2111 | arrayAttachmentsA.push(attachments[i]); |
---|
| 2112 | } |
---|
[5626] | 2113 | } |
---|
[6056] | 2114 | //------------------- |
---|
| 2115 | |
---|
| 2116 | if(arrayAttachments.length > 0) |
---|
| 2117 | { |
---|
| 2118 | |
---|
[6199] | 2119 | var orignialAtt = fileUploadMSG.find('.button-files-upload').append(' <button tabindex="-1" class="message-add-original-att button small">Anexar arquivos originais</button>').find(".message-add-original-att").button(); |
---|
| 2120 | orignialAtt.click(function(event ){ |
---|
[5626] | 2121 | |
---|
[6056] | 2122 | for (var i = 0; i < arrayAttachments.length; i++){ |
---|
[5626] | 2123 | |
---|
[6056] | 2124 | var att = JSON.parse(arrayAttachments[i]); |
---|
| 2125 | addAttachment( new_border_ID , arrayAttachments[i]); |
---|
| 2126 | |
---|
| 2127 | var attach = {}; |
---|
| 2128 | attach.fileName = arrayAttachmentsA[i].text.substring(0, arrayAttachmentsA[i].text.lastIndexOf('(')); |
---|
| 2129 | |
---|
| 2130 | if(attach.fileName.length > 45) |
---|
| 2131 | attach.fileName = attach.fileName.substr(0, 32) + " ... " + attach.fileName.substr(attach.fileName.length-9, attach.fileName.length); |
---|
| 2132 | |
---|
| 2133 | attach.fileSize = arrayAttachmentsA[i].text.substring(( arrayAttachmentsA[i].text.lastIndexOf('(')+1), arrayAttachmentsA[i].text.lastIndexOf(')')); |
---|
| 2134 | |
---|
| 2135 | var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); |
---|
| 2136 | upload.find('.status-upload').remove(); |
---|
| 2137 | upload.find('.in-progress').remove(); |
---|
| 2138 | upload.append('<input type="hidden" name="fileId[]" value=\''+arrayAttachments[i]+'\'/>'); |
---|
| 2139 | upload.find('.button.close').button({ |
---|
| 2140 | icons: { |
---|
| 2141 | primary: "ui-icon-close" |
---|
| 2142 | }, |
---|
| 2143 | text: false |
---|
| 2144 | |
---|
| 2145 | }).click(function(){ |
---|
[6199] | 2146 | var idAttach = $(this).parent().parent().find('input[name="fileId[]"]').val(); |
---|
[6056] | 2147 | var content_body = RichTextEditor.getData('body_'+new_border_ID); |
---|
| 2148 | var imagens = content_body.match(/<img[^>]*>/g); |
---|
| 2149 | var att = JSON.parse(idAttach); |
---|
| 2150 | if(imagens != null) |
---|
| 2151 | { |
---|
| 2152 | for (var x = 0; x < imagens.length; x++) |
---|
| 2153 | if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&msgNumber='+att.uid+'&indexPart='+att.part) !== -1) |
---|
| 2154 | content_body = content_body.replace(imagens[x],''); |
---|
| 2155 | |
---|
| 2156 | RichTextEditor.setData('body_'+new_border_ID,content_body); |
---|
| 2157 | } |
---|
| 2158 | |
---|
| 2159 | fileUploadMSG.find('.attachments-list').find('input[value="'+idAttach+'"]'); |
---|
| 2160 | delAttachment(new_border_ID,idAttach); |
---|
| 2161 | $(this).parent().remove(); |
---|
| 2162 | }); |
---|
| 2163 | |
---|
| 2164 | fileUploadMSG.find('.attachments-list').append(upload); |
---|
| 2165 | |
---|
| 2166 | } |
---|
| 2167 | |
---|
| 2168 | $(this).remove(); |
---|
| 2169 | }); |
---|
| 2170 | } |
---|
| 2171 | |
---|
[5626] | 2172 | } |
---|
| 2173 | |
---|
| 2174 | } |
---|
| 2175 | |
---|
| 2176 | function addOriginalAttachments(new_border_ID,old_id_border) |
---|
| 2177 | { |
---|
| 2178 | var fileUploadMSG = $('#fileupload_msg'+new_border_ID); |
---|
[6113] | 2179 | var attachments = $("#attachments_" + old_id_border).find("a"); |
---|
[5626] | 2180 | for (var i = 0; i < attachments.length; i++){ |
---|
| 2181 | if((attachments[i].tagName=="SPAN") || (attachments[i].tagName=="IMG") || ((attachments[i].href.indexOf("javascript:download_local_attachment")==-1)&&(attachments[i].href.indexOf("javascript:download_attachments")==-1))) |
---|
| 2182 | continue; |
---|
| 2183 | |
---|
| 2184 | var arrayAtt = attachments[i].href.replace("javascript:download_attachments(", "").replace(")", "").split(','); |
---|
| 2185 | var att = new Object(); |
---|
| 2186 | var regex = new RegExp( "'", "g" ); |
---|
| 2187 | att.folder = arrayAtt[0].replace(regex,""); |
---|
| 2188 | att.uid = arrayAtt[1].replace(regex,""); |
---|
| 2189 | att.part = arrayAtt[3].replace(regex,""); |
---|
| 2190 | att.type = 'imapPart'; |
---|
| 2191 | var idATT = JSON.stringify(att); |
---|
| 2192 | addAttachment( new_border_ID , idATT); |
---|
| 2193 | |
---|
| 2194 | var attach = {}; |
---|
| 2195 | attach.fileName = attachments[i].text.substring(0, attachments[i].text.lastIndexOf('(')); |
---|
| 2196 | |
---|
| 2197 | if(attach.fileName.length > 45) |
---|
| 2198 | attach.fileName = attach.fileName.substr(0, 32) + " ... " + attach.fileName.substr(attach.fileName.length-9, attach.fileName.length); |
---|
| 2199 | |
---|
| 2200 | attach.fileSize = attachments[i].text.substring(( attachments[i].text.lastIndexOf('(')+1), attachments[i].text.lastIndexOf(')')); |
---|
| 2201 | |
---|
| 2202 | var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); |
---|
| 2203 | upload.find('.status-upload').remove(); |
---|
| 2204 | upload.find('.in-progress').remove(); |
---|
| 2205 | upload.find('.button.close').button({ |
---|
[5620] | 2206 | icons: { |
---|
| 2207 | primary: "ui-icon-close" |
---|
| 2208 | }, |
---|
| 2209 | text: false |
---|
| 2210 | }).click(function(){ |
---|
| 2211 | var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); |
---|
[5626] | 2212 | var content_body = RichTextEditor.getData('body_'+new_border_ID); |
---|
| 2213 | var imagens = content_body.match(/<img[^>]*>/g); |
---|
| 2214 | var att = JSON.parse(idAttach); |
---|
| 2215 | if(imagens != null) |
---|
| 2216 | { |
---|
| 2217 | for (var x = 0; x < imagens.length; x++) |
---|
| 2218 | if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&msgNumber='+att.uid+'&indexPart='+att.part) !== -1) |
---|
| 2219 | content_body = content_body.replace(imagens[x],''); |
---|
| 2220 | |
---|
| 2221 | RichTextEditor.setData('body_'+new_border_ID,content_body); |
---|
| 2222 | } |
---|
| 2223 | |
---|
[5620] | 2224 | fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]'); |
---|
| 2225 | delAttachment(new_border_ID,idAttach); |
---|
| 2226 | $(this).parent().remove(); |
---|
| 2227 | }); |
---|
[5626] | 2228 | |
---|
| 2229 | |
---|
[6113] | 2230 | upload.find("p").append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>'); |
---|
[5626] | 2231 | fileUploadMSG.find('.attachments-list').append(upload); |
---|
| 2232 | |
---|
| 2233 | } |
---|
[799] | 2234 | } |
---|
| 2235 | |
---|
[2] | 2236 | function send_message_return(data, ID){ |
---|
[5844] | 2237 | |
---|
| 2238 | if (typeof(data) == 'object' && data.load){ |
---|
| 2239 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 2240 | } |
---|
[3035] | 2241 | watch_changes_in_msg(ID); |
---|
[1035] | 2242 | |
---|
[3035] | 2243 | var sign = false; |
---|
[1035] | 2244 | var crypt = false; |
---|
[3035] | 2245 | if ((preferences.use_assinar_criptografar != '0') && (preferences.use_signature_digital_cripto != '0')){ |
---|
[1035] | 2246 | var checkSign = document.getElementById('return_digital_'+ID) |
---|
| 2247 | if (checkSign.checked){ |
---|
| 2248 | sign = true; |
---|
| 2249 | } |
---|
| 2250 | |
---|
| 2251 | var checkCript = document.getElementById('return_cripto_'+ID); |
---|
| 2252 | if (checkCript.checked){ |
---|
| 2253 | crypt = true; |
---|
| 2254 | } |
---|
| 2255 | } |
---|
| 2256 | |
---|
[3035] | 2257 | if (typeof(data) == 'object' && !data.success) |
---|
[1035] | 2258 | { |
---|
[3035] | 2259 | connector = new cConnector(); |
---|
| 2260 | connector.showProgressBar(); |
---|
[1035] | 2261 | |
---|
[3035] | 2262 | if (sign || crypt){ |
---|
| 2263 | var operation = ''; |
---|
[1035] | 2264 | if (sign){ |
---|
| 2265 | operation = 'sign'; |
---|
| 2266 | } |
---|
| 2267 | else { // crypt |
---|
[3035] | 2268 | //TODO: Colocar mensagem de erro, e finalizar o método. |
---|
[1035] | 2269 | operation = 'nop'; |
---|
| 2270 | } |
---|
[3035] | 2271 | } |
---|
[1035] | 2272 | |
---|
[3035] | 2273 | if (data.body){ |
---|
| 2274 | Element('cert_applet').doButtonClickAction(operation, ID, data.body); |
---|
| 2275 | } |
---|
| 2276 | else { |
---|
[1035] | 2277 | alert(data.error); |
---|
| 2278 | } |
---|
| 2279 | |
---|
| 2280 | return; |
---|
[3035] | 2281 | } |
---|
[485] | 2282 | if(data && data.success == true ){ |
---|
[2] | 2283 | // if send ok, set a flag as answered or forwarded |
---|
[6060] | 2284 | var msg_number_replied = $("#content_id_" + ID).find('[name="msg_reply_from"]'); |
---|
| 2285 | var msg_number_forwarded = $("#content_id_" + ID).find('[name="msg_forward_from"]'); |
---|
[2] | 2286 | |
---|
[6060] | 2287 | if (msg_number_replied.val()){ |
---|
| 2288 | proxy_mensagens.proxy_set_message_flag(msg_number_replied.val(), 'answered'); |
---|
[2] | 2289 | } |
---|
[6060] | 2290 | else if (msg_number_forwarded.val()){ |
---|
| 2291 | proxy_mensagens.proxy_set_message_flag(msg_number_forwarded.val(), 'forwarded'); |
---|
[2] | 2292 | } |
---|
[1121] | 2293 | if(expresso_offline){ |
---|
| 2294 | write_msg(get_lang('Your message was sent to queue')); |
---|
| 2295 | delete_border(ID,'true'); |
---|
| 2296 | return; |
---|
[2] | 2297 | }else{ |
---|
[1121] | 2298 | if (wfolders.alert) { |
---|
| 2299 | write_msg(get_lang('Your message was sent and save.')); |
---|
| 2300 | wfolders.alert = false; |
---|
| 2301 | } |
---|
| 2302 | else { |
---|
| 2303 | write_msg(get_lang('Your message was sent.')); |
---|
| 2304 | } |
---|
[2] | 2305 | } |
---|
[485] | 2306 | // If new dynamic contacts were added, update the autocomplete .... |
---|
| 2307 | if(data.new_contacts){ |
---|
| 2308 | var ar_contacts = data.new_contacts.split(',;'); |
---|
| 2309 | for(var j in ar_contacts){ |
---|
| 2310 | // If the dynamic contact don't exist, update the autocomplete.... |
---|
| 2311 | if((contacts+",").indexOf(";"+ar_contacts[j]+",") == -1) |
---|
| 2312 | contacts += ",;" + ar_contacts[j]; |
---|
| 2313 | } |
---|
| 2314 | } |
---|
[5604] | 2315 | delete_border(ID,'true'); |
---|
[649] | 2316 | } |
---|
| 2317 | else{ |
---|
[504] | 2318 | if(data == 'Post-Content-Length') |
---|
[65] | 2319 | write_msg(get_lang('The size of this message has exceeded the limit (%1B).',Element('upload_max_filesize').value)); |
---|
[504] | 2320 | else if(data) |
---|
| 2321 | write_msg(data); |
---|
[2] | 2322 | else |
---|
[504] | 2323 | write_msg(get_lang("Connection failed with %1 Server. Try later.", "Web")); |
---|
[3509] | 2324 | |
---|
[5931] | 2325 | var save_link = $("#content_id_"+ID).find(".save")[0]; |
---|
[4803] | 2326 | save_link.onclick = function onclick(event) {openTab.toPreserve[ID] = true;save_msg(ID);} ; |
---|
[5604] | 2327 | $("#save_message_options_"+ID).button({disabled: false}); |
---|
[5417] | 2328 | //save_link.className = 'message_options'; |
---|
[2] | 2329 | } |
---|
[1121] | 2330 | if(!expresso_offline) |
---|
| 2331 | connector.hideProgressBar(); |
---|
[2] | 2332 | } |
---|
| 2333 | |
---|
[1629] | 2334 | /** |
---|
| 2335 | * Método chamado pela applet para retornar o resultado da assinatura/decifragem do e-mail. |
---|
| 2336 | * para posterior envio ao servidor. |
---|
| 2337 | * @author Mário César Kolling <mario.kolling@serpro.gov.br>, Bruno Vieira da Costa <bruno.vieira-costa@serpro.gov.br> |
---|
| 2338 | * @param smime O e-mail decifrado/assinado |
---|
| 2339 | * @param ID O ID do e-mail, para saber em que aba esse e-mail será mostrado. |
---|
| 2340 | * @param operation A operação que foi realizada pela applet (assinatura ou decifragem) |
---|
| 2341 | */ |
---|
[1035] | 2342 | function appletReturn(smime, ID, operation, folder){ |
---|
[1629] | 2343 | |
---|
[3035] | 2344 | if (!smime){ // Erro aconteceu ao assinar ou decifrar e-mail |
---|
| 2345 | connector = new cConnector(); |
---|
| 2346 | connector.hideProgressBar(); |
---|
| 2347 | return; |
---|
| 2348 | } |
---|
[1629] | 2349 | |
---|
[1035] | 2350 | if(operation=='decript') |
---|
| 2351 | { |
---|
| 2352 | var handler = function(data){ |
---|
[5134] | 2353 | |
---|
[1035] | 2354 | if(data.msg_day == '') |
---|
| 2355 | { |
---|
[3035] | 2356 | header=expresso_local_messages.get_msg_date(data.original_ID, proxy_mensagens.is_local_folder(get_current_folder())); |
---|
[5134] | 2357 | |
---|
[1035] | 2358 | data.fulldate=header.fulldate; |
---|
| 2359 | data.smalldate=header.smalldate; |
---|
| 2360 | data.msg_day = header.msg_day; |
---|
| 2361 | data.msg_hour = header.msg_hour; |
---|
[5134] | 2362 | |
---|
[4933] | 2363 | } |
---|
[1035] | 2364 | this.show_msg(data); |
---|
| 2365 | } |
---|
| 2366 | para="&source="+smime+"&ID="+ID+"&folder="+folder; |
---|
| 2367 | cExecute ("$this.imap_functions.show_decript&", handler, para); |
---|
| 2368 | }else |
---|
| 2369 | { |
---|
[3035] | 2370 | ID_tmp = ID; |
---|
| 2371 | // Lê a variável e chama a nova função cExecuteForm |
---|
| 2372 | // Processa e envia para o servidor web |
---|
| 2373 | // Faz o request do connector novamente. Talvez implementar no connector |
---|
| 2374 | // para manter coerência. |
---|
[1035] | 2375 | |
---|
[3035] | 2376 | var handler_send_smime = function(data){ |
---|
| 2377 | send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug |
---|
| 2378 | }; |
---|
[1035] | 2379 | |
---|
[3035] | 2380 | var textArea = document.createElement("TEXTAREA"); |
---|
| 2381 | textArea.style.display='none'; |
---|
| 2382 | textArea.id = 'smime'; |
---|
| 2383 | textArea.name = "smime"; |
---|
| 2384 | textArea.value += smime; |
---|
[1035] | 2385 | |
---|
[3035] | 2386 | // Lê a variável e chama a nova função cExecuteForm |
---|
| 2387 | // Processa e envia para o servidor web |
---|
| 2388 | // Faz o request do connector novamente. Talvez implementar no connector |
---|
| 2389 | // para manter coerência. |
---|
| 2390 | if (is_ie){ |
---|
| 2391 | var i = 0; |
---|
| 2392 | while (document.forms(i).name != "form_message_"+ID){i++} |
---|
| 2393 | form = document.forms(i); |
---|
| 2394 | } |
---|
| 2395 | else |
---|
| 2396 | form = document.forms["form_message_"+ID]; |
---|
[1035] | 2397 | |
---|
[3035] | 2398 | form.appendChild(textArea); |
---|
[1035] | 2399 | |
---|
[3035] | 2400 | cExecuteForm ("$this.imap_functions.send_mail", form, handler_send_smime, ID); |
---|
| 2401 | } |
---|
[1035] | 2402 | } |
---|
| 2403 | |
---|
[2] | 2404 | function send_message(ID, folder, folder_name){ |
---|
[5702] | 2405 | if(!zebraDiscardEventDialog && $('#fileupload_msg'+ID).find('.in-progress').length ) |
---|
| 2406 | { |
---|
| 2407 | zebraDiscardEventDialog = true; |
---|
| 2408 | window.setTimeout(function() { |
---|
| 2409 | $.Zebra_Dialog('Existem anexos sendo enviados para o servidor. Caso envie sua mensagem agora estes arquivos serão perdidos.', { |
---|
| 2410 | 'type': 'question', |
---|
| 2411 | 'overlay_opacity': '0.5', |
---|
| 2412 | 'buttons': ['Descartar anexos e enviar', 'Continuar editando e esperar anexos'], |
---|
| 2413 | 'width' : 500, |
---|
| 2414 | 'onClose': function(clicked) { |
---|
| 2415 | if(clicked == 'Descartar anexos e enviar' ) |
---|
| 2416 | send_valided_message(ID, folder, folder_name); |
---|
[3035] | 2417 | |
---|
[5702] | 2418 | window.setTimeout(function() { |
---|
| 2419 | zebraDiscardEventDialog = false; |
---|
| 2420 | }, 500); |
---|
| 2421 | } |
---|
| 2422 | }) |
---|
| 2423 | }, 300); |
---|
[1398] | 2424 | |
---|
[5702] | 2425 | } |
---|
| 2426 | else |
---|
| 2427 | send_valided_message(ID, folder, folder_name); |
---|
| 2428 | } |
---|
| 2429 | |
---|
| 2430 | function send_valided_message(ID, folder, folder_name) |
---|
| 2431 | { |
---|
[5911] | 2432 | if (preferences.auto_save_draft == 1) |
---|
| 2433 | autoSaveControl.status[ID] = true; |
---|
| 2434 | var content = $("#content_id_"+ID); |
---|
| 2435 | var save_link = $("#content_id_"+ID).find(".save"); |
---|
| 2436 | var onClick = save_link.onclick; |
---|
[271] | 2437 | save_link.onclick = ''; |
---|
[5911] | 2438 | save_link.button({disabled: true}); |
---|
[3035] | 2439 | |
---|
[2] | 2440 | ID_tmp = ID; |
---|
[271] | 2441 | |
---|
[2] | 2442 | var handler_send_message = function(data){ |
---|
[271] | 2443 | send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug |
---|
| 2444 | }; |
---|
[3035] | 2445 | |
---|
[4757] | 2446 | var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + ID ); |
---|
| 2447 | mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false; |
---|
| 2448 | |
---|
[5604] | 2449 | var content_body = RichTextEditor.getData('body_'+ID); |
---|
[2] | 2450 | var textArea = document.createElement("TEXTAREA"); |
---|
| 2451 | textArea.style.display='none'; |
---|
| 2452 | textArea.name = "body"; |
---|
[5134] | 2453 | textArea.value = content_body; |
---|
| 2454 | |
---|
[2] | 2455 | var input_folder = document.createElement("INPUT"); |
---|
| 2456 | input_folder.style.display='none'; |
---|
| 2457 | input_folder.name = "folder"; |
---|
[5754] | 2458 | input_folder.value = folder; |
---|
[5763] | 2459 | |
---|
| 2460 | var input_type = document.createElement("INPUT"); |
---|
| 2461 | input_type.style.display='none'; |
---|
| 2462 | input_type.name = "type"; |
---|
| 2463 | input_type.value = RichTextEditor.plain[ID] ? 'plain' : 'html'; |
---|
| 2464 | |
---|
[5604] | 2465 | var uids = document.createElement("INPUT"); |
---|
| 2466 | uids.style.display='none'; |
---|
| 2467 | uids.name = "uids_save"; |
---|
| 2468 | uids.value = uidsSave[ID].toString(); |
---|
| 2469 | |
---|
| 2470 | var save_folder = document.createElement("INPUT"); |
---|
| 2471 | save_folder.style.display='none'; |
---|
| 2472 | save_folder.name = "save_folder"; |
---|
| 2473 | save_folder.value = (openTab.imapBox[ID] && openTab.type[ID] < 6) ? openTab.imapBox[ID]: "INBOX" + cyrus_delimiter + draftsfolder; |
---|
| 2474 | |
---|
| 2475 | var msg_attachments = document.createElement("INPUT"); |
---|
| 2476 | msg_attachments.style.display='none'; |
---|
| 2477 | msg_attachments.name = "attachments"; |
---|
| 2478 | msg_attachments.value = listAttachment(ID); |
---|
[3035] | 2479 | |
---|
[2] | 2480 | if (is_ie){ |
---|
| 2481 | var i = 0; |
---|
| 2482 | while (document.forms(i).name != "form_message_"+ID){i++} |
---|
| 2483 | form = document.forms(i); |
---|
| 2484 | } |
---|
| 2485 | else |
---|
| 2486 | form = document.forms["form_message_"+ID]; |
---|
[1632] | 2487 | |
---|
[3035] | 2488 | // Evita que e-mails assinados sejam enviados quando o usuário tenta enviar um e-mail |
---|
| 2489 | // não assinado (desmarcou a opção) após tentar enviar um e-mail assinado que não passou |
---|
| 2490 | // no teste de validação. |
---|
| 2491 | var checkSign = document.getElementById('return_digital_'+ID); |
---|
| 2492 | if (checkSign && !checkSign.checked){ |
---|
| 2493 | var smime = Element('smime'); |
---|
| 2494 | if (smime) |
---|
| 2495 | { |
---|
| 2496 | var parent = smime.parentNode; |
---|
| 2497 | parent.removeChild(smime); |
---|
| 2498 | } |
---|
| 2499 | } |
---|
[1632] | 2500 | |
---|
[2] | 2501 | form.appendChild(textArea); |
---|
| 2502 | form.appendChild(input_folder); |
---|
[6194] | 2503 | form.appendChild(input_type); |
---|
[5453] | 2504 | // Implementação do In_Reply_To e References |
---|
| 2505 | var msgId = document.createElement("INPUT"); |
---|
| 2506 | msgId.style.display = 'none'; |
---|
| 2507 | msgId.name = 'messageNum'; |
---|
| 2508 | msgId.value = currentTab; |
---|
| 2509 | |
---|
| 2510 | form.appendChild(msgId); |
---|
[6194] | 2511 | form.appendChild(save_folder); |
---|
| 2512 | form.appendChild(uids); |
---|
[5604] | 2513 | form.appendChild(msg_attachments); |
---|
[5453] | 2514 | |
---|
[5702] | 2515 | var mail_type = document.createElement('input'); |
---|
[4757] | 2516 | mail_type.setAttribute('type', 'hidden'); |
---|
| 2517 | mail_type.name = 'type'; |
---|
| 2518 | mail_type.value = ( mail_as_plain ) ? 'plain' : 'html'; |
---|
[5702] | 2519 | form.parentNode.appendChild(mail_type); |
---|
[4757] | 2520 | |
---|
[5911] | 2521 | var _subject = trim(content.find(".subject").val()); |
---|
[2] | 2522 | if((_subject.length == 0) && !confirm(get_lang("Send this message without a subject?"))) { |
---|
[5911] | 2523 | save_link.click(onClick); |
---|
| 2524 | content.find(".subject").focus(); |
---|
[2] | 2525 | return; |
---|
| 2526 | } |
---|
[5911] | 2527 | stringEmail = content.find('[name="input_to"]').val(); |
---|
[5378] | 2528 | |
---|
[5911] | 2529 | if ( content.find('[name="input_cco"]').length) |
---|
| 2530 | if(content.find(".cco-tr").css("display") != "none") |
---|
| 2531 | stringEmail += content.find('[name="input_cco"]').val() =='' ? "":", "+content.find('[name="input_cco"]').val(); |
---|
[5417] | 2532 | |
---|
[5911] | 2533 | if(content.find(".cc-tr").css("display") != "none") |
---|
| 2534 | stringEmail += content.find('[name="input_cc"]').val() =='' ? "":", "+content.find('[name="input_cc"]').val(); |
---|
[5417] | 2535 | |
---|
[3035] | 2536 | if (expresso_offline) { |
---|
[5357] | 2537 | |
---|
[3227] | 2538 | var invalidEmail = searchEmail(stringEmail); |
---|
[5911] | 2539 | if(content.find('[name="input_to"]').val()=="" && content.find('[name="input_cco"]').val()=="" && content.find('[name="input_cc"]').val()=="") { |
---|
[5357] | 2540 | write_msg(get_lang("message without receiver")); |
---|
[1121] | 2541 | return; |
---|
| 2542 | }else if(invalidEmail[0] == true){ |
---|
| 2543 | write_msg("Os endereços de destinatário a seguir estão incorretos: "+invalidEmail[1]); |
---|
| 2544 | return; |
---|
| 2545 | } |
---|
| 2546 | |
---|
| 2547 | sucess = expresso_local_messages.send_to_queue(form); |
---|
| 2548 | var data_return = new Array(); |
---|
| 2549 | data_return.success = sucess; |
---|
| 2550 | handler_send_message(data_return,ID); |
---|
| 2551 | } |
---|
[5134] | 2552 | else{ |
---|
[5945] | 2553 | if(stringEmail != ""){ |
---|
[5357] | 2554 | cExecuteForm("$this.imap_functions.send_mail", form, handler_send_message, ID); |
---|
[5945] | 2555 | }else{ |
---|
[5357] | 2556 | write_msg(get_lang("message without receiver")); |
---|
| 2557 | return; |
---|
| 2558 | } |
---|
[5134] | 2559 | } |
---|
[5702] | 2560 | |
---|
[2] | 2561 | } |
---|
[5702] | 2562 | |
---|
| 2563 | |
---|
[5134] | 2564 | function is_valid_email(campo){ |
---|
| 2565 | var invalidEmail = searchEmail(campo); |
---|
| 2566 | var semicolon = campo.split(";"); |
---|
| 2567 | |
---|
| 2568 | if((campo.replace(/^\s+|\s+$/g,"")) != ""){ |
---|
| 2569 | if(invalidEmail[0] == true){ |
---|
| 2570 | write_msg("Erro de SMTP: Os endereços de destinatário a seguir falharam: "+ invalidEmail[1]); |
---|
| 2571 | return false; |
---|
| 2572 | }else{ |
---|
| 2573 | if(semicolon.length > 1){ |
---|
| 2574 | var stringError = "Erro de SMTP: Os endereços devem ser separados apenas por vígula: "; |
---|
| 2575 | for(var i= 0; i < semicolon.length; i++){ |
---|
| 2576 | stringError = stringError + semicolon[i]; |
---|
| 2577 | if(i+1 < semicolon.length) |
---|
| 2578 | stringError = stringError + " ; "; |
---|
| 2579 | } |
---|
| 2580 | write_msg(stringError); |
---|
| 2581 | return false; |
---|
| 2582 | }else { |
---|
| 2583 | return true; |
---|
| 2584 | } |
---|
| 2585 | } |
---|
| 2586 | } |
---|
| 2587 | else{ |
---|
| 2588 | write_msg(get_lang("Message without receiver")); |
---|
| 2589 | return false; |
---|
| 2590 | } |
---|
| 2591 | } |
---|
[1318] | 2592 | function change_tr_properties(tr_element, newUid, newSubject){ |
---|
[1319] | 2593 | message_id=tr_element.id; |
---|
[4771] | 2594 | var td_from = document.getElementById('td_from_'+message_id); |
---|
[1319] | 2595 | if (typeof(newSubject) != 'undefined') |
---|
[4771] | 2596 | td_from.nextSibling.innerHTML = newSubject; |
---|
[1318] | 2597 | tr_element.id = newUid; |
---|
[2] | 2598 | |
---|
[1318] | 2599 | var openNewMessage = function () { |
---|
[6275] | 2600 | $.ajax({ |
---|
| 2601 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 2602 | msg_number: newUid, |
---|
| 2603 | msg_folder: current_folder, |
---|
| 2604 | decoded: true } ), |
---|
| 2605 | success: function( data ){ |
---|
| 2606 | data = connector.unserialize( data ); |
---|
| 2607 | |
---|
| 2608 | if( data ) |
---|
| 2609 | show_msg( data ); |
---|
| 2610 | } |
---|
| 2611 | |
---|
| 2612 | }); |
---|
[1318] | 2613 | }; |
---|
| 2614 | for (var i=2; i < 10; i++){ |
---|
[1319] | 2615 | if (typeof(tr_element.childNodes[i].id) != "undefined") |
---|
| 2616 | tr_element.childNodes[i].id = tr_element.childNodes[i].id.replace(message_id,newUid); |
---|
[1318] | 2617 | tr_element.childNodes[i].onclick = openNewMessage; |
---|
| 2618 | } |
---|
| 2619 | } |
---|
| 2620 | |
---|
[4757] | 2621 | |
---|
[5459] | 2622 | function autoSave( ID ) |
---|
| 2623 | { |
---|
| 2624 | if(autoSaveControl.status[ID] === false) |
---|
| 2625 | save_msg(ID); |
---|
| 2626 | } |
---|
| 2627 | |
---|
[5604] | 2628 | function save_msg(border_id){ |
---|
[6085] | 2629 | |
---|
| 2630 | //seta o status do auto_save = true |
---|
| 2631 | if (preferences.auto_save_draft == 1) |
---|
| 2632 | autoSaveControl.status[border_id] = true; |
---|
| 2633 | /////////////////////////////////////////// |
---|
| 2634 | |
---|
| 2635 | var idJavascript = saveBorderError[border_id]; |
---|
| 2636 | |
---|
| 2637 | if(saveBorderError[border_id] !== false) |
---|
| 2638 | DataLayer.put('message',DataLayer.merge(DataLayer.form("#form_message_"+border_id), {id: idJavascript })); |
---|
| 2639 | else |
---|
| 2640 | idJavascript = DataLayer.put('message',DataLayer.form("#form_message_"+border_id)); |
---|
[4522] | 2641 | |
---|
[6085] | 2642 | uidsSave[border_id] = []; |
---|
| 2643 | DataLayer.commit(false,false,function(data){ |
---|
| 2644 | if(data != null && data['message://'+idJavascript] !== undefined && data['message://'+idJavascript].id !== undefined ) |
---|
| 2645 | { |
---|
| 2646 | uidsSave[border_id].push(data['message://'+idJavascript].id); |
---|
| 2647 | saveBorderError[border_id] = false; |
---|
| 2648 | write_msg('Mensagem salva com sucesso!'); |
---|
| 2649 | } |
---|
| 2650 | else |
---|
| 2651 | { |
---|
| 2652 | saveBorderError[border_id] = idJavascript; |
---|
| 2653 | write_msg('Erro ao salvar sua mensagem! Nova tentativa em alguns segundos.'); |
---|
| 2654 | } |
---|
| 2655 | }); |
---|
| 2656 | |
---|
[271] | 2657 | } |
---|
| 2658 | |
---|
[5264] | 2659 | function set_messages_flag_search_local(flag){ |
---|
| 2660 | var msgs_flag = this.get_selected_messages_search(); |
---|
| 2661 | if(local_messages.prototype.set_messages_flag(msgs_flag, flag, true)){ |
---|
| 2662 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 2663 | var msgs = msgs_flag.split(','); |
---|
| 2664 | for(var i = 0; i < msgs.length; i++){ |
---|
| 2665 | Element("search_local_msg"+id_border+"_check_box_message_"+msgs[i]).checked = false; |
---|
| 2666 | } |
---|
| 2667 | draw_tree_folders(); |
---|
| 2668 | Element('chk_box_select_all_messages_search_local').checked = false; |
---|
| 2669 | refresh(); |
---|
| 2670 | write_msg(get_lang('The messages were marked with success!')); |
---|
| 2671 | }else{ |
---|
| 2672 | write_msg(get_lang('Error marking messages.')); |
---|
| 2673 | } |
---|
| 2674 | } |
---|
[271] | 2675 | |
---|
[5264] | 2676 | function set_messages_flag_search(flag){ |
---|
| 2677 | |
---|
| 2678 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 2679 | var msgs_flag = this.get_selected_messages_search(); |
---|
| 2680 | if (!msgs_flag){ |
---|
| 2681 | write_msg(get_lang('No selected message.')); |
---|
| 2682 | return; |
---|
| 2683 | } |
---|
| 2684 | var selected_param = ""; |
---|
| 2685 | msgs_to_flag = msgs_flag.split(","); |
---|
| 2686 | search = true; |
---|
| 2687 | for (i = 0; i < msgs_to_flag.length; i++){ |
---|
| 2688 | var tr = Element(msgs_to_flag[i]+'_s'+id_border); |
---|
| 2689 | var msg_to_flag = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 2690 | selected_param += ','+msg_to_flag+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 2691 | } |
---|
| 2692 | |
---|
| 2693 | var handler_set_messages_flag = function(data){ |
---|
| 2694 | var errors = false; |
---|
| 2695 | var notErrors = false; |
---|
| 2696 | for (var i = 0; i < data.length; i++){ |
---|
| 2697 | var notArray = true; |
---|
| 2698 | if(data[i].msgs_to_set != ''){ |
---|
| 2699 | var msgs = []; |
---|
| 2700 | if(data[i].msgs_to_set.indexOf(',') > 0){ |
---|
| 2701 | msgs = data[i].msgs_to_set.split(',') |
---|
| 2702 | notArray = false; |
---|
| 2703 | }else |
---|
| 2704 | msgs[0] = data[i].msgs_to_set; |
---|
| 2705 | |
---|
| 2706 | for (var j = 0; j < msgs.length; j++){ |
---|
| 2707 | switch(data[i].flag){ |
---|
| 2708 | case "unseen": |
---|
| 2709 | set_msg_as_unread(msgs[j]+'_s'+id_border, true); |
---|
| 2710 | Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked = false; |
---|
| 2711 | break; |
---|
| 2712 | case "seen": |
---|
| 2713 | set_msg_as_read(msgs[j]+'_s'+id_border, true); |
---|
| 2714 | Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked = false; |
---|
| 2715 | break; |
---|
| 2716 | case "flagged": |
---|
| 2717 | set_msg_as_flagged(msgs[j]+'_s'+id_border, true); |
---|
| 2718 | document.getElementById("search_"+id_border+"_check_box_message_"+msgs[j]).checked = false; |
---|
| 2719 | break; |
---|
| 2720 | case "unflagged": |
---|
| 2721 | set_msg_as_unflagged(msgs[j]+'_s'+id_border, true); |
---|
| 2722 | Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked = false; |
---|
| 2723 | break; |
---|
| 2724 | } |
---|
| 2725 | notErrors = true; |
---|
| 2726 | } |
---|
| 2727 | }else{ |
---|
| 2728 | errors = true; |
---|
| 2729 | } |
---|
| 2730 | } |
---|
| 2731 | |
---|
| 2732 | draw_tree_folders(); |
---|
| 2733 | Element('chk_box_select_all_messages_search').checked = false; |
---|
| 2734 | refresh(); |
---|
| 2735 | |
---|
| 2736 | if(errors && notErrors) |
---|
| 2737 | write_msg(get_lang('Some messages were not marked with success!')); |
---|
| 2738 | else if(notErrors) |
---|
| 2739 | write_msg(get_lang('The messages were marked with success!')); |
---|
| 2740 | else |
---|
| 2741 | write_msg(get_lang('Error marking messages.')); |
---|
| 2742 | } |
---|
| 2743 | cExecute ("$this.imap_functions.set_messages_flag_from_search&msg_to_flag="+selected_param+"&flag="+flag, handler_set_messages_flag); |
---|
| 2744 | } |
---|
| 2745 | |
---|
[2] | 2746 | // Get checked messages |
---|
[5264] | 2747 | function set_messages_flag(flag, msgs_to_set){ |
---|
| 2748 | if(currentTab != 0 && currentTab.indexOf("search_local") >= 0){ |
---|
| 2749 | return set_messages_flag_search_local(flag); |
---|
| 2750 | } |
---|
| 2751 | if (currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
| 2752 | return set_messages_flag_search(flag); |
---|
| 2753 | } |
---|
| 2754 | |
---|
[2] | 2755 | var handler_set_messages_flag = function (data){ |
---|
| 2756 | if(!verify_session(data)) |
---|
| 2757 | return; |
---|
[5134] | 2758 | var msgs_to_set = data.msgs_to_set.split(","); |
---|
[649] | 2759 | |
---|
[614] | 2760 | if(!data.status) { |
---|
[3806] | 2761 | write_msg(data.msg); |
---|
[614] | 2762 | Element('chk_box_select_all_messages').checked = false; |
---|
| 2763 | for (var i = 0; i < msgs_to_set.length; i++) { |
---|
[5134] | 2764 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
| 2765 | remove_className(Element(msgs_to_set[i]), 'selected_msg'); |
---|
[614] | 2766 | } |
---|
[659] | 2767 | if(!data.msgs_unflageds) |
---|
| 2768 | return; |
---|
[5182] | 2769 | |
---|
[659] | 2770 | else |
---|
[5182] | 2771 | if(data.msgs_not_to_set != "") |
---|
| 2772 | write_msg(get_lang("Error processing some messages.")); |
---|
| 2773 | |
---|
[659] | 2774 | msgs_to_set = data.msgs_unflageds.split(","); |
---|
[614] | 2775 | } |
---|
[2] | 2776 | |
---|
| 2777 | for (var i=0; i<msgs_to_set.length; i++){ |
---|
[3032] | 2778 | if (preferences.use_cache == 'True') |
---|
| 2779 | { |
---|
| 2780 | if (current_folder == '') |
---|
| 2781 | current_folder = 'INBOX'; |
---|
| 2782 | var setFlag = function(msgObj) { |
---|
| 2783 | switch(data.flag){ |
---|
| 2784 | case "unseen": |
---|
| 2785 | msgObj.Unseen = "U"; |
---|
| 2786 | break; |
---|
| 2787 | case "seen": |
---|
| 2788 | msgObj.Unseen = ""; |
---|
| 2789 | break; |
---|
| 2790 | case "flagged": |
---|
| 2791 | msgObj.Flagged = "F"; |
---|
| 2792 | break; |
---|
| 2793 | case "unflagged": |
---|
| 2794 | msgObj.Flagged = ""; |
---|
| 2795 | break; |
---|
| 2796 | } |
---|
| 2797 | } |
---|
[4843] | 2798 | } |
---|
[5134] | 2799 | if(Element("check_box_message_" + msgs_to_set[i])){ |
---|
[63] | 2800 | switch(data.flag){ |
---|
| 2801 | case "unseen": |
---|
[4843] | 2802 | set_msg_as_unread(msgs_to_set[i]); |
---|
[5134] | 2803 | if(results_search_messages != "") |
---|
| 2804 | set_msg_as_unread(results_search_messages, true); |
---|
| 2805 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
[63] | 2806 | break; |
---|
| 2807 | case "seen": |
---|
[5134] | 2808 | set_msg_as_read(msgs_to_set[i], false); |
---|
| 2809 | if(results_search_messages != "") |
---|
| 2810 | set_msg_as_read(results_search_messages, false, true); |
---|
| 2811 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
[6487] | 2812 | |
---|
| 2813 | // remove a flag $FilteredMessage da mensagem ao ser marcada como lida |
---|
| 2814 | $.each(fromRules, function(index, value) { |
---|
| 2815 | if(value == folder){ |
---|
| 2816 | cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_to_set, function(){}); |
---|
| 2817 | return false; |
---|
| 2818 | } |
---|
| 2819 | }); |
---|
| 2820 | |
---|
[63] | 2821 | break; |
---|
| 2822 | case "flagged": |
---|
[4843] | 2823 | set_msg_as_flagged(msgs_to_set[i]); |
---|
[5134] | 2824 | if(results_search_messages != "") |
---|
| 2825 | set_msg_as_flagged(results_search_messages, true); |
---|
| 2826 | document.getElementById("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
[63] | 2827 | break; |
---|
| 2828 | case "unflagged": |
---|
[4843] | 2829 | set_msg_as_unflagged(msgs_to_set[i]); |
---|
[5134] | 2830 | if(results_search_messages != "") |
---|
| 2831 | set_msg_as_unflagged(results_search_messages, true); |
---|
| 2832 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
[63] | 2833 | break; |
---|
| 2834 | } |
---|
[2] | 2835 | } |
---|
| 2836 | } |
---|
| 2837 | Element('chk_box_select_all_messages').checked = false; |
---|
| 2838 | } |
---|
[3035] | 2839 | |
---|
[63] | 2840 | var folder = get_current_folder(); |
---|
[5134] | 2841 | if (msgs_to_set == 'get_selected_messages') |
---|
[2] | 2842 | var msgs_to_set = this.get_selected_messages(); |
---|
[63] | 2843 | else |
---|
| 2844 | folder = Element("input_folder_"+msgs_to_set+"_r").value; |
---|
[6487] | 2845 | |
---|
[2] | 2846 | if (msgs_to_set) |
---|
[6288] | 2847 | $.ajax({ |
---|
| 2848 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.set_messages_flag', |
---|
| 2849 | folder: folder, |
---|
| 2850 | msgs_to_set: msgs_to_set, |
---|
| 2851 | flag: flag, |
---|
| 2852 | decoded: true } ), |
---|
| 2853 | success: function( data ){ |
---|
| 2854 | data = connector.unserialize( data ); |
---|
| 2855 | |
---|
| 2856 | if( data ) |
---|
| 2857 | handler_set_messages_flag( data ); |
---|
| 2858 | } |
---|
| 2859 | |
---|
| 2860 | }); |
---|
[2] | 2861 | else |
---|
[3035] | 2862 | write_msg(get_lang('No selected message.')); |
---|
[2] | 2863 | } |
---|
| 2864 | |
---|
| 2865 | // By message number |
---|
[3806] | 2866 | function set_message_flag(msg_number, flag, func_after_flag_change){ |
---|
| 2867 | var msg_number_folder = Element("new_input_folder_"+msg_number+"_r"); //Mensagens respondidas/encaminhadas |
---|
| 2868 | if(!msg_number_folder) |
---|
| 2869 | var msg_number_folder = Element("input_folder_"+msg_number+"_r"); //Mensagens abertas |
---|
| 2870 | |
---|
[2] | 2871 | var handler_set_messages_flag = function (data){ |
---|
| 2872 | if(!verify_session(data)) |
---|
| 2873 | return; |
---|
[3806] | 2874 | if(!data.status) { |
---|
| 2875 | write_msg(get_lang("this message cant be marked as normal")); |
---|
| 2876 | return; |
---|
| 2877 | } |
---|
| 2878 | else if(func_after_flag_change) { |
---|
| 2879 | func_after_flag_change(true); |
---|
| 2880 | } |
---|
[3035] | 2881 | if (data.status && Element("td_message_answered_"+msg_number)) { |
---|
[3716] | 2882 | |
---|
| 2883 | switch(flag){ |
---|
| 2884 | case "unseen": |
---|
| 2885 | set_msg_as_unread(msg_number); |
---|
| 2886 | break; |
---|
| 2887 | case "seen": |
---|
| 2888 | set_msg_as_read(msg_number); |
---|
| 2889 | break; |
---|
| 2890 | case "flagged": |
---|
| 2891 | set_msg_as_flagged(msg_number); |
---|
| 2892 | break; |
---|
| 2893 | case "unflagged": |
---|
| 2894 | set_msg_as_unflagged(msg_number); |
---|
| 2895 | break; |
---|
| 2896 | case "answered": |
---|
| 2897 | Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/'+template+'/images/answered.gif title=Respondida>'; |
---|
| 2898 | break; |
---|
| 2899 | case "forwarded": |
---|
| 2900 | Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/'+template+'/images/forwarded.gif title=Encaminhada>'; |
---|
| 2901 | break; |
---|
| 2902 | } |
---|
[3742] | 2903 | } else { |
---|
| 2904 | refresh(); |
---|
[2] | 2905 | } |
---|
| 2906 | } |
---|
[6288] | 2907 | $.ajax({ |
---|
| 2908 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.set_messages_flag', |
---|
| 2909 | folder: ( msg_number_folder ? msg_number_folder.value : get_current_folder() ), |
---|
| 2910 | msgs_to_set: msg_number, |
---|
| 2911 | flag: flag, |
---|
| 2912 | decoded: true } ), |
---|
| 2913 | success: function( data ){ |
---|
| 2914 | data = connector.unserialize( data ); |
---|
| 2915 | |
---|
| 2916 | if( data ) |
---|
| 2917 | handler_set_messages_flag( data ); |
---|
| 2918 | } |
---|
| 2919 | |
---|
| 2920 | }); |
---|
[2] | 2921 | } |
---|
| 2922 | |
---|
[5172] | 2923 | function print_search_msg(){ |
---|
| 2924 | var folder = "<h2> Resultado da Pesquisa <font color=\"#505050\" face=\"Verdana\" size=\"1\"></h2>"; |
---|
| 2925 | msgs_number = get_selected_messages_search(); |
---|
| 2926 | var tbody = Element('divScrollMain_'+numBox).firstChild.firstChild.innerHTML; |
---|
| 2927 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 2928 | |
---|
| 2929 | if(msgs_number){ |
---|
| 2930 | msgs_number = msgs_number.split(","); |
---|
| 2931 | var tbody = ""; |
---|
| 2932 | for(var i = 0; i < msgs_number.length; i++){ |
---|
| 2933 | tbody += "<tr id=\""+msgs_number[i]+"_s"+id_border+"\" class=\"tr_msg_unread tr_msg_read2\">"+ Element(msgs_number[i]+'_s'+id_border).innerHTML+"</tr>"; |
---|
| 2934 | } |
---|
| 2935 | }else{ |
---|
| 2936 | msgs_number = get_all_messages_search(); |
---|
| 2937 | msgs_number = msgs_number.split(","); |
---|
| 2938 | var tbody = ""; |
---|
| 2939 | for(var i = 0; i < msgs_number.length; i++){ |
---|
| 2940 | tbody += "<tr id=\""+msgs_number[i]+"_s"+id_border+"\" class=\"tr_msg_unread tr_msg_read2\">"+ Element(msgs_number[i]+'_s'+id_border).innerHTML+"</tr>"; |
---|
| 2941 | } |
---|
| 2942 | } |
---|
| 2943 | |
---|
| 2944 | |
---|
| 2945 | var print_width = screen.width - 200; |
---|
| 2946 | var x = ((screen.width - print_width) / 2); |
---|
| 2947 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 2948 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
| 2949 | seekDot = (is_ie ? /width=24/gi : /width="24"/gi); |
---|
| 2950 | |
---|
[6491] | 2951 | var thead = "<tr class=\"message_header\"> <td width=\"3%\"></td><td width=\"2%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"2%\"></td><td id=\"message_header_FOLDER_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">Pasta</td><td id=\"message_header_SORTFROM_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">De</td><td id=\"message_header_SORTSUBJECT_0\" class=\"th_resizable\" align=\"left\" width=\"*\">Assunto</td><td id=\"message_header_SORTARRIVAL_0\" class=\"th_resizable\" align=\"center\" width=\"11%\"><b>Data</b><img src=\"templates/default/images/arrow_descendant.gif\"></td><td id=\"message_header_SORTSIZE_0\" class=\"th_resizable\" align=\"left\" width=\"11%\">Tamanho</td></tr>"; |
---|
[5172] | 2952 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 2953 | seekDot = (is_ie ? /width=16/gi : /width="16"/gi); |
---|
| 2954 | |
---|
| 2955 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 2956 | seekDot = (is_ie ? /width=12/gi : /width="12"/gi); |
---|
| 2957 | |
---|
| 2958 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 2959 | while (1){ |
---|
| 2960 | try{ |
---|
| 2961 | window_print.document.open(); |
---|
| 2962 | var html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>' |
---|
| 2963 | + '<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>' |
---|
| 2964 | + cabecalho + '</h4><hr>' |
---|
| 2965 | + '<h2>'+folder+'</h2><hr/><blockquote><font size="2">' |
---|
| 2966 | + '<table width="100%" cellpadding="0" cellspacing="0">' |
---|
| 2967 | + '<thead>' + thead + '</thead><tbody>' + tbody + '</tbody>' |
---|
| 2968 | + '</table></font></blockquote></body></html>'; |
---|
| 2969 | window_print.document.write(html); |
---|
| 2970 | window_print.document.close(); |
---|
| 2971 | break; |
---|
| 2972 | } |
---|
| 2973 | catch(e){ |
---|
| 2974 | //alert(e.message); |
---|
| 2975 | } |
---|
| 2976 | } |
---|
| 2977 | window_print.document.close(); |
---|
| 2978 | window_print.print(); |
---|
| 2979 | } |
---|
| 2980 | |
---|
[2] | 2981 | function print_all(){ |
---|
[827] | 2982 | if (openTab.type[currentTab] == 2) |
---|
| 2983 | return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab); |
---|
| 2984 | |
---|
[5172] | 2985 | if (currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
| 2986 | return print_search_msg(); |
---|
| 2987 | } |
---|
| 2988 | |
---|
[2] | 2989 | var folder= Element('border_id_0').innerHTML; |
---|
[5158] | 2990 | //var thead = Element('divScrollHead_'+numBox).firstChild.firstChild.innerHTML; |
---|
[5134] | 2991 | |
---|
| 2992 | msgs_number = get_selected_messages(); |
---|
| 2993 | if(msgs_number == false){ |
---|
[4757] | 2994 | var tbody = Element('divScrollMain_'+numBox).firstChild.firstChild.innerHTML; |
---|
[5134] | 2995 | }else{ |
---|
| 2996 | msgs_number = msgs_number.split(","); |
---|
| 2997 | var tbody = ""; |
---|
| 2998 | for(var i = 0; i < msgs_number.length; i++){ |
---|
| 2999 | tbody += "<tr id="+msgs_number[i]+" class=\"tr_msg_unread tr_msg_read2\">"+ Element(msgs_number[i]).innerHTML+"</tr>"; |
---|
| 3000 | } |
---|
| 3001 | } |
---|
[2] | 3002 | var print_width = screen.width - 200; |
---|
| 3003 | var x = ((screen.width - print_width) / 2); |
---|
| 3004 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 3005 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
[4758] | 3006 | seekDot = (is_ie ? /width=24/gi : /width="24"/gi); |
---|
[5158] | 3007 | //thead = thead.replace(seekDot, "style='display:none'"); |
---|
[6491] | 3008 | var thead = "<tr class=\"message_header\"> <td width=\"3%\"></td><td width=\"2%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"1%\"></td><td width=\"2%\"></td><td width=\"2%\"></td><td width=\"2%\"></td><td id=\"message_header_SORTFROM_0\" class=\"th_resizable\" align=\"left\" width=\"20%\">De</td><td id=\"message_header_SORTSUBJECT_0\" class=\"th_resizable\" align=\"left\" width=\"*\">Assunto</td><td id=\"message_header_SORTARRIVAL_0\" class=\"th_resizable\" align=\"center\" width=\"11%\"><b>Data</b><img src=\"templates/default/images/arrow_descendant.gif\"></td><td id=\"message_header_SORTSIZE_0\" class=\"th_resizable\" align=\"left\" width=\"11%\">Tamanho</td></tr>"; |
---|
[4757] | 3009 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
[4758] | 3010 | seekDot = (is_ie ? /width=16/gi : /width="16"/gi); |
---|
[5158] | 3011 | //thead = thead.replace(seekDot, "style='display:none'"); |
---|
[4757] | 3012 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
[4758] | 3013 | seekDot = (is_ie ? /width=12/gi : /width="12"/gi); |
---|
[5158] | 3014 | //thead = thead.replace(seekDot, "style='display:none'"); |
---|
[4757] | 3015 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
[2] | 3016 | while (1){ |
---|
| 3017 | try{ |
---|
[4757] | 3018 | window_print.document.open(); |
---|
| 3019 | var html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>' |
---|
| 3020 | + '<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>' |
---|
[5134] | 3021 | + cabecalho + '</h4><hr>' |
---|
[4757] | 3022 | + '<h2>'+folder+'</h2><hr/><blockquote><font size="2">' |
---|
| 3023 | + '<table width="100%" cellpadding="0" cellspacing="0">' |
---|
| 3024 | + '<thead>' + thead + '</thead><tbody>' + tbody + '</tbody>' |
---|
| 3025 | + '</table></font></blockquote></body></html>'; |
---|
| 3026 | window_print.document.write(html); |
---|
| 3027 | window_print.document.close(); |
---|
[2] | 3028 | break; |
---|
| 3029 | } |
---|
| 3030 | catch(e){ |
---|
| 3031 | //alert(e.message); |
---|
| 3032 | } |
---|
| 3033 | } |
---|
| 3034 | window_print.document.close(); |
---|
| 3035 | window_print.print(); |
---|
| 3036 | } |
---|
| 3037 | |
---|
| 3038 | |
---|
| 3039 | function print_msg(msg_folder, msg_number, border_ID){ |
---|
[3035] | 3040 | var div_toaddress_full = Element("div_toaddress_full_"+border_ID); |
---|
[2] | 3041 | var div_ccaddress_full = Element("div_ccaddress_full_"+border_ID); |
---|
[3342] | 3042 | var div_ccoaddress_full = Element("div_ccoaddress_full_"+border_ID); |
---|
| 3043 | var printListTO = (div_toaddress_full && div_toaddress_full.style.display != 'none') || toaddress_array[border_ID].length == 1 ? true : false; |
---|
[3035] | 3044 | var printListCC = (div_ccaddress_full && div_ccaddress_full.style.display != 'none') || !div_ccaddress_full ? true : false; |
---|
[3342] | 3045 | var printListCCO = (div_ccoaddress_full && div_ccoaddress_full.style.display != 'none') || !div_ccoaddress_full ? true : false; |
---|
[2] | 3046 | var sender = Element('sender_values_'+border_ID) ? Element('sender_values_'+border_ID).value : null; |
---|
| 3047 | var from = Element('from_values_'+border_ID) ? Element('from_values_'+border_ID).value : null; |
---|
| 3048 | var to = Element('to_values_'+border_ID) ? Element('to_values_'+border_ID).value :null; |
---|
[3342] | 3049 | var cco = Element('cco_values_'+border_ID) ? Element('cco_values_'+border_ID).value : null; |
---|
| 3050 | var cc = Element('cc_values_'+border_ID) ? Element('cc_values_'+border_ID).value : null; |
---|
| 3051 | var date = Element('date_'+border_ID); |
---|
[2] | 3052 | var subject = Element('subject_'+border_ID); |
---|
| 3053 | var attachments = Element('attachments_'+border_ID); |
---|
| 3054 | var body = Element('body_'+border_ID); |
---|
| 3055 | |
---|
[4783] | 3056 | |
---|
| 3057 | var att = ''; |
---|
| 3058 | |
---|
| 3059 | var countAtt = 0; |
---|
| 3060 | |
---|
| 3061 | if(attachments !== null) |
---|
| 3062 | { |
---|
| 3063 | countAtt = attachments.getElementsByTagName('a').length; |
---|
| 3064 | if(countAtt === 1) |
---|
| 3065 | att = attachments.getElementsByTagName('a')[0].innerHTML; |
---|
| 3066 | else if(countAtt > 1) |
---|
| 3067 | for (var i = 1; i <attachments.getElementsByTagName('a').length; i++) |
---|
[5134] | 3068 | att += " | " + attachments.getElementsByTagName('a')[i].innerHTML; |
---|
[4783] | 3069 | } |
---|
| 3070 | |
---|
| 3071 | var body = Element('body_'+border_ID); |
---|
| 3072 | |
---|
[2] | 3073 | var print_width = screen.width - 200; |
---|
| 3074 | var x = ((screen.width - print_width) / 2); |
---|
| 3075 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 3076 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
[135] | 3077 | if(window_print == null) { |
---|
| 3078 | alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname)); |
---|
| 3079 | return; |
---|
| 3080 | } |
---|
[1754] | 3081 | |
---|
| 3082 | //needed to get the names of the attachments... only. |
---|
| 3083 | if(attachments != null) |
---|
| 3084 | { |
---|
| 3085 | var a = attachments.childNodes; |
---|
| 3086 | var attachs = ""; |
---|
| 3087 | var show_attachs = ""; |
---|
[4757] | 3088 | var ii = a.length >2?2:1; |
---|
| 3089 | for(i=ii;i<a.length;i++) |
---|
[1754] | 3090 | { |
---|
| 3091 | if(a[i].tagName && a[i].tagName == "A") |
---|
| 3092 | { |
---|
| 3093 | attachs += a[i].innerHTML; |
---|
| 3094 | } |
---|
| 3095 | } |
---|
| 3096 | show_attachs = "<tr><td width=7%><font size='2'>" + get_lang('Attachments: ')+ " </font></td><td><font size='2'>"+attachs+"</font></td></tr>"; |
---|
| 3097 | } else{ |
---|
| 3098 | show_attachs = ""; |
---|
[4757] | 3099 | } |
---|
[4283] | 3100 | var current_path = window.location.href.substr(0,window.location.href.lastIndexOf("/")); |
---|
[4757] | 3101 | var head = '<head><title></title><link href="'+current_path+'/templates/default/main.css" type="text/css" rel="stylesheet"></head>'; |
---|
| 3102 | window_print.document.write(head); |
---|
[3130] | 3103 | |
---|
[2] | 3104 | while (1){ |
---|
| 3105 | try{ |
---|
[6494] | 3106 | var html ='<body style="overflow:auto">'; |
---|
[5134] | 3107 | html += cabecalho + '</h4><hr>'; |
---|
[2] | 3108 | html += '<table><tbody>'; |
---|
| 3109 | if(sender) |
---|
[197] | 3110 | html += "<tr><td width=7% noWrap><font size='2'>" + get_lang('Sent by') + ": </font></td><td><font size='2'>"+sender+"</font></td></tr>"; |
---|
[2] | 3111 | if(from) |
---|
[197] | 3112 | html += "<tr><td width=7%><font size='2'>" + get_lang('From') + ": </font></td><td><font size='2'>"+from+"</font></td></tr>"; |
---|
[2] | 3113 | if(to) { |
---|
| 3114 | if(!printListTO) |
---|
| 3115 | to = 'Os destinatários não estão sendo exibidos para esta impressão'; |
---|
[197] | 3116 | html += "<tr><td width=7%><font size='2'>" + get_lang('To') + ": </font></td><td><font size='2'>"+to+"</font></td></tr>"; |
---|
[3035] | 3117 | } |
---|
[2] | 3118 | if (cc) { |
---|
| 3119 | if(!printListCC) |
---|
| 3120 | cc = 'Os destinatários não estão sendo exibidos para esta impressão'; |
---|
[197] | 3121 | html += "<tr><td width=7%><font size='2'>" + get_lang('Cc') + ": </font></td><td><font size='2'>"+cc+"</font></td></tr>"; |
---|
[2] | 3122 | } |
---|
[3342] | 3123 | if (cco) { |
---|
| 3124 | if(!printListCCO) |
---|
| 3125 | cco = 'Os destinatários não estão sendo exibidos para esta impressão'; |
---|
| 3126 | html += "<tr><td width=7%><font size='2'>" + get_lang('Cco') + ": </font></td><td><font size='2'>"+cco+"</font></td></tr>"; |
---|
| 3127 | } |
---|
[2] | 3128 | if(date) |
---|
[3035] | 3129 | html += "<tr><td width=7%><font size='2'>" + get_lang('Date') + ": </font></td><td><font size='2'>"+date.innerHTML+"</font></td></tr>"; |
---|
[4783] | 3130 | |
---|
[197] | 3131 | html += "<tr><td width=7%><font size='2'>" + get_lang('Subject')+ ": </font></td><td><font size='2'>"+subject.innerHTML+"</font></td></tr>"; |
---|
[4783] | 3132 | //html += show_attachs; //to show the names of the attachments |
---|
| 3133 | if (countAtt > 0) { |
---|
| 3134 | html += "<tr><td width=7%><font size='2'>" + get_lang('Attachments: ') + "</font></td><td><font size='2'>"+att+"</font></td></tr>"; |
---|
| 3135 | } |
---|
[2] | 3136 | html += "</tbody></table><hr>"; |
---|
[4757] | 3137 | window_print.document.write(html + body.innerHTML); |
---|
[5134] | 3138 | |
---|
[3035] | 3139 | var tab_tags = window_print.document.getElementsByTagName("IMG"); |
---|
[5134] | 3140 | var link = location.href.replace(/\/expressoMail1_2\/(.*)/, ""); |
---|
[2] | 3141 | for(var i = 0; i < tab_tags.length;i++){ |
---|
[5134] | 3142 | var _img = tab_tags[i].cloneNode(true); |
---|
| 3143 | if(tab_tags[i].src.toUpperCase().indexOf('INC/GET_ARCHIVE.PHP?MSGFOLDER=') > -1) |
---|
| 3144 | _img.src = link + '/expressoMail1_2/'+tab_tags[i].src.substr(tab_tags[i].src.toUpperCase().indexOf('INC/GET_ARCHIVE.PHP?MSGFOLDER=')); |
---|
| 3145 | |
---|
[2] | 3146 | tab_tags[i].parentNode.replaceChild(_img,tab_tags[i]); |
---|
| 3147 | } |
---|
[5134] | 3148 | |
---|
[2] | 3149 | break; |
---|
| 3150 | } |
---|
| 3151 | catch(e){ |
---|
| 3152 | //alert(e.message); |
---|
| 3153 | } |
---|
| 3154 | } |
---|
| 3155 | window_print.document.close(); |
---|
| 3156 | window_print.print(); |
---|
| 3157 | } |
---|
| 3158 | |
---|
| 3159 | function empty_trash_imap(){ |
---|
| 3160 | var handler_empty_trash = function(data){ |
---|
| 3161 | Element('chk_box_select_all_messages').checked = false; |
---|
| 3162 | if(!verify_session(data)) |
---|
| 3163 | return; |
---|
[5486] | 3164 | //tree_folders.getNodeById(mount_url_folder(["INBOX",special_folders["Trash"]])).alter({caption: get_lang("Trash")}); |
---|
| 3165 | //tree_folders.getNodeById(mount_url_folder(["INBOX",special_folders["Trash"]]))._refresh(); |
---|
[325] | 3166 | update_quota(get_current_folder()); |
---|
[5486] | 3167 | draw_new_tree_folder(); |
---|
[5703] | 3168 | draw_tree_labels(); |
---|
[3018] | 3169 | if (data){ |
---|
[2] | 3170 | write_msg(get_lang('Your Trash folder was empty.')); |
---|
[5306] | 3171 | if (get_current_folder() == mount_url_folder(["INBOX",special_folders["Trash"]])){ |
---|
[3018] | 3172 | draw_paging(0); |
---|
[5134] | 3173 | remove_rows(document.getElementById("table_box")); |
---|
[3018] | 3174 | Element('tot_m').innerHTML = 0; |
---|
| 3175 | Element('new_m').innerHTML = 0; |
---|
| 3176 | } |
---|
| 3177 | } |
---|
[2] | 3178 | else |
---|
| 3179 | write_msg(get_lang('ERROR emptying your Trash folder.')); |
---|
| 3180 | } |
---|
[5440] | 3181 | |
---|
[6175] | 3182 | $.Zebra_Dialog(get_lang('Do you really want to empty your trash folder?'), { |
---|
| 3183 | 'type': 'question', |
---|
| 3184 | 'title': get_lang('Empty Trash'), |
---|
| 3185 | 'buttons': [get_lang("Yes"), get_lang("No")], |
---|
| 3186 | 'overlay_opacity' : 0.5, |
---|
| 3187 | 'onClose': function(caption) { |
---|
| 3188 | if(caption == get_lang("Yes")){ |
---|
| 3189 | cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultTrashFolder", handler_empty_trash); |
---|
| 3190 | } |
---|
| 3191 | } |
---|
[5440] | 3192 | }); |
---|
[2] | 3193 | } |
---|
| 3194 | |
---|
[1965] | 3195 | function empty_spam_imap(){ |
---|
| 3196 | var handler_empty_spam = function(data){ |
---|
| 3197 | Element('chk_box_select_all_messages').checked = false; |
---|
| 3198 | if(!verify_session(data)) |
---|
| 3199 | return; |
---|
[5306] | 3200 | if (get_current_folder() == mount_url_folder(["INBOX",special_folders["Spam"]])){ |
---|
[1965] | 3201 | draw_paging(0); |
---|
[5134] | 3202 | remove_rows(document.getElementById("table_box")); |
---|
[1965] | 3203 | } |
---|
[5486] | 3204 | //tree_folders.getNodeById(mount_url_folder(["INBOX",special_folders["Spam"]])).alter({caption: get_lang("Spam")}); |
---|
| 3205 | //tree_folders.getNodeById(mount_url_folder(["INBOX",special_folders["Spam"]]))._refresh(); |
---|
| 3206 | draw_new_tree_folder(); |
---|
[5703] | 3207 | draw_tree_labels(); |
---|
[1965] | 3208 | update_quota(get_current_folder()); |
---|
| 3209 | if (data) |
---|
| 3210 | write_msg(get_lang('Your Spam folder was empty.')); |
---|
| 3211 | else |
---|
| 3212 | write_msg(get_lang('ERROR emptying your Spam folder.')); |
---|
| 3213 | } |
---|
[5486] | 3214 | |
---|
[6175] | 3215 | $.Zebra_Dialog(get_lang('Do you really want to empty your spam folder?'), { |
---|
| 3216 | 'type': 'question', |
---|
| 3217 | 'title': get_lang('Empty Spam'), |
---|
| 3218 | 'buttons': [get_lang("Yes"), get_lang("No")], |
---|
| 3219 | 'overlay_opacity' : 0.5, |
---|
| 3220 | 'onClose': function(caption) { |
---|
| 3221 | if(caption == get_lang("Yes")){ |
---|
| 3222 | cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultSpamFolder", handler_empty_spam); |
---|
| 3223 | } |
---|
| 3224 | } |
---|
[5486] | 3225 | }); |
---|
[1965] | 3226 | } |
---|
| 3227 | |
---|
| 3228 | |
---|
[2] | 3229 | function export_all_selected_msgs(){ |
---|
[6283] | 3230 | if (openTab.type[currentTab] > 1){ |
---|
| 3231 | source_msg(currentTab,openTab.imapBox[currentTab]); |
---|
[4757] | 3232 | return; |
---|
[827] | 3233 | } |
---|
[5178] | 3234 | var search = false; |
---|
[3035] | 3235 | |
---|
[5172] | 3236 | if(currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
[5178] | 3237 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
[5172] | 3238 | var msgs_to_export = this.get_selected_messages_search(); |
---|
| 3239 | if (!msgs_to_export){ |
---|
| 3240 | write_msg(get_lang('No selected message.')); |
---|
| 3241 | return; |
---|
| 3242 | } |
---|
| 3243 | var selected_param = ""; |
---|
| 3244 | msgs_to_export = msgs_to_export.split(","); |
---|
| 3245 | search = true; |
---|
| 3246 | for (i = 0; i < msgs_to_export.length; i++){ |
---|
| 3247 | var tr = Element(msgs_to_export[i]+'_s'+id_border); |
---|
| 3248 | msg_to_move = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 3249 | selected_param += ','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 3250 | } |
---|
| 3251 | }else{ |
---|
| 3252 | var msgs_to_export = this.get_selected_messages(); |
---|
| 3253 | } |
---|
[2] | 3254 | var handler_export_all_selected_msgs = function(data){ |
---|
[3035] | 3255 | |
---|
[2] | 3256 | if(!data){ |
---|
| 3257 | write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.')); |
---|
| 3258 | } |
---|
[5134] | 3259 | else{ |
---|
| 3260 | var filename = 'mensagens.zip'; |
---|
| 3261 | if (data.match(/\.eml$/gi)) { |
---|
| 3262 | filename = 'fonte_da_mensagem.eml'; |
---|
| 3263 | } |
---|
| 3264 | download_attachments(null, null, data, null,null,filename); |
---|
| 3265 | } |
---|
[2] | 3266 | } |
---|
[3035] | 3267 | |
---|
[5172] | 3268 | if(search){ |
---|
| 3269 | cExecute ("$this.exporteml.makeAll", handler_export_all_selected_msgs, "folder=false&msgs_to_export="+selected_param); |
---|
| 3270 | }else if (msgs_to_export) { |
---|
[2] | 3271 | cExecute ("$this.exporteml.makeAll", handler_export_all_selected_msgs, "folder="+get_current_folder()+"&msgs_to_export="+msgs_to_export); |
---|
[53] | 3272 | write_msg(get_lang('You must wait while the messages will be exported...')); |
---|
[2] | 3273 | } |
---|
| 3274 | else |
---|
| 3275 | write_msg(get_lang('No selected message.')); |
---|
| 3276 | } |
---|
| 3277 | |
---|
[5134] | 3278 | function select_all_search_messages(select, aba){ |
---|
| 3279 | |
---|
[5588] | 3280 | if(select){ |
---|
| 3281 | jQuery("#"+aba+" tr").each(function(i, o) { |
---|
| 3282 | |
---|
| 3283 | o.firstChild.firstChild.checked = true; |
---|
| 3284 | add_className(o, 'selected_msg'); |
---|
| 3285 | }); |
---|
| 3286 | }else{ |
---|
| 3287 | jQuery("#"+aba+" tr").each(function(i, o) { |
---|
| 3288 | |
---|
| 3289 | o.firstChild.firstChild.checked = false; |
---|
| 3290 | remove_className(o, 'selected_msg'); |
---|
| 3291 | }); |
---|
| 3292 | } |
---|
[156] | 3293 | } |
---|
| 3294 | |
---|
[2] | 3295 | function verify_session(data){ |
---|
[504] | 3296 | |
---|
[2] | 3297 | if(data && data.imap_error) { |
---|
[504] | 3298 | if(data.imap_error == "nosession") |
---|
| 3299 | write_msg(get_lang("your session could not be verified.")); |
---|
| 3300 | else |
---|
| 3301 | write_msg(data.imap_error); |
---|
| 3302 | // Hold sesion for edit message. |
---|
| 3303 | //if(!hold_session) |
---|
[3035] | 3304 | // location.href="../login.php?cd=10&phpgw_forward=%2FexpressoMail1_2%2Findex.php"; |
---|
[2] | 3305 | return false; |
---|
| 3306 | } |
---|
| 3307 | else |
---|
| 3308 | return true; |
---|
| 3309 | } |
---|
| 3310 | |
---|
| 3311 | // Save image file. |
---|
[1005] | 3312 | function save_image(e,thumb,file_type){ |
---|
| 3313 | file_type = file_type.replace("/","."); |
---|
[2] | 3314 | thumb.oncontextmenu = function(e) { |
---|
| 3315 | return false; |
---|
| 3316 | } |
---|
| 3317 | var _button = is_ie ? window.event.button : e.which; |
---|
| 3318 | var _target = is_ie ? event.srcElement : e.target; |
---|
[3035] | 3319 | |
---|
[2] | 3320 | if(_button == 2 || _button == 3) { |
---|
| 3321 | var _params = _target.id.split(";;"); |
---|
[1005] | 3322 | download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type); |
---|
[2] | 3323 | } |
---|
[69] | 3324 | } |
---|
[5134] | 3325 | function save_image2(info){ |
---|
| 3326 | var obj = jQuery.parseJSON(unescape(info)); |
---|
| 3327 | download_attachments(obj.folder, obj.message, obj.thumbIndex, obj.pid, obj.encoding, obj.type.replace("/",".")); |
---|
| 3328 | } |
---|
[69] | 3329 | |
---|
[75] | 3330 | function nospam(msgs_number, border_ID, folder){ |
---|
| 3331 | if (folder == 'null') |
---|
| 3332 | folder = get_current_folder(); |
---|
[5134] | 3333 | var new_folder = ''; |
---|
| 3334 | if(folder.substr(0,4) == 'user'){ |
---|
| 3335 | arrayFolder = folder.split(cyrus_delimiter); |
---|
| 3336 | new_folder = 'user'+cyrus_delimiter+arrayFolder[1]; |
---|
| 3337 | } |
---|
| 3338 | else{ |
---|
| 3339 | new_folder = 'INBOX'; |
---|
| 3340 | } |
---|
[69] | 3341 | var new_folder_name = get_lang('INBOX'); |
---|
| 3342 | var handler_move_msgs = function(data){ |
---|
[3035] | 3343 | if (msgs_number == 'selected') |
---|
[75] | 3344 | set_messages_flag("unseen", "get_selected_messages"); |
---|
| 3345 | else |
---|
[1121] | 3346 | proxy_mensagens.proxy_set_message_flag(msgs_number, "unseen"); |
---|
[3035] | 3347 | proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name); |
---|
[3693] | 3348 | |
---|
| 3349 | if (openTab.type[currentTab] > 1) |
---|
| 3350 | delete_border(currentTab,'false'); |
---|
[69] | 3351 | } |
---|
| 3352 | |
---|
[3693] | 3353 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 3354 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
| 3355 | else if(msgs_number == 'selected') |
---|
| 3356 | msgs_number = get_selected_messages(); |
---|
[3035] | 3357 | |
---|
[69] | 3358 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0) |
---|
[5134] | 3359 | cExecute ("$this.imap_functions.spam&folder="+folder+"&spam=false"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+0+"&cyrus_delimiter="+cyrus_delimiter, handler_move_msgs); |
---|
[69] | 3360 | else |
---|
[75] | 3361 | write_msg(get_lang('No selected message.')); |
---|
[69] | 3362 | } |
---|
| 3363 | |
---|
| 3364 | function spam(folder, msgs_number, border_ID){ |
---|
| 3365 | if (folder == 'null') |
---|
| 3366 | folder = get_current_folder(); |
---|
[5134] | 3367 | var new_folder = ''; |
---|
| 3368 | if(folder.substr(0,4) == 'user') |
---|
| 3369 | { |
---|
| 3370 | arrayFolder = folder.split(cyrus_delimiter); |
---|
[5211] | 3371 | new_folder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Spam']; |
---|
[5134] | 3372 | } |
---|
| 3373 | else |
---|
| 3374 | { |
---|
[5306] | 3375 | new_folder = mount_url_folder(["INBOX",special_folders["Spam"]]); |
---|
[5134] | 3376 | } |
---|
[69] | 3377 | var new_folder_name = 'Spam'; |
---|
[5134] | 3378 | var not_opem_previus = true; |
---|
[69] | 3379 | var handler_move_msgs = function(data){ |
---|
[5134] | 3380 | proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name, not_opem_previus); |
---|
| 3381 | if (openTab.type[currentTab] > 1){ |
---|
| 3382 | if(preferences.delete_and_show_previous_message == 1) |
---|
[3693] | 3383 | delete_border(currentTab,'false'); |
---|
[69] | 3384 | } |
---|
[5134] | 3385 | } |
---|
[3693] | 3386 | |
---|
| 3387 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 3388 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
[5172] | 3389 | else if(currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
[5306] | 3390 | var content_search = document.getElementById('content_id_'+currentTab);mount_url_folder(["INBOX",special_folders['Trash']]), 'Trash', |
---|
| 3391 | move_search_msgs('content_id_'+currentTab, mount_url_folder(["INBOX",special_folders["Spam"]]), special_folders['Spam']); |
---|
[5172] | 3392 | refresh(); |
---|
| 3393 | return; |
---|
| 3394 | }else if(msgs_number == 'selected') |
---|
[69] | 3395 | msgs_number = get_selected_messages(); |
---|
[3693] | 3396 | |
---|
[69] | 3397 | if(parseInt(msgs_number) > 0 || msgs_number.length > 0) |
---|
[5134] | 3398 | cExecute ("$this.imap_functions.spam&folder="+folder+"&spam=true"+"&msgs_number="+msgs_number+"&border_ID="+border_ID+"&sort_box_type="+sort_box_type+"&sort_box_reverse="+sort_box_reverse+"&reuse_border="+border_ID+"&new_folder="+new_folder+"&new_folder_name="+new_folder_name+"&get_previous_msg="+0+"&cyrus_delimiter="+cyrus_delimiter, handler_move_msgs); |
---|
[69] | 3399 | else |
---|
[3035] | 3400 | write_msg(get_lang('No selected message.')); |
---|
[271] | 3401 | } |
---|
[660] | 3402 | |
---|
[5858] | 3403 | function import_window() |
---|
| 3404 | { |
---|
[5887] | 3405 | var folder = {}; |
---|
[5858] | 3406 | var importEmails = $("#importEmails"); |
---|
| 3407 | importEmails.html( DataLayer.render( BASE_PATH + "modules/mail/templates/importEmails.ejs", {})); |
---|
| 3408 | importEmails.dialog( |
---|
| 3409 | { |
---|
| 3410 | height : 280, |
---|
| 3411 | width : 500, |
---|
| 3412 | resizable : false, |
---|
| 3413 | title : get_lang('zip mails to import'), |
---|
| 3414 | modal : true, |
---|
| 3415 | buttons : [ |
---|
| 3416 | { |
---|
| 3417 | text : get_lang("Close"), |
---|
| 3418 | click : function() |
---|
| 3419 | { |
---|
| 3420 | importEmails.dialog("destroy"); |
---|
| 3421 | } |
---|
| 3422 | }, |
---|
| 3423 | { |
---|
| 3424 | text : get_lang("Import"), |
---|
| 3425 | click : function() |
---|
| 3426 | { |
---|
| 3427 | var input_file = importEmails.find("input[type=file]"); |
---|
| 3428 | var input_hidden = importEmails.find("input[name=folder]"); |
---|
| 3429 | |
---|
| 3430 | if( input_file.attr("value") == "" ) |
---|
| 3431 | { |
---|
| 3432 | $.Zebra_Dialog(get_lang("You must choose a file") + " !",{ |
---|
| 3433 | 'type' : 'warning', |
---|
| 3434 | 'overlay_opacity' : '0.5', |
---|
| 3435 | 'onClose' : function(){ |
---|
| 3436 | $("#importMessageAccordion").accordion('activate',0); |
---|
| 3437 | } |
---|
| 3438 | }); |
---|
| 3439 | } |
---|
| 3440 | else |
---|
| 3441 | { |
---|
| 3442 | if( input_hidden.attr("value") == "" ) |
---|
| 3443 | $.Zebra_Dialog( get_lang("You must choose a folder") + " !" , { |
---|
| 3444 | 'type' : 'warning', |
---|
| 3445 | 'overlay_opacity' : '0.5', |
---|
| 3446 | 'onClose' : function(){ |
---|
| 3447 | $("#importMessageAccordion").accordion('activate',1); |
---|
| 3448 | } |
---|
| 3449 | }); |
---|
| 3450 | else |
---|
| 3451 | { |
---|
| 3452 | var handler_return = function(data) |
---|
| 3453 | { |
---|
[5887] | 3454 | write_msg(get_lang('The import was executed successfully.')); |
---|
| 3455 | |
---|
| 3456 | return_import_msgs( data, folder ); |
---|
[5858] | 3457 | } |
---|
[5887] | 3458 | |
---|
[5858] | 3459 | var formSend = document.getElementById("importFileMessages"); |
---|
| 3460 | |
---|
[5886] | 3461 | importEmails.dialog("destroy"); |
---|
| 3462 | |
---|
[5858] | 3463 | write_msg(get_lang('You must wait while the messages will be imported...')); |
---|
| 3464 | |
---|
| 3465 | cExecuteForm('$this.imap_functions.import_msgs', formSend , handler_return ); |
---|
| 3466 | } |
---|
| 3467 | } |
---|
| 3468 | } |
---|
| 3469 | } |
---|
| 3470 | ] |
---|
| 3471 | }); |
---|
| 3472 | |
---|
| 3473 | importEmails.css("overflow","hidden"); |
---|
| 3474 | |
---|
| 3475 | importEmails.find("input[type=file]").change(function() |
---|
| 3476 | { |
---|
| 3477 | var deniedExtension = true; |
---|
| 3478 | var fileExtension = ["eml","zip"]; |
---|
| 3479 | var fileName = importEmails.find("input[type=file]").attr('value'); |
---|
| 3480 | fileName = fileName.split("."); |
---|
| 3481 | |
---|
| 3482 | if( fileName[1] ) |
---|
| 3483 | { |
---|
| 3484 | for( var i in fileExtension ) |
---|
| 3485 | { |
---|
| 3486 | if( fileExtension[i].toUpperCase() === fileName[1].toUpperCase() ) |
---|
| 3487 | { |
---|
| 3488 | deniedExtension = false; |
---|
| 3489 | break; |
---|
| 3490 | } |
---|
| 3491 | } |
---|
| 3492 | } |
---|
| 3493 | |
---|
| 3494 | if( deniedExtension ) |
---|
| 3495 | { |
---|
| 3496 | $.Zebra_Dialog( get_lang('File extension forbidden or invalid file') , { |
---|
| 3497 | 'type' : 'warning', |
---|
| 3498 | 'overlay_opacity' : '0.5' |
---|
| 3499 | }); |
---|
| 3500 | } |
---|
| 3501 | |
---|
| 3502 | $("#lblFileName").html( ( !deniedExtension ) ? importEmails.find("input[type=file]").attr('value') : "" ); |
---|
| 3503 | |
---|
| 3504 | }); |
---|
| 3505 | |
---|
| 3506 | $("#importMessageAccordion").accordion(); |
---|
| 3507 | |
---|
| 3508 | var foldersTree = jQuery("#foldertree-container-importMessage") |
---|
| 3509 | .removeClass('empty-container') |
---|
| 3510 | .html(DataLayer.render(BASE_PATH + 'api/templates/foldertree.ejs', {folders: [cp_tree1, cp_tree2, [] ]})) |
---|
| 3511 | .find("#foldertree").treeview() |
---|
| 3512 | .click(function(event) |
---|
| 3513 | { |
---|
| 3514 | //request new selected folder messages |
---|
| 3515 | var target = $(event.target); |
---|
| 3516 | |
---|
| 3517 | if( target.is('.collapsable-hitarea, .expandable-hitarea, .lastCollapsable, .lastExpandable, .treeview') ) |
---|
| 3518 | return; |
---|
| 3519 | |
---|
| 3520 | if( !target.attr('id') ) |
---|
| 3521 | target = target.parent(); |
---|
| 3522 | |
---|
| 3523 | if (target.attr('id') == "foldertree") return; |
---|
| 3524 | |
---|
[5887] | 3525 | folder.id = target.attr('id'); |
---|
| 3526 | folder.child = target.find('.folder'); |
---|
| 3527 | folder.caption = target.find('span').attr('title'); |
---|
[5858] | 3528 | |
---|
| 3529 | $('.filetree span.folder.selected').removeClass('selected'); |
---|
| 3530 | if(!target.is('#foldertree > .expandable, #foldertree > .collapsable')) |
---|
| 3531 | $(target).children('.folder').addClass('selected'); |
---|
| 3532 | |
---|
| 3533 | selectedFolder = { |
---|
[5887] | 3534 | id: folder.id, |
---|
| 3535 | name: folder.child.attr('title'), |
---|
| 3536 | 'class': folder.child.attr('class') |
---|
[5858] | 3537 | }; |
---|
| 3538 | |
---|
[5887] | 3539 | importEmails.find("input[name=folder]").attr("value", folder.id); |
---|
[5858] | 3540 | }); |
---|
[5273] | 3541 | |
---|
[5858] | 3542 | $("#lblFileName").prev().css("margin-left", "10px"); |
---|
| 3543 | $("#lblFileName").prev().css("font-weight", "bold"); |
---|
[660] | 3544 | } |
---|
| 3545 | |
---|
[5887] | 3546 | function return_import_msgs(data, folder) |
---|
| 3547 | { |
---|
[660] | 3548 | if(data && data.error){ |
---|
| 3549 | write_msg(data.error); |
---|
| 3550 | } |
---|
[5887] | 3551 | else |
---|
| 3552 | { |
---|
[660] | 3553 | if(data == 'Post-Content-Length') |
---|
[3018] | 3554 | 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)); |
---|
[5887] | 3555 | else |
---|
| 3556 | { /* |
---|
[1000] | 3557 | * @author Rommel Cysne (rommel.cysne@serpro.gov.br) |
---|
| 3558 | * @date 2009/05/15 |
---|
| 3559 | * Foi colocado um teste para verificar se a pasta selecionada, passada como parametro, |
---|
| 3560 | * eh uma pasta local (qualquer uma) |
---|
| 3561 | */ |
---|
| 3562 | var er = /^local_/; |
---|
[5887] | 3563 | if ( er.test(folder.id) ) |
---|
[1000] | 3564 | { |
---|
[5134] | 3565 | alert( "Mensagens não podem ser importadas em pastas locais" ); |
---|
| 3566 | //archive_msgs('INBOX/Lixeira/tmpMoveToLocal',wfolders_tree._selected.id,data); |
---|
| 3567 | //cExecute('$this.imap_functions.delete_mailbox',function(){},'del_past=INBOX/Lixeira/tmpMoveToLocal'); |
---|
[660] | 3568 | } |
---|
[5887] | 3569 | else |
---|
| 3570 | { |
---|
| 3571 | if( openTab.imapBox[0] == folder.id ) |
---|
[1000] | 3572 | { |
---|
| 3573 | openTab.imapBox[0] = ''; |
---|
[5887] | 3574 | change_folder(folder.id, folder.caption); |
---|
[1000] | 3575 | } |
---|
[5887] | 3576 | |
---|
| 3577 | refresh(); |
---|
[660] | 3578 | } |
---|
[5887] | 3579 | } |
---|
[660] | 3580 | } |
---|
[1000] | 3581 | |
---|
[660] | 3582 | } |
---|
| 3583 | |
---|
[5619] | 3584 | function import_implements_calendar(){ |
---|
| 3585 | |
---|
[5622] | 3586 | if(typeof(Encoder) == "undefined"){ |
---|
| 3587 | /* |
---|
| 3588 | * Deve-se centralizar as informações do usuário logado afim de não incluir |
---|
| 3589 | * arquivos de modulos distintos para este fim. |
---|
| 3590 | */ |
---|
| 3591 | |
---|
| 3592 | //$.ajax({ url: "../expressoCalendar/index.php", async: false}); |
---|
[5729] | 3593 | //$.ajax({url: "../prototype/modules/calendar/js/calendar.date.js", async: false, beforeSend: function( xhr ) { xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[6444] | 3594 | $.ajax({url: "../prototype/modules/calendar/js/load.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5835] | 3595 | $.ajax({url: "../prototype/modules/calendar/js/map.disponibility.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
| 3596 | $.ajax({url: "../prototype/modules/calendar/js/helpers.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5622] | 3597 | //$.ajax({ url: "../prototype/modules/calendar/js/timezone.js", async: false}); |
---|
| 3598 | //$.ajax({ url: "../prototype/modules/calendar/js/calendar.codecs.js", async: false}); |
---|
[5835] | 3599 | $.ajax({url: "../prototype/plugins/encoder/encoder.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5729] | 3600 | //$.ajax({url: "../prototype/plugins/dateFormat/dateFormat.js", async: false, beforeSend: function( xhr ) { xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5619] | 3601 | |
---|
[5835] | 3602 | $.ajax({url: "../prototype/plugins/fullcalendar/fullcalendar.js", async: false , beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5619] | 3603 | |
---|
[5636] | 3604 | |
---|
[5619] | 3605 | DataLayer.dispatchPath = "../prototype/"; |
---|
| 3606 | } |
---|
| 3607 | } |
---|
| 3608 | |
---|
| 3609 | |
---|
[660] | 3610 | function select_import_folder(){ |
---|
| 3611 | //Begin: Verify if the file extension is allowed. |
---|
| 3612 | var imgExtensions = new Array("eml","zip"); |
---|
[3035] | 3613 | var inputFile = document.form_import.file_1; |
---|
[660] | 3614 | if(!inputFile.value){ |
---|
| 3615 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 3616 | return false; |
---|
| 3617 | } |
---|
| 3618 | var fileExtension = inputFile.value.split("."); |
---|
| 3619 | fileExtension = fileExtension[(fileExtension.length-1)]; |
---|
| 3620 | var deniedExtension = true; |
---|
| 3621 | for(var i=0; i<imgExtensions.length; i++) { |
---|
| 3622 | if(imgExtensions[i].toUpperCase() == fileExtension.toUpperCase()) { |
---|
| 3623 | deniedExtension = false; |
---|
| 3624 | break; |
---|
| 3625 | } |
---|
| 3626 | } |
---|
| 3627 | if(deniedExtension) { |
---|
| 3628 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 3629 | return false; |
---|
| 3630 | } |
---|
| 3631 | arrayJSWin['import_window'].close(); |
---|
[3181] | 3632 | connector.loadScript('wfolders'); |
---|
| 3633 | |
---|
| 3634 | if ( typeof(wfolders) == "undefined" ) |
---|
| 3635 | setTimeout( 'select_import_folder()', 500 ); |
---|
| 3636 | else |
---|
| 3637 | wfolders.makeWindow('null','import'); |
---|
[673] | 3638 | } |
---|
| 3639 | function import_calendar(data){ |
---|
[5134] | 3640 | var import_url = '$this.db_functions.import_vcard&msg_folder='+data; |
---|
[5399] | 3641 | var logUser; |
---|
| 3642 | var up; |
---|
[6331] | 3643 | var owner; |
---|
| 3644 | |
---|
| 3645 | //Verifica o contexto de importação |
---|
| 3646 | var decodeOwner = function(){ |
---|
| 3647 | |
---|
| 3648 | owner = User.me.id; |
---|
[6356] | 3649 | var imapBox = openTab.imapBox[currentTab].split(cyrus_delimiter); |
---|
[6331] | 3650 | if(imapBox.length > 1){ |
---|
| 3651 | var user = DataLayer.get('user', {filter: ['=','uid',imapBox[1]]}); |
---|
| 3652 | owner = $.isArray(user) ? user[0].id : user.id; |
---|
| 3653 | } |
---|
| 3654 | |
---|
| 3655 | return owner; |
---|
| 3656 | } |
---|
| 3657 | |
---|
[5357] | 3658 | function handler_import_calendar(data){ |
---|
| 3659 | if(data === true){ |
---|
| 3660 | write_msg(get_lang("The event was imported successfully.")); |
---|
| 3661 | } |
---|
[5134] | 3662 | else if( data['url'] ) |
---|
| 3663 | { |
---|
| 3664 | var form = document.createElement( "form" ); |
---|
| 3665 | |
---|
| 3666 | form.setAttribute( "action", DEFAULT_URL + data['url'] + '&isPost=true' ); |
---|
| 3667 | form.setAttribute( "method", "POST" ); |
---|
| 3668 | |
---|
| 3669 | document.body.appendChild( form ); |
---|
| 3670 | |
---|
| 3671 | form.submit(); |
---|
| 3672 | } |
---|
| 3673 | else |
---|
| 3674 | write_msg(get_lang(data)); |
---|
[5357] | 3675 | } |
---|
[5804] | 3676 | if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){ |
---|
[5619] | 3677 | import_implements_calendar(); |
---|
[5357] | 3678 | $( "#import-dialog" ).dialog({ |
---|
| 3679 | autoOpen: false, |
---|
| 3680 | height: 220, |
---|
| 3681 | modal: true, |
---|
| 3682 | resizable : false, |
---|
| 3683 | close: function(event) { |
---|
| 3684 | event.stopPropagation(); |
---|
| 3685 | }, |
---|
| 3686 | closeOnEscape: true |
---|
| 3687 | }); |
---|
[6331] | 3688 | |
---|
[5514] | 3689 | $.ajax({ |
---|
[6331] | 3690 | url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(), |
---|
[5514] | 3691 | async: false, |
---|
| 3692 | success: function(data){ |
---|
| 3693 | data = connector.unserialize(data); |
---|
[5399] | 3694 | |
---|
| 3695 | |
---|
[5514] | 3696 | var createDialog = function(typeImport, propaget){ |
---|
[6295] | 3697 | |
---|
| 3698 | if(typeof(typeImport) == "object"){ |
---|
| 3699 | var calendarPermission = typeImport.calendar; |
---|
| 3700 | typeImport = typeImport.action; |
---|
| 3701 | } |
---|
| 3702 | |
---|
[5514] | 3703 | switch(parseInt(typeImport)){ |
---|
| 3704 | case 1: |
---|
[5916] | 3705 | case 7: |
---|
[6295] | 3706 | case 10: |
---|
| 3707 | $("#select-agenda").html(''); |
---|
[5399] | 3708 | |
---|
[6331] | 3709 | var options = ''; |
---|
[5399] | 3710 | |
---|
[6295] | 3711 | if(typeImport == 10){ |
---|
[6331] | 3712 | for(var i = 0; i < calendarPermission.length; i++) |
---|
| 3713 | options += '<option value="'+calendarPermission[i]+'">'+Calendar.signatureOf[calendarPermission[i]].calendar.name+'</option>' |
---|
[6295] | 3714 | }else{ |
---|
[6331] | 3715 | for(var id in Calendar.signatures) |
---|
| 3716 | options += parseInt(Calendar.signatures[id].isOwner) ? '<option value="'+Calendar.signatures[id].calendar.id+'">'+Calendar.signatures[id].calendar.name+'</option>' : ''; |
---|
[6295] | 3717 | } |
---|
[6331] | 3718 | |
---|
| 3719 | $("#select-agenda").append(options); |
---|
| 3720 | $("#select-agenda").css("display", "block"); |
---|
| 3721 | |
---|
[6295] | 3722 | $("#import-dialog" ).dialog({ |
---|
| 3723 | buttons: { |
---|
| 3724 | Cancel: function() { |
---|
| 3725 | $( this ).dialog( "close" ); |
---|
| 3726 | }, |
---|
| 3727 | "Importar" : function(){ |
---|
| 3728 | $.ajax({ |
---|
[6331] | 3729 | url: "controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(), |
---|
[6295] | 3730 | success: function(msg){ |
---|
| 3731 | var alt = ( (msg = connector.unserialize(msg)) == "ok") ? "Importado com sucesso para " : "Ocorreu um erro ao importar o evento para a agenda "; |
---|
| 3732 | alert( alt + $("#select-agenda option:selected").text() ); |
---|
[5514] | 3733 | } |
---|
[6295] | 3734 | }); |
---|
| 3735 | $( this ).dialog( "close" ); |
---|
| 3736 | } |
---|
| 3737 | } |
---|
| 3738 | }); |
---|
| 3739 | |
---|
| 3740 | if(typeImport == 7){ |
---|
| 3741 | $("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change'); |
---|
| 3742 | $("#import-dialog").find('#select-status').attr('disabled','disabled'); |
---|
| 3743 | } |
---|
| 3744 | break; |
---|
[5879] | 3745 | case 3: |
---|
[5514] | 3746 | $.ajax({ |
---|
| 3747 | url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', |
---|
| 3748 | success: function(msg){ |
---|
| 3749 | alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi removido " : "Ocorreu um erro ao remover o evento" ); |
---|
| 3750 | } |
---|
| 3751 | }); |
---|
| 3752 | return; |
---|
[5879] | 3753 | break; |
---|
| 3754 | case 5: |
---|
| 3755 | $.ajax({ |
---|
| 3756 | url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', |
---|
| 3757 | success: function(msg){ |
---|
| 3758 | alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento" ); |
---|
| 3759 | } |
---|
| 3760 | }); |
---|
| 3761 | return; |
---|
| 3762 | break; |
---|
[5514] | 3763 | case 6: |
---|
| 3764 | var acceptedSuggestion = confirm("Deseja atualizar o evento de acordo com a sugestão ?"); |
---|
| 3765 | $.ajax({ |
---|
| 3766 | url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&selected=true&cirus_delimiter='+cyrus_delimiter+'&acceptedSuggestion='+acceptedSuggestion+"&from="+document.getElementById('from_values_'+currentTab).value, |
---|
| 3767 | success: function(msg){ |
---|
| 3768 | if(acceptedSuggestion) |
---|
| 3769 | alert( ( ( connector.unserialize(msg)) == "ok") ? "Evento atualizado com sucesso " : "Ocorreu um erro ao atualizar o evento" ); |
---|
| 3770 | } |
---|
| 3771 | }); |
---|
| 3772 | return; |
---|
| 3773 | break; |
---|
[5916] | 3774 | case 9: |
---|
| 3775 | alert('Seu evento não possui alterações!'); |
---|
| 3776 | return; |
---|
| 3777 | break; |
---|
[6295] | 3778 | case 11: |
---|
| 3779 | alert('Este evento já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!'); |
---|
| 3780 | return; |
---|
| 3781 | break; |
---|
[5514] | 3782 | default: |
---|
| 3783 | up = true; |
---|
| 3784 | $("#select-agenda").css("display", "none"); |
---|
| 3785 | $("#import-dialog" ).children("p:first-child").css("display", "none"); |
---|
| 3786 | $("#import-dialog" ).dialog({ |
---|
| 3787 | height: 160, |
---|
| 3788 | title: 'Atualizar Evento', |
---|
| 3789 | buttons: { |
---|
| 3790 | Cancel: function() { |
---|
| 3791 | $( this ).dialog( "close" ); |
---|
| 3792 | }, |
---|
| 3793 | "Atualizar": function() { |
---|
| 3794 | |
---|
| 3795 | $.ajax({ |
---|
[5879] | 3796 | url: "controller.php?action="+import_url+'&from_ajax=true&selected='+ (parseInt(typeImport) == 2 || parseInt(typeImport) == 4 ? 'true' : $("#select-agenda option:selected").val()) +'&status='+$("#select-status option:selected").val(), |
---|
[5514] | 3797 | success: function(msg){ |
---|
| 3798 | alert( ( (msg = connector.unserialize(msg)) == "ok") ? "Atualizado com sucesso para " : "Ocorreu um erro ao atualizar o evento" ); |
---|
| 3799 | } |
---|
| 3800 | }); |
---|
| 3801 | $( this ).dialog( "close" ); |
---|
| 3802 | } |
---|
| 3803 | } |
---|
| 3804 | }); |
---|
| 3805 | $(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar"); |
---|
| 3806 | } |
---|
| 3807 | $( "#import-dialog" ).dialog( "open" ); |
---|
| 3808 | |
---|
| 3809 | }; |
---|
| 3810 | createDialog(data, true); |
---|
[5415] | 3811 | |
---|
[5399] | 3812 | }}); |
---|
| 3813 | |
---|
[5357] | 3814 | } |
---|
[5399] | 3815 | else |
---|
| 3816 | { |
---|
| 3817 | if(confirm(get_lang("Do you confirm this import to your Calendar?"))){ |
---|
| 3818 | cExecute( import_url + "&from_ajax=true", handler_import_calendar); |
---|
| 3819 | } |
---|
| 3820 | } |
---|
[5134] | 3821 | } |
---|
| 3822 | function open_msg_part(data){ |
---|
| 3823 | var handler_open_msg_part = function (data) |
---|
| 3824 | { |
---|
| 3825 | if(data.append == 1) |
---|
| 3826 | { |
---|
| 3827 | proxy_mensagens.get_msg(data.msg_number,data.msg_folder,false,show_msg); |
---|
| 3828 | partMsgs.push(data.msg_number); |
---|
[673] | 3829 | } |
---|
[5134] | 3830 | else |
---|
| 3831 | write_msg(data.append); |
---|
| 3832 | } |
---|
[5211] | 3833 | cExecute('$this.imap_functions.ope_msg_part&msg_folder='+data+'&save_folder=INBOX'+cyrus_delimiter+special_folders['Trash'] , handler_open_msg_part); |
---|
[673] | 3834 | } |
---|
[1121] | 3835 | function hack_sent_queue(data,rowid_message) { |
---|
| 3836 | |
---|
| 3837 | if (data.success != true) { |
---|
| 3838 | queue_send_errors = true; |
---|
| 3839 | expresso_local_messages.set_problem_on_sent(rowid_message,data); |
---|
| 3840 | } |
---|
| 3841 | else { |
---|
| 3842 | expresso_local_messages.set_as_sent(rowid_message); |
---|
| 3843 | 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. |
---|
| 3844 | el =document.getElementById('_action'); |
---|
| 3845 | father = el.parentNode; |
---|
| 3846 | father.removeChild(el); |
---|
| 3847 | } |
---|
| 3848 | send_mail_from_queue(false); |
---|
| 3849 | } |
---|
| 3850 | } |
---|
| 3851 | |
---|
| 3852 | function send_mail_from_queue(first_pass) { |
---|
| 3853 | if(first_pass) |
---|
| 3854 | modal('send_queue'); |
---|
| 3855 | var num_msgs = expresso_local_messages.get_num_msgs_to_send(); |
---|
| 3856 | if (num_msgs <= 0) { |
---|
| 3857 | close_lightbox(); |
---|
| 3858 | return; |
---|
| 3859 | } |
---|
[3035] | 3860 | document.getElementById('text_send_queue').innerHTML = get_lang('Number of messages to send:')+' '+num_msgs; |
---|
[1121] | 3861 | var handler_send_queue_message = function(data,rowid_message) { |
---|
| 3862 | hack_sent_queue(data,this.ID_tmp); |
---|
| 3863 | } |
---|
| 3864 | var msg_to_send = expresso_local_messages.get_form_msg_to_send(); |
---|
| 3865 | if(!is_ie) |
---|
| 3866 | ID_tmp = msg_to_send.rowid.value; |
---|
| 3867 | else {//I.E kills me of shame... |
---|
| 3868 | for (var i=0;i<msg_to_send.length;i++) { |
---|
| 3869 | if(msg_to_send.elements[i].name=='rowid') { |
---|
| 3870 | ID_tmp = msg_to_send.elements[i].value; |
---|
| 3871 | break; |
---|
| 3872 | } |
---|
| 3873 | } |
---|
| 3874 | } |
---|
[3537] | 3875 | expresso_local_messages.set_as_sent(ID_tmp); |
---|
[1121] | 3876 | cExecuteForm("$this.imap_functions.send_mail", msg_to_send, handler_send_queue_message,"queue_"+ID_tmp); |
---|
[3537] | 3877 | send_mail_from_queue(false); |
---|
[1121] | 3878 | } |
---|
| 3879 | |
---|
| 3880 | function check_mail_in_queue() { |
---|
| 3881 | var num_msgs = expresso_local_messages.get_num_msgs_to_send(); |
---|
| 3882 | if(num_msgs>0) { |
---|
| 3883 | control = confirm(get_lang('You have messages to send. Want you to send them now?')); |
---|
| 3884 | if(control) { |
---|
| 3885 | send_mail_from_queue(true); |
---|
| 3886 | } |
---|
| 3887 | return true; |
---|
| 3888 | } |
---|
| 3889 | else { |
---|
| 3890 | return false; |
---|
| 3891 | } |
---|
| 3892 | } |
---|
| 3893 | |
---|
| 3894 | function force_check_queue() { |
---|
| 3895 | if(!check_mail_in_queue()) { |
---|
| 3896 | write_msg(get_lang("No messages to send")); |
---|
| 3897 | } |
---|
| 3898 | } |
---|
| 3899 | |
---|
[5844] | 3900 | function create_new_folder(name_folder, base_path){ |
---|
| 3901 | $.ajax({ |
---|
| 3902 | url : "controller.php?action=$this.imap_functions.create_mailbox", |
---|
| 3903 | type : "POST", |
---|
| 3904 | async : false, |
---|
| 3905 | data : "newp="+name_folder+"&base_path="+base_path, |
---|
| 3906 | success : function(data){ |
---|
| 3907 | data = connector.unserialize(data); |
---|
| 3908 | if(data == "Mailbox already exists"){ |
---|
| 3909 | write_msg(get_lang("Mailbox already exists")); |
---|
| 3910 | } |
---|
| 3911 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 3912 | } |
---|
| 3913 | }); |
---|
| 3914 | } |
---|
| 3915 | |
---|
[3227] | 3916 | function searchEmail(emailString){ |
---|
[1121] | 3917 | var arrayInvalidEmails = new Array(); |
---|
[3035] | 3918 | arrayInvalidEmails[1] = ''; |
---|
[1121] | 3919 | var email; |
---|
| 3920 | var arrayEmailsFull = new Array(); |
---|
| 3921 | arrayEmailsFull = emailString.split(','); |
---|
[3227] | 3922 | var er_Email = new RegExp("<(.*?)>"); |
---|
| 3923 | // TODO Use validateEmail of common functions ! |
---|
[5134] | 3924 | var er_ValidaEmail = new RegExp("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$"); |
---|
[1121] | 3925 | |
---|
| 3926 | for (i=0; i < arrayEmailsFull.length; i++){ |
---|
| 3927 | email = er_Email.exec(arrayEmailsFull[i]); |
---|
| 3928 | tempEmail = email == null ? arrayEmailsFull[i]:email[1]; |
---|
| 3929 | tempEmail = tempEmail.replace(/^\s+|\s+$/g,""); |
---|
[5134] | 3930 | |
---|
[1121] | 3931 | if (tempEmail != '') { |
---|
| 3932 | singleEmail = er_ValidaEmail.exec(tempEmail); |
---|
| 3933 | if (singleEmail == null) { |
---|
| 3934 | arrayInvalidEmails[0] = true; |
---|
[5134] | 3935 | arrayInvalidEmails[1] += (email == null ? arrayEmailsFull[i] : email[1]) + ""; |
---|
[1121] | 3936 | } |
---|
[3035] | 3937 | } |
---|
[1121] | 3938 | } |
---|
[3035] | 3939 | |
---|
[1121] | 3940 | return arrayInvalidEmails; |
---|
[1754] | 3941 | } |
---|
[4830] | 3942 | |
---|
| 3943 | /* Função que chama a tela para o usuário reportar um erro no email. */ |
---|
| 3944 | function reports_window(currentTab){ |
---|
| 3945 | ID_msg = currentTab.substr(0,currentTab.indexOf("_")); |
---|
| 3946 | report_wind.make_report_window(ID_msg); |
---|
| 3947 | } |
---|
| 3948 | |
---|
[5604] | 3949 | |
---|
| 3950 | DataLayer.codec( "message", "detail", { |
---|
| 3951 | |
---|
| 3952 | decoder:function( form ){ |
---|
| 3953 | var border_id = form.abaID; |
---|
[5784] | 3954 | //Defininindo pasta a ser salva mensagem |
---|
[5945] | 3955 | var user_selected = $('#content_id_'+border_id).find('.from-select option:selected').text(); |
---|
[5784] | 3956 | var str_begin_name = user_selected.indexOf('<') + 1; |
---|
| 3957 | var str_end_name = user_selected.indexOf('@'); |
---|
| 3958 | var user_selected_name = user_selected.substring(str_begin_name, str_end_name); |
---|
[5791] | 3959 | |
---|
| 3960 | if(user_selected.length > 0) |
---|
| 3961 | var user_selected_email = user_selected.match(/<([^<]*)>[\s]*$/)[1]; |
---|
| 3962 | else |
---|
| 3963 | var user_selected_email = User.me.mail; |
---|
| 3964 | |
---|
[5784] | 3965 | if(user_selected_email == User.me.mail){ |
---|
| 3966 | var prefix = 'INBOX'; |
---|
| 3967 | }else{ |
---|
[5844] | 3968 | var prefix = 'user' + cyrus_delimiter+user_selected_name; |
---|
| 3969 | |
---|
| 3970 | /** TODO Mudar quando melhorias forem implementadas na API de atualização do cache */ |
---|
| 3971 | DataLayer.remove('folder', false); |
---|
| 3972 | DataLayer.get('folder'); |
---|
| 3973 | |
---|
| 3974 | var has_folder = DataLayer.get('folder', prefix + cyrus_delimiter + draftsfolder); |
---|
| 3975 | if(!has_folder){ |
---|
| 3976 | create_new_folder(draftsfolder, prefix); |
---|
| 3977 | } |
---|
[5784] | 3978 | } |
---|
[5844] | 3979 | |
---|
[5784] | 3980 | var folder_id = (openTab.imapBox[border_id] && openTab.type[border_id] < 6) ? openTab.imapBox[border_id]: prefix + cyrus_delimiter + draftsfolder; |
---|
[5604] | 3981 | form.folder = folder_id; |
---|
| 3982 | form.body = RichTextEditor.getData("body_"+border_id); |
---|
[5784] | 3983 | form.type = RichTextEditor.plain[border_id] ? 'plain' : 'html'; |
---|
[5754] | 3984 | form.attachments = listAttachment(border_id); |
---|
[5604] | 3985 | form.uidsSave = uidsSave[border_id].toString(); |
---|
| 3986 | return( form ); |
---|
| 3987 | |
---|
| 3988 | }, |
---|
| 3989 | |
---|
| 3990 | encoder:function( pref ){ |
---|
| 3991 | |
---|
| 3992 | return( pref ); |
---|
| 3993 | } |
---|
| 3994 | |
---|
| 3995 | }); |
---|
| 3996 | |
---|
| 3997 | DataLayer.codec( "mailAttachment", "detail", { |
---|
| 3998 | |
---|
| 3999 | decoder: function(evtObj){ |
---|
| 4000 | |
---|
| 4001 | if( notArray = $.type(evtObj) !== "array" ) |
---|
| 4002 | evtObj = [ evtObj ]; |
---|
| 4003 | |
---|
| 4004 | var res = $.map(evtObj, function( form){ |
---|
| 4005 | return [$.map(form.files , function( files){ |
---|
[5620] | 4006 | return {source: files , disposition : form['attDisposition'+form.abaID]}; |
---|
[5604] | 4007 | })]; |
---|
| 4008 | }); |
---|
| 4009 | return notArray ? res[0] : res; |
---|
| 4010 | }, |
---|
| 4011 | |
---|
| 4012 | encoder: function(){} |
---|
| 4013 | |
---|
| 4014 | |
---|
[5614] | 4015 | }); |
---|
[5626] | 4016 | |
---|
| 4017 | function formatBytes(bytes) { |
---|
| 4018 | if (bytes >= 1000000000) { |
---|
| 4019 | return (bytes / 1000000000).toFixed(2) + ' GB'; |
---|
| 4020 | } |
---|
| 4021 | if (bytes >= 1000000) { |
---|
| 4022 | return (bytes / 1000000).toFixed(2) + ' MB'; |
---|
| 4023 | } |
---|
| 4024 | if (bytes >= 1000) { |
---|
| 4025 | return (bytes / 1000).toFixed(2) + ' KB'; |
---|
| 4026 | } |
---|
| 4027 | return bytes + ' B'; |
---|
[5922] | 4028 | }; |
---|
[6085] | 4029 | |
---|
[6487] | 4030 | function truncate(text, size){ |
---|
| 4031 | var result = text; |
---|
| 4032 | if(text.length > size){ |
---|
| 4033 | result = text.substring(0,size) + '...'; |
---|
| 4034 | } |
---|
| 4035 | return result; |
---|
| 4036 | } |
---|
| 4037 | |
---|
[6085] | 4038 | DataLayer.links('message'); |
---|
| 4039 | DataLayer.poll('message',30); |
---|
| 4040 | |
---|
| 4041 | |
---|