[2] | 1 | // Tempo do auto refresh (em milisegundos) |
---|
[7919] | 2 | var time_refresh = 150000; |
---|
[6996] | 3 | |
---|
[7414] | 4 | //MAILARCHIVER-01 |
---|
| 5 | // Intervalo de tempo de verificacao de comunicacao com o MailArchiver (milisegundos) |
---|
| 6 | var check_services_interval = 2000; |
---|
| 7 | // Numero de tentativas de reconexao |
---|
| 8 | var check_services_tryouts = 1; |
---|
| 9 | // Limite de tentativas de reconexao |
---|
| 10 | var check_services_tryouts_limit = 5; |
---|
| 11 | |
---|
| 12 | |
---|
[7729] | 13 | // tempo do auto save (em milisegundos) |
---|
[320] | 14 | // 20000 = 20 segundos |
---|
[5459] | 15 | var autosave_time = 40000; |
---|
[5134] | 16 | var results_search_messages = ""; |
---|
[7414] | 17 | var cabecalho = '<h4>ExpressoLivre - ExpressoMail</h4>'; |
---|
[6996] | 18 | var auxNotificationCriteriaVetor = []; |
---|
| 19 | var auxNotification; |
---|
| 20 | |
---|
| 21 | var countNewMessage = 0; |
---|
| 22 | var notifyNewMessageFilter = []; |
---|
| 23 | |
---|
[6528] | 24 | var dynamicPersonalContacts = new Array(); |
---|
[7096] | 25 | var dynamicPersonalGroups = new Array(); |
---|
[6528] | 26 | var dynamicContacts = new Array(); |
---|
| 27 | var topContact = 0; |
---|
| 28 | |
---|
[7567] | 29 | //Os IE's < 9 não possuem suporte a trim() introduzida no JavaScript 1.8.1 |
---|
[6031] | 30 | if(!String.prototype.trim){ |
---|
| 31 | String.prototype.trim = function(){ |
---|
[6528] | 32 | return this.replace(/^\s+|\s+$/g,''); |
---|
| 33 | } |
---|
[6031] | 34 | } |
---|
[6996] | 35 | |
---|
[5302] | 36 | function mount_url_folder(folders){ |
---|
[5306] | 37 | return folders.join(cyrus_delimiter); |
---|
[5486] | 38 | } |
---|
[6528] | 39 | |
---|
[7437] | 40 | function updateDynamicContact(userContacts){ |
---|
[7271] | 41 | |
---|
[7775] | 42 | if(!userContacts){ |
---|
| 43 | userContacts = REST.get("/usercontacts", false, updateDynamicContact); |
---|
| 44 | return true; |
---|
| 45 | } |
---|
[7437] | 46 | |
---|
[7775] | 47 | |
---|
[7437] | 48 | if(userContacts.collection && !userContacts.collection.error){ |
---|
| 49 | dynamicData = normalizeContacts(userContacts.collection.itens); |
---|
| 50 | }else{ |
---|
| 51 | dynamicData = []; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | if(dynamicData){ |
---|
| 55 | var dynamicContactsList = []; |
---|
| 56 | $.each(dynamicData, function(index, dynamic){ |
---|
| 57 | |
---|
| 58 | var dataType = userContacts.collection.itens[index].dataType; |
---|
| 59 | |
---|
| 60 | dynamic['value'] = (dynamic.name ? dynamic.name +' - ': '') + dynamic.mail; |
---|
| 61 | dynamic['type'] = dataType |
---|
| 62 | dynamic['typel'] = (dataType.substring(0,7) == "/shared" ? "/"+dataType.substring(7,dataType.length)+"s" : dataType); |
---|
| 63 | |
---|
| 64 | topContact = dynamic.number_of_messages > topContact ? dynamic.number_of_messages : topContact; |
---|
| 65 | |
---|
| 66 | dynamicContactsList.push(dynamic); |
---|
| 67 | }); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | dynamicData = dynamicContactsList; |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | /*dynamicContacts = new Array(); |
---|
| 74 | |
---|
[7271] | 75 | var dynamicUsers = REST.get("/dynamiccontacts"); |
---|
| 76 | |
---|
| 77 | if(dynamicUsers.collection && !dynamicUsers.collection.error){ |
---|
| 78 | var dynamicData = normalizeContacts(dynamicUsers.collection.itens) |
---|
| 79 | |
---|
| 80 | $.each(dynamicData, function(index, value){ |
---|
[6528] | 81 | if(index ==0){ |
---|
[7271] | 82 | topContact = parseInt(value['number_of_messages']); |
---|
[6528] | 83 | } |
---|
| 84 | var dynamic = { |
---|
[7271] | 85 | name : value.name, |
---|
| 86 | mail : value.mail, |
---|
| 87 | value: value.name + " - " + value.mail, |
---|
[6528] | 88 | type: "", |
---|
[7271] | 89 | id: value.id, |
---|
| 90 | qtd : value['number_of_messages'] |
---|
[6528] | 91 | }; |
---|
| 92 | dynamicContacts.push(dynamic); |
---|
| 93 | }); |
---|
[7437] | 94 | }*/ |
---|
[6528] | 95 | } |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | function updateDynamicPersonalContacts(){ |
---|
| 99 | dynamicPersonalContacts = new Array(); |
---|
[7271] | 100 | |
---|
| 101 | var personalContacts = REST.get("/personalContact"); |
---|
| 102 | |
---|
| 103 | if(personalContacts.collection && !personalContacts.collection.error){ |
---|
| 104 | var contactsData = normalizeContacts(personalContacts.collection.itens); |
---|
| 105 | if(contactsData){ |
---|
| 106 | $.each(contactsData, function(index, value){ |
---|
| 107 | var contact = { |
---|
| 108 | id : parseInt(value.id), |
---|
| 109 | name : value.name, |
---|
| 110 | email: value.email, |
---|
| 111 | value: value.name+ " - " + value.email, |
---|
| 112 | type: "P" |
---|
| 113 | }; |
---|
| 114 | dynamicPersonalContacts.push(contact); |
---|
| 115 | }); |
---|
| 116 | } |
---|
| 117 | } |
---|
[6528] | 118 | } |
---|
| 119 | |
---|
[7096] | 120 | |
---|
| 121 | function updateDynamicPersonalGroups(){ |
---|
| 122 | dynamicPersonalGroups = new Array(); |
---|
[7271] | 123 | |
---|
| 124 | var groups = REST.get("/groups"); |
---|
| 125 | |
---|
| 126 | if(groups.collection && !groups.collection.error){ |
---|
| 127 | var contactsData = normalizeContacts(groups.collection.itens); |
---|
| 128 | if(contactsData.collecion && !contactsData.collecion.error){ |
---|
| 129 | $.each(contactsData, function(index, value){ |
---|
| 130 | var contact = { |
---|
| 131 | id : parseInt(value.id), |
---|
| 132 | owner : value.owner, |
---|
| 133 | name : value.name, |
---|
| 134 | email: value.email, |
---|
| 135 | type: "G" |
---|
| 136 | }; |
---|
| 137 | dynamicPersonalGroups.push(contact); |
---|
| 138 | }); |
---|
| 139 | } |
---|
| 140 | } |
---|
[7096] | 141 | } |
---|
| 142 | |
---|
| 143 | |
---|
[2] | 144 | function init(){ |
---|
| 145 | if (!is_ie) |
---|
| 146 | Element('tableDivAppbox').width = '100%'; |
---|
[3035] | 147 | |
---|
[7414] | 148 | //MailArchiver save offset to gmt user preference data to list correctly date/time from messages list |
---|
| 149 | var save_gmtoffset = function(data){ |
---|
| 150 | gmtoffset = data; |
---|
| 151 | } |
---|
| 152 | |
---|
[3730] | 153 | |
---|
[7919] | 154 | if(preferences.show_name_print_messages == "1") { |
---|
| 155 | var getUserName = document.getElementById("user_info"); |
---|
| 156 | var userName = getUserName.innerHTML; |
---|
| 157 | var position = userName.indexOf("-"); |
---|
| 158 | var userName = userName.substring(3, position); |
---|
| 159 | cabecalho = '<h4>' + userName; |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | current_folder="INBOX"; |
---|
| 163 | |
---|
| 164 | //MAILARCHIVER-02 |
---|
| 165 | //Try to get ArchiveServices object directly |
---|
| 166 | if(ArchiveServices) |
---|
| 167 | expresso_mail_archive.Startup(); |
---|
| 168 | //ArchiveServices not runnnig: catch the user preferences to set up message at header |
---|
| 169 | else{ |
---|
| 170 | if(preferences.use_local_messages=="1") |
---|
| 171 | write_msg(get_lang('Sorry, but Mail Archiver does not seems to be running or installed at this workstation. By now, we are turning off local messages!')); |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | //cExecute ("$this.db_functions.get_dropdown_contacts", save_contacts); //Save contacts needs preferences. |
---|
| 175 | $.ajax({ |
---|
| 176 | async: false, |
---|
| 177 | url: "controller.php?" + $.param( {action: "$this.imap_functions.getMessagesIds", |
---|
| 178 | folder: get_current_folder(), |
---|
| 179 | msg_range_begin: "0", |
---|
| 180 | msg_range_end: "0", |
---|
| 181 | sort_box_type: "SORTARRIVAL", |
---|
| 182 | search_box_type: search_box_type, |
---|
| 183 | sort_box_reverse: "1" |
---|
| 184 | }), |
---|
| 185 | success: function(data){ |
---|
| 186 | data = connector.unserialize(data); |
---|
| 187 | if(data){ |
---|
| 188 | var _data = {}; |
---|
| 189 | $.each(data,function(index,value){ |
---|
| 190 | if (data[index]){ |
---|
| 191 | _data[data[index]] = data[index]; |
---|
| 192 | } |
---|
| 193 | }); |
---|
| 194 | populateSelectedMsgs(_data); |
---|
| 195 | } |
---|
| 196 | }, |
---|
| 197 | beforeSend: function( jqXHR, settings ){ |
---|
| 198 | connector.showProgressBar(); |
---|
| 199 | }, |
---|
| 200 | complete: function( jqXHR, settings ){ |
---|
| 201 | connector.hideProgressBar(); |
---|
[7535] | 202 | } |
---|
[7919] | 203 | }); |
---|
| 204 | 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); |
---|
| 205 | |
---|
| 206 | if(preferences.hide_folders == "1") |
---|
| 207 | Element('divAppboxHeader').innerHTML = title_app_menu; |
---|
| 208 | |
---|
| 209 | //Desbilitado limpeza de lixeira por request. Ticket #3253 |
---|
| 210 | //if (preferences.delete_trash_messages_after_n_days != 0) |
---|
| 211 | /// cExecute ("$this.imap_functions.automatic_trash_cleanness&before_date="+preferences.delete_trash_messages_after_n_days+"&cyrus_delimiter="+cyrus_delimiter, handler_automatic_trash_cleanness); |
---|
| 212 | |
---|
| 213 | //if(preferences.outoffice == "1") |
---|
| 214 | // |
---|
| 215 | |
---|
| 216 | //Troca da forma de construção de menu para o plugin jquery.contextMenu |
---|
| 217 | //ConstructMenuTools(); |
---|
| 218 | //MAILARCHIVER-00 |
---|
| 219 | //if ( (preferences.use_local_messages==1) && (expresso_local_messages.is_offline_installed()) ) //Precisa ser feito após a renderização da caixa de emails |
---|
| 220 | //check_mail_in_queue(); |
---|
| 221 | |
---|
| 222 | // Insere a applet de criptografia |
---|
| 223 | if (preferences.use_signature_digital_cripto == '1'){ |
---|
| 224 | loadApplet(); |
---|
| 225 | } |
---|
| 226 | // Fim da inserção da applet |
---|
| 227 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 228 | |
---|
| 229 | if($.cookie('collapse_folders') == "true"){ |
---|
| 230 | if(!is_ie) |
---|
| 231 | $("#folderscol").addClass( "hidden"); |
---|
| 232 | else |
---|
| 233 | $("#folderscol").hide(); |
---|
| 234 | $(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-e").children().attr('title', "Expandir"); |
---|
| 235 | refresh(); |
---|
| 236 | resizeWindow(); |
---|
| 237 | } |
---|
| 238 | else{ |
---|
| 239 | $(".collapse_folders").addClass("ui-icon ui-icon-triangle-1-w").children().attr('title', "Ocultar"); |
---|
| 240 | refresh(); |
---|
| 241 | resizeWindow(); |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | $(".collapse_folders_td").attr('title', "Ocultar/Expandir").click(function(){ |
---|
| 245 | if($("#folderscol").css("display") != "none"){ |
---|
| 246 | if(!is_ie) |
---|
| 247 | $("#folderscol").addClass( "hidden"); |
---|
| 248 | else |
---|
| 249 | $("#folderscol").hide(); |
---|
| 250 | |
---|
| 251 | $(".collapse_folders").removeClass("ui-icon-triangle-1-w"); |
---|
| 252 | $(".collapse_folders").addClass("ui-icon-triangle-1-e"); |
---|
| 253 | $(".collapse_folders").parent().attr('title', "Expandir"); |
---|
| 254 | $.cookie('collapse_folders', "true"); |
---|
| 255 | refresh(); |
---|
| 256 | resizeWindow(); |
---|
| 257 | }else{ |
---|
| 258 | if(!is_ie) |
---|
| 259 | $("#folderscol").removeClass( "hidden"); |
---|
| 260 | else |
---|
| 261 | $("#folderscol").show(); |
---|
| 262 | $(".collapse_folders").removeClass("ui-icon-triangle-1-e"); |
---|
| 263 | $(".collapse_folders").addClass("ui-icon-triangle-1-w"); |
---|
| 264 | $(".collapse_folders").parent().attr('title', "Ocultar"); |
---|
| 265 | $.cookie('collapse_folders', "false"); |
---|
| 266 | refresh(); |
---|
| 267 | resizeWindow(); |
---|
| 268 | } |
---|
| 269 | resizeWindow(); |
---|
| 270 | |
---|
| 271 | }).hover( |
---|
| 272 | function(){ |
---|
| 273 | $(this).addClass("collapse_folders_td_over"); |
---|
| 274 | }, |
---|
| 275 | function(){ |
---|
| 276 | $(this).removeClass("collapse_folders_td_over"); |
---|
| 277 | } |
---|
| 278 | ); |
---|
| 279 | |
---|
| 280 | if(parseInt(preferences.use_dynamic_contacts)){ |
---|
| 281 | updateDynamicContact(); |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | var handler_automatic_trash_cleanness = function(data) |
---|
| 286 | { |
---|
[2] | 287 | if (data != false){ |
---|
| 288 | write_msg(data.length +' '+ Element('txt_clear_trash').value); |
---|
| 289 | } |
---|
| 290 | } |
---|
[3035] | 291 | |
---|
[2] | 292 | // Versão |
---|
| 293 | Element('divAppboxHeader').innerHTML = title_app; |
---|
[3035] | 294 | |
---|
[2] | 295 | // Get cyrus delimiter |
---|
| 296 | cyrus_delimiter = Element('cyrus_delimiter').value; |
---|
[1035] | 297 | |
---|
[5486] | 298 | cExecute ("phpgwapi.browser.isMobile", function( data ){ |
---|
[4757] | 299 | mobile_device = ( ( data.constructor == Boolean ) ? data : ( data === 'true' ) ); |
---|
[5486] | 300 | }); |
---|
[6487] | 301 | |
---|
[6592] | 302 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 303 | |
---|
[2] | 304 | setTimeout('auto_refresh()', time_refresh); |
---|
[5486] | 305 | |
---|
| 306 | $("#divAppbox").css("padding-left", "0px"); |
---|
[2] | 307 | } |
---|
[1035] | 308 | |
---|
[1121] | 309 | function init_offline(){ |
---|
[3570] | 310 | current_folder = 'local_Inbox'; |
---|
[1121] | 311 | if (account_id != null) { |
---|
[3035] | 312 | if (!is_ie) |
---|
[1121] | 313 | Element('tableDivAppbox').width = '100%'; |
---|
| 314 | else |
---|
| 315 | connector.createXMLHTTP(); |
---|
| 316 | Element('divStatusBar').innerHTML = '<table height="16px" border=0 width=100% cellspacing=0 cellpadding=2>' + |
---|
| 317 | '<tr>' + |
---|
| 318 | '<td style="padding-left:17px" width=33% id="content_quota" align=left></td>' + |
---|
| 319 | '<td width=33% height=16px align=center nowrap><font face=Verdana, Arial, Helvetica, sans-serif color=#000066 size=2>' + |
---|
| 320 | '<b>ExpressoMail Offline</b><font size=1><b> - Versão 1.0</b></font></td>' + |
---|
| 321 | '<td width=33% id="div_menu_c3" align=right></td>' + |
---|
| 322 | '</tr></table>'; |
---|
[3035] | 323 | |
---|
[5497] | 324 | //Troca da forma de construção de menu para o plugin jquery.contextMenu |
---|
| 325 | //ConstructMenuTools(); |
---|
[1121] | 326 | |
---|
| 327 | draw_tree_folders(); |
---|
[3035] | 328 | |
---|
[1814] | 329 | proxy_mensagens.messages_list('local_Inbox', 1, preferences.max_email_per_page, 'SORTARRIVAL', null, 1,1,1, function handler(data){ |
---|
[1121] | 330 | draw_box(data, 'local_Inbox'); |
---|
| 331 | }) |
---|
[3035] | 332 | |
---|
[1121] | 333 | // Get cyrus delimiter |
---|
| 334 | cyrus_delimiter = Element('cyrus_delimiter').value; |
---|
[3035] | 335 | |
---|
[6528] | 336 | //cExecute ("$this.db_functions.get_dropdown_contacts_to_cache", function(data) {contacts = data;}); |
---|
[1121] | 337 | //cExecute ("$this.functions.get_preferences", save_preferences); |
---|
| 338 | } |
---|
| 339 | } |
---|
[1035] | 340 | /** |
---|
| 341 | * Carrega a applet java no objeto search_div |
---|
| 342 | * @author Mário César Kolling <mario.kolling@serpro.gov.br> |
---|
| 343 | */ |
---|
| 344 | |
---|
| 345 | function loadApplet(){ |
---|
| 346 | |
---|
[3035] | 347 | var search_div = Element('search_div'); |
---|
| 348 | var applet = null; |
---|
| 349 | if (navigator.userAgent.match('MSIE')){ |
---|
| 350 | applet = document.createElement('<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" ' + |
---|
| 351 | 'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"></object>'); |
---|
[1035] | 352 | |
---|
[3035] | 353 | var parameters = { |
---|
| 354 | type:'application/x-java-applet;version=1.5', |
---|
| 355 | code:'ExpressoSmimeApplet', |
---|
| 356 | codebase:'/security/', |
---|
| 357 | mayscript:'true', |
---|
| 358 | token: token_param, |
---|
| 359 | locale: locale, |
---|
| 360 | archive:'ExpressoCertMail.jar,' + |
---|
| 361 | 'ExpressoCert.jar,' + |
---|
| 362 | 'bcmail-jdk15-142.jar,' + |
---|
| 363 | 'mail.jar,' + |
---|
| 364 | 'activation.jar,' + |
---|
| 365 | 'bcprov-jdk15-142.jar,' + |
---|
| 366 | 'commons-codec-1.3.jar,' + |
---|
| 367 | 'commons-httpclient-3.1.jar,' + |
---|
| 368 | 'commons-logging-1.1.1.jar' |
---|
| 369 | //debug:'true' |
---|
| 370 | } |
---|
[1035] | 371 | |
---|
[3035] | 372 | if (parameters != 'undefined' && parameters != null){ |
---|
| 373 | for (var parameter in parameters) { |
---|
| 374 | var param = document.createElement("PARAM"); |
---|
| 375 | param.setAttribute("name",parameter); |
---|
| 376 | param.setAttribute("value",parameters[parameter]); |
---|
| 377 | applet.appendChild(param); |
---|
| 378 | } |
---|
| 379 | } |
---|
| 380 | } |
---|
[3781] | 381 | else |
---|
| 382 | { |
---|
[3035] | 383 | applet = document.createElement('embed'); |
---|
| 384 | applet.innerHTML = '<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="cert_applet" code="ExpressoSmimeApplet.class" ' + |
---|
| 385 | 'codebase="/security/" locale="'+locale+'"'+ |
---|
| 386 | '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" ' + |
---|
| 387 | 'token="' + token_param + '" ' + |
---|
| 388 | 'type="application/x-java-applet;version=1.5" mayscript > ' + |
---|
| 389 | //'type="application/x-java-applet;version=1.5" debug="true" mayscript > ' + |
---|
| 390 | '<noembed> ' + |
---|
| 391 | 'No Java Support. ' + |
---|
| 392 | '</noembed> ' + |
---|
| 393 | '</embed> '; |
---|
| 394 | } |
---|
[3781] | 395 | |
---|
| 396 | if( applet != null ) |
---|
| 397 | { |
---|
| 398 | applet.style.top = "-100px"; |
---|
| 399 | applet.style.left = "-100px"; |
---|
| 400 | window.document.body.insertBefore( applet, document.body.lastChild ); |
---|
| 401 | } |
---|
| 402 | |
---|
[1035] | 403 | } |
---|
| 404 | |
---|
[689] | 405 | function disable_field(field,condition) { |
---|
| 406 | var comando = "if ("+condition+") { document.getElementById('"+field.id+"').disabled=true;} else { document.getElementById('"+field.id+"').disabled=false; }"; |
---|
| 407 | eval(comando); |
---|
| 408 | } |
---|
[613] | 409 | /* |
---|
[7601] | 410 | funcão que remove todos os anexos... |
---|
[613] | 411 | */ |
---|
| 412 | function remove_all_attachments(folder,msg_num) { |
---|
[649] | 413 | |
---|
[613] | 414 | var call_back = function(data) { |
---|
[1319] | 415 | if(!data.status) { |
---|
| 416 | alert(data.msg); |
---|
| 417 | } |
---|
| 418 | else { |
---|
| 419 | msg_to_delete = Element(msg_num); |
---|
| 420 | change_tr_properties(msg_to_delete, data.msg_no); |
---|
| 421 | msg_to_delete.childNodes[1].innerHTML = ""; |
---|
| 422 | write_msg(get_lang("Attachments removed")); |
---|
[6550] | 423 | folderName = Base64.encode(folder); |
---|
| 424 | folderName = folderName.replace(/=/gi, ''); |
---|
| 425 | delete_border(msg_num+'_r_'+folderName,'false'); //close email tab |
---|
[7481] | 426 | |
---|
| 427 | } |
---|
[1319] | 428 | }; |
---|
[7749] | 429 | |
---|
| 430 | $.Zebra_Dialog(get_lang("delete all attachments confirmation"), { |
---|
| 431 | 'type': 'question', |
---|
| 432 | 'buttons': [get_lang("Yes"), get_lang("No")], |
---|
| 433 | 'overlay_opacity' : 0.5, |
---|
| 434 | 'width' : 500, |
---|
| 435 | 'custom_class': 'custom-zebra-filter', |
---|
| 436 | 'onClose': function(caption) { |
---|
| 437 | if(caption == get_lang("Yes")) |
---|
| 438 | cExecute ("$this.imap_functions.remove_attachments&folder="+folder+"&msg_num="+msg_num, call_back); |
---|
| 439 | } |
---|
| 440 | }); |
---|
[613] | 441 | } |
---|
[271] | 442 | function watch_changes_in_msg(border_id) |
---|
| 443 | { |
---|
| 444 | if (document.getElementById('border_id_'+border_id)) |
---|
[3035] | 445 | { |
---|
[271] | 446 | function keypress_handler () |
---|
| 447 | { |
---|
| 448 | away=false; |
---|
[5911] | 449 | var save_link = content.find(".save"); |
---|
[4803] | 450 | save_link.onclick = function onclick(event) {openTab.toPreserve[border_id] = true;save_msg(border_id);} ; |
---|
[5911] | 451 | save_link.button({disabled: false}); |
---|
[5417] | 452 | $(".header-button").button(); |
---|
[271] | 453 | }; |
---|
[5911] | 454 | var content = $("#content_id_"+border_id); |
---|
| 455 | |
---|
| 456 | var subject_obj = content.find(".subject"); |
---|
[271] | 457 | if ( subject_obj.addEventListener ) |
---|
| 458 | subject_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 459 | else if ( subject_obj.attachEvent ) |
---|
| 460 | subject_obj.attachEvent('onkeypress', keypress_handler); |
---|
[3035] | 461 | |
---|
[5911] | 462 | var to_obj = content.find('[name="input_to"]'); |
---|
[271] | 463 | if ( to_obj.addEventListener ) |
---|
| 464 | to_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 465 | else if ( to_obj.attachEvent ) |
---|
| 466 | to_obj.attachEvent('onkeypress', keypress_handler); |
---|
[5417] | 467 | |
---|
[5911] | 468 | var cc_obj = content.find('[name="input_cc"]'); |
---|
[5417] | 469 | if ( cc_obj.addEventListener ) |
---|
| 470 | cc_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 471 | else if ( cc_obj.attachEvent ) |
---|
| 472 | cc_obj.attachEvent('onkeypress', keypress_handler); |
---|
| 473 | |
---|
[5911] | 474 | if(content.find('[name="input_cco"]').length){ |
---|
| 475 | var cco_obj = content.find('[name="input_cco"]'); |
---|
[5423] | 476 | if ( cco_obj.addEventListener ) |
---|
[5417] | 477 | cco_obj.addEventListener('keypress', keypress_handler, false); |
---|
[5423] | 478 | else if ( cco_obj.attachEvent ) |
---|
| 479 | cco_obj.attachEvent('onkeypress', keypress_handler); |
---|
| 480 | } |
---|
[5417] | 481 | //var important_obj = $("important_message_options_"+border_id).bind('click',keypress_handler); |
---|
| 482 | //important_obj.addEventListener('click', keypress_handler, false); |
---|
| 483 | |
---|
[5194] | 484 | var txtarea_obj = Element('body_'+border_id); |
---|
| 485 | if (txtarea_obj){ |
---|
| 486 | if ((preferences.plain_text_editor == 1)||(Element('body_')+border_id).checked){ |
---|
| 487 | if ( txtarea_obj.addEventListener ) |
---|
| 488 | txtarea_obj.addEventListener('keypress', keypress_handler, false); |
---|
| 489 | else if ( txtarea_obj.attachEvent ) |
---|
| 490 | txtarea_obj.attachEvent('onkeypress', keypress_handler); |
---|
| 491 | } |
---|
| 492 | } |
---|
[271] | 493 | } |
---|
| 494 | } |
---|
| 495 | |
---|
[1000] | 496 | function show_msg_img(msg_number,folder){ |
---|
[3035] | 497 | var call_back = function(data){ |
---|
| 498 | data.showImg = true; |
---|
| 499 | if (!Element(data.msg_number)){ |
---|
| 500 | trElement = document.createElement('DIV'); |
---|
| 501 | trElement.id = data.msg_number; |
---|
| 502 | Element("tbody_box").appendChild(trElement); |
---|
| 503 | } |
---|
| 504 | show_msg(data); |
---|
| 505 | } |
---|
[1000] | 506 | |
---|
[3035] | 507 | proxy_mensagens.msg_img(msg_number,folder,call_back); |
---|
[1000] | 508 | |
---|
[800] | 509 | } |
---|
[271] | 510 | |
---|
[827] | 511 | function show_msg(msg_info){ |
---|
[7768] | 512 | |
---|
[2] | 513 | if(!verify_session(msg_info)) |
---|
| 514 | return; |
---|
[800] | 515 | if (typeof(msg_info) != 'object') |
---|
| 516 | alert(get_lang("Error in show_msg param is not object")); |
---|
[3035] | 517 | |
---|
[206] | 518 | if (msg_info.status_get_msg_info == 'false') |
---|
| 519 | { |
---|
| 520 | write_msg(get_lang("Problems reading your message")+ "."); |
---|
| 521 | return; |
---|
| 522 | } |
---|
[3035] | 523 | |
---|
[2] | 524 | var handler_sendNotification = function(data){ |
---|
| 525 | if (data) |
---|
| 526 | write_msg(get_lang("A read confirmation was sent.")); |
---|
| 527 | else |
---|
| 528 | write_msg(get_lang("Error in SMTP sending read confirmation.")); |
---|
| 529 | } |
---|
[3035] | 530 | |
---|
[1035] | 531 | if(msg_info.source) |
---|
| 532 | { |
---|
[3035] | 533 | // Abrindo um e-mail criptografado |
---|
| 534 | // Verifica se existe o objeto applet |
---|
| 535 | if (!Element('cert_applet')){ |
---|
| 536 | // se não existir, mostra mensagem de erro. |
---|
| 537 | write_msg(get_lang('The preference "%1" isn\'t enabled.', get_lang('Enable digitally sign/cipher the message?'))); |
---|
| 538 | } else { |
---|
| 539 | // se existir prepara os dados para serem enviados e chama a |
---|
| 540 | // operação na applet |
---|
[847] | 541 | |
---|
[3035] | 542 | // if ((msg_info.DispositionNotificationTo) && ((msg_info.Unseen == 'U') || (msg_info.Recent == 'N'))){ |
---|
| 543 | /* var confNotification = confirm(get_lang("The sender waits your notification of reading. Do you want to confirm this?"), ""); |
---|
| 544 | if (confNotification)*/ |
---|
| 545 | // cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&subject="+url_encode(msg_info.subject), handler_sendNotification); |
---|
| 546 | // } |
---|
[1035] | 547 | |
---|
[3035] | 548 | Element('cert_applet').doButtonClickAction('decript', |
---|
| 549 | msg_info.msg_number, |
---|
| 550 | msg_info.source, |
---|
| 551 | msg_info.msg_folder); // Passa os dados para a applet |
---|
| 552 | } |
---|
[1035] | 553 | return; |
---|
| 554 | |
---|
| 555 | } |
---|
| 556 | |
---|
| 557 | |
---|
| 558 | if (msg_info.status_get_msg_info == 'false') |
---|
| 559 | { |
---|
| 560 | write_msg(get_lang("Problems reading your message")+ "."); |
---|
| 561 | return; |
---|
| 562 | } |
---|
| 563 | |
---|
[2] | 564 | if (msg_info.status == 'false'){ |
---|
| 565 | eval(msg_info.command_to_exec); |
---|
| 566 | } |
---|
| 567 | else{ |
---|
[3035] | 568 | var ID = msg_info.original_ID ? msg_info.original_ID : msg_info.msg_number; |
---|
[6330] | 569 | |
---|
[6349] | 570 | var folderName = msg_info.msg_folder; |
---|
| 571 | folderName = Base64.encode(folderName); |
---|
| 572 | folderName = folderName.replace(/=/gi, ''); |
---|
| 573 | var id_msg_read = ID+"_r_"+folderName; |
---|
[5284] | 574 | |
---|
| 575 | //Evita a tentativa de criação de uma aba cujo ID já existe |
---|
[5614] | 576 | if (Element("border_id_"+id_msg_read) && currentTab > 0) |
---|
[5284] | 577 | id_msg_read += "n"; |
---|
[5936] | 578 | |
---|
[6337] | 579 | if (preferences.use_shortcuts == '1') |
---|
| 580 | select_msg(ID, 'null'); |
---|
| 581 | |
---|
[2] | 582 | // Call function to draw message |
---|
[59] | 583 | // If needed, delete old border |
---|
[5134] | 584 | var isPartMsg = false; |
---|
| 585 | for(var ii = 0; ii < partMsgs.length; ii++) |
---|
[5689] | 586 | if(partMsgs[ii] == ID) isPartMsg = true; |
---|
| 587 | |
---|
| 588 | if(msg_info.alarm == false){ |
---|
[7768] | 589 | if ((openTab.type[currentTab] == 2 || openTab.type[currentTab] == 3) && isPartMsg === false && msg_info.openSameBorder == true){ |
---|
[7481] | 590 | delete_border(currentTab,'false'); |
---|
| 591 | } |
---|
| 592 | |
---|
[5689] | 593 | } |
---|
| 594 | |
---|
[3018] | 595 | if(Element("border_id_" + id_msg_read)) { |
---|
[3035] | 596 | alternate_border(id_msg_read); |
---|
| 597 | resizeWindow(); |
---|
[3018] | 598 | } |
---|
[2] | 599 | else { |
---|
| 600 | var border_id = create_border(msg_info.subject, id_msg_read); |
---|
| 601 | if(border_id) |
---|
[827] | 602 | { |
---|
| 603 | openTab.type[border_id] = 2; |
---|
[6283] | 604 | openTab.imapBox[border_id] = msg_info.msg_folder; |
---|
[2] | 605 | draw_message(msg_info,border_id); |
---|
[7603] | 606 | // var unseen_sort = document.getElementById('span_flag_UNSEEN').getAttribute('onclick'); |
---|
| 607 | // unseen_sort = unseen_sort.toString(); |
---|
| 608 | // if ( !(unseen_sort.indexOf("'UNSEEN' == 'UNSEEN'") < 0) ) |
---|
| 609 | // { |
---|
[7591] | 610 | // var sort_type = sort_box_type; |
---|
| 611 | // sort_box_type = null; |
---|
| 612 | // sort_box('UNSEEN', sort_type,false); |
---|
| 613 | // delete selectedPagingMsgs[msg_info.msg_number]; |
---|
| 614 | // totalFolderMsgs--; |
---|
[7603] | 615 | // } |
---|
[827] | 616 | } |
---|
[2] | 617 | else |
---|
| 618 | return; |
---|
| 619 | } |
---|
| 620 | |
---|
[605] | 621 | var domains = ""; |
---|
[1035] | 622 | if ((msg_info.DispositionNotificationTo) && (!msg_is_read(ID) || (msg_info.Recent == 'N'))) |
---|
[3035] | 623 | { |
---|
[605] | 624 | if (preferences.notification_domains != undefined && preferences.notification_domains != "") |
---|
[3035] | 625 | { |
---|
[605] | 626 | domains = preferences.notification_domains.split(','); |
---|
[3035] | 627 | } |
---|
[605] | 628 | else |
---|
[3035] | 629 | { |
---|
[605] | 630 | var confNotification = true; |
---|
| 631 | } |
---|
| 632 | for (var i = 0; i < domains.length; i++) |
---|
[6673] | 633 | if (Base64.decode(msg_info.DispositionNotificationTo).match("@"+domains[i])) |
---|
[605] | 634 | { |
---|
| 635 | var confNotification = true; |
---|
| 636 | break; |
---|
| 637 | } |
---|
| 638 | if (confNotification == undefined) |
---|
[6673] | 639 | var confNotification = confirm(get_lang("The sender:\n%1\nwaits your notification of reading. Do you want to confirm this?",Base64.decode(msg_info.DispositionNotificationTo)), ""); |
---|
[605] | 640 | |
---|
[6860] | 641 | if (confNotification) { |
---|
| 642 | /* Adequação a nova funcionalidade. Agora, a confirmação de leitura é uma preferência do usuário. */ |
---|
| 643 | if(preferences.confirm_read_message) { |
---|
| 644 | $.Zebra_Dialog(get_lang("Would you like to send the read receipt?"), { |
---|
| 645 | 'type': 'question', |
---|
| 646 | 'title': get_lang('Read receipt'), |
---|
| 647 | 'buttons': [get_lang("Yes"), get_lang("No")], |
---|
| 648 | 'overlay_opacity' : 0.5, |
---|
[7612] | 649 | 'custom_class': 'custom-zebra-filter', |
---|
[6860] | 650 | 'onClose': function(caption) { |
---|
| 651 | if(caption == get_lang("Yes")) |
---|
| 652 | cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject), handler_sendNotification); |
---|
| 653 | else |
---|
| 654 | write_msg(get_lang("Confirmation message is not sent")); |
---|
| 655 | } |
---|
| 656 | }); |
---|
| 657 | } |
---|
| 658 | else |
---|
| 659 | cExecute ("$this.imap_functions.send_notification¬ificationto="+msg_info.DispositionNotificationTo+"&date="+msg_info.udate+"&subject="+url_encode(msg_info.subject), handler_sendNotification); |
---|
| 660 | } |
---|
| 661 | |
---|
[605] | 662 | } |
---|
[7414] | 663 | |
---|
[163] | 664 | //Change msg class to read. |
---|
[1035] | 665 | if (!msg_is_read(ID)) |
---|
[605] | 666 | { |
---|
[7414] | 667 | //MAILARCHIVER-01 TAG MESSAGE AS SEEN |
---|
| 668 | if (proxy_mensagens.is_local_folder(get_current_folder())){ |
---|
| 669 | expresso_mail_archive.drawdata = null //no draw action |
---|
| 670 | var tl = expresso_mail_archive.pattern.tagConfig('unseen', ID, 1); |
---|
| 671 | expresso_mail_archive.taglist = tl; |
---|
| 672 | expresso_mail_archive.progressbar = window.setTimeout("expresso_mail_archive.tagMessage()",1); |
---|
| 673 | } |
---|
| 674 | set_msg_as_read(ID, true); |
---|
[1035] | 675 | if (msg_info.cacheHit || (!proxy_mensagens.is_local_folder(get_current_folder()) && msg_info.original_ID)) |
---|
[3035] | 676 | { |
---|
[7414] | 677 | set_message_flag(ID, "seen"); // avoid caducous (lazy) data |
---|
[3035] | 678 | } |
---|
| 679 | } |
---|
[2] | 680 | } |
---|
[5339] | 681 | setTimeout('resizeWindow()',300); |
---|
[2] | 682 | } |
---|
| 683 | |
---|
| 684 | function auto_refresh(){ |
---|
[6996] | 685 | refresh(preferences.alert_new_msg, preferences.notifications); |
---|
[2] | 686 | setTimeout('auto_refresh()', time_refresh); |
---|
| 687 | } |
---|
| 688 | |
---|
[1518] | 689 | function auto_archiving() { |
---|
| 690 | expresso_mail_sync.start_sync(); |
---|
| 691 | setTimeout('auto_archiving()',600000); |
---|
| 692 | } |
---|
| 693 | |
---|
[6996] | 694 | function notificationFilter(data, notifyCriteria){ |
---|
| 695 | |
---|
| 696 | if(parseInt(notifyCriteria) && data.length > 0 && !activePage ){ |
---|
| 697 | |
---|
| 698 | var howManyCriteria = $('div.gray.filtersDeadline .message-list li').length; |
---|
| 699 | var differenceOfNewCriteria = data.length - howManyCriteria; |
---|
| 700 | |
---|
| 701 | if(differenceOfNewCriteria > 0){ |
---|
| 702 | for(var i=data.length - differenceOfNewCriteria; i < data.length; i++){ |
---|
[7919] | 703 | var msg_folder = data[i].msg_folder; |
---|
| 704 | var msg_number = data[i].msg_number; |
---|
[6996] | 705 | desktopNotification.sentNotification("",get_lang("Filter criteria"), truncate(new Date(data[i].udate).toString('dd/MM HH:mm') + ' - ' + data[i].from+' - '+data[i].subject, 75)); |
---|
[7919] | 706 | desktopNotification.showNotification(function(){ |
---|
| 707 | cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+msg_folder+"&msg_number="+msg_number, function(){}); |
---|
| 708 | }, function(){ |
---|
[6996] | 709 | window.focus(); |
---|
| 710 | this.cancel(); |
---|
| 711 | }); |
---|
| 712 | } |
---|
| 713 | } |
---|
| 714 | } |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | function refresh(alert_new_msg, notifyPermission){ |
---|
| 718 | |
---|
[6487] | 719 | getFromAlertRules(); |
---|
[2] | 720 | var handler_refresh = function(data){ |
---|
[6996] | 721 | handlerMessageFilter = function (data) { |
---|
[7056] | 722 | notificationFilter(data, notifyPermission); |
---|
[6996] | 723 | alarmFollowupflagged('filtersAlarms', data); |
---|
[7056] | 724 | |
---|
[6487] | 725 | } |
---|
[6996] | 726 | /* Busca nas pastas indexadas para ver se há novas mensagens com a flag $FilteredMessage */ |
---|
| 727 | cExecute ("$this.imap_functions.getFlaggedAlertMessages&folders="+fromRules, handlerMessageFilter); |
---|
| 728 | |
---|
[5158] | 729 | if(data['msg_range_end']) |
---|
| 730 | if(data['msg_range_end'] > 0) |
---|
| 731 | current_page = data['msg_range_end']/preferences.max_email_per_page; |
---|
[2] | 732 | if(!verify_session(data)) |
---|
| 733 | return; |
---|
[5134] | 734 | var total_messages_element = Element('tot_m'); |
---|
[3955] | 735 | |
---|
[833] | 736 | var box = Element("tbody_box"); |
---|
| 737 | if (box.childNodes.length == 0) |
---|
[4189] | 738 | showEmptyBoxMsg(box); |
---|
[833] | 739 | |
---|
[6996] | 740 | if (data.length > 0 || countNewMessage > 0){ |
---|
[6426] | 741 | for(var i=0;i< data.length;i++){ |
---|
| 742 | if (!onceOpenedHeadersMessages[current_folder]) |
---|
| 743 | onceOpenedHeadersMessages[current_folder] = {}; |
---|
| 744 | onceOpenedHeadersMessages[current_folder][data[i].msg_number] = data[i]; |
---|
| 745 | } |
---|
[7124] | 746 | Element("table_message_header_box_0").emptyBody = false; |
---|
[4189] | 747 | table_element = Element("table_box"); |
---|
[3145] | 748 | var msg_info = document.getElementById('msg_info'); |
---|
[3265] | 749 | if (msg_info != null) |
---|
| 750 | { |
---|
[4189] | 751 | var msg_tr = msg_info.parentNode.parentNode; |
---|
| 752 | msg_tr.removeChild(msg_info.parentNode); |
---|
[4814] | 753 | if (!Element("colgroup_main_"+numBox)) { |
---|
| 754 | var colgr_element = buildColGroup(); |
---|
| 755 | colgr_element.setAttribute("id","colgroup_main_"+numBox); |
---|
| 756 | table_element.appendChild(colgr_element); |
---|
| 757 | } |
---|
[3265] | 758 | } |
---|
[139] | 759 | |
---|
[2] | 760 | var box = Element("tbody_box"); |
---|
[5134] | 761 | //table_element.insertBefore(box, Element("colgroup_main_"+numBox)); // keeps colgroup as the last child |
---|
| 762 | //table_element.appendChild(Element("colgroup_main_"+numBox)); |
---|
| 763 | |
---|
[7323] | 764 | |
---|
| 765 | if (!$("#colgroup_main_0").size()){ |
---|
| 766 | $(table_element).append(Element("colgroup_main_"+numBox)); |
---|
| 767 | } |
---|
[3265] | 768 | |
---|
[5134] | 769 | if (data.msgs_to_delete.length > 0){ |
---|
[3265] | 770 | for (var i=0; i<data.msgs_to_delete.length; i++){ |
---|
[4110] | 771 | if ( (data.msgs_to_delete[i] != undefined) && (data.msgs_to_delete[i] != "")){ |
---|
[3265] | 772 | removeAll(data.msgs_to_delete[i]); |
---|
| 773 | } |
---|
| 774 | } |
---|
[5134] | 775 | } |
---|
[7759] | 776 | if (data[0] && data[0].msg_folder != current_folder) // Bad request |
---|
[3140] | 777 | return false; |
---|
[7742] | 778 | /* removido incremento da variável pois estava incrementando mais do que o necessário |
---|
| 779 | * devido ao incremento realizado em seguida, quando novas são recebidas */ |
---|
| 780 | //totalFolderMsgs += data.new_msgs; |
---|
[7061] | 781 | |
---|
[271] | 782 | for (var i=0; i<data.length; i++){ |
---|
[3035] | 783 | var existent = document.getElementById(data[i].msg_number); |
---|
| 784 | if (!existent) |
---|
| 785 | { |
---|
[6930] | 786 | selectedPagingMsgs[data[i].msg_number] = false; |
---|
[7742] | 787 | if(data.new_msgs != 0) |
---|
| 788 | totalFolderMsgs++; |
---|
[6930] | 789 | updateSelectedMsgs(false,data[i].msg_number); |
---|
[3493] | 790 | var new_msg = this.make_tr_message(data[i], current_folder, data.offsetToGMT); |
---|
[5486] | 791 | $(new_msg).draggable({ |
---|
| 792 | start : function(){ |
---|
[7751] | 793 | $('.upper, .lower').show(); |
---|
| 794 | $(".lower").css("top", ($("#content_folders").height()-18) + $("#content_folders").offset().top); |
---|
[5499] | 795 | if($(".shared-folders").length){ |
---|
| 796 | $(".shared-folders").parent().find('.folder:not(".shared-folders")').droppable({ |
---|
| 797 | over : function(a, b){ |
---|
| 798 | //SETA BORDA EM VOLTA DA PASTA |
---|
[5765] | 799 | over = $(this); |
---|
| 800 | $(this).addClass("folder-over"); |
---|
| 801 | if(($(this)[0] != $(this).parent().find(".head_folder")[0])) |
---|
| 802 | if($(this).prev()[0]) |
---|
| 803 | if($(this).parent().find(".expandable-hitarea")[0] == $(this).prev()[0]){ |
---|
| 804 | setTimeout(function(){ |
---|
| 805 | if(over.hasClass("folder-over")) |
---|
| 806 | over.prev().trigger("click"); |
---|
| 807 | }, 500); |
---|
| 808 | |
---|
| 809 | } |
---|
[5499] | 810 | }, |
---|
| 811 | out : function(){ |
---|
| 812 | //RETIRA BORDA EM VOLTA DA PASTA |
---|
[5765] | 813 | $(this).removeClass("folder-over"); |
---|
[5499] | 814 | }, |
---|
| 815 | //accept: ".draggin_mail", |
---|
| 816 | drop : function(event, ui){ |
---|
| 817 | $(this).css("border", ""); |
---|
| 818 | if($(this).parent().attr('id') == undefined){ |
---|
| 819 | var folder_to = 'INBOX'; |
---|
| 820 | var to_folder_title = get_lang("Inbox"); |
---|
| 821 | }else{ |
---|
| 822 | var folder_to = $(this).parent().attr('id'); |
---|
| 823 | var to_folder_title = $(this).attr('title'); |
---|
| 824 | } |
---|
| 825 | var folder_to_move = ui.draggable.parent().attr('id'); |
---|
| 826 | var border_id = ui.draggable.find("input[type=hidden]").attr("name"); |
---|
| 827 | // Mensagens : SE O DROP VIER DA LISTA DE MENSAGENS : |
---|
| 828 | if(folder_to_move == "tbody_box"){ |
---|
| 829 | move_msgs2(get_current_folder(), 'selected', 0, folder_to, to_folder_title,true); |
---|
| 830 | return refresh(); |
---|
| 831 | } |
---|
| 832 | } |
---|
| 833 | }); |
---|
| 834 | } |
---|
[5486] | 835 | }, |
---|
[5499] | 836 | stop :function(){ |
---|
[7751] | 837 | $('.upper, .lower').hide(); |
---|
[5499] | 838 | $(".shared-folders").parent().find(".folder").droppable("destroy"); |
---|
[5486] | 839 | }, |
---|
| 840 | helper: function(event){ |
---|
[6930] | 841 | $(this).addClass("selected_msg").find("input:checkbox").attr("checked", true); |
---|
| 842 | updateSelectedMsgs($(this).find("input:checkbox").is(':checked'),$(this).attr("id")); |
---|
| 843 | if ( $("#tbody_box .selected_shortcut_msg").length > 1) { |
---|
| 844 | $("#tbody_box .selected_shortcut_msg").addClass("selected_msg").find('.checkbox').attr('checked',true); |
---|
| 845 | $.each( $(".selected_shortcut_msg"), function(index, value){ |
---|
| 846 | updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id")); |
---|
| 847 | }); |
---|
| 848 | } |
---|
| 849 | if(totalSelected() > 1) |
---|
| 850 | return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : (totalSelected()+" mensagens selecionadas"), type: "messages"})+"</td></tr>"); |
---|
| 851 | if( $(this).find(".td_msg_subject").text().length > 18 ) |
---|
| 852 | 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>"); |
---|
| 853 | else |
---|
| 854 | return $("<tr><td>"+DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : $(this).find(".td_msg_subject").text(), type: "messages"})+"</td></tr>"); |
---|
[5486] | 855 | }, |
---|
[5754] | 856 | iframeFix: true, |
---|
| 857 | delay: 150, |
---|
| 858 | cursorAt: {top: 5, left: 56}, |
---|
| 859 | refreshPositions: true, |
---|
[5486] | 860 | containment: "#divAppbox" |
---|
[5506] | 861 | }).bind("contextmenu", function(){ |
---|
[6930] | 862 | if (!(($(event.target).find('img').length > 0) && ($(event.target).hasClass('td-label')))){ |
---|
| 863 | if($(this).find("input:checkbox").attr("checked") != "checked"){ |
---|
| 864 | $(this).find("input:checkbox").trigger('click'); |
---|
| 865 | $(this).addClass("selected_msg"); |
---|
| 866 | } |
---|
| 867 | updateSelectedMsgs($(this).find("input:checkbox").is(':checked'),$(this).attr("id")); |
---|
[5506] | 868 | } |
---|
[5486] | 869 | }); |
---|
| 870 | //_dragArea.makeDragged(new_msg, data[i].msg_number, data[i].subject, true); |
---|
[3955] | 871 | |
---|
[4764] | 872 | if( data[i].next_msg_number != undefined && data[i].next_msg_number != null ){ |
---|
[5134] | 873 | try { |
---|
[5891] | 874 | box.insertBefore(new_msg, box.childNodes[data[i].msg_key_position]); |
---|
[5134] | 875 | } |
---|
| 876 | catch (e){ |
---|
[5292] | 877 | box.insertBefore(new_msg, box.firstChild); |
---|
[5134] | 878 | } |
---|
[4764] | 879 | } |
---|
| 880 | else if (data[i].Recent == 'N'){ |
---|
[3265] | 881 | box.insertBefore(new_msg,box.firstChild); |
---|
[4764] | 882 | } |
---|
| 883 | else { |
---|
[3265] | 884 | box.appendChild(new_msg); |
---|
[4764] | 885 | } |
---|
[3035] | 886 | } |
---|
[2] | 887 | } |
---|
[7729] | 888 | var box = Element("tbody_box"); |
---|
| 889 | if(box.childNodes.length > 1){ |
---|
| 890 | updateBoxBgColor(box.childNodes); |
---|
| 891 | } |
---|
| 892 | |
---|
[6188] | 893 | if(parseInt(preferences.use_shortcuts)) |
---|
| 894 | select_msg("null","reload_msg","null"); |
---|
[6996] | 895 | |
---|
| 896 | if(parseInt(alert_new_msg) && data.new_msgs > 0 && activePage) |
---|
[1951] | 897 | alert(data['new_msgs'] > 1 ? get_lang("You have %1 new messages", data['new_msgs']) + "!" : get_lang("You have 1 new message") +"!"); |
---|
[6996] | 898 | |
---|
| 899 | |
---|
| 900 | if(parseInt(notifyPermission) && (data.new_msgs > 0 || !!countNewMessage) && !activePage ){ |
---|
| 901 | |
---|
| 902 | countNewMessage += data.length; |
---|
| 903 | |
---|
[7729] | 904 | param = (countNewMessage > 1 ? (get_lang("You have %1 new messages", countNewMessage) + "!") : (get_lang("You have 1 new message") + "!")); |
---|
| 905 | desktopNotificationAux = desktopNotification.sentNotification("",get_lang("Notification"), param); |
---|
[6996] | 906 | |
---|
[7777] | 907 | if(!auxNotification) |
---|
[6996] | 908 | desktopNotification.cancelByReference(auxNotification); |
---|
| 909 | |
---|
| 910 | desktopNotification.showNotification(function(){ |
---|
| 911 | countNewMessage = 0; |
---|
| 912 | }, function(){ |
---|
| 913 | window.focus(); |
---|
| 914 | this.cancel(); |
---|
| 915 | countNewMessage = 0; |
---|
| 916 | }); |
---|
| 917 | |
---|
| 918 | auxNotification = desktopNotificationAux; |
---|
| 919 | } |
---|
[3265] | 920 | build_quota(data['quota']); |
---|
[2] | 921 | } |
---|
[5134] | 922 | if(data.new_msgs){ |
---|
| 923 | total_messages_element.innerHTML = parseInt( total_messages_element.innerHTML ) + data.new_msgs; |
---|
| 924 | }else if(data.tot_msgs){ |
---|
[7123] | 925 | total_messages_element.innerHTML = data.tot_msgs >=0 ? data.tot_msgs : 0; |
---|
[5134] | 926 | } |
---|
[976] | 927 | // Update Box BgColor |
---|
| 928 | var box = Element("tbody_box"); |
---|
| 929 | if(box.childNodes.length > 1){ |
---|
| 930 | updateBoxBgColor(box.childNodes); |
---|
| 931 | } |
---|
[1443] | 932 | connector.purgeCache(); |
---|
[7641] | 933 | cExecute("$this.imap_functions.get_folders_list&onload=true", force_update_menu); |
---|
[4189] | 934 | resizeMailList(); |
---|
[5754] | 935 | |
---|
[2] | 936 | } |
---|
[5936] | 937 | |
---|
[2] | 938 | msg_range_end = (current_page*preferences.max_email_per_page); |
---|
| 939 | msg_range_begin = (msg_range_end-(preferences.max_email_per_page)+1); |
---|
[3035] | 940 | |
---|
| 941 | |
---|
[2] | 942 | //Get element tBody. |
---|
| 943 | main = Element("tbody_box"); |
---|
| 944 | if(!main) |
---|
[3035] | 945 | return; |
---|
[139] | 946 | |
---|
[2] | 947 | // Get all TR (messages) in tBody. |
---|
| 948 | main_list = main.childNodes; |
---|
| 949 | var tmp = ''; |
---|
| 950 | var string_msgs_in_main = ''; |
---|
[139] | 951 | |
---|
[3035] | 952 | var len = main_list.length; |
---|
[2] | 953 | for (var j=0; j < len; j++) |
---|
| 954 | tmp += main_list[j].id + ','; |
---|
[3035] | 955 | |
---|
[2] | 956 | string_msgs_in_main = tmp.substring(0,(tmp.length-1)); |
---|
[1121] | 957 | if(!expresso_offline) |
---|
[6287] | 958 | $.ajax({ |
---|
| 959 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.refresh', |
---|
| 960 | folder: current_folder, |
---|
| 961 | msgs_existent: string_msgs_in_main, |
---|
| 962 | msg_range_begin: msg_range_begin, |
---|
| 963 | msg_range_end: msg_range_end, |
---|
| 964 | sort_box_type: sort_box_type, |
---|
| 965 | search_box_type: search_box_type, |
---|
| 966 | sort_box_reverse: sort_box_reverse } ), |
---|
| 967 | success: function( data ){ |
---|
| 968 | data = connector.unserialize( data ); |
---|
| 969 | |
---|
| 970 | if( data ) |
---|
| 971 | handler_refresh( data ); |
---|
[7729] | 972 | |
---|
[6469] | 973 | }, |
---|
[7729] | 974 | async: false, |
---|
[6469] | 975 | beforeSend: function( jqXHR, settings ){ |
---|
[6587] | 976 | connector.showProgressBar(); |
---|
[6469] | 977 | }, |
---|
| 978 | complete: function( jqXHR, settings ){ |
---|
| 979 | connector.hideProgressBar(); |
---|
[7729] | 980 | |
---|
[6287] | 981 | } |
---|
| 982 | |
---|
| 983 | }); |
---|
[7729] | 984 | |
---|
[7487] | 985 | var msgs = $("#tbody_box tr"); |
---|
[7683] | 986 | //Se a classe abaixo (somente ela) não existir a barra de seleção azul deve voltar ao topo. |
---|
| 987 | if(!msgs.hasClass("current_selected_shortcut_msg")) |
---|
[7487] | 988 | { |
---|
[7758] | 989 | if(preferences.use_shortcuts == '1') |
---|
| 990 | { |
---|
| 991 | msgs.first().addClass("current_selected_shortcut_msg selected_shortcut_msg"); |
---|
| 992 | } |
---|
[7487] | 993 | } |
---|
[2] | 994 | } |
---|
| 995 | |
---|
[7603] | 996 | function delete_msgs(folder, msgs_number, border_ID, show_success_msg,archive, prev_message){ |
---|
[7481] | 997 | if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){ |
---|
[7601] | 998 | alert( "Impossivel deletar mensagens que ainda estão sendo arquivadas." ); |
---|
[5134] | 999 | return; |
---|
| 1000 | } |
---|
| 1001 | |
---|
[4840] | 1002 | var userTrashFolder = ''; |
---|
| 1003 | |
---|
[7658] | 1004 | if (arguments.length <= 6) show_success_msg = true; |
---|
[4840] | 1005 | if (folder == 'null') folder = current_folder; |
---|
| 1006 | |
---|
| 1007 | if(folder.substr(0,4) == 'user') |
---|
| 1008 | { |
---|
[5844] | 1009 | var arrayFolder = folder.split(cyrus_delimiter); |
---|
[7738] | 1010 | userTrashFolder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Trash']; |
---|
[8085] | 1011 | var has_folder = false;//Folder.get( userTrashFolder, false ); |
---|
[8079] | 1012 | var folders = DataLayer.get("folder"); |
---|
| 1013 | $.each(folders,function(index,value){ |
---|
| 1014 | if(value && value.id == userTrashFolder) |
---|
| 1015 | has_folder = true; |
---|
| 1016 | }); |
---|
| 1017 | |
---|
[5844] | 1018 | if(!has_folder){ |
---|
| 1019 | create_new_folder(special_folders['Trash'], 'user'+cyrus_delimiter+arrayFolder[1]); |
---|
| 1020 | } |
---|
| 1021 | |
---|
[4840] | 1022 | } |
---|
[5306] | 1023 | else userTrashFolder = mount_url_folder(["INBOX",special_folders["Trash"]]); |
---|
[4840] | 1024 | |
---|
[5134] | 1025 | if(openTab.type[currentTab] == 1) |
---|
[5211] | 1026 | return move_search_msgs('content_id_'+currentTab,userTrashFolder,special_folders['Trash']); |
---|
[5134] | 1027 | |
---|
| 1028 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 1029 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
[4840] | 1030 | |
---|
| 1031 | if (!archive && (parseInt(preferences.save_deleted_msg)) && (folder != userTrashFolder)){ |
---|
[7603] | 1032 | move_msgs2(folder, ""+msgs_number, border_ID, userTrashFolder,special_folders['Trash'],show_success_msg, undefined, prev_message ); |
---|
[7414] | 1033 | return; |
---|
| 1034 | } |
---|
[827] | 1035 | |
---|
[2] | 1036 | var handler_delete_msgs = function(data){ |
---|
[3035] | 1037 | |
---|
[2] | 1038 | Element('chk_box_select_all_messages').checked = false; |
---|
[827] | 1039 | if (currentTab) |
---|
| 1040 | mail_msg = Element("tbody_box_"+currentTab); |
---|
| 1041 | else |
---|
| 1042 | mail_msg = Element("tbody_box"); |
---|
[7113] | 1043 | |
---|
| 1044 | if ( preferences.use_shortcuts == '1') { |
---|
| 1045 | //Last msg is selected |
---|
| 1046 | if (mail_msg && exist_className(mail_msg.childNodes[mail_msg.childNodes.length-1], 'selected_shortcut_msg') ) { |
---|
| 1047 | select_msg('null', 'up', true); |
---|
| 1048 | } |
---|
| 1049 | else { |
---|
| 1050 | if (!select_msg('null', 'down', true)) { |
---|
| 1051 | select_msg('null', 'up', true); |
---|
| 1052 | } |
---|
| 1053 | } |
---|
| 1054 | } |
---|
| 1055 | |
---|
[7067] | 1056 | if(data.status == false){ |
---|
| 1057 | write_msg(get_lang("You don't have permission for this operation in this shared folder!")); |
---|
| 1058 | return false; |
---|
| 1059 | } |
---|
[7113] | 1060 | |
---|
[7449] | 1061 | //Se pref. usar mensagens locais ativaada e não for operação de arquivamento exibe mensagem de remoção. |
---|
| 1062 | if(preferences.use_local_messages == 1){ |
---|
| 1063 | if(!expresso_mail_archive.isArchiveOperation){ |
---|
| 1064 | if (show_success_msg){ |
---|
| 1065 | if (data.msgs_number.length == 1) |
---|
| 1066 | write_msg(get_lang("The message was deleted.")); |
---|
| 1067 | else |
---|
| 1068 | write_msg(get_lang("The messages were deleted.")); |
---|
| 1069 | } |
---|
| 1070 | } |
---|
[689] | 1071 | } |
---|
[7449] | 1072 | else{ |
---|
| 1073 | if (show_success_msg){ |
---|
| 1074 | if (data.msgs_number.length == 1) |
---|
| 1075 | write_msg(get_lang("The message was deleted.")); |
---|
| 1076 | else |
---|
| 1077 | write_msg(get_lang("The messages were deleted.")); |
---|
| 1078 | } |
---|
| 1079 | } |
---|
[7067] | 1080 | |
---|
[827] | 1081 | if (openTab.type[currentTab] > 1){ |
---|
[1658] | 1082 | var msg_to_delete = Element(msgs_number); |
---|
| 1083 | if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) { |
---|
| 1084 | if (msg_to_delete.previousSibling){ |
---|
[7603] | 1085 | var previous_msg = prev_message ? prev_message : msg_to_delete.previousSibling.id; |
---|
| 1086 | if(previous_msg){ |
---|
| 1087 | $.ajax({ |
---|
| 1088 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 1089 | msg_number: previous_msg, |
---|
| 1090 | msg_folder: current_folder, |
---|
| 1091 | decoded: true } ), |
---|
| 1092 | success: function( data ){ |
---|
| 1093 | data = connector.unserialize( data ); |
---|
| 1094 | |
---|
| 1095 | if( data ) |
---|
| 1096 | show_msg( data ); |
---|
| 1097 | }, |
---|
| 1098 | beforeSend: function( jqXHR, settings ){ |
---|
| 1099 | connector.showProgressBar(); |
---|
| 1100 | }, |
---|
| 1101 | complete: function( jqXHR, settings ){ |
---|
| 1102 | connector.hideProgressBar(); |
---|
| 1103 | } |
---|
[6275] | 1104 | |
---|
[7603] | 1105 | }); |
---|
| 1106 | } |
---|
[3035] | 1107 | } |
---|
[7481] | 1108 | else{ |
---|
| 1109 | delete_border(currentTab,'false'); |
---|
| 1110 | } |
---|
| 1111 | |
---|
[827] | 1112 | } |
---|
[7481] | 1113 | else{ |
---|
| 1114 | delete_border(currentTab,'false'); |
---|
| 1115 | } |
---|
| 1116 | |
---|
[2] | 1117 | } |
---|
[3035] | 1118 | for (var i=0; i<data.msgs_number.length; i++){ |
---|
| 1119 | var msg_to_delete = Element(data.msgs_number[i]); |
---|
| 1120 | if (msg_to_delete){ |
---|
| 1121 | removeAll(msg_to_delete.id); |
---|
[7113] | 1122 | delete selectedPagingMsgs[data.msgs_number[i]]; |
---|
| 1123 | } |
---|
[7742] | 1124 | // removido decremento da variável pois estava decrementando em outros lugares |
---|
| 1125 | // totalFolderMsgs = totalFolderMsgs - data.msgs_number.length; |
---|
[3035] | 1126 | } |
---|
[7345] | 1127 | $.each(data.msgs_number, function(index, value){ |
---|
| 1128 | msgFolder = Base64.encode(get_current_folder()); |
---|
| 1129 | tabToRemove = value + "_r_" + msgFolder.replace(/=/g,""); |
---|
[7601] | 1130 | if ($("#"+tabToRemove).length != 0){ |
---|
[7345] | 1131 | delete_border(tabToRemove,'false'); |
---|
| 1132 | } |
---|
| 1133 | }); |
---|
[2] | 1134 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length; |
---|
[3035] | 1135 | refresh(); |
---|
[2] | 1136 | } |
---|
[7061] | 1137 | |
---|
[7776] | 1138 | if (msgs_number.length > 0 || parseInt(msgs_number) > 0){ |
---|
| 1139 | params_to_delete = "&folder="+folder; |
---|
| 1140 | params_to_delete += "&msgs_number="+msgs_number; |
---|
| 1141 | params_to_delete += "&border_ID="+border_ID; |
---|
| 1142 | params_to_delete += "&sort_box_type="+sort_box_type; |
---|
| 1143 | params_to_delete += "&search_box_type="+search_box_type; |
---|
| 1144 | params_to_delete += "&sort_box_reverse="+sort_box_reverse; |
---|
| 1145 | cExecute ("$this.imap_functions.delete_msgs", handler_delete_msgs, params_to_delete); |
---|
| 1146 | } |
---|
| 1147 | else{ |
---|
[3035] | 1148 | write_msg(get_lang('No selected message.')); |
---|
[7776] | 1149 | } |
---|
[2] | 1150 | } |
---|
| 1151 | |
---|
[5134] | 1152 | |
---|
[5172] | 1153 | function move_search_msgs(border_id, new_folder, new_folder_name, action){ |
---|
[5134] | 1154 | |
---|
[5172] | 1155 | var msg_to_delete = ""; |
---|
| 1156 | var msg_to_move = ""; |
---|
[163] | 1157 | var selected_messages = ''; |
---|
[689] | 1158 | var temp_msg; |
---|
[5172] | 1159 | var remove_currente_folder = ""; |
---|
| 1160 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
[7414] | 1161 | |
---|
| 1162 | //Validação para não poder manipular mensagens locais na busca |
---|
| 1163 | if (currentTab.indexOf('search_local') != -1 || proxy_mensagens.is_local_folder(new_folder)) |
---|
| 1164 | { |
---|
| 1165 | alert(get_lang("You cant manipulate local messages on search")); |
---|
| 1166 | return; |
---|
| 1167 | } |
---|
| 1168 | |
---|
[5172] | 1169 | var delete_msg = false; |
---|
| 1170 | |
---|
| 1171 | if(new_folder_name == special_folders['Trash']){ |
---|
| 1172 | delete_msg = true; |
---|
[163] | 1173 | } |
---|
[5172] | 1174 | selected_messages = get_selected_messages_search(); |
---|
| 1175 | |
---|
| 1176 | if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( selected_messages, folder ) ){ |
---|
[7414] | 1177 | alert( "Impossivel mover mensagens que ainda estão sendo arquivadas." ); |
---|
[5172] | 1178 | return; |
---|
[163] | 1179 | } |
---|
| 1180 | var handler_move_search_msgs = function(data){ |
---|
| 1181 | if(!data || !data.msgs_number) |
---|
| 1182 | return; |
---|
[3035] | 1183 | else if(data.deleted) { |
---|
[5172] | 1184 | if(data.no_move && data.move) |
---|
| 1185 | alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission.")); |
---|
| 1186 | else if (data.msgs_number.length == 1) |
---|
[163] | 1187 | write_msg(get_lang("The message was deleted.")); |
---|
| 1188 | else |
---|
[3035] | 1189 | write_msg(get_lang("The messages were deleted.")); |
---|
[5172] | 1190 | }else if(data.status == false && data.move ){ |
---|
| 1191 | alert(get_lang("Unable to remove the message (s) of shared folders which you do not have permission.")); |
---|
| 1192 | }else if(data.status == false){ |
---|
| 1193 | alert(get_lang("You don't have permission for this operation in this shared folder!")); |
---|
| 1194 | return false; |
---|
| 1195 | }else{ |
---|
[163] | 1196 | if (data.msgs_number.length == 1) |
---|
| 1197 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 1198 | else |
---|
| 1199 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 1200 | } |
---|
[569] | 1201 | |
---|
[5172] | 1202 | if(data.no_move){ |
---|
| 1203 | var no_remove = data.no_move.split(','); |
---|
| 1204 | var continua = true; |
---|
| 1205 | |
---|
[163] | 1206 | selected_messages = selected_messages.split(","); |
---|
| 1207 | for (i = 0; i < selected_messages.length; i++){ |
---|
[5172] | 1208 | for(j = 0; j < no_remove.length; j++) |
---|
| 1209 | if(selected_messages[i] == no_remove[j]) |
---|
| 1210 | continua = false; |
---|
| 1211 | if(continua) |
---|
| 1212 | removeAll(selected_messages[i]+'_s'+id_border); |
---|
| 1213 | continua = true; |
---|
[827] | 1214 | } |
---|
[5172] | 1215 | }else{ |
---|
| 1216 | selected_messages = selected_messages.split(","); |
---|
| 1217 | for (i = 0; i < selected_messages.length; i++){ |
---|
| 1218 | removeAll(selected_messages[i]+'_s'+id_border); |
---|
| 1219 | |
---|
| 1220 | } |
---|
| 1221 | } |
---|
| 1222 | |
---|
[976] | 1223 | // Update Box BgColor |
---|
[4810] | 1224 | var box = Element("tbody_box_"+getNumBoxFromTabId(currentTab)).childNodes; |
---|
[5172] | 1225 | if(box.length > 1){ |
---|
[976] | 1226 | updateBoxBgColor(box); |
---|
| 1227 | } |
---|
[1443] | 1228 | connector.purgeCache(); |
---|
[4821] | 1229 | |
---|
[5172] | 1230 | |
---|
| 1231 | if(remove_currente_folder != ""){ |
---|
| 1232 | var mail_msg = Element('tbody_box').childNodes; |
---|
| 1233 | remove_currente_folder = remove_currente_folder.substring(0,(remove_currente_folder.length-1)); |
---|
| 1234 | remove_currente_folder = remove_currente_folder.split(","); |
---|
| 1235 | for(i = 0; i < remove_currente_folder.length; i++) |
---|
| 1236 | removeAll(remove_currente_folder[i]); |
---|
| 1237 | |
---|
| 1238 | // Update Box BgColor |
---|
| 1239 | var box = Element("tbody_box"); |
---|
| 1240 | if(box.childNodes.length > 0){ |
---|
| 1241 | updateBoxBgColor(box.childNodes); |
---|
| 1242 | } |
---|
| 1243 | if(folder == get_current_folder()){ |
---|
| 1244 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - remove_currente_folder.length; |
---|
| 1245 | } |
---|
| 1246 | } |
---|
| 1247 | |
---|
[7392] | 1248 | draw_new_tree_folder(); |
---|
[4821] | 1249 | EsearchE.refresh(); |
---|
[827] | 1250 | } |
---|
[163] | 1251 | |
---|
| 1252 | if (selected_messages){ |
---|
[5306] | 1253 | |
---|
[569] | 1254 | var selected_param = ""; |
---|
| 1255 | if (selected_messages.indexOf(',') != -1) |
---|
| 1256 | { |
---|
| 1257 | selected_msg_array = selected_messages.split(","); |
---|
| 1258 | for (i = 0; i < selected_msg_array.length; i++){ |
---|
[5172] | 1259 | var tr = Element(selected_msg_array[i]+'_s'+id_border); |
---|
| 1260 | if(tr.getAttribute('name') == current_folder) |
---|
| 1261 | remove_currente_folder += tr.id.replace(/_[a-zA-Z0-9]+/,"")+','; |
---|
[5306] | 1262 | |
---|
| 1263 | if ((action == 'delete' && tr.getAttribute('name') == mount_url_folder(["INBOX",special_folders["Trash"]])) || !(parseInt(preferences.save_deleted_msg))) |
---|
[829] | 1264 | { |
---|
[5172] | 1265 | msg_to_delete += ','+special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 1266 | } |
---|
| 1267 | else if (!(tr.getAttribute('name') == new_folder && action != 'delete')) |
---|
| 1268 | { |
---|
| 1269 | msg_to_move = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 1270 | selected_param += ','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 1271 | }else{ |
---|
[829] | 1272 | write_msg(get_lang('At least one message have the same origin')); |
---|
| 1273 | return false; |
---|
| 1274 | } |
---|
[569] | 1275 | } |
---|
| 1276 | } |
---|
| 1277 | else |
---|
| 1278 | { |
---|
[5172] | 1279 | var tr=Element(selected_messages+'_s'+id_border); |
---|
| 1280 | if(tr.getAttribute('name') == current_folder) |
---|
| 1281 | remove_currente_folder += tr.id.replace(/_[a-zA-Z0-9]+/,"")+','; |
---|
[5306] | 1282 | if((action == 'delete' && tr.getAttribute('name') == mount_url_folder(["INBOX",special_folders["Trash"]])) || !(parseInt(preferences.save_deleted_msg))){ |
---|
[5172] | 1283 | msg_to_delete = special_folders['Trash']+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 1284 | }else if (!(tr.getAttribute('name') == new_folder && action != 'delete')){ |
---|
| 1285 | trfolder = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 1286 | selected_param=trfolder+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 1287 | }else{ |
---|
[829] | 1288 | write_msg(get_lang('The origin folder and the destination folder are the same.')); |
---|
| 1289 | return false; |
---|
| 1290 | } |
---|
[569] | 1291 | } |
---|
[163] | 1292 | var params = ""; |
---|
[5172] | 1293 | if(msg_to_delete != "" && msg_to_move != ""){ |
---|
| 1294 | params += "&selected_messages_move="+url_encode(selected_param); |
---|
| 1295 | params += "&new_folder_move="+url_encode(new_folder); |
---|
| 1296 | params += "&new_folder_name_move="+url_encode(new_folder_name); |
---|
| 1297 | |
---|
[5306] | 1298 | new_folder = mount_url_folder(["INBOX",special_folders["Trash"]]); |
---|
[5211] | 1299 | new_folder_name = special_folders['Trash']; |
---|
[5172] | 1300 | params += "&selected_messages_delete="+url_encode(msg_to_delete); |
---|
| 1301 | params += "&new_folder_delete="+url_encode(new_folder); |
---|
| 1302 | cExecute ("$this.imap_functions.move_delete_search_messages", handler_move_search_msgs, params); |
---|
| 1303 | }else if(msg_to_delete != ""){ |
---|
[5306] | 1304 | new_folder = mount_url_folder(["INBOX",special_folders["Trash"]]); |
---|
[5211] | 1305 | new_folder_name = special_folders['Trash']; |
---|
[5172] | 1306 | params += "&delete=true"; |
---|
| 1307 | params += "&selected_messages="+url_encode(msg_to_delete); |
---|
[163] | 1308 | params += "&new_folder="+url_encode(new_folder); |
---|
[5172] | 1309 | cExecute ("$this.imap_functions.move_search_messages", handler_move_search_msgs, params); |
---|
| 1310 | }else{ |
---|
| 1311 | params = "&selected_messages="+url_encode(selected_param); |
---|
| 1312 | params += "&delete=false"; |
---|
| 1313 | params += "&new_folder="+url_encode(new_folder); |
---|
[163] | 1314 | params += "&new_folder_name="+url_encode(new_folder_name); |
---|
[6930] | 1315 | cExecute ("$this.imap_functions.move_search_messages", handler_move_search_msgs, params); |
---|
| 1316 | } |
---|
[163] | 1317 | } |
---|
| 1318 | else |
---|
[3035] | 1319 | write_msg(get_lang('No selected message.')); |
---|
[163] | 1320 | } |
---|
| 1321 | |
---|
[7603] | 1322 | function move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,show_success_msg, not_opem_previus, prev_message){ |
---|
[5134] | 1323 | not_opem_previus = typeof(not_opem_previus) != 'undefined' ? not_opem_previus : false; |
---|
[5211] | 1324 | var folder_error = new_folder_name; |
---|
| 1325 | if( preferences.use_local_messages == 1 && expresso_local_messages.isArchiving( msgs_number, folder ) ){ |
---|
[7601] | 1326 | alert( "Impossivel mover mensagens que ainda estão sendo arquivadas." ); |
---|
[5134] | 1327 | return; |
---|
| 1328 | } |
---|
| 1329 | |
---|
[320] | 1330 | if (! folder || folder == 'null') |
---|
[3018] | 1331 | folder = Element("input_folder_"+msgs_number+"_r") ? Element("input_folder_"+msgs_number+"_r").value : (openTab.imapBox[currentTab] ? openTab.imapBox[currentTab]:get_current_folder()); |
---|
[845] | 1332 | if(openTab.type[currentTab] == 1) |
---|
| 1333 | return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name); |
---|
| 1334 | |
---|
[2] | 1335 | var handler_move_msgs = function(data){ |
---|
[320] | 1336 | if(typeof(data) == 'string') |
---|
| 1337 | if (data.match(/^(.*)TRYCREATE(.*)$/)){ |
---|
| 1338 | connector.loadScript('TreeS'); |
---|
[5211] | 1339 | var move_to_folder = data.match(/^(.*)Spam(.*)$/) ? "Spam" : special_folders['Trash']; |
---|
| 1340 | alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.', folder_error)); |
---|
[320] | 1341 | ttree.FOLDER = 'root'; |
---|
[6930] | 1342 | create_new_folder(move_to_folder,"INBOX"); |
---|
[320] | 1343 | return false; |
---|
| 1344 | }else{ |
---|
[7414] | 1345 | write_msg(get_lang('Error moving message.')+" "+get_lang('Permission denied to folder "%1".', new_folder_name)); |
---|
| 1346 | /*Verifica se a pasta destino é a "Trash" e se a pasta origem e destino são do mesma estrutura compartilhada*/ |
---|
| 1347 | if(new_folder_name == "Trash" && folder.split("/")[1] == new_folder.split("/")[1]){ |
---|
| 1348 | alert(get_lang("You can not remove the message with the preference 'Send to Trash' enabled. There is no permission to move messages to the trash folder.")); |
---|
| 1349 | } |
---|
[320] | 1350 | return false; |
---|
| 1351 | } |
---|
[325] | 1352 | //Este bloco verifica as permissoes ACL sobre pastas compartilhadas |
---|
| 1353 | if(data.status == false){ |
---|
[6952] | 1354 | write_msg(get_lang("You don't have permission for this operation in this shared folder!")); |
---|
[325] | 1355 | return false; |
---|
| 1356 | } |
---|
[827] | 1357 | mail_msg = ( Element("divScrollMain_"+numBox) ) ? Element("divScrollMain_"+numBox).firstChild.firstChild : Element("divScrollMain_0").firstChild.firstChild; |
---|
| 1358 | |
---|
[7485] | 1359 | if (openTab.type[currentTab] > 1) |
---|
| 1360 | { |
---|
[827] | 1361 | msg_to_delete = Element(msgs_number); |
---|
| 1362 | if (parseInt(preferences.delete_and_show_previous_message) && msg_to_delete) |
---|
| 1363 | { |
---|
[7485] | 1364 | if (msg_to_delete.previousSibling) |
---|
| 1365 | { |
---|
[7603] | 1366 | var previous_msg = prev_message ? prev_message : msg_to_delete.previousSibling.id; |
---|
| 1367 | |
---|
[1635] | 1368 | //cExecute("$this.imap_functions.get_info_msg&msg_number="+previous_msg+"&msg_folder=" + current_folder, show_msg); |
---|
[5134] | 1369 | if(!not_opem_previus){ |
---|
[7603] | 1370 | if(previous_msg){ |
---|
[7676] | 1371 | /* |
---|
[7603] | 1372 | $.ajax({ |
---|
| 1373 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 1374 | msg_number: previous_msg, |
---|
| 1375 | msg_folder: folder, |
---|
| 1376 | decoded: true } ), |
---|
| 1377 | success: function( data ){ |
---|
| 1378 | data = connector.unserialize( data ); |
---|
| 1379 | |
---|
| 1380 | if( data ) |
---|
| 1381 | show_msg( data ); |
---|
| 1382 | }, |
---|
| 1383 | beforeSend: function( jqXHR, settings ){ |
---|
| 1384 | connector.showProgressBar(); |
---|
| 1385 | }, |
---|
| 1386 | complete: function( jqXHR, settings ){ |
---|
| 1387 | connector.hideProgressBar(); |
---|
| 1388 | } |
---|
[7676] | 1389 | });*/ |
---|
| 1390 | proxy_mensagens.get_msg(previous_msg,folder,null,show_msg); |
---|
[7603] | 1391 | } |
---|
[5486] | 1392 | } |
---|
[827] | 1393 | } |
---|
[5524] | 1394 | //se houver pagina anterior a paginação deve ser refeita |
---|
[7485] | 1395 | else |
---|
| 1396 | { |
---|
[7603] | 1397 | var border_id = $("#border_id_"+currentTab).prev().attr("id").split("_").slice(2, 3).join("") |
---|
| 1398 | var folderName = current_folder; |
---|
[7679] | 1399 | if(prev_message || current_page > 1) |
---|
[7485] | 1400 | { |
---|
[7677] | 1401 | /* |
---|
[7603] | 1402 | $.ajax({ |
---|
| 1403 | url: 'controller.php?' + $.param({ |
---|
| 1404 | action: '$this.imap_functions.get_info_msg', |
---|
| 1405 | msg_number: prev_message, |
---|
| 1406 | msg_folder: folderName, |
---|
| 1407 | decoded: true |
---|
| 1408 | }), |
---|
| 1409 | success: function( data ){ |
---|
| 1410 | data = connector.unserialize( data ); |
---|
| 1411 | delete_border(currentTab,'false'); |
---|
| 1412 | if( data ) |
---|
| 1413 | { |
---|
| 1414 | show_msg( data ); |
---|
| 1415 | } |
---|
| 1416 | }, |
---|
| 1417 | beforeSend: function( jqXHR, settings ){ |
---|
| 1418 | connector.showProgressBar(); |
---|
| 1419 | }, |
---|
| 1420 | complete: function( jqXHR, settings ){ |
---|
| 1421 | connector.hideProgressBar(); |
---|
| 1422 | } |
---|
[7677] | 1423 | });*/ |
---|
| 1424 | current_page--; |
---|
| 1425 | var range_begin = (current_page - 1)*preferences.max_email_per_page + 1; |
---|
| 1426 | var range_end = current_page*preferences.max_email_per_page; |
---|
| 1427 | var creatBoxAnterior = function (data){ |
---|
| 1428 | draw_box(data, get_current_folder()); |
---|
| 1429 | lastRow(); |
---|
| 1430 | }; |
---|
| 1431 | proxy_mensagens.messages_list(get_current_folder(),range_begin,range_end,sort_box_type,search_box_type,sort_box_reverse,'','', creatBoxAnterior); |
---|
[7485] | 1432 | } |
---|
[7603] | 1433 | else |
---|
[7485] | 1434 | { |
---|
[7603] | 1435 | delete_border(currentTab,'false'); |
---|
[7485] | 1436 | } |
---|
[5524] | 1437 | } |
---|
[827] | 1438 | } |
---|
[7485] | 1439 | else |
---|
| 1440 | { |
---|
[7486] | 1441 | if (msg_to_delete.id === String(currentTab).split('_')[0]) |
---|
| 1442 | { |
---|
| 1443 | delete_border(currentTab,'false'); |
---|
| 1444 | } |
---|
[5134] | 1445 | } |
---|
[7485] | 1446 | |
---|
[827] | 1447 | if(msg_to_delete) |
---|
[7485] | 1448 | { |
---|
[827] | 1449 | mail_msg.removeChild(msg_to_delete); |
---|
[7485] | 1450 | } |
---|
[1652] | 1451 | |
---|
| 1452 | // Update Box BgColor |
---|
| 1453 | var box = Element("tbody_box"); |
---|
[7485] | 1454 | if(box.childNodes.length > 0) |
---|
| 1455 | { |
---|
[1652] | 1456 | updateBoxBgColor(box.childNodes); |
---|
| 1457 | } |
---|
[7485] | 1458 | if(folder == get_current_folder()) |
---|
| 1459 | { |
---|
[5134] | 1460 | Element('tot_m').innerHTML = parseInt(Element('tot_m').innerHTML) - 1; |
---|
| 1461 | } |
---|
[827] | 1462 | return; |
---|
| 1463 | } |
---|
| 1464 | |
---|
[2] | 1465 | Element('chk_box_select_all_messages').checked = false; |
---|
[345] | 1466 | if (! mail_msg) |
---|
| 1467 | mail_msg = Element("tbody_box"); |
---|
[2] | 1468 | data.msgs_number = data.msgs_number.split(","); |
---|
[320] | 1469 | |
---|
[345] | 1470 | var msg_to_delete; |
---|
| 1471 | if( typeof(msgs_number) == 'string' ) |
---|
| 1472 | all_search_msg = msgs_number.split(','); |
---|
[827] | 1473 | else if( typeof(msgs_number) == 'number') |
---|
[345] | 1474 | all_search_msg = msgs_number; |
---|
[3035] | 1475 | |
---|
[320] | 1476 | for (var i=0; i <= all_search_msg.length; i++) |
---|
| 1477 | { |
---|
[3035] | 1478 | msg_to_delete = Element(folder+';'+all_search_msg[i]); |
---|
[320] | 1479 | if (msg_to_delete) |
---|
| 1480 | msg_to_delete.parentNode.removeChild(msg_to_delete); |
---|
| 1481 | } |
---|
| 1482 | |
---|
[214] | 1483 | if ( preferences.use_shortcuts == '1') { |
---|
| 1484 | var all_messages = Element('tbody_box').childNodes; |
---|
[5922] | 1485 | // verificar se a msg selecionada com o checkbox é a mesma selecionada com o shortcut |
---|
| 1486 | var msg_list_shortcut = get_selected_messages_shortcut().split(','); |
---|
| 1487 | if(data.msgs_number.length > 0 && msg_list_shortcut.length > 0 && data.msgs_number.toString() == msg_list_shortcut.toString()){ |
---|
| 1488 | //Last msg is selected |
---|
| 1489 | if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) { |
---|
[214] | 1490 | select_msg('null', 'up', true); |
---|
[135] | 1491 | } |
---|
[5922] | 1492 | else { |
---|
| 1493 | if (!select_msg('null', 'down', true)) { |
---|
| 1494 | select_msg('null', 'up', true); |
---|
| 1495 | } |
---|
| 1496 | } |
---|
[2] | 1497 | } |
---|
| 1498 | } |
---|
[214] | 1499 | for (var i=0; i<data.msgs_number.length; i++) |
---|
| 1500 | { |
---|
| 1501 | msg_to_delete = Element(data.msgs_number[i]); |
---|
| 1502 | if (msg_to_delete) |
---|
[5936] | 1503 | mail_msg.removeChild(msg_to_delete); |
---|
[3035] | 1504 | } |
---|
| 1505 | |
---|
[7566] | 1506 | //Se pref. usar mensagens locais ativada e não for operação de arquivamento exibe mensagem de remoção. |
---|
| 1507 | if(preferences.use_local_messages == 1){ |
---|
| 1508 | if(!expresso_mail_archive.isArchiveOperation){ |
---|
| 1509 | if (data.msgs_number.length == 1) |
---|
| 1510 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 1511 | else |
---|
| 1512 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 1513 | } |
---|
| 1514 | } else { |
---|
| 1515 | if (data.msgs_number.length == 1) |
---|
| 1516 | write_msg(get_lang("The message was moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 1517 | else |
---|
| 1518 | write_msg(get_lang("The messages were moved to folder ") + lang_folder(data.new_folder_name)); |
---|
| 1519 | } |
---|
| 1520 | |
---|
[320] | 1521 | if (data.border_ID.indexOf('r') != -1){ |
---|
[605] | 1522 | if (parseInt(preferences.delete_and_show_previous_message) && folder == get_current_folder()){ |
---|
| 1523 | delete_border(data.border_ID,'false'); |
---|
[2] | 1524 | show_msg(data.previous_msg); |
---|
[605] | 1525 | } |
---|
[7481] | 1526 | else{ |
---|
| 1527 | delete_border(data.border_ID,'false'); |
---|
| 1528 | } |
---|
| 1529 | |
---|
[2] | 1530 | } |
---|
[5134] | 1531 | if(folder == get_current_folder()){ |
---|
[5771] | 1532 | var n_total_msg = parseInt(Element('tot_m').innerHTML) - data.msgs_number.length; |
---|
[7123] | 1533 | n_total_msg = n_total_msg >= 0 ? n_total_msg : 0; |
---|
[5771] | 1534 | draw_paging(n_total_msg); |
---|
| 1535 | Element('tot_m').innerHTML = n_total_msg; |
---|
[7742] | 1536 | // removido decremento da variável pois estava decrementando em outros lugares |
---|
| 1537 | //totalFolderMsgs -= data.msgs_number.length; |
---|
[5134] | 1538 | } |
---|
[2] | 1539 | refresh(); |
---|
| 1540 | } |
---|
| 1541 | |
---|
| 1542 | if (folder == new_folder){ |
---|
[53] | 1543 | write_msg(get_lang('The origin folder and the destination folder are the same.')); |
---|
[2] | 1544 | return; |
---|
[7467] | 1545 | } |
---|
[2] | 1546 | |
---|
[4836] | 1547 | try{ |
---|
[7467] | 1548 | if (proxy_mensagens.is_local_folder(Element('input_folder_'+currentTab).getAttribute('value')) && !border_ID) { |
---|
[4836] | 1549 | alert(get_lang("You cant manipulate local messages on search")); |
---|
| 1550 | return; |
---|
| 1551 | } |
---|
| 1552 | } catch (e) {} |
---|
[7414] | 1553 | //Validação para recuperar o id caso não seja aba de listagem |
---|
| 1554 | if (currentTab == 0 && msgs_number == "selected") |
---|
[2] | 1555 | msgs_number = get_selected_messages(); |
---|
[7414] | 1556 | else if (currentTab != 0 && msgs_number == "selected") |
---|
| 1557 | msgs_number = currentTab.substr(0,currentTab.indexOf('_r')); |
---|
[2] | 1558 | |
---|
[827] | 1559 | if(openTab.type[currentTab] == 1){ |
---|
| 1560 | return move_search_msgs('content_id_'+currentTab,new_folder,new_folder_name); |
---|
| 1561 | } |
---|
| 1562 | |
---|
[5134] | 1563 | // se a aba estiver aberta e selecionada, apenas a msg da aba é movida |
---|
[7414] | 1564 | if(currentTab.toString().indexOf("_r") != -1 && currentTab == border_ID) |
---|
[5134] | 1565 | { |
---|
| 1566 | //se a aba for aberta atraves de uma pesquisa |
---|
| 1567 | if(currentTab.toString().indexOf('_s') != -1) |
---|
| 1568 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf('_s')); |
---|
| 1569 | else |
---|
| 1570 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf('_r')); |
---|
[827] | 1571 | } |
---|
[7635] | 1572 | // if (msgs_number) { |
---|
| 1573 | // refresh(); |
---|
| 1574 | // } |
---|
| 1575 | if (!msgs_number){ |
---|
[7492] | 1576 | $("#"+get_current_folder()).find('span:first').addClass('selected'); |
---|
| 1577 | } |
---|
[6287] | 1578 | |
---|
[7414] | 1579 | if (proxy_mensagens.is_local_folder(folder)){ |
---|
| 1580 | |
---|
| 1581 | expresso_mail_archive.update_counters = true; |
---|
[7601] | 1582 | //Folder de onde sai a mensagem é local (armazenamento local) |
---|
[6930] | 1583 | |
---|
[7414] | 1584 | if(msgs_number=='selected'){ |
---|
| 1585 | msgs_number = get_selected_messages(); |
---|
| 1586 | } |
---|
[6930] | 1587 | |
---|
[7414] | 1588 | if (new_folder == 'local_root'){ |
---|
| 1589 | alert(get_lang("Select a folder!")); |
---|
| 1590 | } |
---|
| 1591 | |
---|
| 1592 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0) { |
---|
| 1593 | if (proxy_mensagens.is_local_folder(new_folder)){ |
---|
| 1594 | //esta tirando de um folder local para outro folder local |
---|
| 1595 | //expresso_mail_archive.moveMessages(new_folder.substr(6), msgs_number); |
---|
| 1596 | expresso_mail_archive.moveMessages(new_folder.replace('local_messages_', ''), msgs_number); |
---|
[7472] | 1597 | delete_border(border_ID); |
---|
[7414] | 1598 | } |
---|
| 1599 | else{ |
---|
| 1600 | //esta tirando de um folder local para um folder IMAP (desarquivamento) |
---|
| 1601 | if(!new_folder){ |
---|
| 1602 | new_folder = 'INBOX'; |
---|
| 1603 | } |
---|
| 1604 | if(currentTab.toString().indexOf("_r") != -1){ |
---|
| 1605 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
| 1606 | } |
---|
| 1607 | expresso_mail_archive.unarchieve(folder, new_folder, msgs_number); |
---|
[7472] | 1608 | if(currentTab != 0) |
---|
| 1609 | delete_border(border_ID); |
---|
[7414] | 1610 | } |
---|
| 1611 | } |
---|
| 1612 | else{ |
---|
| 1613 | write_msg(get_lang('No selected message.')); |
---|
| 1614 | } |
---|
[7467] | 1615 | |
---|
[7414] | 1616 | } |
---|
| 1617 | else{ |
---|
| 1618 | if (proxy_mensagens.is_local_folder(new_folder)){ |
---|
[7601] | 1619 | //esta tirando de um folder não local para um folder local (arquivamento) |
---|
[7414] | 1620 | if(msgs_number=='selected'){ |
---|
| 1621 | archive_msgs(folder, new_folder); |
---|
| 1622 | } |
---|
| 1623 | else{ |
---|
| 1624 | archive_msgs(folder, new_folder, msgs_number); |
---|
| 1625 | } |
---|
| 1626 | } |
---|
| 1627 | else{ |
---|
[7601] | 1628 | //esta tirando de um folder não local para outro folder não local (move) |
---|
[7414] | 1629 | //move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name); |
---|
| 1630 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0){ |
---|
| 1631 | // remove a flag $FilteredMessage da mensagem, depois move |
---|
[7776] | 1632 | |
---|
[7414] | 1633 | var handler_removeFlag = function(){ |
---|
| 1634 | $.ajax({ |
---|
[7776] | 1635 | type: "POST", |
---|
| 1636 | url: 'controller.php?action=$this.imap_functions.move_messages', |
---|
| 1637 | data: { |
---|
| 1638 | folder: folder, |
---|
| 1639 | msgs_number: ""+msgs_number, |
---|
| 1640 | border_ID: border_ID, |
---|
| 1641 | sort_box_type: sort_box_type, |
---|
| 1642 | search_box_type: search_box_type, |
---|
| 1643 | sort_box_reverse: sort_box_reverse, |
---|
| 1644 | reuse_border: border_ID, |
---|
| 1645 | new_folder: new_folder, |
---|
| 1646 | new_folder_name: new_folder_name, |
---|
| 1647 | get_previous_msg: ( !not_opem_previus ? preferences.delete_and_show_previous_message : false ), |
---|
| 1648 | decoded: true }, |
---|
[7635] | 1649 | async: true, |
---|
[7414] | 1650 | success: function( data ){ |
---|
| 1651 | data = connector.unserialize( data ); |
---|
| 1652 | $.each(msgs_number.split(","), function(index, value){ |
---|
| 1653 | delete selectedPagingMsgs[value]; |
---|
| 1654 | msgFolder = Base64.encode(get_current_folder()); |
---|
| 1655 | tabToRemove = value + "_r_" + msgFolder.replace(/=/g,""); |
---|
| 1656 | if ($("#"+tabToRemove)){ |
---|
[7481] | 1657 | //delete_border(tabToRemove,'false'); |
---|
[7414] | 1658 | } |
---|
| 1659 | }); |
---|
| 1660 | totalFolderMsgs -= msgs_number.split(",").length; |
---|
| 1661 | |
---|
| 1662 | //TESTE |
---|
| 1663 | selectAllFolderMsgs(); |
---|
| 1664 | $('.select-link').unbind('click'); |
---|
| 1665 | |
---|
| 1666 | if( data ) |
---|
| 1667 | handler_move_msgs( data ); |
---|
| 1668 | }, |
---|
| 1669 | beforeSend: function( jqXHR, settings ){ |
---|
| 1670 | connector.showProgressBar(); |
---|
| 1671 | }, |
---|
| 1672 | complete: function( jqXHR, settings ){ |
---|
| 1673 | connector.hideProgressBar(); |
---|
| 1674 | } |
---|
| 1675 | |
---|
| 1676 | }); |
---|
| 1677 | } |
---|
| 1678 | var hasFolder = false; |
---|
| 1679 | $.each(fromRules, function(index, value) { |
---|
| 1680 | if(value == folder){ |
---|
| 1681 | hasFolder = true; |
---|
| 1682 | cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_number, handler_removeFlag); |
---|
| 1683 | return false; |
---|
| 1684 | } |
---|
| 1685 | }); |
---|
| 1686 | if(!hasFolder){ |
---|
| 1687 | handler_removeFlag(); |
---|
| 1688 | } |
---|
| 1689 | |
---|
| 1690 | }else |
---|
| 1691 | write_msg(get_lang('No selected message.')); |
---|
| 1692 | } |
---|
| 1693 | } |
---|
| 1694 | |
---|
| 1695 | //Código adicionado para o correto funcionamento da seleção independente de paginação. |
---|
| 1696 | $.each(msgs_number.split(","), function(index, value){ |
---|
| 1697 | delete selectedPagingMsgs[value]; |
---|
| 1698 | }); |
---|
[7742] | 1699 | // removido decremento da variável pois estava decrementando em outros lugares |
---|
| 1700 | //totalFolderMsgs = totalFolderMsgs - msgs_number.split(",").length; |
---|
[7414] | 1701 | selectAllFolderMsgs(false); |
---|
| 1702 | updateSelectedMsgs(); |
---|
[2] | 1703 | } |
---|
| 1704 | |
---|
[5134] | 1705 | function move_msgs(folder, msgs_number, border_ID, new_folder, new_folder_name, not_opem_previus) { |
---|
| 1706 | move_msgs2(folder, msgs_number, border_ID, new_folder, new_folder_name,true, not_opem_previus); |
---|
[689] | 1707 | } |
---|
| 1708 | |
---|
[5134] | 1709 | function normalizeMsgNumber( msgNumber ){ |
---|
| 1710 | |
---|
| 1711 | if (msgNumber || msgNumber == 'selected') |
---|
| 1712 | msgNumber = get_selected_messages(); |
---|
| 1713 | |
---|
| 1714 | |
---|
| 1715 | // se a aba estiver aberta e selecionada, apenas a msg da aba é movida |
---|
| 1716 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 1717 | { |
---|
| 1718 | //se a aba for aberta atraves de uma pesquisa |
---|
| 1719 | if(currentTab.toString().indexOf('_s') != -1) |
---|
| 1720 | msgNumber = currentTab.toString().substr(0,currentTab.toString().indexOf('_s')); |
---|
| 1721 | else |
---|
| 1722 | msgNumber = currentTab.toString().substr(0,currentTab.toString().indexOf('_r')); |
---|
| 1723 | } |
---|
| 1724 | |
---|
| 1725 | if (parseInt(msgNumber) <= 0 || msgNumber.length <= 0){ |
---|
| 1726 | write_msg(get_lang('No selected message.')); |
---|
| 1727 | return( false ); |
---|
| 1728 | } |
---|
| 1729 | |
---|
| 1730 | return( msgNumber ); |
---|
| 1731 | |
---|
| 1732 | } |
---|
| 1733 | |
---|
[5172] | 1734 | function archive_search_msgs(folder_dest) { |
---|
| 1735 | |
---|
| 1736 | var id_msgs = ""; |
---|
| 1737 | id_msgs = get_selected_messages_search(); |
---|
| 1738 | var msg_to_arquive = ""; |
---|
| 1739 | var messages = ""; |
---|
| 1740 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 1741 | |
---|
| 1742 | if ( parseInt(id_msgs) <= 0 || id_msgs.length <= 0 ) |
---|
| 1743 | return write_msg(get_lang('No selected message.')); |
---|
| 1744 | |
---|
| 1745 | if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento... |
---|
| 1746 | folder_dest = 'local_Inbox'; |
---|
| 1747 | |
---|
| 1748 | id_msgs = expresso_local_messages.checkArchived( id_msgs, folder_dest ); |
---|
| 1749 | |
---|
| 1750 | if( !id_msgs ){ |
---|
| 1751 | write_msg( "Todas as mensagens já foram arquivadas anteriormente." ); |
---|
| 1752 | return; |
---|
| 1753 | } |
---|
| 1754 | |
---|
| 1755 | document.getElementById("overlay").style.visibility = "visible"; |
---|
| 1756 | |
---|
| 1757 | var handler_arquivar_mensagens = function(data) { |
---|
| 1758 | |
---|
| 1759 | var msgs_info = []; |
---|
| 1760 | |
---|
| 1761 | for( var i = 0; i < data.length; i++ ) |
---|
| 1762 | msgs_info[i] = connector.unserialize( data[i] ); |
---|
| 1763 | |
---|
| 1764 | //vejo se já tinha mensagens locais |
---|
| 1765 | var h = expresso_local_messages.has_local_mails(); |
---|
| 1766 | |
---|
| 1767 | expresso_local_messages.insert_mails( msgs_info, folder_dest, function( s, f ){complete_archiving( s, f, h )} ); |
---|
| 1768 | |
---|
| 1769 | document.getElementById("overlay").style.visibility = "hidden"; |
---|
| 1770 | } |
---|
| 1771 | |
---|
| 1772 | id_msgs = id_msgs.split(','); |
---|
| 1773 | for (i = 0; i < id_msgs.length; i++){ |
---|
| 1774 | var tr = Element(id_msgs[i]+'_s'+id_border); |
---|
| 1775 | msg_to_arquive = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 1776 | messages += ','+msg_to_arquive+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 1777 | } |
---|
| 1778 | |
---|
[6275] | 1779 | $.ajax({ |
---|
| 1780 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 1781 | msg_number: messages, |
---|
| 1782 | msg_folder: folder_dest, |
---|
| 1783 | decoded: true } ), |
---|
| 1784 | success: function( data ){ |
---|
| 1785 | data = connector.unserialize( data ); |
---|
| 1786 | |
---|
| 1787 | if( data ) |
---|
| 1788 | handler_arquivar_mensagens( data ); |
---|
[6469] | 1789 | }, |
---|
| 1790 | beforeSend: function( jqXHR, settings ){ |
---|
| 1791 | connector.showProgressBar(); |
---|
| 1792 | }, |
---|
| 1793 | complete: function( jqXHR, settings ){ |
---|
| 1794 | connector.hideProgressBar(); |
---|
[6275] | 1795 | } |
---|
| 1796 | |
---|
| 1797 | }); |
---|
[5172] | 1798 | } |
---|
| 1799 | |
---|
| 1800 | |
---|
[7414] | 1801 | function archive_msgs(folder,folder_dest,id_msgs) { |
---|
[7426] | 1802 | |
---|
| 1803 | if(typeof (currentTab) == "string" && currentTab.indexOf("local") != -1){ |
---|
[7601] | 1804 | alert("Impossével manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais."); |
---|
[7426] | 1805 | return true; |
---|
| 1806 | } |
---|
[7414] | 1807 | write_msg(get_lang('Starting to archive messages')); |
---|
| 1808 | |
---|
| 1809 | if(currentTab.toString().indexOf("_r") != -1){ |
---|
| 1810 | id_msgs = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
| 1811 | } |
---|
| 1812 | |
---|
| 1813 | if(!id_msgs) |
---|
| 1814 | id_msgs = get_selected_messages(); |
---|
| 1815 | |
---|
| 1816 | if(folder_dest=='local_root' || folder_dest==null)//Default archive destiny = local_inbox folder |
---|
| 1817 | folder_dest = 'local_inbox'; |
---|
| 1818 | |
---|
| 1819 | if (parseInt(id_msgs) > 0 || id_msgs.length > 0){ |
---|
| 1820 | //expresso_mail_archive.Archive(folder,folder_dest,id_msgs); |
---|
| 1821 | window.setTimeout("expresso_mail_archive.Archive('" + folder + "','" + folder_dest + "','" + id_msgs + "')", 1); |
---|
| 1822 | selectAllFolderMsgs(false); |
---|
| 1823 | } |
---|
| 1824 | else |
---|
| 1825 | write_msg(get_lang('No selected message.')); |
---|
| 1826 | |
---|
| 1827 | |
---|
| 1828 | /* |
---|
[689] | 1829 | if(proxy_mensagens.is_local_folder(folder)) { |
---|
| 1830 | write_msg(get_lang("You cant archive local mails")); |
---|
| 1831 | return; |
---|
| 1832 | } |
---|
[1595] | 1833 | |
---|
[5200] | 1834 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 1835 | id_msgs = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
| 1836 | |
---|
| 1837 | if(currentTab.toString().indexOf("_s") != -1) |
---|
| 1838 | id_msgs = currentTab.toString().substr(0,currentTab.toString().indexOf("_s")); |
---|
[3411] | 1839 | |
---|
[5172] | 1840 | if(!id_msgs){ |
---|
| 1841 | if (currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
| 1842 | archive_search_msgs(folder_dest); |
---|
| 1843 | return; |
---|
| 1844 | }else |
---|
[5200] | 1845 | id_msgs = get_selected_messages(); |
---|
[5172] | 1846 | } |
---|
[3035] | 1847 | |
---|
[5134] | 1848 | if ( parseInt(id_msgs) <= 0 || id_msgs.length <= 0 ) |
---|
| 1849 | return write_msg(get_lang('No selected message.')); |
---|
| 1850 | |
---|
[1595] | 1851 | if(folder_dest=='local_root' || folder_dest==null) //Caso seja o primeiro arquivamento... |
---|
| 1852 | folder_dest = 'local_Inbox'; |
---|
[3035] | 1853 | |
---|
[5134] | 1854 | id_msgs = expresso_local_messages.checkArchived( id_msgs, folder_dest ); |
---|
[827] | 1855 | |
---|
[5134] | 1856 | if( !id_msgs ){ |
---|
| 1857 | write_msg( "Todas as mensagens já foram arquivadas anteriormente." ); |
---|
| 1858 | return; |
---|
| 1859 | } |
---|
| 1860 | |
---|
| 1861 | document.getElementById("overlay").style.visibility = "visible"; |
---|
| 1862 | |
---|
| 1863 | var handler_arquivar_mensagens = function(data) { |
---|
| 1864 | |
---|
[7414] | 1865 | //var msgs_info = []; |
---|
[5134] | 1866 | |
---|
[7414] | 1867 | //for( var i = 0; i < data.length; i++ ) |
---|
| 1868 | //msgs_info[i] = connector.unserialize( data[i] ); |
---|
[5134] | 1869 | |
---|
| 1870 | //vejo se já tinha mensagens locais |
---|
[7414] | 1871 | //var h = expresso_local_messages.has_local_mails(); |
---|
[5134] | 1872 | |
---|
[7414] | 1873 | //expresso_local_messages.insert_mails( msgs_info, folder_dest, function( s, f ){complete_archiving( s, f, h )} ); |
---|
[5134] | 1874 | |
---|
[7414] | 1875 | expresso_mail_archive.Archive(folder,folder_dest,id_msgs); |
---|
[5134] | 1876 | document.getElementById("overlay").style.visibility = "hidden"; |
---|
| 1877 | } |
---|
| 1878 | |
---|
[6275] | 1879 | $.ajax({ |
---|
| 1880 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 1881 | msg_number: id_msgs, |
---|
| 1882 | msg_folder: folder, |
---|
| 1883 | decoded: true } ), |
---|
| 1884 | success: function( data ){ |
---|
| 1885 | data = connector.unserialize( data ); |
---|
| 1886 | |
---|
| 1887 | if( data ) |
---|
| 1888 | handler_arquivar_mensagens( data ); |
---|
[6469] | 1889 | }, |
---|
| 1890 | beforeSend: function( jqXHR, settings ){ |
---|
| 1891 | connector.showProgressBar(); |
---|
| 1892 | }, |
---|
| 1893 | complete: function( jqXHR, settings ){ |
---|
| 1894 | connector.hideProgressBar(); |
---|
[6275] | 1895 | } |
---|
| 1896 | |
---|
| 1897 | }); |
---|
[7414] | 1898 | */ |
---|
| 1899 | |
---|
[689] | 1900 | } |
---|
| 1901 | |
---|
[5134] | 1902 | function complete_archiving( success, fails, has_local_messages_before ) |
---|
| 1903 | { |
---|
| 1904 | var msgs_to_remove = {}; |
---|
[5306] | 1905 | var target = mount_url_folder(["INBOX",special_folders["Trash"],'tmpMoveToLocal']); |
---|
[5134] | 1906 | |
---|
| 1907 | success = expresso_local_messages.select_mail( [ 'original_id', 'original_folder' ], success ); |
---|
| 1908 | |
---|
| 1909 | for (var i = 0; i < success.length; i++) { |
---|
| 1910 | |
---|
| 1911 | var msg_info = success[i]; |
---|
| 1912 | |
---|
| 1913 | // if ( msg_info.dest_folder == target ) |
---|
| 1914 | // { |
---|
| 1915 | // msg_info.msg_folder += (Date.parse(new Date)); |
---|
| 1916 | // } |
---|
| 1917 | |
---|
| 1918 | //////////////// deselecionando //////////////// |
---|
| 1919 | Element('chk_box_select_all_messages').checked = false; |
---|
| 1920 | |
---|
| 1921 | if ( Element("check_box_message_" + msg_info.original_id) ) |
---|
| 1922 | { |
---|
| 1923 | Element("check_box_message_" + msg_info.original_id).checked = false; |
---|
| 1924 | } |
---|
| 1925 | if ( Element(msg_info.original_id) ) |
---|
| 1926 | { |
---|
| 1927 | remove_className(Element(msg_info.original_id), 'selected_msg'); |
---|
| 1928 | } |
---|
| 1929 | |
---|
| 1930 | // if ( tree_folders._selected.id.indexOf( 'local_' ) == 0 || msg_info.dest_folder.indexOf( target ) == 0 ) |
---|
| 1931 | // { |
---|
| 1932 | // openTab.imapBox[0] = ''; |
---|
| 1933 | // tree_folders.getNodeById( 'local_Inbox' )._select( ); |
---|
| 1934 | // change_folder('local_Inbox','Inbox'); |
---|
| 1935 | // } |
---|
| 1936 | ///////////////////////////////////////////////// |
---|
| 1937 | |
---|
| 1938 | //As mensagens arquivadas devem ser removidas, caso o usuario tenha isso configurado. |
---|
| 1939 | msgs_to_remove[ msg_info.original_folder ] = msgs_to_remove[ msg_info.original_folder ] || []; |
---|
| 1940 | msgs_to_remove[ msg_info.original_folder ].push( msg_info.original_id ); |
---|
| 1941 | } |
---|
| 1942 | |
---|
| 1943 | if (preferences.keep_archived_messages == 0) { |
---|
| 1944 | //Remove as mensagens |
---|
| 1945 | for( var folder in msgs_to_remove ){ |
---|
| 1946 | if(folder != 'undefined') |
---|
| 1947 | delete_msgs(folder, msgs_to_remove[folder],'null',false,true); |
---|
| 1948 | } |
---|
| 1949 | } |
---|
| 1950 | |
---|
| 1951 | if( !has_local_messages_before && expresso_local_messages.has_local_mails() ) |
---|
| 1952 | ttreeBox.update_folder(); |
---|
| 1953 | else |
---|
| 1954 | update_menu(); |
---|
| 1955 | } |
---|
| 1956 | |
---|
[5172] | 1957 | function action_msg_selected_from_search(aba, evento){ |
---|
| 1958 | if(evento == "delete") |
---|
| 1959 | move_search_msgs(aba,'INBOX/Trash', 'Trash', 'delete'); |
---|
| 1960 | } |
---|
| 1961 | |
---|
| 1962 | function get_all_messages_search(){ |
---|
| 1963 | var aba = document.getElementById('content_id_'+currentTab); |
---|
| 1964 | var messages = ""; |
---|
| 1965 | jQuery(function() { |
---|
| 1966 | jQuery("#"+aba.id+" tr").each(function(i, main_list) { |
---|
| 1967 | messages += main_list.id.replace(/_[a-zA-Z0-9]+/,"") + ',' ; |
---|
| 1968 | }); |
---|
| 1969 | |
---|
| 1970 | }); |
---|
| 1971 | if(messages.indexOf(',') == 0) |
---|
| 1972 | messages = messages.substring(1,(messages.length)); |
---|
| 1973 | return messages.substring(0,(messages.length-1)); |
---|
| 1974 | } |
---|
| 1975 | |
---|
| 1976 | function get_selected_messages_search(){ |
---|
| 1977 | var aba = document.getElementById('content_id_'+currentTab); |
---|
| 1978 | var selected_messages = ""; |
---|
| 1979 | jQuery("#"+aba.id+" tr").each(function(i, main_list) { |
---|
| 1980 | var check_box = main_list.firstChild.firstChild; |
---|
| 1981 | if(check_box && check_box.checked) { |
---|
| 1982 | selected_messages += main_list.id.replace(/_[a-zA-Z0-9]+/,"") + ',' ; |
---|
| 1983 | }; |
---|
| 1984 | }); |
---|
| 1985 | |
---|
| 1986 | if (selected_messages != ""){ |
---|
| 1987 | if(selected_messages.indexOf(',') == 0) |
---|
| 1988 | selected_messages = selected_messages.substring(1,(selected_messages.length)); |
---|
| 1989 | selected_messages = selected_messages.substring(0,(selected_messages.length-1)); |
---|
| 1990 | return selected_messages; |
---|
| 1991 | }else{ |
---|
| 1992 | return false; |
---|
| 1993 | } |
---|
| 1994 | } |
---|
| 1995 | |
---|
[5584] | 1996 | function get_selected_messages_search_role(){ |
---|
| 1997 | var aba = document.getElementById('content_id_'+currentTab); |
---|
| 1998 | var selected_messages = ""; |
---|
[5588] | 1999 | jQuery("#"+aba.id+" tr").each(function(i, main_list) { |
---|
| 2000 | var check_box = main_list.firstChild.firstChild; |
---|
[6033] | 2001 | if(check_box && check_box.checked && check_box.id != 'chk_box_select_all_messages_search') { |
---|
[5588] | 2002 | selected_messages += main_list.role + ',' ; |
---|
| 2003 | }; |
---|
| 2004 | }); |
---|
| 2005 | |
---|
[5584] | 2006 | if (selected_messages != ""){ |
---|
| 2007 | if(selected_messages.indexOf(',') == 0) |
---|
| 2008 | selected_messages = selected_messages.substring(1,(selected_messages.length)); |
---|
| 2009 | selected_messages = selected_messages.substring(0,(selected_messages.length-1)); |
---|
| 2010 | return selected_messages; |
---|
| 2011 | }else{ |
---|
| 2012 | return false; |
---|
| 2013 | } |
---|
| 2014 | } |
---|
[5172] | 2015 | |
---|
[5922] | 2016 | function get_selected_messages_shortcut(){ |
---|
| 2017 | var main; |
---|
| 2018 | try{ |
---|
| 2019 | main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; |
---|
| 2020 | }catch(e){ |
---|
| 2021 | }; |
---|
| 2022 | |
---|
| 2023 | if (! main) |
---|
| 2024 | main = Element("tbody_box_"+numBox); |
---|
| 2025 | |
---|
| 2026 | if (! main) |
---|
| 2027 | main = Element("tbody_box"); |
---|
| 2028 | |
---|
| 2029 | // Get all TR (messages) in tBody. |
---|
| 2030 | var main_list = main.childNodes; |
---|
| 2031 | var selected_messages_by_shortcuts = ''; |
---|
| 2032 | var j = 0; |
---|
| 2033 | for (j; j<(main_list.length); j++) |
---|
| 2034 | { |
---|
| 2035 | |
---|
| 2036 | if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') ) |
---|
| 2037 | { |
---|
| 2038 | selected_messages_by_shortcuts += main_list[j].id + ','; |
---|
| 2039 | } |
---|
| 2040 | |
---|
| 2041 | } |
---|
| 2042 | selected_messages_by_shortcuts = selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1)); |
---|
| 2043 | |
---|
| 2044 | return selected_messages_by_shortcuts; |
---|
| 2045 | |
---|
| 2046 | } |
---|
| 2047 | |
---|
[6930] | 2048 | /*function get_selected_messages(){ |
---|
[4812] | 2049 | var main; |
---|
[3062] | 2050 | try{ |
---|
| 2051 | main = document.getElementById("divScrollMain_"+numBox).firstChild.firstChild; |
---|
| 2052 | }catch(e){ |
---|
| 2053 | }; |
---|
| 2054 | |
---|
[345] | 2055 | if (! main) |
---|
[4810] | 2056 | main = Element("tbody_box_"+numBox); |
---|
| 2057 | |
---|
| 2058 | if (! main) |
---|
[345] | 2059 | main = Element("tbody_box"); |
---|
[320] | 2060 | |
---|
[2] | 2061 | // Get all TR (messages) in tBody. |
---|
[4812] | 2062 | var main_list = main.childNodes; |
---|
[320] | 2063 | |
---|
[5134] | 2064 | var _tab_prefix = getTabPrefix(); |
---|
[2] | 2065 | var selected_messages = ''; |
---|
[163] | 2066 | var selected_messages_by_shortcuts = ''; |
---|
[2] | 2067 | var j = 0; |
---|
[163] | 2068 | for (j; j<(main_list.length); j++) |
---|
| 2069 | { |
---|
[3724] | 2070 | |
---|
[5922] | 2071 | if ( (!isNaN(parseInt(numBox))) && (numBox == 0)) { |
---|
| 2072 | check_box = Element("check_box_message_" + main_list[j].id); |
---|
| 2073 | } else { |
---|
| 2074 | id_mensagem = main_list[j].id.split('_'); |
---|
| 2075 | check_box = Element("search_" + numBox + "_check_box_message_" + id_mensagem[0]); |
---|
| 2076 | } |
---|
[5134] | 2077 | |
---|
[5922] | 2078 | if ( (check_box) && (check_box.checked) ) |
---|
| 2079 | selected_messages += main_list[j].id + ','; |
---|
[3035] | 2080 | |
---|
[163] | 2081 | if (preferences.use_shortcuts == '1') |
---|
| 2082 | { |
---|
| 2083 | if ( exist_className(Element(main_list[j].id), 'selected_shortcut_msg') ) |
---|
| 2084 | { |
---|
| 2085 | selected_messages_by_shortcuts += main_list[j].id + ','; |
---|
| 2086 | } |
---|
| 2087 | } |
---|
[2] | 2088 | } |
---|
| 2089 | selected_messages = selected_messages.substring(0,(selected_messages.length-1)); |
---|
[3035] | 2090 | |
---|
[5134] | 2091 | |
---|
[6930] | 2092 | /* Verifica se está na tela de pesquisa. */ /* |
---|
[5134] | 2093 | if(selected_messages.indexOf("_") != -1) |
---|
| 2094 | { |
---|
| 2095 | results_search_messages = selected_messages; |
---|
[6930] | 2096 | /* Retira a informação da aba */ /* |
---|
[5134] | 2097 | selected_messages = selected_messages.substring(0,selected_messages.indexOf("_")); |
---|
| 2098 | } |
---|
| 2099 | |
---|
| 2100 | |
---|
[163] | 2101 | if (preferences.use_shortcuts == '1') |
---|
| 2102 | { |
---|
| 2103 | selected_messages_by_shortcuts = selected_messages_by_shortcuts.substring(0,(selected_messages_by_shortcuts.length-1)); |
---|
[3035] | 2104 | |
---|
[163] | 2105 | var array_selected_messages_by_shortcuts = selected_messages_by_shortcuts.split(","); |
---|
| 2106 | var array_selected_messages = selected_messages.split(","); |
---|
[6721] | 2107 | /* |
---|
[5922] | 2108 | if ((array_selected_messages.length == 0) && (array_selected_messages_by_shortcuts.length > 0)) |
---|
[163] | 2109 | { |
---|
| 2110 | return selected_messages_by_shortcuts; |
---|
[6721] | 2111 | }*/ |
---|
[6930] | 2112 | /*Se houver mais de uma mensagem selecionada por atalho*//* |
---|
[6721] | 2113 | if (array_selected_messages_by_shortcuts.length > 1){ |
---|
| 2114 | if (selected_messages == "") |
---|
| 2115 | return selected_messages_by_shortcuts; |
---|
| 2116 | else |
---|
| 2117 | return selected_messages + "," + selected_messages_by_shortcuts; |
---|
[163] | 2118 | } |
---|
[6721] | 2119 | } |
---|
[2] | 2120 | if (selected_messages == '') |
---|
| 2121 | return false; |
---|
| 2122 | else |
---|
| 2123 | return selected_messages; |
---|
[6930] | 2124 | }*/ |
---|
[7539] | 2125 | |
---|
[6930] | 2126 | function get_selected_messages(){ |
---|
[7539] | 2127 | var selectedMsg = new Array(); |
---|
[6930] | 2128 | $.each(selectedPagingMsgs, function(index, value){ |
---|
| 2129 | if(value) |
---|
[7539] | 2130 | selectedMsg.push(index); |
---|
[6930] | 2131 | }); |
---|
[7539] | 2132 | return ""+selectedMsg; |
---|
[2] | 2133 | } |
---|
[7539] | 2134 | function clear_selected_messages(){ |
---|
| 2135 | selectedPagingMsgs = {}; |
---|
| 2136 | } |
---|
[2] | 2137 | |
---|
[689] | 2138 | function replaceAll(string, token, newtoken) { |
---|
| 2139 | while (string.indexOf(token) != -1) { |
---|
| 2140 | string = string.replace(token, newtoken); |
---|
| 2141 | } |
---|
| 2142 | return string; |
---|
| 2143 | } |
---|
| 2144 | |
---|
[603] | 2145 | function new_message_to(email) { |
---|
| 2146 | var new_border_ID = new_message('new','null'); |
---|
| 2147 | document.getElementById("to_" + new_border_ID).value=email; |
---|
| 2148 | } |
---|
| 2149 | |
---|
[7639] | 2150 | function new_message(type, border_ID, flagged) |
---|
| 2151 | { |
---|
[7657] | 2152 | action_tab_id = border_ID.replace('_r', ''); |
---|
| 2153 | if (openTab.type[action_tab_id]) |
---|
[7639] | 2154 | { |
---|
[7657] | 2155 | // if there's a reply already open, just switch to it |
---|
| 2156 | if (openTab.type[action_tab_id] == tabTypes[type]) |
---|
| 2157 | { |
---|
| 2158 | alternate_border(action_tab_id); |
---|
| 2159 | resizeWindow(); |
---|
| 2160 | return action_tab_id; |
---|
| 2161 | } |
---|
| 2162 | else |
---|
| 2163 | { |
---|
| 2164 | // if not, ask the user: |
---|
| 2165 | var a_types = { |
---|
| 2166 | 6: get_lang("Forward"), |
---|
| 2167 | 7: get_lang("Reply"), |
---|
| 2168 | 8: get_lang("Reply to all with history"), |
---|
| 2169 | 9: get_lang("Reply without history"), |
---|
| 2170 | 10: get_lang("Reply to all without history") |
---|
| 2171 | }; |
---|
| 2172 | var response = confirm( |
---|
| 2173 | get_lang( |
---|
| 2174 | "Your message to %1 has not been saved or sent. " + |
---|
| 2175 | "To %2 will be necessary open it again. Discard your message?", |
---|
| 2176 | a_types[openTab.type[action_tab_id]].toUpperCase(), |
---|
| 2177 | a_types[tabTypes[type]].toUpperCase() |
---|
| 2178 | ) |
---|
| 2179 | ); |
---|
| 2180 | if (response) |
---|
| 2181 | { |
---|
| 2182 | alternate_border(action_tab_id); |
---|
| 2183 | resizeWindow(); |
---|
| 2184 | delete_border(currentTab); |
---|
| 2185 | } |
---|
| 2186 | else |
---|
| 2187 | { |
---|
| 2188 | return action_tab_id; |
---|
| 2189 | } |
---|
| 2190 | } |
---|
[7639] | 2191 | } |
---|
[7628] | 2192 | |
---|
[7639] | 2193 | if (RichTextEditor.editorReady === false) return false; |
---|
[5083] | 2194 | |
---|
[7639] | 2195 | RichTextEditor.editorReady = false; |
---|
[605] | 2196 | |
---|
[5193] | 2197 | |
---|
[7639] | 2198 | if (Element('show_img_link_' + border_ID)) |
---|
| 2199 | { |
---|
| 2200 | show_msg_img(border_ID.match(/^\d*/)[0], Element('input_folder_' + border_ID).value); |
---|
| 2201 | } |
---|
[7640] | 2202 | var new_border_ID = draw_new_message((type == 'new') ? parseInt(border_ID.replace('_r','')) : border_ID.replace('_r','')); |
---|
[6060] | 2203 | |
---|
[7657] | 2204 | // Does this block has any purpose at all? |
---|
[7639] | 2205 | if (typeof (openTab.type[new_border_ID]) != "undefined") |
---|
| 2206 | { |
---|
| 2207 | if (tabTypes[type] == openTab.type[new_border_ID]) |
---|
| 2208 | { |
---|
| 2209 | if (type != 'edit') |
---|
| 2210 | { |
---|
| 2211 | delete_border(currentTab); |
---|
| 2212 | new_border_ID = draw_new_message(border_ID); |
---|
| 2213 | } |
---|
| 2214 | } |
---|
| 2215 | } |
---|
| 2216 | if (new_border_ID == 'maximo') |
---|
| 2217 | { |
---|
| 2218 | RichTextEditor.editorReady = true; |
---|
| 2219 | return false; |
---|
| 2220 | } |
---|
| 2221 | if (new_border_ID == false) |
---|
| 2222 | { |
---|
| 2223 | RichTextEditor.editorReady = true; |
---|
| 2224 | setTimeout('new_message(\'' + type + '\',\'' + border_ID + '\',\'' + flagged + '\');', 500); |
---|
| 2225 | return false; |
---|
| 2226 | } |
---|
| 2227 | openTab.type[new_border_ID] = tabTypes[type]; |
---|
[7520] | 2228 | |
---|
[7639] | 2229 | // Salva a pasta da mensagem respondida ou encaminhada: |
---|
| 2230 | var folder_message = Element("input_folder_" + border_ID); |
---|
| 2231 | if (folder_message) |
---|
| 2232 | { |
---|
| 2233 | var input_current_folder = document.createElement('input'); |
---|
| 2234 | input_current_folder.id = "new_input_folder_" + border_ID; |
---|
| 2235 | input_current_folder.name = "input_folder"; |
---|
| 2236 | input_current_folder.type = "hidden"; |
---|
| 2237 | input_current_folder.value = folder_message.value; |
---|
| 2238 | Element("content_id_" + new_border_ID).appendChild(input_current_folder); |
---|
| 2239 | } //Fim. |
---|
| 2240 | var title = ''; |
---|
| 2241 | data = []; |
---|
[7520] | 2242 | |
---|
[7639] | 2243 | |
---|
| 2244 | if (Element("from_" + border_ID)) |
---|
| 2245 | { |
---|
| 2246 | if (document.getElementById("reply_to_" + border_ID)) |
---|
| 2247 | { |
---|
| 2248 | data.to = document.getElementById("reply_to_values_" + border_ID).value; |
---|
| 2249 | data.to = data.to.replace(/</gi, "<"); |
---|
| 2250 | data.to = data.to.replace(/>/gi, ">"); |
---|
| 2251 | } |
---|
| 2252 | else |
---|
| 2253 | { |
---|
| 2254 | if (document.getElementById("sender_values_" + border_ID)) |
---|
| 2255 | { |
---|
| 2256 | data.to = document.getElementById("sender_values_" + border_ID).value; |
---|
| 2257 | data.to = data.to.replace(/</gi, "<"); |
---|
| 2258 | data.to = data.to.replace(/>/gi, ">"); |
---|
| 2259 | } |
---|
| 2260 | else if (document.getElementById("from_values_" + border_ID)) |
---|
| 2261 | { |
---|
| 2262 | data.to = document.getElementById("from_values_" + border_ID).value; |
---|
| 2263 | data.to = data.to.replace(/</gi, "<"); |
---|
| 2264 | data.to = data.to.replace(/>/gi, ">"); |
---|
| 2265 | } |
---|
| 2266 | } |
---|
| 2267 | if (document.getElementById("to_values_" + border_ID)) |
---|
| 2268 | { |
---|
| 2269 | data.to_all = document.getElementById("to_values_" + border_ID).value; |
---|
| 2270 | data.to_all_alternative = document.getElementById("user_email_alternative").value; |
---|
| 2271 | data.to_all = data.to_all.replace(/\n/gi, " "); |
---|
| 2272 | data.to_all = data.to_all.replace(/</gi, "<"); |
---|
| 2273 | data.to_all = data.to_all.replace(/>/gi, ">"); |
---|
| 2274 | var _array_to_all = data.to_all.split(","); |
---|
| 2275 | var _array_to_alternative = data.to_all_alternative.split(","); |
---|
| 2276 | } |
---|
[7526] | 2277 | } |
---|
[7639] | 2278 | if (document.getElementById("cc_" + border_ID)) |
---|
| 2279 | { |
---|
| 2280 | data.cc = document.getElementById("cc_values_" + border_ID).value; |
---|
| 2281 | data.cc = data.cc.replace(/</gi, "<"); |
---|
| 2282 | data.cc = data.cc.replace(/>/gi, ">"); |
---|
| 2283 | var _array_cc = data.cc.split(","); |
---|
| 2284 | } |
---|
| 2285 | if (document.getElementById("cco_" + border_ID)) |
---|
| 2286 | { |
---|
| 2287 | data.cco = document.getElementById("cco_values_" + border_ID).value; |
---|
| 2288 | data.cco = data.cco.replace(/</gi, "<"); |
---|
| 2289 | data.cco = data.cco.replace(/>/gi, ">"); |
---|
| 2290 | } |
---|
| 2291 | if ($("#subject_" + border_ID)) data.subject = $("#subject_" + border_ID).text(); |
---|
| 2292 | if (data.subject == get_lang("(no subject) ")) data.subject = ''; |
---|
| 2293 | if (document.getElementById("body_" + border_ID)) data.body = document.getElementById("body_" + border_ID).innerHTML; |
---|
| 2294 | if (document.getElementById("from_values_" + border_ID)) data.from = document.getElementById("from_values_" + border_ID).value; |
---|
| 2295 | if (Element('date_' + border_ID)) |
---|
| 2296 | { |
---|
| 2297 | data.date = Element('date_' + border_ID).innerHTML; |
---|
| 2298 | } |
---|
| 2299 | if (Element('date_day_' + border_ID)) |
---|
| 2300 | { |
---|
| 2301 | data.date_day = Element('date_day_' + border_ID).value; |
---|
| 2302 | } |
---|
| 2303 | if (Element('date_hour_' + border_ID)) |
---|
| 2304 | { |
---|
| 2305 | data.date_hour = Element('date_hour_' + border_ID).value; |
---|
| 2306 | } |
---|
[7520] | 2307 | |
---|
[7639] | 2308 | var signature = RichTextEditor.getSignatureDefault(); |
---|
[7520] | 2309 | |
---|
[7639] | 2310 | if (type != "new" && type != "edit" && document.getElementById("is_local_" + border_ID) != null) data.is_local_message = (document.getElementById("is_local_" + border_ID).value == "1") ? true : false; |
---|
| 2311 | |
---|
| 2312 | if (typeof ($.fn.elastic) == "undefined") |
---|
| 2313 | { |
---|
| 2314 | $.lazy( |
---|
| 2315 | { |
---|
| 2316 | src: '../prototype/plugins/jquery-elastic/jquery.elastic.source.js', |
---|
| 2317 | name: 'elastic' |
---|
| 2318 | }); |
---|
| 2319 | } |
---|
| 2320 | var content = $("#content_id_" + new_border_ID); |
---|
| 2321 | |
---|
| 2322 | //It is verifying if the message was modified or not. |
---|
| 2323 | var btnSaveVerify = function () |
---|
| 2324 | { |
---|
| 2325 | $("#content_id_" + currentTab + " .save").button("disable"); |
---|
| 2326 | |
---|
| 2327 | dataBtn = new Array(".to", ".cc", ".cco", "input[name=input_subject]", ".reply-to"); |
---|
| 2328 | |
---|
| 2329 | for (var i in dataBtn) |
---|
| 2330 | { |
---|
| 2331 | $("#content_id_" + currentTab + " " + dataBtn[i]).keydown(function () |
---|
| 2332 | { |
---|
| 2333 | $("#content_id_" + currentTab + " .save").button("enable"); |
---|
| 2334 | }); |
---|
| 2335 | } |
---|
| 2336 | |
---|
| 2337 | RichTextEditor.keydown(new_border_ID); |
---|
| 2338 | } |
---|
| 2339 | |
---|
| 2340 | switch (type) |
---|
| 2341 | { |
---|
| 2342 | case "reply_without_history": |
---|
[7520] | 2343 | btnSaveVerify(); |
---|
| 2344 | |
---|
[7639] | 2345 | RichTextEditor.replyController = true; //Seta o editor como modo reply |
---|
| 2346 | content.find('[name="input_to"]').val(data.to); |
---|
[5134] | 2347 | |
---|
[7639] | 2348 | draw_reply_boxes_by_field("to", data.to, content); |
---|
| 2349 | |
---|
| 2350 | title = "Re: " + html_entities(data.subject); |
---|
| 2351 | content.find(".subject").val("Re: " + data.subject); |
---|
| 2352 | useOriginalAttachments(new_border_ID, border_ID); |
---|
| 2353 | content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); |
---|
| 2354 | |
---|
| 2355 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 2356 | if (preferences.use_signature == "1") |
---|
| 2357 | { |
---|
| 2358 | RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature, true); |
---|
| 2359 | } |
---|
| 2360 | break; |
---|
| 2361 | case "reply_with_history": |
---|
[7520] | 2362 | btnSaveVerify(); |
---|
| 2363 | |
---|
[7639] | 2364 | RichTextEditor.replyController = true; //Seta o editor como modo reply |
---|
| 2365 | title = "Re: " + html_entities(data.subject); |
---|
| 2366 | content.find(".subject").val("Re: " + data.subject); |
---|
| 2367 | content.find('[name="input_to"]').val(data.to); |
---|
| 2368 | |
---|
| 2369 | draw_reply_boxes_by_field("to", data.to, content); |
---|
| 2370 | content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); |
---|
| 2371 | block_quoted_body = make_body_reply(data.body, data.from, data.date_day, data.date_hour); |
---|
| 2372 | |
---|
| 2373 | useOriginalAttachments(new_border_ID, border_ID); |
---|
| 2374 | |
---|
| 2375 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 2376 | if (preferences.use_signature == "1") |
---|
| 2377 | { |
---|
| 2378 | var body_text = '<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>' + block_quoted_body; |
---|
| 2379 | if (preferences.plain_text_editor == "1") |
---|
| 2380 | { |
---|
| 2381 | body_text = "\n\n" + remove_tags(body_text); |
---|
| 2382 | $("#body_" + new_border_ID).val(body_text, true); |
---|
| 2383 | } |
---|
| 2384 | else |
---|
| 2385 | { |
---|
| 2386 | RichTextEditor.setInitData(new_border_ID, body_text, true); |
---|
| 2387 | } |
---|
| 2388 | } |
---|
| 2389 | else |
---|
| 2390 | { |
---|
| 2391 | body_text = '<div><br type="_moz"></div>' + block_quoted_body; |
---|
| 2392 | if (preferences.plain_text_editor == "1") |
---|
| 2393 | { |
---|
| 2394 | body_text = "\n\n" + remove_tags(body_text); |
---|
| 2395 | $("#body_" + new_border_ID).val(body_text, true); |
---|
| 2396 | } |
---|
| 2397 | else |
---|
| 2398 | { |
---|
| 2399 | RichTextEditor.setInitData(new_border_ID, body_text, true); |
---|
| 2400 | } |
---|
| 2401 | } |
---|
| 2402 | break; |
---|
| 2403 | case "reply_to_all_without_history": |
---|
[7520] | 2404 | btnSaveVerify(); |
---|
| 2405 | |
---|
[7639] | 2406 | RichTextEditor.replyController = true; //Seta o editor como modo reply |
---|
| 2407 | // delete user email from to_all array. |
---|
| 2408 | data.to_all = new Array(); |
---|
| 2409 | data.to_all = removeUserEmail(_array_to_all); |
---|
| 2410 | data.to_all = removeAlternative(data.to_all, _array_to_alternative); |
---|
| 2411 | content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); |
---|
[5257] | 2412 | |
---|
[7639] | 2413 | data.to_all = data.to_all.join(","); |
---|
[320] | 2414 | |
---|
[7639] | 2415 | title = "Re: " + html_entities(data.subject); |
---|
| 2416 | content.find(".subject").val("Re: " + data.subject); |
---|
[7520] | 2417 | |
---|
[7639] | 2418 | if (data.to.indexOf(Element("user_email").value) > 0) |
---|
| 2419 | { |
---|
| 2420 | draw_reply_boxes_by_field("to", data.to_all, content); |
---|
| 2421 | content.find('[name="input_to"]').val(data.to_all); |
---|
| 2422 | } |
---|
| 2423 | else |
---|
| 2424 | { |
---|
| 2425 | draw_reply_boxes_by_field("to", data.to + ',' + data.to_all, content); |
---|
| 2426 | content.find('[name="input_to"]').val(data.to + ',' + data.to_all); |
---|
| 2427 | } |
---|
| 2428 | |
---|
| 2429 | if (data.cc) |
---|
| 2430 | { |
---|
| 2431 | data.cc = new Array(); |
---|
| 2432 | data.cc = removeUserEmail(_array_cc); |
---|
| 2433 | data.cc = removeAlternative(data.cc, _array_to_alternative); |
---|
| 2434 | if (data.cc != get_lang("undisclosed-recipient")) data.cc = data.cc.join(","); |
---|
| 2435 | else data.cc = ""; |
---|
| 2436 | if (data.cc != "") |
---|
| 2437 | { |
---|
| 2438 | content.find('[name="input_cc"]').val(data.cc); |
---|
| 2439 | input_binds(content.find('[name="input_cc"]').parent(), new_border_ID); |
---|
| 2440 | content.find(".cc-tr").show(); //cc-button |
---|
| 2441 | //document.getElementById("a_cc_link" + new_border_ID).value = data.cc; |
---|
| 2442 | content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); |
---|
| 2443 | content.find(".cc-button").find("span").html("Remover CC"); |
---|
| 2444 | draw_reply_boxes_by_field("cc", data.cc, content); |
---|
| 2445 | } |
---|
| 2446 | } |
---|
| 2447 | |
---|
| 2448 | useOriginalAttachments(new_border_ID, border_ID); |
---|
| 2449 | if (preferences.use_signature == "1") |
---|
| 2450 | { |
---|
| 2451 | RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature, true); |
---|
| 2452 | } |
---|
| 2453 | |
---|
| 2454 | break; |
---|
| 2455 | case "reply_to_all_with_history": |
---|
[7520] | 2456 | btnSaveVerify(); |
---|
| 2457 | |
---|
[7639] | 2458 | RichTextEditor.replyController = true; //Seta o editor como modo reply |
---|
| 2459 | //delete user email from to_all array. |
---|
| 2460 | data.to_all = new Array(); |
---|
| 2461 | data.to_all = removeUserEmail(_array_to_all); |
---|
| 2462 | data.to_all = removeAlternative(data.to_all, _array_to_alternative); |
---|
| 2463 | content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); |
---|
[7568] | 2464 | |
---|
[7639] | 2465 | if (data.to_all != get_lang("undisclosed-recipient")) data.to_all = data.to_all.join(","); |
---|
| 2466 | else data.to_all = ""; |
---|
[5485] | 2467 | |
---|
[7639] | 2468 | title = "Re: " + html_entities(data.subject); |
---|
[7520] | 2469 | |
---|
[7639] | 2470 | if (data.to.indexOf(Element("user_email").value) > 0) |
---|
| 2471 | { |
---|
| 2472 | draw_reply_boxes_by_field("to", data.to_all, content); |
---|
| 2473 | content.find('[name="input_to"]').val(data.to_all); |
---|
| 2474 | } |
---|
| 2475 | else |
---|
| 2476 | { |
---|
| 2477 | draw_reply_boxes_by_field("to", data.to + ',' + data.to_all, content); |
---|
| 2478 | content.find('[name="input_to"]').val(data.to + ',' + data.to_all); |
---|
| 2479 | } |
---|
[7637] | 2480 | |
---|
[7639] | 2481 | if (data.cc) |
---|
| 2482 | { |
---|
| 2483 | data.cc = new Array(); |
---|
| 2484 | data.cc = removeUserEmail(_array_cc); |
---|
| 2485 | data.cc = removeAlternative(data.cc, _array_to_alternative); |
---|
| 2486 | if (data.cc != get_lang("undisclosed-recipient")) data.cc = data.cc.join(","); |
---|
| 2487 | else data.cc = ""; |
---|
| 2488 | if (data.cc != "") |
---|
| 2489 | { |
---|
| 2490 | content.find('[name="input_cc"]').val(data.cc); |
---|
| 2491 | input_binds(content.find('[name="input_aux_cc"]').parent(), new_border_ID); |
---|
| 2492 | content.find(".cc-tr").show(); |
---|
| 2493 | content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); |
---|
| 2494 | content.find(".cc-button").find("span").html("Remover CC"); |
---|
[7637] | 2495 | |
---|
[7639] | 2496 | draw_reply_boxes_by_field("cc", data.cc, content); |
---|
| 2497 | } |
---|
| 2498 | } |
---|
| 2499 | content.find(".subject").val("Re: " + data.subject); |
---|
[7520] | 2500 | |
---|
[7639] | 2501 | block_quoted_body = make_body_reply(data.body, data.from, data.date_day, data.date_hour); |
---|
[3035] | 2502 | |
---|
[7639] | 2503 | useOriginalAttachments(new_border_ID, border_ID); |
---|
[3035] | 2504 | |
---|
[7639] | 2505 | if (preferences.use_signature == "1") |
---|
| 2506 | { |
---|
| 2507 | var body_text = '<div><br type="_moz"></div><div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>' + block_quoted_body; |
---|
| 2508 | if (preferences.plain_text_editor == "1") |
---|
| 2509 | { |
---|
| 2510 | body_text = "\n\n" + remove_tags(body_text); |
---|
| 2511 | $("#body_" + new_border_ID).val(body_text, true); |
---|
| 2512 | } |
---|
| 2513 | else |
---|
| 2514 | { |
---|
| 2515 | RichTextEditor.setInitData(new_border_ID, body_text, true); |
---|
| 2516 | } |
---|
| 2517 | } |
---|
| 2518 | else |
---|
| 2519 | { |
---|
| 2520 | var body_text = '<div><br type="_moz"></div><div><br type="_moz"></div>' + block_quoted_body; |
---|
| 2521 | if (preferences.plain_text_editor == "1") |
---|
| 2522 | { |
---|
| 2523 | body_text = "\n\n" + remove_tags(body_text); |
---|
| 2524 | $("#body_" + new_border_ID).val(body_text, true); |
---|
| 2525 | } |
---|
| 2526 | else |
---|
| 2527 | { |
---|
| 2528 | RichTextEditor.setInitData(new_border_ID, body_text, true); |
---|
| 2529 | } |
---|
| 2530 | } |
---|
[3798] | 2531 | |
---|
[7639] | 2532 | break; |
---|
| 2533 | case "forward": |
---|
| 2534 | btnSaveVerify(); |
---|
[7568] | 2535 | |
---|
[7639] | 2536 | title = "Fw: " + html_entities(data.subject); |
---|
| 2537 | content.find(".subject").val("Fw: " + data.subject); |
---|
| 2538 | var divFiles = Element("divFiles_" + new_border_ID); |
---|
| 2539 | var campo_arquivo; |
---|
| 2540 | content.find('[name="msg_forward_from"]').val($("#msg_number_" + border_ID).val()); |
---|
| 2541 | |
---|
| 2542 | if (Element("attachments_" + border_ID)) addOriginalAttachments(new_border_ID, border_ID); |
---|
[7663] | 2543 | RichTextEditor.dataReady(new_border_ID, 'forward'); |
---|
[7639] | 2544 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 2545 | if (preferences.use_signature == "1") |
---|
| 2546 | { |
---|
| 2547 | var body_text = '<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); |
---|
| 2548 | if (preferences.plain_text_editor == "1") |
---|
| 2549 | { |
---|
| 2550 | body_text = "\n\n" + remove_tags(body_text); |
---|
| 2551 | $("#body_" + new_border_ID).val(body_text); |
---|
| 2552 | } |
---|
| 2553 | else |
---|
| 2554 | { |
---|
| 2555 | RichTextEditor.setInitData(new_border_ID, body_text, true); |
---|
| 2556 | } |
---|
| 2557 | } |
---|
| 2558 | else |
---|
| 2559 | { |
---|
| 2560 | var body_text = '<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); |
---|
| 2561 | if (preferences.plain_text_editor == "1") |
---|
| 2562 | { |
---|
| 2563 | body_text = "\n\n" + remove_tags(body_text); |
---|
| 2564 | $("#body_" + new_border_ID).val(body_text); |
---|
| 2565 | } |
---|
| 2566 | else |
---|
| 2567 | { |
---|
| 2568 | RichTextEditor.setInitData(new_border_ID, body_text, true); |
---|
| 2569 | } |
---|
| 2570 | } |
---|
| 2571 | RichTextEditor.dataReady(new_border_ID, 'forward'); |
---|
| 2572 | |
---|
| 2573 | break; |
---|
| 2574 | case "new": |
---|
| 2575 | |
---|
| 2576 | btnSaveVerify(); |
---|
| 2577 | |
---|
| 2578 | title = get_lang("New Message"); |
---|
| 2579 | if (Element('msg_number').value) |
---|
| 2580 | { |
---|
| 2581 | var _to = Element('msg_number').value; |
---|
| 2582 | 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}\])$/; |
---|
| 2583 | if (!reEmail.test(_to)) |
---|
| 2584 | { |
---|
| 2585 | var array_contacts = contacts.split(','); |
---|
| 2586 | for (i = 0; i < array_contacts.length; i++) |
---|
| 2587 | { |
---|
| 2588 | if (array_contacts[i].lastIndexOf(_to) != "-1") |
---|
| 2589 | { |
---|
| 2590 | var _group = array_contacts[i].split(";"); |
---|
| 2591 | _to = '"' + _group[0] + '" <' + _group[1] + '>'; |
---|
| 2592 | break; |
---|
| 2593 | } |
---|
| 2594 | } |
---|
| 2595 | } |
---|
| 2596 | content.find('[name="input_to"]').val(_to + ','); |
---|
| 2597 | draw_email_box(_to, content.find(".to").filter("input")); |
---|
| 2598 | Element('msg_number').value = ''; |
---|
| 2599 | } |
---|
[7663] | 2600 | RichTextEditor.dataReady(new_border_ID, 'new'); |
---|
[7639] | 2601 | // Insert the signature automaticaly at message body if use_signature preference is set |
---|
| 2602 | if (preferences.use_signature == "1") |
---|
| 2603 | { |
---|
| 2604 | var signature_text = '<div><br type="_moz"></div><div><br type="_moz"></div>' + signature; |
---|
| 2605 | if (preferences.plain_text_editor == "1") |
---|
| 2606 | { |
---|
| 2607 | signature_text = "\n\n" + remove_tags(signature_text); |
---|
| 2608 | $("#body_" + new_border_ID).val(signature_text); |
---|
| 2609 | } |
---|
| 2610 | else |
---|
| 2611 | { |
---|
| 2612 | RichTextEditor.setInitData(new_border_ID, signature_text, true); |
---|
| 2613 | } |
---|
| 2614 | content.find(".to").focus(); |
---|
| 2615 | } |
---|
| 2616 | else content.find('[name="input_to"]').focus(); |
---|
| 2617 | |
---|
| 2618 | RichTextEditor.dataReady(new_border_ID, 'new'); |
---|
| 2619 | |
---|
| 2620 | break; |
---|
| 2621 | case "edit": |
---|
| 2622 | btnSaveVerify(); |
---|
| 2623 | |
---|
| 2624 | if (flagged == 'F') $(".important").addClass("expressomail-button-icon-ative"); |
---|
| 2625 | |
---|
| 2626 | openTab.imapBox[new_border_ID] = folder_message.value; |
---|
| 2627 | document.getElementById('font_border_id_' + new_border_ID).innerHTML = data.subject; |
---|
| 2628 | title = "Edição: " + html_entities(data.subject); |
---|
| 2629 | |
---|
| 2630 | data.to = Element("to_values_" + border_ID).value; |
---|
| 2631 | if (data.to != get_lang("without destination")) |
---|
| 2632 | { |
---|
| 2633 | data.to = data.to.replace(/</gi, "<"); |
---|
| 2634 | data.to = data.to.replace(/>/gi, ">"); |
---|
| 2635 | } |
---|
| 2636 | else |
---|
| 2637 | { |
---|
| 2638 | data.to = ""; |
---|
| 2639 | } |
---|
| 2640 | |
---|
| 2641 | draw_reply_boxes_by_field("to", data.to, content); |
---|
| 2642 | |
---|
| 2643 | content.find('[name="input_to"]').val(data.to); |
---|
| 2644 | if (data.cc) |
---|
| 2645 | { |
---|
| 2646 | data.cc = data.cc.replace(/</gi, "<"); |
---|
| 2647 | data.cc = data.cc.replace(/>/gi, ">"); |
---|
| 2648 | content.find('[name="input_cc"]').val(data.cc); |
---|
| 2649 | input_binds(content.find('[name="input_cc"]').parent(), new_border_ID); |
---|
| 2650 | content.find(".cc-tr").show(); |
---|
| 2651 | content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); |
---|
| 2652 | content.find(".cc-button").find("span").html(get_lang('Remove CC')); |
---|
| 2653 | draw_reply_boxes_by_field("cc", data.cc, content); |
---|
| 2654 | } |
---|
| 2655 | if (data.cco) |
---|
| 2656 | { |
---|
| 2657 | if (content.find('[name="input_cco"]').length) |
---|
| 2658 | { |
---|
| 2659 | content.find('[name="input_cco"]').val(data.cco); |
---|
| 2660 | content.find(".cco-tr").show(); |
---|
| 2661 | content.find(".cco-button").toggleClass("expressomail-button-icon-ative"); |
---|
| 2662 | content.find(".cco-button").find("span").html(get_lang('Remove CCo')); |
---|
| 2663 | input_binds(content.find('[name="input_cco"]').parent(), new_border_ID); |
---|
| 2664 | draw_reply_boxes_by_field("cco", data.cco, content); |
---|
| 2665 | } |
---|
| 2666 | } |
---|
| 2667 | content.find(".subject").val(data.subject); |
---|
| 2668 | |
---|
| 2669 | if ($("#disposition_notification_" + border_ID).length) |
---|
| 2670 | { |
---|
| 2671 | content.find('[name="input_return_receipt"]').attr("checked", true); |
---|
| 2672 | content.find(".return-recept").toggleClass("expressomail-button-icon-ative"); |
---|
| 2673 | //Element("return_receipt_" + new_border_ID).checked = true; |
---|
| 2674 | } |
---|
| 2675 | |
---|
| 2676 | var element_important_message = Element("important_message_" + new_border_ID); |
---|
| 2677 | if (element_important_message) |
---|
| 2678 | { |
---|
| 2679 | |
---|
| 2680 | if ($("#disposition_important_" + border_ID).length) |
---|
| 2681 | { |
---|
| 2682 | content.find('[name="input_important_message"]').attr("checked", true); |
---|
| 2683 | content.find(".important").toggleClass("expressomail-button-icon-ative"); |
---|
| 2684 | } |
---|
| 2685 | } |
---|
| 2686 | |
---|
| 2687 | if (Element("attachments_" + border_ID)) addOriginalAttachments(new_border_ID, border_ID); |
---|
| 2688 | |
---|
| 2689 | if (preferences.plain_text_editor == "1") |
---|
| 2690 | { |
---|
| 2691 | data.body = remove_tags(data.body); |
---|
| 2692 | $("#body_" + new_border_ID).val(data.body); |
---|
| 2693 | } |
---|
| 2694 | else |
---|
| 2695 | { |
---|
| 2696 | RichTextEditor.setInitData(new_border_ID, data.body, 'edit'); |
---|
| 2697 | } |
---|
| 2698 | |
---|
| 2699 | uidsSave[new_border_ID].push(new_border_ID); |
---|
| 2700 | close_delete(border_ID); |
---|
| 2701 | |
---|
| 2702 | break; |
---|
| 2703 | default: |
---|
| 2704 | } |
---|
| 2705 | |
---|
| 2706 | content.find('[name="input_to"]').trigger("update"); |
---|
| 2707 | var txtarea = $('#body_' + new_border_ID); |
---|
| 2708 | var height = document.body.scrollHeight - 330; |
---|
| 2709 | txtarea.css("overflowY", "auto"); |
---|
| 2710 | txtarea.css("height", height); |
---|
| 2711 | $("#border_id_" + new_border_ID).attr("title", title); |
---|
| 2712 | set_border_caption("border_id_" + new_border_ID, title); |
---|
| 2713 | resizeWindow(); |
---|
| 2714 | return new_border_ID; //Preciso retornar o ID da nova mensagem. |
---|
[2] | 2715 | } |
---|
| 2716 | |
---|
[6528] | 2717 | //DESENHA OS RETANGULOS PARA OS E-MAIL NA OPÇÃO REPLY |
---|
| 2718 | function draw_reply_boxes_by_field(field, value, context){ |
---|
[6882] | 2719 | array = break_comma(value); |
---|
[6528] | 2720 | $.each(array, function(index, value){ |
---|
[7113] | 2721 | draw_email_box(value, context.find("."+field).filter("textarea:first")); |
---|
[6528] | 2722 | }); |
---|
| 2723 | } |
---|
| 2724 | |
---|
[5408] | 2725 | //Remove o email do usuario ao responder a todos |
---|
| 2726 | function removeUserEmail(emailList){ |
---|
| 2727 | var userEmail = Element("user_email").value; |
---|
| 2728 | var array_emails = Array(); |
---|
| 2729 | var j = 0; |
---|
| 2730 | for (var i=0;i<emailList.length;i++){ |
---|
| 2731 | if (emailList[i].indexOf(userEmail) < 0){ |
---|
| 2732 | array_emails[j++] = emailList[i]; |
---|
| 2733 | } |
---|
| 2734 | } |
---|
| 2735 | return array_emails; |
---|
| 2736 | } |
---|
| 2737 | |
---|
| 2738 | //Remove os emails alternativos ao responder a todos |
---|
[5257] | 2739 | function removeAlternative(value_to_all, _array_to_alternative){ |
---|
| 2740 | for(i = 0; i < _array_to_alternative.length; i++) { |
---|
| 2741 | for(k = 0; k < value_to_all.length; k++){ |
---|
| 2742 | if(value_to_all[k].match(/<([^<]*)>[\s]*$/)){ |
---|
| 2743 | if(value_to_all[k].match(/<([^<]*)>[\s]*$/)[1].toLowerCase() == _array_to_alternative[i].toLowerCase()){ |
---|
| 2744 | value_to_all.splice( k , 1); |
---|
| 2745 | k--; |
---|
| 2746 | } |
---|
| 2747 | }else if(value_to_all[k].replace(/^\s+|\s+$/g,"").toLowerCase() == _array_to_alternative[i].toLowerCase()){ |
---|
| 2748 | value_to_all.splice( k , 1); |
---|
| 2749 | k--; |
---|
| 2750 | } |
---|
| 2751 | } |
---|
| 2752 | } |
---|
| 2753 | return value_to_all; |
---|
| 2754 | } |
---|
| 2755 | |
---|
[5620] | 2756 | function useOriginalAttachments(new_border_ID,old_id_border) |
---|
[5626] | 2757 | { |
---|
[5620] | 2758 | if (Element("attachments_" + old_id_border)) |
---|
[7414] | 2759 | { |
---|
| 2760 | var fileUploadMSG = $('#fileupload_msg'+new_border_ID); |
---|
| 2761 | var attachments = $("#attachments_" + old_id_border).find("a"); |
---|
| 2762 | if(openTab.imapBox[new_border_ID].split("local").length > 1 && attachments.length > 0){ |
---|
| 2763 | alert("Não é possivel utilizar os anexos das mensagens locais, favor desarquivar para ter acesso aos anexos"); |
---|
| 2764 | return false; |
---|
| 2765 | } |
---|
| 2766 | |
---|
| 2767 | var imagens = block_quoted_body.match(/<img[^>]*>/g); |
---|
[6056] | 2768 | var arrayAttachments = []; |
---|
| 2769 | var arrayAttachmentsA = []; |
---|
[5626] | 2770 | |
---|
[6056] | 2771 | //------------------- |
---|
| 2772 | for (var i = 0; i < attachments.length; i++){ |
---|
[5626] | 2773 | 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))) |
---|
| 2774 | continue; |
---|
[7414] | 2775 | if(attachments[i].href.split("local") > 1){ |
---|
| 2776 | var arrayAtt = attachments[i].href.replace("javascript:download_local_attachment(", "").replace(")", "").split(','); |
---|
| 2777 | }else{ |
---|
| 2778 | var arrayAtt = attachments[i].href.replace("javascript:download_attachments(", "").replace(")", "").split(','); |
---|
| 2779 | } |
---|
| 2780 | |
---|
[5626] | 2781 | var att = new Object(); |
---|
| 2782 | var regex = new RegExp( "'", "g" ); |
---|
[7176] | 2783 | att.folder = utf8_decoder(Base64.decode(arrayAtt[0].replace(regex,""))); |
---|
[5626] | 2784 | att.uid = arrayAtt[1].replace(regex,""); |
---|
| 2785 | att.part = arrayAtt[3].replace(regex,""); |
---|
| 2786 | att.type = 'imapPart'; |
---|
[6056] | 2787 | var idATT = JSON.stringify(att); |
---|
| 2788 | |
---|
| 2789 | if(block_quoted_body.indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&msgNumber='+att.uid+'&indexPart='+att.part+'"') !== -1) |
---|
| 2790 | { |
---|
| 2791 | addAttachment( new_border_ID , idATT); |
---|
[5620] | 2792 | |
---|
[6056] | 2793 | var attach = {}; |
---|
| 2794 | attach.fileName = attachments[i].text.substring(0, attachments[i].text.lastIndexOf('(')); |
---|
[6930] | 2795 | attach.fullFileName = attach.fileName; |
---|
| 2796 | if(attach.fileName.length > 20) |
---|
| 2797 | attach.fileName = attach.fileName.substr(0, 17) + " ... " + attach.fileName.substr(attach.fileName.length-9, attach.fileName.length); |
---|
[5620] | 2798 | |
---|
[6056] | 2799 | attach.fileSize = attachments[i].text.substring(( attachments[i].text.lastIndexOf('(')+1), attachments[i].text.lastIndexOf(')')); |
---|
[5620] | 2800 | |
---|
[6930] | 2801 | attach.error = false; |
---|
| 2802 | fileUploadMSG.find(' .attachments-list').show(); |
---|
[6056] | 2803 | var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); |
---|
| 2804 | upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>'); |
---|
[6930] | 2805 | upload.find(".att-box-loading").remove(); |
---|
| 2806 | upload.find('.att-box-delete').click(function(){ |
---|
[6056] | 2807 | var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); |
---|
| 2808 | var content_body = RichTextEditor.getData('body_'+new_border_ID); |
---|
| 2809 | var imagens = content_body.match(/<img[^>]*>/g); |
---|
| 2810 | var att = JSON.parse(idAttach); |
---|
| 2811 | if(imagens != null) |
---|
| 2812 | { |
---|
| 2813 | for (var x = 0; x < imagens.length; x++) |
---|
| 2814 | if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&msgNumber='+att.uid+'&indexPart='+att.part) !== -1) |
---|
| 2815 | content_body = content_body.replace(imagens[x],''); |
---|
[5626] | 2816 | |
---|
[6056] | 2817 | RichTextEditor.setData('body_'+new_border_ID,content_body); |
---|
| 2818 | } |
---|
[5626] | 2819 | |
---|
[6056] | 2820 | fileUploadMSG.find('.attachments-list').find('input[value="'+idAttach+'"]'); |
---|
| 2821 | delAttachment(new_border_ID,idAttach); |
---|
[6930] | 2822 | $(this).parent().qtip("destroy"); |
---|
| 2823 | $(this).parent().remove(); |
---|
| 2824 | if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){ |
---|
| 2825 | fileUploadMSG.find(' .attachments-list').hide(); |
---|
| 2826 | } |
---|
[6056] | 2827 | }); |
---|
| 2828 | |
---|
| 2829 | fileUploadMSG.find('.attachments-list').append(upload); |
---|
[6930] | 2830 | fileUploadMSG.find('.attachments-list .att-box:last').qtip({ |
---|
| 2831 | content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", {attach : attach}), |
---|
| 2832 | position: { |
---|
| 2833 | corner: { |
---|
| 2834 | tooltip: 'bottomMiddle', |
---|
| 2835 | target: 'topMiddle' |
---|
| 2836 | }, |
---|
| 2837 | adjust: { |
---|
| 2838 | resize: true, |
---|
| 2839 | scroll: true, |
---|
[7001] | 2840 | screen: true |
---|
[6930] | 2841 | } |
---|
| 2842 | }, |
---|
| 2843 | show: { |
---|
| 2844 | when: 'mouseover', // Don't specify a show event |
---|
| 2845 | ready: false // Show the tooltip when ready |
---|
| 2846 | }, |
---|
| 2847 | hide: 'mouseout', // Don't specify a hide event |
---|
| 2848 | style: { |
---|
| 2849 | border: { |
---|
| 2850 | width: 1, |
---|
| 2851 | radius: 5 |
---|
| 2852 | }, |
---|
| 2853 | width: { |
---|
| 2854 | min: 75, |
---|
| 2855 | max : 1000 |
---|
| 2856 | }, |
---|
| 2857 | padding: 3, |
---|
| 2858 | textAlign: 'left', |
---|
| 2859 | tip: true, // Give it a speech bubble tip with automatic corner detection |
---|
| 2860 | name: 'blue' // Style it according to the preset 'cream' style |
---|
| 2861 | } |
---|
| 2862 | }); |
---|
[6056] | 2863 | } |
---|
| 2864 | else |
---|
| 2865 | { |
---|
| 2866 | arrayAttachments.push(idATT); |
---|
| 2867 | arrayAttachmentsA.push(attachments[i]); |
---|
| 2868 | } |
---|
[7414] | 2869 | } |
---|
[6056] | 2870 | //------------------- |
---|
| 2871 | |
---|
| 2872 | if(arrayAttachments.length > 0) |
---|
| 2873 | { |
---|
| 2874 | |
---|
[7697] | 2875 | 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(); |
---|
[6199] | 2876 | orignialAtt.click(function(event ){ |
---|
[5626] | 2877 | |
---|
[6056] | 2878 | for (var i = 0; i < arrayAttachments.length; i++){ |
---|
[5626] | 2879 | |
---|
[6056] | 2880 | var att = JSON.parse(arrayAttachments[i]); |
---|
| 2881 | addAttachment( new_border_ID , arrayAttachments[i]); |
---|
| 2882 | |
---|
| 2883 | var attach = {}; |
---|
| 2884 | attach.fileName = arrayAttachmentsA[i].text.substring(0, arrayAttachmentsA[i].text.lastIndexOf('(')); |
---|
[6930] | 2885 | attach.fullFileName = attach.fileName; |
---|
| 2886 | if(attach.fileName.length > 20) |
---|
| 2887 | attach.fileName = attach.fileName.substr(0, 17) + " ... " + attach.fileName.substr(attach.fileName.length-9, attach.fileName.length); |
---|
[6056] | 2888 | |
---|
| 2889 | attach.fileSize = arrayAttachmentsA[i].text.substring(( arrayAttachmentsA[i].text.lastIndexOf('(')+1), arrayAttachmentsA[i].text.lastIndexOf(')')); |
---|
[6930] | 2890 | attach.error = false; |
---|
| 2891 | fileUploadMSG.find(' .attachments-list').show(); |
---|
[6056] | 2892 | var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); |
---|
[6930] | 2893 | upload.find('.att-box-loading').remove(); |
---|
[6056] | 2894 | upload.append('<input type="hidden" name="fileId[]" value=\''+arrayAttachments[i]+'\'/>'); |
---|
[6930] | 2895 | upload.find('.att-box-delete').click(function(){ |
---|
| 2896 | var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); |
---|
[6056] | 2897 | var content_body = RichTextEditor.getData('body_'+new_border_ID); |
---|
| 2898 | var imagens = content_body.match(/<img[^>]*>/g); |
---|
| 2899 | var att = JSON.parse(idAttach); |
---|
| 2900 | if(imagens != null) |
---|
| 2901 | { |
---|
| 2902 | for (var x = 0; x < imagens.length; x++) |
---|
| 2903 | if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&msgNumber='+att.uid+'&indexPart='+att.part) !== -1) |
---|
| 2904 | content_body = content_body.replace(imagens[x],''); |
---|
| 2905 | |
---|
| 2906 | RichTextEditor.setData('body_'+new_border_ID,content_body); |
---|
| 2907 | } |
---|
| 2908 | |
---|
| 2909 | fileUploadMSG.find('.attachments-list').find('input[value="'+idAttach+'"]'); |
---|
| 2910 | delAttachment(new_border_ID,idAttach); |
---|
[6930] | 2911 | $(this).parent().qtip("destroy"); |
---|
| 2912 | $(this).parent().remove(); |
---|
| 2913 | if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){ |
---|
| 2914 | fileUploadMSG.find(' .attachments-list').hide(); |
---|
| 2915 | } |
---|
[6056] | 2916 | }); |
---|
| 2917 | |
---|
| 2918 | fileUploadMSG.find('.attachments-list').append(upload); |
---|
[6930] | 2919 | fileUploadMSG.find('.attachments-list .att-box:last').qtip({ |
---|
| 2920 | content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", {attach : attach}), |
---|
| 2921 | position: { |
---|
| 2922 | corner: { |
---|
| 2923 | tooltip: 'bottomMiddle', |
---|
| 2924 | target: 'topMiddle' |
---|
| 2925 | }, |
---|
| 2926 | adjust: { |
---|
| 2927 | resize: true, |
---|
| 2928 | scroll: true, |
---|
[7001] | 2929 | screen: true |
---|
[6930] | 2930 | } |
---|
| 2931 | }, |
---|
| 2932 | show: { |
---|
| 2933 | when: 'mouseover', // Don't specify a show event |
---|
| 2934 | ready: false // Show the tooltip when ready |
---|
| 2935 | }, |
---|
| 2936 | hide: 'mouseout', // Don't specify a hide event |
---|
| 2937 | style: { |
---|
| 2938 | border: { |
---|
| 2939 | width: 1, |
---|
| 2940 | radius: 5 |
---|
| 2941 | }, |
---|
| 2942 | width: { |
---|
| 2943 | min: 75, |
---|
| 2944 | max : 1000 |
---|
| 2945 | }, |
---|
| 2946 | padding: 3, |
---|
| 2947 | textAlign: 'left', |
---|
| 2948 | tip: true, // Give it a speech bubble tip with automatic corner detection |
---|
| 2949 | name: 'blue' // Style it according to the preset 'cream' style |
---|
| 2950 | } |
---|
| 2951 | }); |
---|
[6056] | 2952 | } |
---|
| 2953 | |
---|
| 2954 | $(this).remove(); |
---|
| 2955 | }); |
---|
| 2956 | } |
---|
| 2957 | |
---|
[5626] | 2958 | } |
---|
| 2959 | |
---|
| 2960 | } |
---|
| 2961 | |
---|
| 2962 | function addOriginalAttachments(new_border_ID,old_id_border) |
---|
| 2963 | { |
---|
| 2964 | var fileUploadMSG = $('#fileupload_msg'+new_border_ID); |
---|
[6113] | 2965 | var attachments = $("#attachments_" + old_id_border).find("a"); |
---|
[7414] | 2966 | |
---|
| 2967 | if(openTab.imapBox[new_border_ID].split("local").length > 1 && attachments.length > 0){ |
---|
| 2968 | alert("Não é possivel utilizar os anexos das mensagens locais, favor desarquivar para ter acesso aos anexos"); |
---|
| 2969 | return false; |
---|
| 2970 | } |
---|
| 2971 | |
---|
[5626] | 2972 | for (var i = 0; i < attachments.length; i++){ |
---|
| 2973 | 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))) |
---|
| 2974 | continue; |
---|
[6930] | 2975 | fileUploadMSG.find(' .attachments-list').show(); |
---|
[7414] | 2976 | if(attachments[i].href.split("local").length > 1){ |
---|
| 2977 | var arrayAtt = attachments[i].href.replace("javascript:download_local_attachment(", "").replace(")", "").split(','); |
---|
| 2978 | }else{ |
---|
| 2979 | var arrayAtt = attachments[i].href.replace("javascript:download_attachments(", "").replace(")", "").split(','); |
---|
| 2980 | } |
---|
[5626] | 2981 | var att = new Object(); |
---|
| 2982 | var regex = new RegExp( "'", "g" ); |
---|
[7176] | 2983 | att.folder = utf8_decoder(Base64.decode(arrayAtt[0].replace(regex,""))); |
---|
[5626] | 2984 | att.uid = arrayAtt[1].replace(regex,""); |
---|
| 2985 | att.part = arrayAtt[3].replace(regex,""); |
---|
| 2986 | att.type = 'imapPart'; |
---|
| 2987 | var idATT = JSON.stringify(att); |
---|
[7332] | 2988 | addAttachment( new_border_ID , idATT); |
---|
| 2989 | |
---|
[5626] | 2990 | var attach = {}; |
---|
[7332] | 2991 | var attachText = (is_ie ? attachments[i].innerText : attachments[i].text); |
---|
| 2992 | attach.fileName = attachText.substring(0, attachText.lastIndexOf('(')); |
---|
[6930] | 2993 | attach.fullFileName = attach.fileName; |
---|
| 2994 | if(attach.fileName.length > 20) |
---|
| 2995 | attach.fileName = attach.fileName.substr(0, 17) + " ... " + attach.fileName.substr(attach.fileName.length-9, attach.fileName.length); |
---|
[7332] | 2996 | attach.fileSize = attachText.substring((attachText.lastIndexOf('(')+1),attachText.lastIndexOf(')')); |
---|
[6930] | 2997 | attach.error = false; |
---|
[5626] | 2998 | |
---|
| 2999 | var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); |
---|
[6930] | 3000 | upload.find('.att-box-loading').remove(); |
---|
| 3001 | upload.find('.att-box-delete').click(function(){ |
---|
| 3002 | var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); |
---|
| 3003 | var content_body = RichTextEditor.getData('body_'+new_border_ID); |
---|
| 3004 | var imagens = content_body.match(/<img[^>]*>/g); |
---|
| 3005 | var att = JSON.parse(idAttach); |
---|
| 3006 | if(imagens != null) |
---|
| 3007 | { |
---|
| 3008 | for (var x = 0; x < imagens.length; x++) |
---|
| 3009 | if(imagens[x].indexOf('src="./inc/get_archive.php?msgFolder='+att.folder+'&msgNumber='+att.uid+'&indexPart='+att.part) !== -1) |
---|
| 3010 | content_body = content_body.replace(imagens[x],''); |
---|
[5626] | 3011 | |
---|
[6930] | 3012 | RichTextEditor.setData('body_'+new_border_ID,content_body); |
---|
| 3013 | } |
---|
[5626] | 3014 | |
---|
[6930] | 3015 | fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]'); |
---|
| 3016 | delAttachment(new_border_ID,idAttach); |
---|
| 3017 | $(this).parent().qtip("destroy"); |
---|
| 3018 | $(this).parent().remove(); |
---|
| 3019 | if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length){ |
---|
| 3020 | fileUploadMSG.find(' .attachments-list').hide(); |
---|
| 3021 | } |
---|
[5620] | 3022 | }); |
---|
[5626] | 3023 | |
---|
| 3024 | |
---|
[6930] | 3025 | upload.append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>'); |
---|
[5626] | 3026 | fileUploadMSG.find('.attachments-list').append(upload); |
---|
[6930] | 3027 | fileUploadMSG.find('.attachments-list .att-box:last').qtip({ |
---|
| 3028 | content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", {attach : attach}), |
---|
| 3029 | position: { |
---|
| 3030 | corner: { |
---|
| 3031 | tooltip: 'bottomMiddle', |
---|
| 3032 | target: 'topMiddle' |
---|
| 3033 | }, |
---|
| 3034 | adjust: { |
---|
| 3035 | resize: true, |
---|
| 3036 | scroll: true, |
---|
[7001] | 3037 | screen: true |
---|
[6930] | 3038 | } |
---|
| 3039 | }, |
---|
| 3040 | show: { |
---|
| 3041 | when: 'mouseover', // Don't specify a show event |
---|
| 3042 | ready: false // Show the tooltip when ready |
---|
| 3043 | }, |
---|
| 3044 | hide: 'mouseout', // Don't specify a hide event |
---|
| 3045 | style: { |
---|
| 3046 | border: { |
---|
| 3047 | width: 1, |
---|
| 3048 | radius: 5 |
---|
| 3049 | }, |
---|
| 3050 | width: { |
---|
| 3051 | min: 75, |
---|
| 3052 | max : 1000 |
---|
| 3053 | }, |
---|
| 3054 | padding: 3, |
---|
| 3055 | textAlign: 'left', |
---|
| 3056 | tip: true, // Give it a speech bubble tip with automatic corner detection |
---|
| 3057 | name: 'blue' // Style it according to the preset 'cream' style |
---|
| 3058 | } |
---|
| 3059 | }); |
---|
[5626] | 3060 | |
---|
| 3061 | } |
---|
[799] | 3062 | } |
---|
| 3063 | |
---|
[2] | 3064 | function send_message_return(data, ID){ |
---|
[5844] | 3065 | |
---|
| 3066 | if (typeof(data) == 'object' && data.load){ |
---|
| 3067 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 3068 | } |
---|
[3035] | 3069 | watch_changes_in_msg(ID); |
---|
[1035] | 3070 | |
---|
[6528] | 3071 | var content = $("#content_id_"+ID); |
---|
[3035] | 3072 | var sign = false; |
---|
[1035] | 3073 | var crypt = false; |
---|
[6528] | 3074 | var reComplexEmail = /<([^<]*)>[\s]*$/; |
---|
[3035] | 3075 | if ((preferences.use_assinar_criptografar != '0') && (preferences.use_signature_digital_cripto != '0')){ |
---|
[1035] | 3076 | var checkSign = document.getElementById('return_digital_'+ID) |
---|
| 3077 | if (checkSign.checked){ |
---|
| 3078 | sign = true; |
---|
| 3079 | } |
---|
| 3080 | |
---|
| 3081 | var checkCript = document.getElementById('return_cripto_'+ID); |
---|
| 3082 | if (checkCript.checked){ |
---|
| 3083 | crypt = true; |
---|
| 3084 | } |
---|
| 3085 | } |
---|
| 3086 | |
---|
[3035] | 3087 | if (typeof(data) == 'object' && !data.success) |
---|
[1035] | 3088 | { |
---|
[3035] | 3089 | connector = new cConnector(); |
---|
[1035] | 3090 | |
---|
[3035] | 3091 | if (sign || crypt){ |
---|
| 3092 | var operation = ''; |
---|
[1035] | 3093 | if (sign){ |
---|
| 3094 | operation = 'sign'; |
---|
| 3095 | } |
---|
| 3096 | else { // crypt |
---|
[3035] | 3097 | //TODO: Colocar mensagem de erro, e finalizar o método. |
---|
[1035] | 3098 | operation = 'nop'; |
---|
| 3099 | } |
---|
[3035] | 3100 | } |
---|
[1035] | 3101 | |
---|
[3035] | 3102 | if (data.body){ |
---|
| 3103 | Element('cert_applet').doButtonClickAction(operation, ID, data.body); |
---|
| 3104 | } |
---|
| 3105 | else { |
---|
[1035] | 3106 | alert(data.error); |
---|
| 3107 | } |
---|
| 3108 | |
---|
| 3109 | return; |
---|
[3035] | 3110 | } |
---|
[485] | 3111 | if(data && data.success == true ){ |
---|
[2] | 3112 | // if send ok, set a flag as answered or forwarded |
---|
[6528] | 3113 | var msg_number_replied = content.find('[name="msg_reply_from"]'); |
---|
| 3114 | var msg_number_forwarded = content.find('[name="msg_forward_from"]'); |
---|
[2] | 3115 | |
---|
[6060] | 3116 | if (msg_number_replied.val()){ |
---|
| 3117 | proxy_mensagens.proxy_set_message_flag(msg_number_replied.val(), 'answered'); |
---|
[2] | 3118 | } |
---|
[6060] | 3119 | else if (msg_number_forwarded.val()){ |
---|
| 3120 | proxy_mensagens.proxy_set_message_flag(msg_number_forwarded.val(), 'forwarded'); |
---|
[2] | 3121 | } |
---|
[1121] | 3122 | if(expresso_offline){ |
---|
| 3123 | write_msg(get_lang('Your message was sent to queue')); |
---|
| 3124 | delete_border(ID,'true'); |
---|
| 3125 | return; |
---|
[2] | 3126 | }else{ |
---|
[1121] | 3127 | if (wfolders.alert) { |
---|
| 3128 | write_msg(get_lang('Your message was sent and save.')); |
---|
| 3129 | wfolders.alert = false; |
---|
| 3130 | } |
---|
| 3131 | else { |
---|
| 3132 | write_msg(get_lang('Your message was sent.')); |
---|
| 3133 | } |
---|
[2] | 3134 | } |
---|
[7369] | 3135 | |
---|
[6528] | 3136 | //REFAZER ISTO COM UMA CHAMADA ASSINCRONA PARA REGISTRAR E ATUALIZAR A LISTA DOS NOVOS CONTATOS DINAMICOS |
---|
[485] | 3137 | // If new dynamic contacts were added, update the autocomplete .... |
---|
[6528] | 3138 | /*if(data.new_contacts){ |
---|
[485] | 3139 | var ar_contacts = data.new_contacts.split(',;'); |
---|
| 3140 | for(var j in ar_contacts){ |
---|
| 3141 | // If the dynamic contact don't exist, update the autocomplete.... |
---|
| 3142 | if((contacts+",").indexOf(";"+ar_contacts[j]+",") == -1) |
---|
| 3143 | contacts += ",;" + ar_contacts[j]; |
---|
| 3144 | } |
---|
| 3145 | } |
---|
[6528] | 3146 | var dynamicPersonalContacts = new Array(); |
---|
| 3147 | var dynamicPersonalGroups = new Array(); |
---|
| 3148 | var dynamicContacts = new Array(); |
---|
| 3149 | var dynamicContactList = new Array(); |
---|
| 3150 | |
---|
| 3151 | */ |
---|
[6577] | 3152 | delete_border(ID,'true'); |
---|
[7775] | 3153 | if(parseInt(preferences.use_dynamic_contacts)){ |
---|
| 3154 | var arrayTo = content.find(".to-tr").find(".box").clone(); |
---|
| 3155 | save_dynamic_contacts(arrayTo); |
---|
| 3156 | var arrayCC = content.find(".cc-tr").find(".box").clone(); |
---|
| 3157 | save_dynamic_contacts(arrayCC); |
---|
| 3158 | var arrayCCo = content.find(".cco-tr").find(".box").clone(); |
---|
| 3159 | save_dynamic_contacts(arrayCCo); |
---|
[7369] | 3160 | updateDynamicContact(); |
---|
[7775] | 3161 | } |
---|
| 3162 | |
---|
[6592] | 3163 | cache = new Array(); |
---|
[649] | 3164 | } |
---|
| 3165 | else{ |
---|
[504] | 3166 | if(data == 'Post-Content-Length') |
---|
[65] | 3167 | write_msg(get_lang('The size of this message has exceeded the limit (%1B).',Element('upload_max_filesize').value)); |
---|
[6528] | 3168 | else if(data){ |
---|
| 3169 | var error_mail = $.trim(data.split(":")[data.split(":").length-1]); |
---|
| 3170 | var array = content.find(".to-tr").find(".box"); |
---|
| 3171 | //$(value).find("input").val() |
---|
[7665] | 3172 | |
---|
| 3173 | $(content).find('button.send').button('option', 'disabled', false); |
---|
| 3174 | |
---|
[6528] | 3175 | $.each(array, function(index, value){ |
---|
| 3176 | if(error_mail == $(value).find("input").val().match(reComplexEmail)[1]) |
---|
| 3177 | $(value).addClass("invalid-email-box"); |
---|
| 3178 | }); |
---|
| 3179 | if ( content.find('[name="input_cco"]').length){ |
---|
| 3180 | if(content.find(".cco-tr").css("display") != "none"){ |
---|
| 3181 | var array = content.find(".cco-tr").find(".box"); |
---|
| 3182 | $.each(array, function(index, value){ |
---|
| 3183 | if(error_mail == $(value).find("input").val().match(reComplexEmail)[1]) |
---|
| 3184 | $(value).addClass("invalid-email-box"); |
---|
| 3185 | }); |
---|
| 3186 | } |
---|
| 3187 | } |
---|
| 3188 | if(content.find(".cc-tr").css("display") != "none") |
---|
| 3189 | { |
---|
| 3190 | var array = content.find(".cc-tr").find(".box"); |
---|
| 3191 | $.each(array, function(index, value){ |
---|
| 3192 | if(error_mail == $(value).find("input").val().match(reComplexEmail)[1]) |
---|
| 3193 | $(value).addClass("invalid-email-box"); |
---|
| 3194 | }); |
---|
| 3195 | } |
---|
[504] | 3196 | write_msg(data); |
---|
[6528] | 3197 | }else |
---|
[504] | 3198 | write_msg(get_lang("Connection failed with %1 Server. Try later.", "Web")); |
---|
[3509] | 3199 | |
---|
[5931] | 3200 | var save_link = $("#content_id_"+ID).find(".save")[0]; |
---|
[4803] | 3201 | save_link.onclick = function onclick(event) {openTab.toPreserve[ID] = true;save_msg(ID);} ; |
---|
[5604] | 3202 | $("#save_message_options_"+ID).button({disabled: false}); |
---|
[5417] | 3203 | //save_link.className = 'message_options'; |
---|
[2] | 3204 | } |
---|
[1121] | 3205 | if(!expresso_offline) |
---|
| 3206 | connector.hideProgressBar(); |
---|
[2] | 3207 | } |
---|
| 3208 | |
---|
[6577] | 3209 | /*Função que grava o destinatário nos contatos dinâmicos*/ |
---|
| 3210 | function save_dynamic_contacts(array){ |
---|
[6592] | 3211 | |
---|
[7775] | 3212 | $.each(array, function(i, value){ |
---|
| 3213 | var stop = false; |
---|
| 3214 | $.each(dynamicPersonalContacts, function(x, valuex){ |
---|
| 3215 | if(valuex.email == $(value).find("input").val().match(reComplexEmail)[1]){ |
---|
| 3216 | stop = true; |
---|
| 3217 | return false; |
---|
| 3218 | } |
---|
| 3219 | }); |
---|
| 3220 | $.each(dynamicPersonalGroups, function(x, valuex){ |
---|
| 3221 | if(valuex.email == $(value).find("input").val().match(reComplexEmail)[1]){ |
---|
| 3222 | stop = true; |
---|
| 3223 | return false; |
---|
| 3224 | } |
---|
| 3225 | }); |
---|
| 3226 | if(!stop){ |
---|
| 3227 | var exist = 0; |
---|
| 3228 | $.each(dynamicData, function(x, valuex){ |
---|
| 3229 | if(valuex.mail == $(value).find("input").val().match(reComplexEmail)[1]){ |
---|
| 3230 | exist = valuex.id; |
---|
| 3231 | return false; |
---|
| 3232 | } |
---|
| 3233 | }); |
---|
| 3234 | if(exist){ |
---|
| 3235 | REST.put("/dynamiccontact/"+exist, {name: $(value).find("input").val().split('"')[1], mail:$(value).find("input").val().match(reComplexEmail)[1]}); |
---|
| 3236 | }else{ |
---|
| 3237 | REST.post("/dynamiccontacts", {name: $(value).find("input").val().split('"')[1], mail:$(value).find("input").val().match(reComplexEmail)[1]}); |
---|
| 3238 | } |
---|
| 3239 | } |
---|
| 3240 | }); |
---|
| 3241 | |
---|
[6577] | 3242 | } |
---|
| 3243 | |
---|
[1629] | 3244 | /** |
---|
| 3245 | * Método chamado pela applet para retornar o resultado da assinatura/decifragem do e-mail. |
---|
| 3246 | * para posterior envio ao servidor. |
---|
| 3247 | * @author Mário César Kolling <mario.kolling@serpro.gov.br>, Bruno Vieira da Costa <bruno.vieira-costa@serpro.gov.br> |
---|
| 3248 | * @param smime O e-mail decifrado/assinado |
---|
| 3249 | * @param ID O ID do e-mail, para saber em que aba esse e-mail será mostrado. |
---|
| 3250 | * @param operation A operação que foi realizada pela applet (assinatura ou decifragem) |
---|
| 3251 | */ |
---|
[1035] | 3252 | function appletReturn(smime, ID, operation, folder){ |
---|
[1629] | 3253 | |
---|
[3035] | 3254 | if (!smime){ // Erro aconteceu ao assinar ou decifrar e-mail |
---|
| 3255 | connector = new cConnector(); |
---|
| 3256 | connector.hideProgressBar(); |
---|
| 3257 | return; |
---|
| 3258 | } |
---|
[1629] | 3259 | |
---|
[1035] | 3260 | if(operation=='decript') |
---|
| 3261 | { |
---|
| 3262 | var handler = function(data){ |
---|
[5134] | 3263 | |
---|
[1035] | 3264 | if(data.msg_day == '') |
---|
| 3265 | { |
---|
[3035] | 3266 | header=expresso_local_messages.get_msg_date(data.original_ID, proxy_mensagens.is_local_folder(get_current_folder())); |
---|
[5134] | 3267 | |
---|
[1035] | 3268 | data.fulldate=header.fulldate; |
---|
| 3269 | data.smalldate=header.smalldate; |
---|
| 3270 | data.msg_day = header.msg_day; |
---|
| 3271 | data.msg_hour = header.msg_hour; |
---|
[5134] | 3272 | |
---|
[4933] | 3273 | } |
---|
[1035] | 3274 | this.show_msg(data); |
---|
| 3275 | } |
---|
| 3276 | para="&source="+smime+"&ID="+ID+"&folder="+folder; |
---|
| 3277 | cExecute ("$this.imap_functions.show_decript&", handler, para); |
---|
| 3278 | }else |
---|
| 3279 | { |
---|
[3035] | 3280 | ID_tmp = ID; |
---|
[7601] | 3281 | // Lá a variável e chama a nova função cExecuteForm |
---|
[3035] | 3282 | // Processa e envia para o servidor web |
---|
| 3283 | // Faz o request do connector novamente. Talvez implementar no connector |
---|
| 3284 | // para manter coerência. |
---|
[1035] | 3285 | |
---|
[3035] | 3286 | var handler_send_smime = function(data){ |
---|
| 3287 | send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug |
---|
| 3288 | }; |
---|
[1035] | 3289 | |
---|
[3035] | 3290 | var textArea = document.createElement("TEXTAREA"); |
---|
| 3291 | textArea.style.display='none'; |
---|
| 3292 | textArea.id = 'smime'; |
---|
| 3293 | textArea.name = "smime"; |
---|
| 3294 | textArea.value += smime; |
---|
[1035] | 3295 | |
---|
[7601] | 3296 | // Lá a variável e chama a nova função cExecuteForm |
---|
[3035] | 3297 | // Processa e envia para o servidor web |
---|
| 3298 | // Faz o request do connector novamente. Talvez implementar no connector |
---|
| 3299 | // para manter coerência. |
---|
| 3300 | if (is_ie){ |
---|
| 3301 | var i = 0; |
---|
| 3302 | while (document.forms(i).name != "form_message_"+ID){i++} |
---|
| 3303 | form = document.forms(i); |
---|
| 3304 | } |
---|
| 3305 | else |
---|
| 3306 | form = document.forms["form_message_"+ID]; |
---|
[1035] | 3307 | |
---|
[3035] | 3308 | form.appendChild(textArea); |
---|
[1035] | 3309 | |
---|
[3035] | 3310 | cExecuteForm ("$this.imap_functions.send_mail", form, handler_send_smime, ID); |
---|
| 3311 | } |
---|
[1035] | 3312 | } |
---|
| 3313 | |
---|
[7420] | 3314 | /* |
---|
[7601] | 3315 | * Método que verifica se existe algum item de 'words' em 'body'. |
---|
| 3316 | * Se houver, retorna a primeira ocorrência encontrada de words, caso contrário retorna false. |
---|
[7420] | 3317 | */ |
---|
[7705] | 3318 | function verifyBodyWords(body, words) |
---|
| 3319 | { |
---|
| 3320 | var forwStartPT = body.search(/\<div\>\n*\s*---------- Mensagem encaminhada ----------/); |
---|
| 3321 | if(forwStartPT >= 0) |
---|
| 3322 | body = body.substr(0,forwStartPT); |
---|
| 3323 | |
---|
| 3324 | var forwStartEN = body.search(/\<div\>\n*\s*---------- Forwarded message ----------/); |
---|
| 3325 | if(forwStartEN >= 0) |
---|
| 3326 | body = body.substr(0,forwStartEN); |
---|
| 3327 | |
---|
| 3328 | var forwStartES = body.search(/\<div\>\n*\s*---------- Mensaje reenviada ----------/); |
---|
| 3329 | if(forwStartES >= 0) |
---|
| 3330 | body = body.substr(0,forwStartES); |
---|
| 3331 | |
---|
| 3332 | var replyStartPT = body.search(/\<div\>\n*\s*Em (\d{1,2})\/(\d{1,2})\/(\d{4}) \à\;s (\d{1,2}):(\d{1,2}) horas, (.)+ escreveu:/); |
---|
| 3333 | if(replyStartPT >= 0) |
---|
| 3334 | body = body.substr(0,replyStartPT); |
---|
| 3335 | |
---|
| 3336 | var replyStartEN = body.search(/\<div\>\n*\s*At (\d{1,2})\/(\d{1,2})\/(\d{4}), (\d{1,2}):(\d{1,2}) hours, (.)+ wrote:/); |
---|
| 3337 | if(replyStartEN >= 0) |
---|
| 3338 | body = body.substr(0,replyStartEN); |
---|
| 3339 | |
---|
| 3340 | var replyStartES = body.search(/\<div\>\n*\s*En (\d{1,2})\/(\d{1,2})\/(\d{4}) las (\d{1,2}):(\d{1,2}) horas, (.)+ escribi\ó\;:/); |
---|
| 3341 | if(replyStartES >= 0) |
---|
| 3342 | body = body.substr(0,replyStartES); |
---|
| 3343 | |
---|
| 3344 | for(i = 0; i < words.length; i++) { |
---|
[7420] | 3345 | if(body.search(words[i]) != -1) { |
---|
| 3346 | return words[i]; |
---|
| 3347 | } |
---|
| 3348 | } |
---|
[7705] | 3349 | |
---|
[7420] | 3350 | return false; |
---|
| 3351 | } |
---|
| 3352 | |
---|
| 3353 | |
---|
[2] | 3354 | function send_message(ID, folder, folder_name){ |
---|
[7420] | 3355 | var content_body = RichTextEditor.getData('body_'+ID); |
---|
| 3356 | /* |
---|
| 3357 | Funcionalidade que verifica se o usuário escreveu a palavra anexo no corpo da mensagem e não anexou nenhum arquivo. |
---|
| 3358 | Esta funcionalidade é ativada nas preferências do módulo ExpressoMail. |
---|
| 3359 | */ |
---|
| 3360 | /* Lista de palavras que vão ser procuradas no corpo do email, referente às variantes da palavra anexo em português, inglês e espanhol. */ |
---|
| 3361 | if(language == "pt-br") //Português brasileiro |
---|
[7446] | 3362 | var words = ['anexo', 'anexos', 'anexada', 'anexado', 'anexei', 'anexando', 'anexaste', 'anexastes', 'anexamos', 'anexaram']; |
---|
| 3363 | else if(language == "es-es") //Espanhol |
---|
| 3364 | var words = ['anexo','adjunto', 'adjuntos', 'adjuntado','adjuntamos']; |
---|
[7601] | 3365 | else //Inglês ('en') |
---|
[7420] | 3366 | var words = ['attach', 'attachment', 'attached', 'annex', 'appending']; |
---|
| 3367 | |
---|
| 3368 | if($('#fileupload_msg'+ID).find('.att-box').length == 0 && preferences.alert_message_attachment == '1' ) { |
---|
| 3369 | var bodyWord = verifyBodyWords(content_body, words); |
---|
| 3370 | if(bodyWord) { |
---|
| 3371 | $.Zebra_Dialog(get_lang('You wrote "%1" in your message, but there are no files attached. Send it anyway?', bodyWord), { |
---|
| 3372 | 'type': 'question', |
---|
| 3373 | 'overlay_opacity': '0.5', |
---|
[7744] | 3374 | 'buttons': [get_lang('Yes'), get_lang('No')], |
---|
[7420] | 3375 | 'width' : 500, |
---|
[7612] | 3376 | 'custom_class': 'custom-zebra-filter', |
---|
[7420] | 3377 | 'onClose': function(clicked) { |
---|
[7744] | 3378 | if(clicked == get_lang('Yes')){ |
---|
[7420] | 3379 | send_valided_message(ID, folder, folder_name); |
---|
| 3380 | return; |
---|
| 3381 | } else { |
---|
| 3382 | return; |
---|
| 3383 | } |
---|
| 3384 | } |
---|
| 3385 | }); |
---|
| 3386 | } |
---|
| 3387 | else |
---|
| 3388 | send_valided_message(ID, folder, folder_name); |
---|
| 3389 | } |
---|
| 3390 | else if(!zebraDiscardEventDialog && $('#fileupload_msg'+ID).find('.att-box-loading').length) |
---|
| 3391 | { |
---|
| 3392 | zebraDiscardEventDialog = true; |
---|
| 3393 | window.setTimeout(function() { |
---|
| 3394 | $.Zebra_Dialog('Existem anexos sendo enviados para o servidor. Caso envie sua mensagem agora estes arquivos serão perdidos.', { |
---|
| 3395 | 'type': 'question', |
---|
| 3396 | 'overlay_opacity': '0.5', |
---|
[7612] | 3397 | 'custom_class': 'custom-zebra-filter', |
---|
[7420] | 3398 | 'buttons': ['Descartar anexos e enviar', 'Continuar editando e esperar anexos'], |
---|
| 3399 | 'width' : 500, |
---|
| 3400 | 'onClose': function(clicked) { |
---|
| 3401 | if(clicked == 'Descartar anexos e enviar' ){ |
---|
| 3402 | $.each($('#fileupload_msg'+ID).find('.att-box'), function(index, value){ |
---|
| 3403 | if($(value).find(".att-box-loading").length) |
---|
| 3404 | $(value).find('.att-box-delete').trigger("click"); |
---|
| 3405 | }); |
---|
| 3406 | send_valided_message(ID, folder, folder_name); |
---|
| 3407 | } |
---|
| 3408 | window.setTimeout(function() { |
---|
| 3409 | zebraDiscardEventDialog = false; |
---|
| 3410 | }, 500); |
---|
| 3411 | } |
---|
| 3412 | }) |
---|
| 3413 | }, 300); |
---|
| 3414 | }else { |
---|
| 3415 | send_valided_message(ID, folder, folder_name); |
---|
| 3416 | } |
---|
[5702] | 3417 | } |
---|
| 3418 | |
---|
| 3419 | function send_valided_message(ID, folder, folder_name) |
---|
| 3420 | { |
---|
[5911] | 3421 | if (preferences.auto_save_draft == 1) |
---|
| 3422 | autoSaveControl.status[ID] = true; |
---|
[7276] | 3423 | |
---|
[5911] | 3424 | var content = $("#content_id_"+ID); |
---|
| 3425 | var save_link = $("#content_id_"+ID).find(".save"); |
---|
| 3426 | var onClick = save_link.onclick; |
---|
[271] | 3427 | save_link.onclick = ''; |
---|
[5911] | 3428 | save_link.button({disabled: true}); |
---|
[3035] | 3429 | |
---|
[7276] | 3430 | var _subject = trim(content.find(".subject").val()); |
---|
| 3431 | if((_subject.length == 0) && !confirm(get_lang("Send this message without a subject?"))) { |
---|
| 3432 | save_link.click(onClick); |
---|
| 3433 | content.find(".subject").focus(); |
---|
| 3434 | return; |
---|
| 3435 | } |
---|
[271] | 3436 | |
---|
[6882] | 3437 | var stringReply = ""; |
---|
[7135] | 3438 | draw_email_box(content.find(".reply-to-tr").find("textarea:first").val(), content.find(".reply-to-tr").find("textarea:first")); |
---|
| 3439 | content.find(".reply-to-tr").find("textarea:first").val(""); |
---|
[6882] | 3440 | var array = content.find(".reply-to-tr").find(".box"); |
---|
| 3441 | $.each(array, function(index, value){ |
---|
| 3442 | stringReply += $(value).find("input").val() + ","; |
---|
[7286] | 3443 | }); |
---|
[7276] | 3444 | var stringToEmail = ""; |
---|
| 3445 | draw_email_box(content.find(".to-tr").find("textarea:first").val() || content.find(".to-tr").find("input:visible").val(), content.find(".to-tr").find("textarea:first")); |
---|
| 3446 | content.find(".to-tr").find("textarea:first").val(""); |
---|
| 3447 | content.find(".to-tr").find("input:visible").val(""); |
---|
| 3448 | var array = content.find(".to-tr").find(".box"); |
---|
| 3449 | $.each(array, function(index, value){ |
---|
| 3450 | stringToEmail += $(value).find("input").val() + ","; |
---|
| 3451 | }); |
---|
| 3452 | var stringEmail = ""; |
---|
| 3453 | stringEmail = stringToEmail; |
---|
| 3454 | var stringCCoEmail = ""; |
---|
| 3455 | if ( content.find('[name="input_cco"]').length){ |
---|
| 3456 | if(content.find(".cco-tr").css("display") != "none"){ |
---|
| 3457 | draw_email_box(content.find(".cco-tr").find("textarea:first").val() || content.find(".cco-tr").find("input:visible").val(), content.find(".cco-tr").find("textarea:first")); |
---|
| 3458 | content.find(".cco-tr").find("textarea:first").val(""); |
---|
| 3459 | content.find(".cco-tr").find("input:visible").val(""); |
---|
| 3460 | var array = content.find(".cco-tr").find(".box"); |
---|
| 3461 | $.each(array, function(index, value){ |
---|
| 3462 | stringCCoEmail += $(value).find("input").val() + ","; |
---|
| 3463 | }); |
---|
| 3464 | } |
---|
| 3465 | } |
---|
| 3466 | stringEmail += stringCCoEmail; |
---|
| 3467 | var stringCCEmail = ""; |
---|
| 3468 | if(content.find(".cc-tr").css("display") != "none") |
---|
| 3469 | { |
---|
| 3470 | draw_email_box(content.find(".cc-tr").find("textarea:first").val() || content.find(".cc-tr").find("input:visible").val(), content.find(".cc-tr").find("textarea:first")); |
---|
| 3471 | content.find(".cc-tr").find("textarea:first").val(""); |
---|
| 3472 | content.find(".cc-tr").find("input:visible").val(""); |
---|
| 3473 | var array = content.find(".cc-tr").find(".box"); |
---|
| 3474 | $.each(array, function(index, value){ |
---|
| 3475 | stringCCEmail += $(value).find("input").val() + ","; |
---|
| 3476 | }); |
---|
| 3477 | } |
---|
| 3478 | stringEmail += stringCCEmail; |
---|
[6882] | 3479 | |
---|
[7276] | 3480 | var mailData = new Object(); |
---|
| 3481 | mailData.body = Base64.encode(RichTextEditor.getData('body_'+ID)); |
---|
| 3482 | mailData.folder = folder; |
---|
| 3483 | mailData.type = RichTextEditor.plain[ID] ? 'plain' : 'html'; |
---|
| 3484 | mailData.uids_save = uidsSave[ID].toString(); |
---|
| 3485 | mailData.save_folder = (openTab.imapBox[ID] && openTab.type[ID] < 6) ? openTab.imapBox[ID]: "INBOX" + cyrus_delimiter + draftsfolder; |
---|
| 3486 | mailData.attachments = listAttachment(ID); |
---|
| 3487 | mailData.messageNum = currentTab; |
---|
| 3488 | mailData.input_subject = trim(content.find(".subject").val()); |
---|
| 3489 | mailData.input_reply_to = stringReply; |
---|
| 3490 | mailData.input_to = stringToEmail; |
---|
| 3491 | mailData.input_cco = stringCCoEmail; |
---|
| 3492 | mailData.input_cc = stringCCEmail; |
---|
| 3493 | mailData.input_cc = stringCCEmail; |
---|
| 3494 | mailData.abaID = $(content).find('[name="abaID"]').val(); |
---|
| 3495 | mailData.input_important_message = $(content).find('input:checkbox:checked[name="input_important_message"]').val(); |
---|
| 3496 | mailData.input_return_receipt = $(content).find('input:checkbox:checked[name="input_return_receipt"]').val(); |
---|
| 3497 | mailData.msg_forward_from = $(content).find('[name="msg_forward_from"]').val(); |
---|
| 3498 | mailData.msg_reply_from = $(content).find('[name="msg_reply_from"]').val(); |
---|
[7286] | 3499 | |
---|
| 3500 | if ($(content).find('select[name="input_from"]').val()) |
---|
| 3501 | mailData.input_from = $(content).find('select[name="input_from"]').val(); |
---|
[7276] | 3502 | |
---|
| 3503 | |
---|
| 3504 | if(stringEmail != ""){ |
---|
| 3505 | $.ajax({ |
---|
| 3506 | url: "controller.php?action=$this.imap_functions.send_mail", |
---|
| 3507 | data: mailData, |
---|
| 3508 | type: 'POST', |
---|
[7665] | 3509 | |
---|
| 3510 | beforeSend: function(jqXHR, settings){ |
---|
| 3511 | |
---|
| 3512 | write_msg( get_lang( 'Sending the message...' ) ); |
---|
| 3513 | $(content).find('button.send').button('option', 'disabled', true); |
---|
| 3514 | |
---|
| 3515 | |
---|
| 3516 | }, |
---|
| 3517 | success: function(data){ |
---|
[7276] | 3518 | send_message_return(connector.unserialize(data),ID); |
---|
| 3519 | }, |
---|
| 3520 | error: function(){ |
---|
[7665] | 3521 | write_msg(get_lang( 'Error trying to send the message. Retry in a few seconds...' ) ); |
---|
| 3522 | $(content).find('button.send').button('option', 'disabled', false); |
---|
| 3523 | var interval = setInterval(function(){ |
---|
[7276] | 3524 | send_valided_message(ID,folder,folder_name); |
---|
| 3525 | clearInterval(interval); |
---|
| 3526 | },15000); |
---|
| 3527 | return; |
---|
| 3528 | } |
---|
[6528] | 3529 | }); |
---|
[7276] | 3530 | }else{ |
---|
| 3531 | write_msg(get_lang("message without receiver")); |
---|
| 3532 | return; |
---|
[6528] | 3533 | } |
---|
[1121] | 3534 | |
---|
[5702] | 3535 | |
---|
[2] | 3536 | } |
---|
[5702] | 3537 | |
---|
[5134] | 3538 | function is_valid_email(campo){ |
---|
| 3539 | var invalidEmail = searchEmail(campo); |
---|
| 3540 | var semicolon = campo.split(";"); |
---|
| 3541 | |
---|
| 3542 | if((campo.replace(/^\s+|\s+$/g,"")) != ""){ |
---|
| 3543 | if(invalidEmail[0] == true){ |
---|
| 3544 | write_msg("Erro de SMTP: Os endereços de destinatário a seguir falharam: "+ invalidEmail[1]); |
---|
| 3545 | return false; |
---|
| 3546 | }else{ |
---|
| 3547 | if(semicolon.length > 1){ |
---|
[7601] | 3548 | var stringError = "Erro de SMTP: Os endereços devem ser separados apenas por vírgula: "; |
---|
[5134] | 3549 | for(var i= 0; i < semicolon.length; i++){ |
---|
| 3550 | stringError = stringError + semicolon[i]; |
---|
| 3551 | if(i+1 < semicolon.length) |
---|
| 3552 | stringError = stringError + " ; "; |
---|
| 3553 | } |
---|
| 3554 | write_msg(stringError); |
---|
| 3555 | return false; |
---|
| 3556 | }else { |
---|
| 3557 | return true; |
---|
| 3558 | } |
---|
| 3559 | } |
---|
| 3560 | } |
---|
| 3561 | else{ |
---|
| 3562 | write_msg(get_lang("Message without receiver")); |
---|
| 3563 | return false; |
---|
| 3564 | } |
---|
| 3565 | } |
---|
[1318] | 3566 | function change_tr_properties(tr_element, newUid, newSubject){ |
---|
[1319] | 3567 | message_id=tr_element.id; |
---|
[4771] | 3568 | var td_from = document.getElementById('td_from_'+message_id); |
---|
[1319] | 3569 | if (typeof(newSubject) != 'undefined') |
---|
[4771] | 3570 | td_from.nextSibling.innerHTML = newSubject; |
---|
[1318] | 3571 | tr_element.id = newUid; |
---|
[2] | 3572 | |
---|
[1318] | 3573 | var openNewMessage = function () { |
---|
[6275] | 3574 | $.ajax({ |
---|
| 3575 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.get_info_msg', |
---|
| 3576 | msg_number: newUid, |
---|
| 3577 | msg_folder: current_folder, |
---|
| 3578 | decoded: true } ), |
---|
| 3579 | success: function( data ){ |
---|
| 3580 | data = connector.unserialize( data ); |
---|
| 3581 | |
---|
| 3582 | if( data ) |
---|
| 3583 | show_msg( data ); |
---|
[6587] | 3584 | }, |
---|
| 3585 | beforeSend: function( jqXHR, settings ){ |
---|
| 3586 | connector.showProgressBar(); |
---|
| 3587 | }, |
---|
| 3588 | complete: function( jqXHR, settings ){ |
---|
| 3589 | connector.hideProgressBar(); |
---|
[6275] | 3590 | } |
---|
| 3591 | |
---|
| 3592 | }); |
---|
[1318] | 3593 | }; |
---|
| 3594 | for (var i=2; i < 10; i++){ |
---|
[1319] | 3595 | if (typeof(tr_element.childNodes[i].id) != "undefined") |
---|
| 3596 | tr_element.childNodes[i].id = tr_element.childNodes[i].id.replace(message_id,newUid); |
---|
[1318] | 3597 | tr_element.childNodes[i].onclick = openNewMessage; |
---|
| 3598 | } |
---|
| 3599 | } |
---|
| 3600 | |
---|
[4757] | 3601 | |
---|
[7626] | 3602 | function autoSave( ID ){ |
---|
[7611] | 3603 | var content = $("#content_id_"+ID); |
---|
[7498] | 3604 | saveButtonDisabled = $("#content_id_"+ID).find(".save").button('option','disabled'); |
---|
| 3605 | if(autoSaveControl.status[ID] === false && !saveButtonDisabled) |
---|
[7526] | 3606 | save_msg(ID); |
---|
[5459] | 3607 | } |
---|
| 3608 | |
---|
[5604] | 3609 | function save_msg(border_id){ |
---|
[7520] | 3610 | |
---|
[6085] | 3611 | //seta o status do auto_save = true |
---|
| 3612 | if (preferences.auto_save_draft == 1) |
---|
| 3613 | autoSaveControl.status[border_id] = true; |
---|
| 3614 | /////////////////////////////////////////// |
---|
[6528] | 3615 | var content = $("#content_id_"+border_id); |
---|
[7498] | 3616 | content.find(".save").button('option','disabled',true); |
---|
[6863] | 3617 | |
---|
[6882] | 3618 | var array = content.find(".reply-to-tr").find(".box"); |
---|
| 3619 | var stringReplyToEmail = ""; |
---|
| 3620 | $.each(array, function(index, value){ |
---|
| 3621 | stringReplyToEmail += $(value).find("input").val() + ","; |
---|
| 3622 | }); |
---|
| 3623 | content.find('[name="input_reply_to"]').val(stringReplyToEmail); |
---|
| 3624 | |
---|
[6528] | 3625 | var stringEmail = ""; |
---|
| 3626 | var array = content.find(".to-tr").find(".box"); |
---|
| 3627 | $.each(array, function(index, value){ |
---|
| 3628 | stringEmail += $(value).find("input").val() + ","; |
---|
| 3629 | }); |
---|
| 3630 | content.find('[name="input_to"]').val(stringEmail); |
---|
| 3631 | stringEmail = ""; |
---|
| 3632 | if ( content.find('[name="input_cco"]').length){ |
---|
| 3633 | if(content.find(".cco-tr").css("display") != "none"){ |
---|
| 3634 | var array = content.find(".cco-tr").find(".box"); |
---|
| 3635 | $.each(array, function(index, value){ |
---|
| 3636 | stringEmail += $(value).find("input").val() + ","; |
---|
| 3637 | }); |
---|
| 3638 | content.find('[name="input_cco"]').val(stringEmail); |
---|
| 3639 | } |
---|
| 3640 | } |
---|
| 3641 | |
---|
| 3642 | stringEmail = ""; |
---|
| 3643 | if(content.find(".cc-tr").css("display") != "none") |
---|
| 3644 | { |
---|
| 3645 | var array = content.find(".cc-tr").find(".box"); |
---|
| 3646 | $.each(array, function(index, value){ |
---|
| 3647 | stringEmail += $(value).find("input").val() + ","; |
---|
| 3648 | }); |
---|
| 3649 | content.find('[name="input_cc"]').val(stringEmail); |
---|
| 3650 | } |
---|
| 3651 | |
---|
[6085] | 3652 | var idJavascript = saveBorderError[border_id]; |
---|
| 3653 | |
---|
| 3654 | if(saveBorderError[border_id] !== false) |
---|
| 3655 | DataLayer.put('message',DataLayer.merge(DataLayer.form("#form_message_"+border_id), {id: idJavascript })); |
---|
| 3656 | else |
---|
| 3657 | idJavascript = DataLayer.put('message',DataLayer.form("#form_message_"+border_id)); |
---|
[4522] | 3658 | |
---|
[6085] | 3659 | uidsSave[border_id] = []; |
---|
| 3660 | DataLayer.commit(false,false,function(data){ |
---|
| 3661 | if(data != null && data['message://'+idJavascript] !== undefined && data['message://'+idJavascript].id !== undefined ) |
---|
| 3662 | { |
---|
[7626] | 3663 | uidsSave[border_id].push(data['message://'+idJavascript].id); |
---|
| 3664 | saveBorderError[border_id] = false; |
---|
| 3665 | write_msg('Mensagem salva com sucesso!'); |
---|
| 3666 | if(folder == 'INBOX'+cyrus_delimiter+'Drafts'){ |
---|
| 3667 | refresh(); |
---|
| 3668 | } |
---|
[6085] | 3669 | } |
---|
| 3670 | else |
---|
| 3671 | { |
---|
| 3672 | saveBorderError[border_id] = idJavascript; |
---|
[7498] | 3673 | write_msg('Erro ao salvar sua mensagem! Nova tentativa em alguns segundos.'); |
---|
[6085] | 3674 | } |
---|
| 3675 | }); |
---|
| 3676 | |
---|
[271] | 3677 | } |
---|
| 3678 | |
---|
[5264] | 3679 | function set_messages_flag_search_local(flag){ |
---|
[7414] | 3680 | // var msgs_flag = this.get_selected_messages_search(); |
---|
| 3681 | // if(local_messages.prototype.set_messages_flag(msgs_flag, flag, true)){ |
---|
| 3682 | // var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 3683 | // var msgs = msgs_flag.split(','); |
---|
| 3684 | // for(var i = 0; i < msgs.length; i++){ |
---|
| 3685 | // Element("search_local_msg"+id_border+"_check_box_message_"+msgs[i]).checked = false; |
---|
| 3686 | // } |
---|
| 3687 | // draw_tree_folders(); |
---|
| 3688 | // Element('chk_box_select_all_messages_search_local').checked = false; |
---|
| 3689 | // refresh(); |
---|
| 3690 | // write_msg(get_lang('The messages were marked with success!')); |
---|
| 3691 | // }else{ |
---|
| 3692 | // write_msg(get_lang('Error marking messages.')); |
---|
| 3693 | // } |
---|
[5264] | 3694 | } |
---|
[271] | 3695 | |
---|
[5264] | 3696 | function set_messages_flag_search(flag){ |
---|
| 3697 | |
---|
| 3698 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 3699 | var msgs_flag = this.get_selected_messages_search(); |
---|
| 3700 | if (!msgs_flag){ |
---|
| 3701 | write_msg(get_lang('No selected message.')); |
---|
| 3702 | return; |
---|
| 3703 | } |
---|
| 3704 | var selected_param = ""; |
---|
| 3705 | msgs_to_flag = msgs_flag.split(","); |
---|
| 3706 | search = true; |
---|
| 3707 | for (i = 0; i < msgs_to_flag.length; i++){ |
---|
| 3708 | var tr = Element(msgs_to_flag[i]+'_s'+id_border); |
---|
| 3709 | var msg_to_flag = (tr.getAttribute('name') == null?get_current_folder():tr.getAttribute('name')); |
---|
| 3710 | selected_param += ','+msg_to_flag+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 3711 | } |
---|
| 3712 | |
---|
| 3713 | var handler_set_messages_flag = function(data){ |
---|
| 3714 | var errors = false; |
---|
| 3715 | var notErrors = false; |
---|
| 3716 | for (var i = 0; i < data.length; i++){ |
---|
| 3717 | var notArray = true; |
---|
| 3718 | if(data[i].msgs_to_set != ''){ |
---|
| 3719 | var msgs = []; |
---|
| 3720 | if(data[i].msgs_to_set.indexOf(',') > 0){ |
---|
| 3721 | msgs = data[i].msgs_to_set.split(',') |
---|
| 3722 | notArray = false; |
---|
| 3723 | }else |
---|
| 3724 | msgs[0] = data[i].msgs_to_set; |
---|
| 3725 | |
---|
| 3726 | for (var j = 0; j < msgs.length; j++){ |
---|
| 3727 | switch(data[i].flag){ |
---|
| 3728 | case "unseen": |
---|
| 3729 | set_msg_as_unread(msgs[j]+'_s'+id_border, true); |
---|
| 3730 | Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked = false; |
---|
| 3731 | break; |
---|
| 3732 | case "seen": |
---|
| 3733 | set_msg_as_read(msgs[j]+'_s'+id_border, true); |
---|
| 3734 | Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked = false; |
---|
| 3735 | break; |
---|
| 3736 | case "flagged": |
---|
| 3737 | set_msg_as_flagged(msgs[j]+'_s'+id_border, true); |
---|
| 3738 | document.getElementById("search_"+id_border+"_check_box_message_"+msgs[j]).checked = false; |
---|
| 3739 | break; |
---|
| 3740 | case "unflagged": |
---|
| 3741 | set_msg_as_unflagged(msgs[j]+'_s'+id_border, true); |
---|
| 3742 | Element("search_"+id_border+"_check_box_message_"+msgs[j]).checked = false; |
---|
| 3743 | break; |
---|
| 3744 | } |
---|
| 3745 | notErrors = true; |
---|
| 3746 | } |
---|
| 3747 | }else{ |
---|
| 3748 | errors = true; |
---|
| 3749 | } |
---|
| 3750 | } |
---|
| 3751 | |
---|
| 3752 | draw_tree_folders(); |
---|
| 3753 | Element('chk_box_select_all_messages_search').checked = false; |
---|
| 3754 | refresh(); |
---|
| 3755 | |
---|
| 3756 | if(errors && notErrors) |
---|
| 3757 | write_msg(get_lang('Some messages were not marked with success!')); |
---|
| 3758 | else if(notErrors) |
---|
| 3759 | write_msg(get_lang('The messages were marked with success!')); |
---|
| 3760 | else |
---|
| 3761 | write_msg(get_lang('Error marking messages.')); |
---|
| 3762 | } |
---|
| 3763 | cExecute ("$this.imap_functions.set_messages_flag_from_search&msg_to_flag="+selected_param+"&flag="+flag, handler_set_messages_flag); |
---|
| 3764 | } |
---|
| 3765 | |
---|
[2] | 3766 | // Get checked messages |
---|
[5264] | 3767 | function set_messages_flag(flag, msgs_to_set){ |
---|
| 3768 | if(currentTab != 0 && currentTab.indexOf("search_local") >= 0){ |
---|
| 3769 | return set_messages_flag_search_local(flag); |
---|
| 3770 | } |
---|
| 3771 | if (currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
| 3772 | return set_messages_flag_search(flag); |
---|
| 3773 | } |
---|
| 3774 | |
---|
[2] | 3775 | var handler_set_messages_flag = function (data){ |
---|
| 3776 | if(!verify_session(data)) |
---|
| 3777 | return; |
---|
[5134] | 3778 | var msgs_to_set = data.msgs_to_set.split(","); |
---|
[649] | 3779 | |
---|
[7258] | 3780 | |
---|
| 3781 | if(data.disposition_notification_to){ |
---|
| 3782 | $.Zebra_Dialog(data.disposition_notification_to.length == 1 ? get_lang('One of his messages can not be marked as read, because it contains a read confirmation.') : data.disposition_notification_to.length + get_lang(' of its messages could not be marked as read, because it contains a read confirmation.'), { |
---|
| 3783 | 'type': 'warning', |
---|
| 3784 | 'overlay_opacity': '0.5', |
---|
[7612] | 3785 | 'custom_class': 'custom-zebra-filter', |
---|
[7744] | 3786 | 'buttons': [get_lang('Close')] |
---|
[7258] | 3787 | }); |
---|
| 3788 | } |
---|
| 3789 | |
---|
[614] | 3790 | if(!data.status) { |
---|
[3806] | 3791 | write_msg(data.msg); |
---|
[614] | 3792 | Element('chk_box_select_all_messages').checked = false; |
---|
| 3793 | for (var i = 0; i < msgs_to_set.length; i++) { |
---|
[5134] | 3794 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
| 3795 | remove_className(Element(msgs_to_set[i]), 'selected_msg'); |
---|
[614] | 3796 | } |
---|
[659] | 3797 | if(!data.msgs_unflageds) |
---|
| 3798 | return; |
---|
[5182] | 3799 | |
---|
[659] | 3800 | else |
---|
[5182] | 3801 | if(data.msgs_not_to_set != "") |
---|
| 3802 | write_msg(get_lang("Error processing some messages.")); |
---|
| 3803 | |
---|
[659] | 3804 | msgs_to_set = data.msgs_unflageds.split(","); |
---|
[614] | 3805 | } |
---|
[2] | 3806 | |
---|
| 3807 | for (var i=0; i<msgs_to_set.length; i++){ |
---|
[3032] | 3808 | if (preferences.use_cache == 'True') |
---|
| 3809 | { |
---|
| 3810 | if (current_folder == '') |
---|
| 3811 | current_folder = 'INBOX'; |
---|
| 3812 | var setFlag = function(msgObj) { |
---|
| 3813 | switch(data.flag){ |
---|
| 3814 | case "unseen": |
---|
| 3815 | msgObj.Unseen = "U"; |
---|
| 3816 | break; |
---|
| 3817 | case "seen": |
---|
| 3818 | msgObj.Unseen = ""; |
---|
| 3819 | break; |
---|
| 3820 | case "flagged": |
---|
| 3821 | msgObj.Flagged = "F"; |
---|
| 3822 | break; |
---|
| 3823 | case "unflagged": |
---|
| 3824 | msgObj.Flagged = ""; |
---|
| 3825 | break; |
---|
| 3826 | } |
---|
| 3827 | } |
---|
[4843] | 3828 | } |
---|
[5134] | 3829 | if(Element("check_box_message_" + msgs_to_set[i])){ |
---|
[63] | 3830 | switch(data.flag){ |
---|
| 3831 | case "unseen": |
---|
[4843] | 3832 | set_msg_as_unread(msgs_to_set[i]); |
---|
[5134] | 3833 | if(results_search_messages != "") |
---|
| 3834 | set_msg_as_unread(results_search_messages, true); |
---|
| 3835 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
[63] | 3836 | break; |
---|
| 3837 | case "seen": |
---|
[5134] | 3838 | set_msg_as_read(msgs_to_set[i], false); |
---|
| 3839 | if(results_search_messages != "") |
---|
| 3840 | set_msg_as_read(results_search_messages, false, true); |
---|
| 3841 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
[7765] | 3842 | |
---|
[6487] | 3843 | // remove a flag $FilteredMessage da mensagem ao ser marcada como lida |
---|
| 3844 | $.each(fromRules, function(index, value) { |
---|
| 3845 | if(value == folder){ |
---|
| 3846 | cExecute ("$this.imap_functions.removeFlagMessagesFilter&folder="+folder+"&msg_number="+msgs_to_set, function(){}); |
---|
| 3847 | return false; |
---|
| 3848 | } |
---|
| 3849 | }); |
---|
| 3850 | |
---|
[63] | 3851 | break; |
---|
| 3852 | case "flagged": |
---|
[4843] | 3853 | set_msg_as_flagged(msgs_to_set[i]); |
---|
[5134] | 3854 | if(results_search_messages != "") |
---|
| 3855 | set_msg_as_flagged(results_search_messages, true); |
---|
| 3856 | document.getElementById("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
[63] | 3857 | break; |
---|
| 3858 | case "unflagged": |
---|
[4843] | 3859 | set_msg_as_unflagged(msgs_to_set[i]); |
---|
[5134] | 3860 | if(results_search_messages != "") |
---|
| 3861 | set_msg_as_unflagged(results_search_messages, true); |
---|
| 3862 | Element("check_box_message_" + msgs_to_set[i]).checked = false; |
---|
[63] | 3863 | break; |
---|
| 3864 | } |
---|
[2] | 3865 | } |
---|
| 3866 | } |
---|
| 3867 | Element('chk_box_select_all_messages').checked = false; |
---|
| 3868 | } |
---|
[3035] | 3869 | |
---|
[63] | 3870 | var folder = get_current_folder(); |
---|
[5134] | 3871 | if (msgs_to_set == 'get_selected_messages') |
---|
[2] | 3872 | var msgs_to_set = this.get_selected_messages(); |
---|
[63] | 3873 | else |
---|
| 3874 | folder = Element("input_folder_"+msgs_to_set+"_r").value; |
---|
[6487] | 3875 | |
---|
[2] | 3876 | if (msgs_to_set) |
---|
[6288] | 3877 | $.ajax({ |
---|
[7776] | 3878 | type: "POST", |
---|
| 3879 | url: "controller.php?action=$this.imap_functions.set_messages_flag", |
---|
| 3880 | data: { |
---|
| 3881 | folder: folder, |
---|
| 3882 | msgs_to_set: msgs_to_set, |
---|
| 3883 | flag: flag, |
---|
| 3884 | decoded: true |
---|
| 3885 | }, |
---|
[6288] | 3886 | success: function( data ){ |
---|
| 3887 | data = connector.unserialize( data ); |
---|
[6930] | 3888 | |
---|
| 3889 | selectAllFolderMsgs(); |
---|
| 3890 | $('.select-link').unbind('click'); |
---|
| 3891 | |
---|
[6288] | 3892 | if( data ) |
---|
| 3893 | handler_set_messages_flag( data ); |
---|
[6587] | 3894 | }, |
---|
| 3895 | beforeSend: function( jqXHR, settings ){ |
---|
| 3896 | connector.showProgressBar(); |
---|
| 3897 | }, |
---|
| 3898 | complete: function( jqXHR, settings ){ |
---|
| 3899 | connector.hideProgressBar(); |
---|
[6288] | 3900 | } |
---|
| 3901 | |
---|
| 3902 | }); |
---|
[2] | 3903 | else |
---|
[3035] | 3904 | write_msg(get_lang('No selected message.')); |
---|
[2] | 3905 | } |
---|
| 3906 | |
---|
| 3907 | // By message number |
---|
[3806] | 3908 | function set_message_flag(msg_number, flag, func_after_flag_change){ |
---|
| 3909 | var msg_number_folder = Element("new_input_folder_"+msg_number+"_r"); //Mensagens respondidas/encaminhadas |
---|
| 3910 | if(!msg_number_folder) |
---|
| 3911 | var msg_number_folder = Element("input_folder_"+msg_number+"_r"); //Mensagens abertas |
---|
| 3912 | |
---|
[2] | 3913 | var handler_set_messages_flag = function (data){ |
---|
| 3914 | if(!verify_session(data)) |
---|
| 3915 | return; |
---|
[3806] | 3916 | if(!data.status) { |
---|
| 3917 | write_msg(get_lang("this message cant be marked as normal")); |
---|
| 3918 | return; |
---|
| 3919 | } |
---|
| 3920 | else if(func_after_flag_change) { |
---|
| 3921 | func_after_flag_change(true); |
---|
| 3922 | } |
---|
[3035] | 3923 | if (data.status && Element("td_message_answered_"+msg_number)) { |
---|
[3716] | 3924 | |
---|
| 3925 | switch(flag){ |
---|
| 3926 | case "unseen": |
---|
| 3927 | set_msg_as_unread(msg_number); |
---|
| 3928 | break; |
---|
| 3929 | case "seen": |
---|
| 3930 | set_msg_as_read(msg_number); |
---|
| 3931 | break; |
---|
| 3932 | case "flagged": |
---|
| 3933 | set_msg_as_flagged(msg_number); |
---|
| 3934 | break; |
---|
| 3935 | case "unflagged": |
---|
| 3936 | set_msg_as_unflagged(msg_number); |
---|
| 3937 | break; |
---|
| 3938 | case "answered": |
---|
[7199] | 3939 | Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/'+template+'/images/answered.png title=Respondida>'; |
---|
[3716] | 3940 | break; |
---|
| 3941 | case "forwarded": |
---|
[7199] | 3942 | Element("td_message_answered_"+msg_number).innerHTML = '<img src=templates/'+template+'/images/forwarded.png title=Encaminhada>'; |
---|
[3716] | 3943 | break; |
---|
| 3944 | } |
---|
[3742] | 3945 | } else { |
---|
| 3946 | refresh(); |
---|
[2] | 3947 | } |
---|
| 3948 | } |
---|
[6288] | 3949 | $.ajax({ |
---|
| 3950 | url: 'controller.php?' + $.param( {action: '$this.imap_functions.set_messages_flag', |
---|
| 3951 | folder: ( msg_number_folder ? msg_number_folder.value : get_current_folder() ), |
---|
| 3952 | msgs_to_set: msg_number, |
---|
| 3953 | flag: flag, |
---|
| 3954 | decoded: true } ), |
---|
| 3955 | success: function( data ){ |
---|
| 3956 | data = connector.unserialize( data ); |
---|
| 3957 | |
---|
| 3958 | if( data ) |
---|
| 3959 | handler_set_messages_flag( data ); |
---|
[6587] | 3960 | }, |
---|
| 3961 | beforeSend: function( jqXHR, settings ){ |
---|
| 3962 | connector.showProgressBar(); |
---|
| 3963 | }, |
---|
| 3964 | complete: function( jqXHR, settings ){ |
---|
| 3965 | connector.hideProgressBar(); |
---|
| 3966 | } |
---|
[6288] | 3967 | |
---|
| 3968 | }); |
---|
[2] | 3969 | } |
---|
| 3970 | |
---|
[5172] | 3971 | function print_search_msg(){ |
---|
| 3972 | var folder = "<h2> Resultado da Pesquisa <font color=\"#505050\" face=\"Verdana\" size=\"1\"></h2>"; |
---|
| 3973 | msgs_number = get_selected_messages_search(); |
---|
| 3974 | var tbody = Element('divScrollMain_'+numBox).firstChild.firstChild.innerHTML; |
---|
| 3975 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
| 3976 | |
---|
| 3977 | if(msgs_number){ |
---|
| 3978 | msgs_number = msgs_number.split(","); |
---|
| 3979 | var tbody = ""; |
---|
| 3980 | for(var i = 0; i < msgs_number.length; i++){ |
---|
| 3981 | 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>"; |
---|
| 3982 | } |
---|
| 3983 | }else{ |
---|
| 3984 | msgs_number = get_all_messages_search(); |
---|
| 3985 | msgs_number = msgs_number.split(","); |
---|
| 3986 | var tbody = ""; |
---|
| 3987 | for(var i = 0; i < msgs_number.length; i++){ |
---|
| 3988 | 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>"; |
---|
| 3989 | } |
---|
| 3990 | } |
---|
| 3991 | |
---|
| 3992 | var print_width = screen.width - 200; |
---|
| 3993 | var x = ((screen.width - print_width) / 2); |
---|
| 3994 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 3995 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
| 3996 | seekDot = (is_ie ? /width=24/gi : /width="24"/gi); |
---|
| 3997 | |
---|
[6491] | 3998 | 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] | 3999 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 4000 | seekDot = (is_ie ? /width=16/gi : /width="16"/gi); |
---|
| 4001 | |
---|
| 4002 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 4003 | seekDot = (is_ie ? /width=12/gi : /width="12"/gi); |
---|
| 4004 | |
---|
| 4005 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 4006 | while (1){ |
---|
| 4007 | try{ |
---|
| 4008 | window_print.document.open(); |
---|
| 4009 | var html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>' |
---|
| 4010 | + '<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>' |
---|
| 4011 | + cabecalho + '</h4><hr>' |
---|
| 4012 | + '<h2>'+folder+'</h2><hr/><blockquote><font size="2">' |
---|
| 4013 | + '<table width="100%" cellpadding="0" cellspacing="0">' |
---|
| 4014 | + '<thead>' + thead + '</thead><tbody>' + tbody + '</tbody>' |
---|
| 4015 | + '</table></font></blockquote></body></html>'; |
---|
| 4016 | window_print.document.write(html); |
---|
| 4017 | window_print.document.close(); |
---|
| 4018 | break; |
---|
| 4019 | } |
---|
| 4020 | catch(e){ |
---|
| 4021 | //alert(e.message); |
---|
| 4022 | } |
---|
| 4023 | } |
---|
| 4024 | window_print.document.close(); |
---|
| 4025 | window_print.print(); |
---|
| 4026 | } |
---|
| 4027 | |
---|
[7525] | 4028 | |
---|
[7514] | 4029 | /*PERMITE A IMPRESSÃO DE UMA LISTA DE MENSAGENS E SEU CONTEÚDO*/ |
---|
| 4030 | function print_messages_bodies(){ |
---|
| 4031 | var messages = {}; |
---|
| 4032 | messages[get_current_folder()] = get_selected_messages().split(','); |
---|
[827] | 4033 | |
---|
[7514] | 4034 | var print_bodies = function (data){ |
---|
| 4035 | var print_width = screen.width - 200; |
---|
| 4036 | var x = ((screen.width - print_width) / 2); |
---|
| 4037 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 4038 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
| 4039 | if(window_print == null) { |
---|
| 4040 | alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname)); |
---|
| 4041 | return; |
---|
| 4042 | } |
---|
| 4043 | var header = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>' |
---|
| 4044 | + '<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>'; |
---|
| 4045 | window_print.document.write(header); |
---|
| 4046 | var printData ='<body style="overflow:auto">' + cabecalho + '</h4><hr>'; |
---|
| 4047 | window_print.document.write(printData); |
---|
| 4048 | var newRow = function(label,data){ |
---|
| 4049 | return "<tr><td width=7%><font size='2'><b>"+label+" </b></font></td><td><font size='2'>"+data+"</font></td></tr>"; |
---|
| 4050 | } |
---|
| 4051 | /*INSERE AS MENSAGENS NO DOCUMENTO DE IMPRESSÃO*/ |
---|
| 4052 | $.each(data,function(index,message){ |
---|
| 4053 | var html = "<table><tbody>"; |
---|
| 4054 | if(message.sender) |
---|
| 4055 | for(var i=0; i<message.sender.length; i++){ |
---|
| 4056 | html += newRow(get_lang('Sent by')+":",message.sender[i]); |
---|
| 4057 | } |
---|
| 4058 | if(message.from) |
---|
| 4059 | for(var i=0; i<message.from.length; i++){ |
---|
| 4060 | html += newRow(get_lang('From')+":",message.from[i]); |
---|
| 4061 | } |
---|
| 4062 | if(message.toaddress2) { |
---|
| 4063 | html += newRow(get_lang('To')+":",message.toaddress2); |
---|
| 4064 | } |
---|
| 4065 | if (message.cc) { |
---|
| 4066 | html += newRow(get_lang('Cc')+":",message.cc); |
---|
| 4067 | } |
---|
| 4068 | if (message.bcc) { |
---|
| 4069 | html += newRow(get_lang('Cco')+":",message.bcc); |
---|
| 4070 | } |
---|
| 4071 | if(message.smalldate) |
---|
| 4072 | html += newRow(get_lang('Date')+":",message.smalldate); |
---|
[7525] | 4073 | /*DATA NAS MESAGENS LOCAIS*/ |
---|
| 4074 | else if(message.udate){ |
---|
| 4075 | var norm = function (arg) {return (arg < 10 ? '0'+arg : arg);}; |
---|
| 4076 | var weekDays = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; |
---|
| 4077 | var today = new Date(); |
---|
| 4078 | today.setHours(23); |
---|
| 4079 | today.setMinutes(59); |
---|
| 4080 | today.setSeconds(59); |
---|
| 4081 | today.setMilliseconds(999); |
---|
| 4082 | udate_local = message.udate*1000 + today.getTimezoneOffset()*60*1000; |
---|
| 4083 | date_msg = new Date(udate_local); |
---|
| 4084 | if (preferences.show_date_numerical == 0 || typeof(preferences.show_date_numerical) == 'undefined') { |
---|
| 4085 | if (today.getTime() - date_msg.getTime() < 86400000) |
---|
| 4086 | html += newRow(get_lang('Date')+":",norm(date_msg.getHours()) + ':' + norm(date_msg.getMinutes())); |
---|
| 4087 | else |
---|
| 4088 | if (today.getTime() - date_msg.getTime() < 172800000) |
---|
| 4089 | newRow(get_lang('Date')+":",get_lang('Yesterday')); |
---|
| 4090 | else if (today.getTime() - date_msg.getTime() < 259200000) |
---|
| 4091 | html += newRow(get_lang('Date')+":",get_lang(weekDays[date_msg.getDay()])); |
---|
| 4092 | else |
---|
| 4093 | html += newRow(get_lang('Date')+":",norm(date_msg.getDate()) + '/' + norm(date_msg.getMonth()+1) + '/' +date_msg.getFullYear()); |
---|
| 4094 | }else |
---|
| 4095 | html += newRow(get_lang('Date')+":",norm(date_msg.getDate()) + '/' + norm(date_msg.getMonth()+1) + '/' +date_msg.getFullYear()); |
---|
| 4096 | } |
---|
[7514] | 4097 | html += newRow(get_lang('Subject')+":",message.subject); |
---|
| 4098 | /*LISTA DE ANEXOS*/ |
---|
| 4099 | if (message.attachments && message.attachments.length) { |
---|
| 4100 | var img = '<img style="margin-bottom : -5px; cursor : pointer;" src="templates/'+template+'/images/new.png">'; |
---|
| 4101 | var atts = ""; |
---|
| 4102 | $.each(message.attachments,function(index,attach){ |
---|
| 4103 | atts += " | " + attach.name + "("+ formatBytes(attach.fsize) +") " + img + " | "; |
---|
| 4104 | }); |
---|
| 4105 | html += newRow(get_lang('Attachments: '),atts); |
---|
| 4106 | } |
---|
[7525] | 4107 | /*ANEXOS LOCAIS*/ |
---|
| 4108 | else if (message.attachment && message.attachment.number_attachments > 0) { |
---|
| 4109 | var img = '<img style="margin-bottom : -5px; cursor : pointer;" src="templates/'+template+'/images/new.png">'; |
---|
| 4110 | var atts = ""; |
---|
| 4111 | $.each(message.attachment.names.split(','),function(index,attach){ |
---|
| 4112 | atts += " | " + attach + img + " |"; |
---|
| 4113 | }); |
---|
| 4114 | html += newRow(get_lang('Attachments: '),atts); |
---|
| 4115 | } |
---|
[7514] | 4116 | html += '</tbody></table>'; |
---|
| 4117 | if (message.body){ |
---|
| 4118 | html += "<hr>" + message.body; |
---|
| 4119 | } |
---|
[7529] | 4120 | else if (message._return){ |
---|
| 4121 | html += "<hr>" + message._return; |
---|
| 4122 | } |
---|
[7514] | 4123 | html += "<hr>"; |
---|
| 4124 | window_print.document.write(html); |
---|
| 4125 | }); |
---|
| 4126 | window_print.document.close(); |
---|
| 4127 | window_print.print(); |
---|
[5172] | 4128 | } |
---|
[7525] | 4129 | /*MENSAGENS LOCAIS*/ |
---|
| 4130 | if ( proxy_mensagens.is_local_folder(get_current_folder()) ){ |
---|
| 4131 | var msgs = Array(); |
---|
[7529] | 4132 | var _msg = {}; |
---|
[7525] | 4133 | $.each(get_selected_messages().split(','),function(index,value){ |
---|
[7529] | 4134 | _msg.header = expresso_mail_archive.getMessageHeaders(value); |
---|
| 4135 | _msg.body = expresso_mail_archive.getMessageBodies([value]); |
---|
| 4136 | msgs.push($.extend({},_msg.header,_msg.body[0])); |
---|
[7525] | 4137 | }); |
---|
| 4138 | print_bodies(msgs); |
---|
| 4139 | } |
---|
| 4140 | else{ |
---|
| 4141 | $.ajax({ |
---|
[7776] | 4142 | type: "POST", |
---|
| 4143 | url: "controller.php?action=$this.imap_functions.getMessages", |
---|
| 4144 | data: { |
---|
[7525] | 4145 | details: "all", |
---|
| 4146 | messages : messages, |
---|
[7776] | 4147 | }, |
---|
[7525] | 4148 | success: function(data){ |
---|
| 4149 | data = connector.unserialize(data); |
---|
| 4150 | if(data){ |
---|
| 4151 | print_bodies(data[get_current_folder()]); |
---|
| 4152 | } |
---|
| 4153 | }, |
---|
| 4154 | beforeSend: function( jqXHR, settings ){ |
---|
| 4155 | connector.showProgressBar(); |
---|
| 4156 | }, |
---|
| 4157 | complete: function( jqXHR, settings ){ |
---|
| 4158 | connector.hideProgressBar(); |
---|
[7514] | 4159 | } |
---|
[7525] | 4160 | }); |
---|
| 4161 | } |
---|
[7514] | 4162 | } |
---|
| 4163 | |
---|
[7523] | 4164 | function newTbody(messages){ |
---|
| 4165 | var tbody = $("<tbody>"); |
---|
| 4166 | $.each(messages,function(index,msg){ |
---|
[7525] | 4167 | var newTr = make_tr_message(msg,get_current_folder()); |
---|
[7523] | 4168 | if (msg.attachments && msg.attachments.length){ |
---|
[7550] | 4169 | $(newTr).find('td').eq(1).css({'background-image':'url(templates/'+template+'/images/mail-gifs.gif)','background-position': '0 -242px'}); |
---|
[7523] | 4170 | } |
---|
| 4171 | tbody.append(newTr); |
---|
| 4172 | }); |
---|
| 4173 | return tbody.html(); |
---|
| 4174 | } |
---|
| 4175 | |
---|
[7514] | 4176 | function print_messages_list(){ |
---|
[7523] | 4177 | var print_list = function(tbody,folder){ |
---|
| 4178 | var print_width = screen.width - 200; |
---|
| 4179 | var x = ((screen.width - print_width) / 2); |
---|
| 4180 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 4181 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
| 4182 | seekDot = (is_ie ? /width=24/gi : /width="24"/gi); |
---|
| 4183 | //thead = thead.replace(seekDot, "style='display:none'"); |
---|
| 4184 | 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>"; |
---|
| 4185 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 4186 | seekDot = (is_ie ? /width=16/gi : /width="16"/gi); |
---|
| 4187 | //thead = thead.replace(seekDot, "style='display:none'"); |
---|
| 4188 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 4189 | seekDot = (is_ie ? /width=12/gi : /width="12"/gi); |
---|
| 4190 | //thead = thead.replace(seekDot, "style='display:none'"); |
---|
| 4191 | tbody = tbody.replace(seekDot, "style='display:none'"); |
---|
| 4192 | while (1){ |
---|
| 4193 | try{ |
---|
| 4194 | window_print.document.open(); |
---|
| 4195 | var html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>' |
---|
| 4196 | + '<head><link rel="stylesheet" type="text/css" href="templates/'+template+'/print.css"></head>' |
---|
| 4197 | + cabecalho + '</h4><hr>' |
---|
| 4198 | + '<h2>'+$('#border_id_0').html()+'</h2><hr/><blockquote><font size="2">' |
---|
| 4199 | + '<table width="100%" cellpadding="0" cellspacing="0">' |
---|
| 4200 | + '<thead>' + thead + '</thead><tbody>' + tbody + '</tbody>' |
---|
| 4201 | + '</table></font></blockquote></body></html>'; |
---|
| 4202 | window_print.document.write(html); |
---|
| 4203 | window_print.document.close(); |
---|
| 4204 | break; |
---|
| 4205 | } |
---|
| 4206 | catch(e){ |
---|
| 4207 | //alert(e.message); |
---|
| 4208 | } |
---|
| 4209 | } |
---|
| 4210 | window_print.document.close(); |
---|
| 4211 | window_print.print(); |
---|
| 4212 | } |
---|
[5134] | 4213 | msgs_number = get_selected_messages(); |
---|
| 4214 | if(msgs_number == false){ |
---|
[7523] | 4215 | var tbody = Element('divScrollMain_0').firstChild.firstChild.innerHTML; |
---|
| 4216 | print_list(tbody); |
---|
[5134] | 4217 | }else{ |
---|
[7523] | 4218 | var messages = {}; |
---|
| 4219 | messages[get_current_folder()] = msgs_number.split(','); |
---|
[7525] | 4220 | /*MENSAGENS LOCAIS*/ |
---|
| 4221 | if ( proxy_mensagens.is_local_folder(get_current_folder()) ){ |
---|
| 4222 | var msgs = Array(); |
---|
| 4223 | $.each(msgs_number.split(','),function(index,value){ |
---|
| 4224 | msgs.push(expresso_mail_archive.getMessageHeaders(value)); |
---|
| 4225 | }); |
---|
| 4226 | print_list(newTbody(msgs)); |
---|
[2] | 4227 | } |
---|
[7525] | 4228 | else{ |
---|
| 4229 | $.ajax({ |
---|
[7776] | 4230 | type: "POST", |
---|
| 4231 | url: "controller.php?action=$this.imap_functions.getMessages", |
---|
| 4232 | data:{ |
---|
[7525] | 4233 | details : "all", |
---|
| 4234 | messages : messages, |
---|
[7776] | 4235 | }, |
---|
[7525] | 4236 | success: function(data){ |
---|
| 4237 | data = connector.unserialize(data); |
---|
| 4238 | if(data){ |
---|
| 4239 | data = data[get_current_folder()]; |
---|
| 4240 | print_list(newTbody(data)); |
---|
| 4241 | } |
---|
| 4242 | }, |
---|
| 4243 | beforeSend: function( jqXHR, settings ){ |
---|
| 4244 | connector.showProgressBar(); |
---|
| 4245 | }, |
---|
| 4246 | complete: function( jqXHR, settings ){ |
---|
| 4247 | connector.hideProgressBar(); |
---|
| 4248 | } |
---|
| 4249 | }); |
---|
| 4250 | } |
---|
[2] | 4251 | } |
---|
| 4252 | } |
---|
| 4253 | |
---|
[7514] | 4254 | function print_all(){ |
---|
| 4255 | if(typeof (currentTab) == "string" && currentTab.indexOf("local") != -1){ |
---|
[7601] | 4256 | alert("Impossével manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais."); |
---|
[7514] | 4257 | return true; |
---|
| 4258 | } |
---|
| 4259 | if (openTab.type[currentTab] == 2) |
---|
| 4260 | return print_msg(current_folder,currentTab.substr(0,currentTab.indexOf("_r")),currentTab); |
---|
[2] | 4261 | |
---|
[7514] | 4262 | if (currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
| 4263 | return print_search_msg(); |
---|
| 4264 | } |
---|
[7525] | 4265 | |
---|
[7514] | 4266 | if (get_selected_messages() == false){ |
---|
| 4267 | return print_messages_list(); |
---|
| 4268 | } |
---|
| 4269 | var msg = 'Algumas mensagens foram selecionadas para impressão. Deseja imprimir o conteúdo de cada uma delas? Caso contrário, apenas uma lista das mensagens selecionadas será impressa.'; |
---|
| 4270 | $.Zebra_Dialog(msg, { |
---|
| 4271 | 'type': 'question', |
---|
| 4272 | 'buttons': ['Sim','Não'], |
---|
| 4273 | 'overlay_opacity': '0.5', |
---|
[7612] | 4274 | 'custom_class': 'custom-zebra-filter', |
---|
[7514] | 4275 | 'onClose': function(caption) { |
---|
| 4276 | if(caption == 'Sim'){ |
---|
| 4277 | return print_messages_bodies(); |
---|
| 4278 | } |
---|
| 4279 | else{ |
---|
| 4280 | return print_messages_list(); |
---|
| 4281 | } |
---|
| 4282 | } |
---|
| 4283 | }); |
---|
| 4284 | } |
---|
| 4285 | |
---|
[2] | 4286 | function print_msg(msg_folder, msg_number, border_ID){ |
---|
[3035] | 4287 | var div_toaddress_full = Element("div_toaddress_full_"+border_ID); |
---|
[2] | 4288 | var div_ccaddress_full = Element("div_ccaddress_full_"+border_ID); |
---|
[3342] | 4289 | var div_ccoaddress_full = Element("div_ccoaddress_full_"+border_ID); |
---|
| 4290 | var printListTO = (div_toaddress_full && div_toaddress_full.style.display != 'none') || toaddress_array[border_ID].length == 1 ? true : false; |
---|
[3035] | 4291 | var printListCC = (div_ccaddress_full && div_ccaddress_full.style.display != 'none') || !div_ccaddress_full ? true : false; |
---|
[3342] | 4292 | var printListCCO = (div_ccoaddress_full && div_ccoaddress_full.style.display != 'none') || !div_ccoaddress_full ? true : false; |
---|
[2] | 4293 | var sender = Element('sender_values_'+border_ID) ? Element('sender_values_'+border_ID).value : null; |
---|
| 4294 | var from = Element('from_values_'+border_ID) ? Element('from_values_'+border_ID).value : null; |
---|
| 4295 | var to = Element('to_values_'+border_ID) ? Element('to_values_'+border_ID).value :null; |
---|
[3342] | 4296 | var cco = Element('cco_values_'+border_ID) ? Element('cco_values_'+border_ID).value : null; |
---|
| 4297 | var cc = Element('cc_values_'+border_ID) ? Element('cc_values_'+border_ID).value : null; |
---|
| 4298 | var date = Element('date_'+border_ID); |
---|
[2] | 4299 | var subject = Element('subject_'+border_ID); |
---|
| 4300 | var attachments = Element('attachments_'+border_ID); |
---|
| 4301 | var body = Element('body_'+border_ID); |
---|
| 4302 | |
---|
[4783] | 4303 | |
---|
| 4304 | var att = ''; |
---|
| 4305 | |
---|
| 4306 | var countAtt = 0; |
---|
| 4307 | |
---|
| 4308 | if(attachments !== null) |
---|
| 4309 | { |
---|
| 4310 | countAtt = attachments.getElementsByTagName('a').length; |
---|
| 4311 | if(countAtt === 1) |
---|
| 4312 | att = attachments.getElementsByTagName('a')[0].innerHTML; |
---|
| 4313 | else if(countAtt > 1) |
---|
| 4314 | for (var i = 1; i <attachments.getElementsByTagName('a').length; i++) |
---|
[5134] | 4315 | att += " | " + attachments.getElementsByTagName('a')[i].innerHTML; |
---|
[4783] | 4316 | } |
---|
| 4317 | |
---|
| 4318 | var body = Element('body_'+border_ID); |
---|
| 4319 | |
---|
[2] | 4320 | var print_width = screen.width - 200; |
---|
| 4321 | var x = ((screen.width - print_width) / 2); |
---|
| 4322 | var y = ((screen.height - 400) / 2) - 35; |
---|
| 4323 | var window_print = window.open('','ExpressoMail','width='+print_width+',height=400,resizable=yes,scrollbars=yes,left='+x+',top='+y); |
---|
[135] | 4324 | if(window_print == null) { |
---|
| 4325 | alert(get_lang("The Anti Pop-Up is enabled. Allow this site (%1) for print.",document.location.hostname)); |
---|
| 4326 | return; |
---|
| 4327 | } |
---|
[1754] | 4328 | |
---|
| 4329 | //needed to get the names of the attachments... only. |
---|
| 4330 | if(attachments != null) |
---|
| 4331 | { |
---|
| 4332 | var a = attachments.childNodes; |
---|
| 4333 | var attachs = ""; |
---|
| 4334 | var show_attachs = ""; |
---|
[4757] | 4335 | var ii = a.length >2?2:1; |
---|
| 4336 | for(i=ii;i<a.length;i++) |
---|
[1754] | 4337 | { |
---|
| 4338 | if(a[i].tagName && a[i].tagName == "A") |
---|
| 4339 | { |
---|
| 4340 | attachs += a[i].innerHTML; |
---|
| 4341 | } |
---|
| 4342 | } |
---|
| 4343 | show_attachs = "<tr><td width=7%><font size='2'>" + get_lang('Attachments: ')+ " </font></td><td><font size='2'>"+attachs+"</font></td></tr>"; |
---|
| 4344 | } else{ |
---|
| 4345 | show_attachs = ""; |
---|
[4757] | 4346 | } |
---|
[4283] | 4347 | var current_path = window.location.href.substr(0,window.location.href.lastIndexOf("/")); |
---|
[4757] | 4348 | var head = '<head><title></title><link href="'+current_path+'/templates/default/main.css" type="text/css" rel="stylesheet"></head>'; |
---|
| 4349 | window_print.document.write(head); |
---|
[3130] | 4350 | |
---|
[2] | 4351 | while (1){ |
---|
| 4352 | try{ |
---|
[6494] | 4353 | var html ='<body style="overflow:auto">'; |
---|
[5134] | 4354 | html += cabecalho + '</h4><hr>'; |
---|
[2] | 4355 | html += '<table><tbody>'; |
---|
| 4356 | if(sender) |
---|
[197] | 4357 | html += "<tr><td width=7% noWrap><font size='2'>" + get_lang('Sent by') + ": </font></td><td><font size='2'>"+sender+"</font></td></tr>"; |
---|
[2] | 4358 | if(from) |
---|
[197] | 4359 | html += "<tr><td width=7%><font size='2'>" + get_lang('From') + ": </font></td><td><font size='2'>"+from+"</font></td></tr>"; |
---|
[2] | 4360 | if(to) { |
---|
| 4361 | if(!printListTO) |
---|
| 4362 | to = 'Os destinatários não estão sendo exibidos para esta impressão'; |
---|
[197] | 4363 | html += "<tr><td width=7%><font size='2'>" + get_lang('To') + ": </font></td><td><font size='2'>"+to+"</font></td></tr>"; |
---|
[3035] | 4364 | } |
---|
[2] | 4365 | if (cc) { |
---|
| 4366 | if(!printListCC) |
---|
| 4367 | cc = 'Os destinatários não estão sendo exibidos para esta impressão'; |
---|
[197] | 4368 | html += "<tr><td width=7%><font size='2'>" + get_lang('Cc') + ": </font></td><td><font size='2'>"+cc+"</font></td></tr>"; |
---|
[2] | 4369 | } |
---|
[3342] | 4370 | if (cco) { |
---|
| 4371 | if(!printListCCO) |
---|
| 4372 | cco = 'Os destinatários não estão sendo exibidos para esta impressão'; |
---|
| 4373 | html += "<tr><td width=7%><font size='2'>" + get_lang('Cco') + ": </font></td><td><font size='2'>"+cco+"</font></td></tr>"; |
---|
| 4374 | } |
---|
[2] | 4375 | if(date) |
---|
[3035] | 4376 | html += "<tr><td width=7%><font size='2'>" + get_lang('Date') + ": </font></td><td><font size='2'>"+date.innerHTML+"</font></td></tr>"; |
---|
[4783] | 4377 | |
---|
[197] | 4378 | html += "<tr><td width=7%><font size='2'>" + get_lang('Subject')+ ": </font></td><td><font size='2'>"+subject.innerHTML+"</font></td></tr>"; |
---|
[4783] | 4379 | //html += show_attachs; //to show the names of the attachments |
---|
| 4380 | if (countAtt > 0) { |
---|
| 4381 | html += "<tr><td width=7%><font size='2'>" + get_lang('Attachments: ') + "</font></td><td><font size='2'>"+att+"</font></td></tr>"; |
---|
| 4382 | } |
---|
[2] | 4383 | html += "</tbody></table><hr>"; |
---|
[4757] | 4384 | window_print.document.write(html + body.innerHTML); |
---|
[5134] | 4385 | |
---|
[3035] | 4386 | var tab_tags = window_print.document.getElementsByTagName("IMG"); |
---|
[5134] | 4387 | var link = location.href.replace(/\/expressoMail1_2\/(.*)/, ""); |
---|
[2] | 4388 | for(var i = 0; i < tab_tags.length;i++){ |
---|
[5134] | 4389 | var _img = tab_tags[i].cloneNode(true); |
---|
| 4390 | if(tab_tags[i].src.toUpperCase().indexOf('INC/GET_ARCHIVE.PHP?MSGFOLDER=') > -1) |
---|
| 4391 | _img.src = link + '/expressoMail1_2/'+tab_tags[i].src.substr(tab_tags[i].src.toUpperCase().indexOf('INC/GET_ARCHIVE.PHP?MSGFOLDER=')); |
---|
| 4392 | |
---|
[2] | 4393 | tab_tags[i].parentNode.replaceChild(_img,tab_tags[i]); |
---|
| 4394 | } |
---|
[5134] | 4395 | |
---|
[2] | 4396 | break; |
---|
| 4397 | } |
---|
| 4398 | catch(e){ |
---|
| 4399 | //alert(e.message); |
---|
| 4400 | } |
---|
| 4401 | } |
---|
| 4402 | window_print.document.close(); |
---|
| 4403 | window_print.print(); |
---|
| 4404 | } |
---|
| 4405 | |
---|
[7414] | 4406 | function empty_trash_imap(shared, button, type){ |
---|
[6930] | 4407 | if(shared){ |
---|
| 4408 | var folder_part = $(button).parents("li:first").attr("id").split(cyrus_delimiter); |
---|
| 4409 | var folder = folder_part[0]+cyrus_delimiter+folder_part[1]; |
---|
| 4410 | } |
---|
| 4411 | |
---|
[2] | 4412 | var handler_empty_trash = function(data){ |
---|
| 4413 | Element('chk_box_select_all_messages').checked = false; |
---|
| 4414 | if(!verify_session(data)) |
---|
| 4415 | return; |
---|
[5486] | 4416 | //tree_folders.getNodeById(mount_url_folder(["INBOX",special_folders["Trash"]])).alter({caption: get_lang("Trash")}); |
---|
| 4417 | //tree_folders.getNodeById(mount_url_folder(["INBOX",special_folders["Trash"]]))._refresh(); |
---|
[325] | 4418 | update_quota(get_current_folder()); |
---|
[5486] | 4419 | draw_new_tree_folder(); |
---|
[5703] | 4420 | draw_tree_labels(); |
---|
[3018] | 4421 | if (data){ |
---|
[6930] | 4422 | if(typeof(data) == "object"){ |
---|
| 4423 | if(data[1] == "Permission denied"){ |
---|
| 4424 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 4425 | return write_msg(get_lang("Permission denied")); |
---|
| 4426 | } |
---|
| 4427 | } |
---|
[2] | 4428 | write_msg(get_lang('Your Trash folder was empty.')); |
---|
[7708] | 4429 | if (get_current_folder() == mount_url_folder(["INBOX",special_folders["Trash"]]) || get_current_folder() == mount_url_folder([folder,special_folders["Trash"]])){ |
---|
[3018] | 4430 | draw_paging(0); |
---|
[7742] | 4431 | totalFolderMsgs = 0; |
---|
| 4432 | updateSelectedMsgs(); |
---|
[5134] | 4433 | remove_rows(document.getElementById("table_box")); |
---|
[3018] | 4434 | Element('tot_m').innerHTML = 0; |
---|
| 4435 | Element('new_m').innerHTML = 0; |
---|
| 4436 | } |
---|
[7716] | 4437 | refresh(); |
---|
[3018] | 4438 | } |
---|
[2] | 4439 | else |
---|
| 4440 | write_msg(get_lang('ERROR emptying your Trash folder.')); |
---|
| 4441 | } |
---|
[5440] | 4442 | |
---|
[6175] | 4443 | $.Zebra_Dialog(get_lang('Do you really want to empty your trash folder?'), { |
---|
| 4444 | 'type': 'question', |
---|
| 4445 | 'title': get_lang('Empty Trash'), |
---|
| 4446 | 'buttons': [get_lang("Yes"), get_lang("No")], |
---|
| 4447 | 'overlay_opacity' : 0.5, |
---|
[7612] | 4448 | 'custom_class': 'custom-zebra-filter', |
---|
[6175] | 4449 | 'onClose': function(caption) { |
---|
[7414] | 4450 | |
---|
[6175] | 4451 | if(caption == get_lang("Yes")){ |
---|
[7718] | 4452 | if(type && (type.id == "local_messages_trash")){ |
---|
[7414] | 4453 | expresso_mail_archive.deleteAllMessages(type.id); |
---|
| 4454 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 4455 | } else { |
---|
| 4456 | cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultTrashFolder"+(shared ? "&shared="+folder : ""), handler_empty_trash); |
---|
| 4457 | } |
---|
[6175] | 4458 | } |
---|
| 4459 | } |
---|
[5440] | 4460 | }); |
---|
[2] | 4461 | } |
---|
| 4462 | |
---|
[7414] | 4463 | function empty_spam_imap(shared, button, type){ |
---|
[6930] | 4464 | if(shared){ |
---|
| 4465 | var folder_part = $(button).parents("li:first").attr("id").split(cyrus_delimiter); |
---|
| 4466 | var folder = folder_part[0]+cyrus_delimiter+folder_part[1]; |
---|
| 4467 | } |
---|
[1965] | 4468 | var handler_empty_spam = function(data){ |
---|
| 4469 | Element('chk_box_select_all_messages').checked = false; |
---|
| 4470 | if(!verify_session(data)) |
---|
| 4471 | return; |
---|
[7708] | 4472 | if (get_current_folder() == mount_url_folder(["INBOX",special_folders["Spam"]]) || get_current_folder() == mount_url_folder([folder,special_folders["Spam"]])){ |
---|
[1965] | 4473 | draw_paging(0); |
---|
[5134] | 4474 | remove_rows(document.getElementById("table_box")); |
---|
[1965] | 4475 | } |
---|
[5486] | 4476 | //tree_folders.getNodeById(mount_url_folder(["INBOX",special_folders["Spam"]])).alter({caption: get_lang("Spam")}); |
---|
| 4477 | //tree_folders.getNodeById(mount_url_folder(["INBOX",special_folders["Spam"]]))._refresh(); |
---|
| 4478 | draw_new_tree_folder(); |
---|
[5703] | 4479 | draw_tree_labels(); |
---|
[1965] | 4480 | update_quota(get_current_folder()); |
---|
[6930] | 4481 | if (data){ |
---|
| 4482 | if(typeof(data) == "object"){ |
---|
| 4483 | if(data[1] == "Permission denied"){ |
---|
| 4484 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 4485 | return write_msg(get_lang("Permission denied")); |
---|
| 4486 | }else{ |
---|
| 4487 | write_msg(get_lang('Your Spam folder was empty.')); |
---|
| 4488 | } |
---|
| 4489 | }else{ |
---|
| 4490 | write_msg(get_lang('Your Spam folder was empty.')); |
---|
| 4491 | } |
---|
[7716] | 4492 | refresh(); |
---|
[6930] | 4493 | } |
---|
[1965] | 4494 | else |
---|
| 4495 | write_msg(get_lang('ERROR emptying your Spam folder.')); |
---|
| 4496 | } |
---|
[5486] | 4497 | |
---|
[6175] | 4498 | $.Zebra_Dialog(get_lang('Do you really want to empty your spam folder?'), { |
---|
| 4499 | 'type': 'question', |
---|
| 4500 | 'title': get_lang('Empty Spam'), |
---|
| 4501 | 'buttons': [get_lang("Yes"), get_lang("No")], |
---|
| 4502 | 'overlay_opacity' : 0.5, |
---|
[7612] | 4503 | 'custom_class': 'custom-zebra-filter', |
---|
[6175] | 4504 | 'onClose': function(caption) { |
---|
| 4505 | if(caption == get_lang("Yes")){ |
---|
[7414] | 4506 | if(type.id == "local_messages_spam"){ |
---|
| 4507 | expresso_mail_archive.deleteAllMessages(type.id); |
---|
| 4508 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 4509 | } else { |
---|
| 4510 | cExecute ("$this.imap_functions.empty_folder&clean_folder="+"imapDefaultSpamFolder"+(shared ? "&shared="+folder : ""), handler_empty_spam); |
---|
| 4511 | } |
---|
[6175] | 4512 | } |
---|
| 4513 | } |
---|
[5486] | 4514 | }); |
---|
[1965] | 4515 | } |
---|
| 4516 | |
---|
[7414] | 4517 | function buildExportArchiver(msgsArchive, name_box){ |
---|
[1965] | 4518 | |
---|
[7414] | 4519 | var hand_export = function(data){ |
---|
| 4520 | if(!data){ |
---|
| 4521 | write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.')) |
---|
| 4522 | }else if(data["empty_folder"] || data == "empty_folder"){ |
---|
| 4523 | write_msg(get_lang("The selected folder is empty.")); |
---|
| 4524 | }else |
---|
| 4525 | download_attachments(null, null, data, null,null, get_current_folder().split("_")[2] +'.zip'); |
---|
| 4526 | } |
---|
| 4527 | |
---|
| 4528 | var array = new Array(); |
---|
| 4529 | |
---|
| 4530 | for(var i =0; i < msgsArchive.length; i++){ |
---|
| 4531 | eachMsg = { |
---|
| 4532 | 'ContentType' : msgsArchive[i].ContentType, |
---|
| 4533 | 'from' : { 'email' : msgsArchive[i].from.email, 'full' : msgsArchive[i].from.full, 'name' : msgsArchive[i].from.name}, |
---|
| 4534 | 'msg_sample' : msgsArchive[i].msg_sample, |
---|
| 4535 | 'subject' : msgsArchive[i].subject, |
---|
| 4536 | 'to' : { 'email' : msgsArchive[i].to.email, 'full' : msgsArchive[i].to.full, 'name' : msgsArchive[i].to.name}, |
---|
| 4537 | 'toaddress2' : msgsArchive[i].toaddress2, |
---|
| 4538 | 'msg_number' : msgsArchive[i].msg_number, |
---|
| 4539 | 'date' : new Date(msgsArchive[i].timestamp).toString() |
---|
| 4540 | }; |
---|
| 4541 | array.push(eachMsg); |
---|
| 4542 | } |
---|
| 4543 | |
---|
| 4544 | $.ajax({ |
---|
| 4545 | type: "POST", |
---|
| 4546 | url: "controller.php?action=$this.exporteml.export_all_byLocalFolder", |
---|
| 4547 | data: { folder: name_box, type: "msg_local", messages : array} |
---|
| 4548 | }).done(function(msg) { |
---|
| 4549 | hand_export(msg.split('"')[1]); |
---|
| 4550 | }); |
---|
| 4551 | } |
---|
| 4552 | |
---|
[2] | 4553 | function export_all_selected_msgs(){ |
---|
[7414] | 4554 | if(get_current_folder().split("_")[0] == "local"){ |
---|
| 4555 | |
---|
| 4556 | if(get_selected_messages().indexOf(",") != -1){ |
---|
| 4557 | expresso_mail_archive.getSomeMsgs(get_selected_messages().split(",")); |
---|
| 4558 | } else { |
---|
| 4559 | expresso_mail_archive.getSomeMsgs([get_selected_messages()]); |
---|
| 4560 | } |
---|
| 4561 | |
---|
| 4562 | buildExportArchiver(expresso_mail_archive.getSomeMsg, get_current_folder().split("_")[2]); |
---|
| 4563 | |
---|
| 4564 | } else { |
---|
| 4565 | |
---|
| 4566 | if (openTab.type[currentTab] > 1){ |
---|
[6283] | 4567 | source_msg(currentTab,openTab.imapBox[currentTab]); |
---|
[4757] | 4568 | return; |
---|
[827] | 4569 | } |
---|
[5178] | 4570 | var search = false; |
---|
[3035] | 4571 | |
---|
[5172] | 4572 | if(currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
[5178] | 4573 | var id_border = currentTab.replace(/[a-zA-Z_]+/, ""); |
---|
[5172] | 4574 | var msgs_to_export = this.get_selected_messages_search(); |
---|
| 4575 | if (!msgs_to_export){ |
---|
| 4576 | write_msg(get_lang('No selected message.')); |
---|
| 4577 | return; |
---|
| 4578 | } |
---|
| 4579 | var selected_param = ""; |
---|
| 4580 | msgs_to_export = msgs_to_export.split(","); |
---|
| 4581 | search = true; |
---|
| 4582 | for (i = 0; i < msgs_to_export.length; i++){ |
---|
| 4583 | var tr = Element(msgs_to_export[i]+'_s'+id_border); |
---|
[8039] | 4584 | msg_to_move = (tr.getAttribute('name') == null ? get_current_folder() : tr.getAttribute('name')); |
---|
[5172] | 4585 | selected_param += ','+msg_to_move+';'+tr.id.replace(/_[a-zA-Z0-9]+/,""); |
---|
| 4586 | } |
---|
| 4587 | }else{ |
---|
| 4588 | var msgs_to_export = this.get_selected_messages(); |
---|
| 4589 | } |
---|
[2] | 4590 | var handler_export_all_selected_msgs = function(data){ |
---|
[3035] | 4591 | |
---|
[2] | 4592 | if(!data){ |
---|
| 4593 | write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.')); |
---|
| 4594 | } |
---|
[5134] | 4595 | else{ |
---|
| 4596 | var filename = 'mensagens.zip'; |
---|
[6860] | 4597 | if (data[0].match(/\.eml$/gi)) { |
---|
| 4598 | filename = data[1]+'.eml'; |
---|
[5134] | 4599 | } |
---|
[8039] | 4600 | |
---|
| 4601 | if(typeof data == "object") |
---|
| 4602 | download_attachments(null, null, data[0], null,null,filename); |
---|
| 4603 | else |
---|
| 4604 | download_attachments(null, null, data, null,null,filename); |
---|
[5134] | 4605 | } |
---|
[2] | 4606 | } |
---|
[3035] | 4607 | |
---|
[5172] | 4608 | if(search){ |
---|
| 4609 | cExecute ("$this.exporteml.makeAll", handler_export_all_selected_msgs, "folder=false&msgs_to_export="+selected_param); |
---|
| 4610 | }else if (msgs_to_export) { |
---|
[2] | 4611 | cExecute ("$this.exporteml.makeAll", handler_export_all_selected_msgs, "folder="+get_current_folder()+"&msgs_to_export="+msgs_to_export); |
---|
[53] | 4612 | write_msg(get_lang('You must wait while the messages will be exported...')); |
---|
[2] | 4613 | } |
---|
| 4614 | else |
---|
| 4615 | write_msg(get_lang('No selected message.')); |
---|
[7414] | 4616 | } |
---|
[2] | 4617 | } |
---|
| 4618 | |
---|
[5134] | 4619 | function select_all_search_messages(select, aba){ |
---|
| 4620 | |
---|
[5588] | 4621 | if(select){ |
---|
| 4622 | jQuery("#"+aba+" tr").each(function(i, o) { |
---|
| 4623 | |
---|
| 4624 | o.firstChild.firstChild.checked = true; |
---|
| 4625 | add_className(o, 'selected_msg'); |
---|
| 4626 | }); |
---|
| 4627 | }else{ |
---|
| 4628 | jQuery("#"+aba+" tr").each(function(i, o) { |
---|
| 4629 | |
---|
| 4630 | o.firstChild.firstChild.checked = false; |
---|
| 4631 | remove_className(o, 'selected_msg'); |
---|
| 4632 | }); |
---|
| 4633 | } |
---|
[156] | 4634 | } |
---|
| 4635 | |
---|
[2] | 4636 | function verify_session(data){ |
---|
[504] | 4637 | |
---|
[2] | 4638 | if(data && data.imap_error) { |
---|
[504] | 4639 | if(data.imap_error == "nosession") |
---|
| 4640 | write_msg(get_lang("your session could not be verified.")); |
---|
| 4641 | else |
---|
| 4642 | write_msg(data.imap_error); |
---|
| 4643 | // Hold sesion for edit message. |
---|
| 4644 | //if(!hold_session) |
---|
[3035] | 4645 | // location.href="../login.php?cd=10&phpgw_forward=%2FexpressoMail1_2%2Findex.php"; |
---|
[2] | 4646 | return false; |
---|
| 4647 | } |
---|
| 4648 | else |
---|
| 4649 | return true; |
---|
| 4650 | } |
---|
| 4651 | |
---|
| 4652 | // Save image file. |
---|
[1005] | 4653 | function save_image(e,thumb,file_type){ |
---|
| 4654 | file_type = file_type.replace("/","."); |
---|
[2] | 4655 | thumb.oncontextmenu = function(e) { |
---|
| 4656 | return false; |
---|
| 4657 | } |
---|
| 4658 | var _button = is_ie ? window.event.button : e.which; |
---|
| 4659 | var _target = is_ie ? event.srcElement : e.target; |
---|
[3035] | 4660 | |
---|
[2] | 4661 | if(_button == 2 || _button == 3) { |
---|
| 4662 | var _params = _target.id.split(";;"); |
---|
[7145] | 4663 | download_attachments(Base64.encode(_params[0]),_params[1],_params[2],_params[3],_params[4],file_type); |
---|
[7414] | 4664 | if($(_target).parent().attr("href").split("http").length > 1){ |
---|
| 4665 | var part_find = thumb.toString().split("#"); |
---|
| 4666 | var part2_find = part_find[1].split("/temp"); |
---|
| 4667 | var part_id_dwl = part2_find[0] + '/temp/download' + part2_find[1]; |
---|
| 4668 | download_local_attachment(part_id_dwl); |
---|
| 4669 | return; |
---|
| 4670 | }else{ |
---|
| 4671 | var _params = _target.id.split(";;"); |
---|
| 4672 | download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type); |
---|
| 4673 | } |
---|
[2] | 4674 | } |
---|
[69] | 4675 | } |
---|
[7414] | 4676 | |
---|
[5134] | 4677 | function save_image2(info){ |
---|
| 4678 | var obj = jQuery.parseJSON(unescape(info)); |
---|
| 4679 | download_attachments(obj.folder, obj.message, obj.thumbIndex, obj.pid, obj.encoding, obj.type.replace("/",".")); |
---|
| 4680 | } |
---|
[69] | 4681 | |
---|
[75] | 4682 | function nospam(msgs_number, border_ID, folder){ |
---|
| 4683 | if (folder == 'null') |
---|
| 4684 | folder = get_current_folder(); |
---|
[5134] | 4685 | var new_folder = ''; |
---|
| 4686 | if(folder.substr(0,4) == 'user'){ |
---|
| 4687 | arrayFolder = folder.split(cyrus_delimiter); |
---|
| 4688 | new_folder = 'user'+cyrus_delimiter+arrayFolder[1]; |
---|
| 4689 | } |
---|
| 4690 | else{ |
---|
| 4691 | new_folder = 'INBOX'; |
---|
| 4692 | } |
---|
[69] | 4693 | var new_folder_name = get_lang('INBOX'); |
---|
| 4694 | var handler_move_msgs = function(data){ |
---|
[3035] | 4695 | if (msgs_number == 'selected') |
---|
[75] | 4696 | set_messages_flag("unseen", "get_selected_messages"); |
---|
| 4697 | else |
---|
[1121] | 4698 | proxy_mensagens.proxy_set_message_flag(msgs_number, "unseen"); |
---|
[3035] | 4699 | proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name); |
---|
[3693] | 4700 | |
---|
| 4701 | if (openTab.type[currentTab] > 1) |
---|
| 4702 | delete_border(currentTab,'false'); |
---|
[69] | 4703 | } |
---|
| 4704 | |
---|
[3693] | 4705 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 4706 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
| 4707 | else if(msgs_number == 'selected') |
---|
| 4708 | msgs_number = get_selected_messages(); |
---|
[3035] | 4709 | |
---|
[6930] | 4710 | //TODO: REFATORAR O CÓDIGO PARA EVITAR recodificação |
---|
| 4711 | if(currentTab == 0) |
---|
| 4712 | msgs_number = get_selected_messages(); |
---|
[7321] | 4713 | if (typeof currentTab == "string" && currentTab.indexOf("search_") != "-1"){ |
---|
| 4714 | msgs_number = ""; |
---|
| 4715 | var checked = $("#divScrollMain_"+currentTab.substr(currentTab.indexOf('_')+1,255)).find("tr input:checked"); |
---|
| 4716 | $.each(checked,function(index,value){ |
---|
| 4717 | if (value){ |
---|
| 4718 | if (index == 0) |
---|
| 4719 | msgs_number = $(value).parents("tr").attr("id"); |
---|
| 4720 | else |
---|
| 4721 | msgs_number += "," + $(value).parents("tr").attr("id"); |
---|
| 4722 | } |
---|
| 4723 | }); |
---|
| 4724 | } |
---|
[69] | 4725 | if (parseInt(msgs_number) > 0 || msgs_number.length > 0) |
---|
[5134] | 4726 | 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] | 4727 | else |
---|
[75] | 4728 | write_msg(get_lang('No selected message.')); |
---|
[69] | 4729 | } |
---|
| 4730 | |
---|
| 4731 | function spam(folder, msgs_number, border_ID){ |
---|
| 4732 | if (folder == 'null') |
---|
| 4733 | folder = get_current_folder(); |
---|
[5134] | 4734 | var new_folder = ''; |
---|
| 4735 | if(folder.substr(0,4) == 'user') |
---|
| 4736 | { |
---|
| 4737 | arrayFolder = folder.split(cyrus_delimiter); |
---|
[5211] | 4738 | new_folder = 'user'+cyrus_delimiter+arrayFolder[1]+cyrus_delimiter+special_folders['Spam']; |
---|
[5134] | 4739 | } |
---|
| 4740 | else |
---|
| 4741 | { |
---|
[5306] | 4742 | new_folder = mount_url_folder(["INBOX",special_folders["Spam"]]); |
---|
[5134] | 4743 | } |
---|
[69] | 4744 | var new_folder_name = 'Spam'; |
---|
[5134] | 4745 | var not_opem_previus = true; |
---|
[69] | 4746 | var handler_move_msgs = function(data){ |
---|
[5134] | 4747 | proxy_mensagens.proxy_move_messages(folder, msgs_number, border_ID, new_folder, new_folder_name, not_opem_previus); |
---|
| 4748 | if (openTab.type[currentTab] > 1){ |
---|
| 4749 | if(preferences.delete_and_show_previous_message == 1) |
---|
[3693] | 4750 | delete_border(currentTab,'false'); |
---|
[69] | 4751 | } |
---|
[5134] | 4752 | } |
---|
[3693] | 4753 | |
---|
| 4754 | if(currentTab.toString().indexOf("_r") != -1) |
---|
| 4755 | msgs_number = currentTab.toString().substr(0,currentTab.toString().indexOf("_r")); |
---|
[5172] | 4756 | else if(currentTab != 0 && currentTab.indexOf("search_") >= 0){ |
---|
[5306] | 4757 | var content_search = document.getElementById('content_id_'+currentTab);mount_url_folder(["INBOX",special_folders['Trash']]), 'Trash', |
---|
| 4758 | move_search_msgs('content_id_'+currentTab, mount_url_folder(["INBOX",special_folders["Spam"]]), special_folders['Spam']); |
---|
[5172] | 4759 | refresh(); |
---|
| 4760 | return; |
---|
| 4761 | }else if(msgs_number == 'selected') |
---|
[69] | 4762 | msgs_number = get_selected_messages(); |
---|
[3693] | 4763 | |
---|
[6930] | 4764 | //TODO: REFATORAR O CÓDIGO PARA EVITAR recodificação |
---|
| 4765 | if(currentTab == 0) |
---|
| 4766 | msgs_number = get_selected_messages(); |
---|
| 4767 | |
---|
[69] | 4768 | if(parseInt(msgs_number) > 0 || msgs_number.length > 0) |
---|
[5134] | 4769 | 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] | 4770 | else |
---|
[3035] | 4771 | write_msg(get_lang('No selected message.')); |
---|
[271] | 4772 | } |
---|
[660] | 4773 | |
---|
[5858] | 4774 | function import_window() |
---|
| 4775 | { |
---|
[7427] | 4776 | if(typeof (currentTab) == "string" && currentTab.indexOf("local") != -1){ |
---|
[7426] | 4777 | alert("Impossível manipular mensagens locais a partir de uma busca. Isso é permitido apenas para mensagens não locais."); |
---|
| 4778 | return true; |
---|
| 4779 | } |
---|
[5887] | 4780 | var folder = {}; |
---|
[5858] | 4781 | var importEmails = $("#importEmails"); |
---|
| 4782 | importEmails.html( DataLayer.render( BASE_PATH + "modules/mail/templates/importEmails.ejs", {})); |
---|
| 4783 | importEmails.dialog( |
---|
| 4784 | { |
---|
| 4785 | height : 280, |
---|
| 4786 | width : 500, |
---|
| 4787 | resizable : false, |
---|
| 4788 | title : get_lang('zip mails to import'), |
---|
| 4789 | modal : true, |
---|
| 4790 | buttons : [ |
---|
| 4791 | { |
---|
| 4792 | text : get_lang("Close"), |
---|
| 4793 | click : function() |
---|
| 4794 | { |
---|
[6910] | 4795 | importEmails.dialog("close").dialog("destroy"); |
---|
[5858] | 4796 | } |
---|
| 4797 | }, |
---|
| 4798 | { |
---|
| 4799 | text : get_lang("Import"), |
---|
| 4800 | click : function() |
---|
| 4801 | { |
---|
| 4802 | var input_file = importEmails.find("input[type=file]"); |
---|
| 4803 | var input_hidden = importEmails.find("input[name=folder]"); |
---|
| 4804 | |
---|
| 4805 | if( input_file.attr("value") == "" ) |
---|
| 4806 | { |
---|
| 4807 | $.Zebra_Dialog(get_lang("You must choose a file") + " !",{ |
---|
| 4808 | 'type' : 'warning', |
---|
| 4809 | 'overlay_opacity' : '0.5', |
---|
[7612] | 4810 | 'custom_class': 'custom-zebra-filter', |
---|
[7744] | 4811 | 'buttons' : [get_lang("Close")], |
---|
[5858] | 4812 | 'onClose' : function(){ |
---|
| 4813 | $("#importMessageAccordion").accordion('activate',0); |
---|
| 4814 | } |
---|
| 4815 | }); |
---|
| 4816 | } |
---|
| 4817 | else |
---|
| 4818 | { |
---|
| 4819 | if( input_hidden.attr("value") == "" ) |
---|
| 4820 | $.Zebra_Dialog( get_lang("You must choose a folder") + " !" , { |
---|
| 4821 | 'type' : 'warning', |
---|
| 4822 | 'overlay_opacity' : '0.5', |
---|
[7612] | 4823 | 'custom_class': 'custom-zebra-filter', |
---|
[7744] | 4824 | 'buttons' : [get_lang("Close")], |
---|
[5858] | 4825 | 'onClose' : function(){ |
---|
| 4826 | $("#importMessageAccordion").accordion('activate',1); |
---|
| 4827 | } |
---|
| 4828 | }); |
---|
| 4829 | else |
---|
| 4830 | { |
---|
| 4831 | var handler_return = function(data) |
---|
| 4832 | { |
---|
[7563] | 4833 | write_msg(get_lang('The import was executed successfully.')); |
---|
[5887] | 4834 | return_import_msgs( data, folder ); |
---|
[7563] | 4835 | if(typeof(shortcut) != 'undefined') shortcut.disabled = false; |
---|
[5858] | 4836 | } |
---|
[5887] | 4837 | |
---|
[5858] | 4838 | var formSend = document.getElementById("importFileMessages"); |
---|
| 4839 | |
---|
[5886] | 4840 | importEmails.dialog("destroy"); |
---|
| 4841 | |
---|
[5858] | 4842 | write_msg(get_lang('You must wait while the messages will be imported...')); |
---|
| 4843 | |
---|
[8113] | 4844 | var local_folder = input_hidden.attr("value"); //recupera a pasta selecionada |
---|
| 4845 | if(local_folder.indexOf("local_") == 0){ //verifica se a pasta selecionada é uma pasta local |
---|
| 4846 | |
---|
| 4847 | var fdata = local_folder.substr(15, local_folder.length); //recupera somente a estrutura da pasta ou o id |
---|
| 4848 | expresso_mail_archive.getFolderInfo(fdata); //recuperar a estrutura da pasta, |
---|
| 4849 | //para realizar a importação de mensagens |
---|
| 4850 | fdata = expresso_mail_archive.folder.path; |
---|
| 4851 | |
---|
| 4852 | //o mailarchiver não provê um serviço para a importação de mensagens nas pastas locais, |
---|
| 4853 | //mas sim uma modal, da qual são extraídas as informações e as urls para submitar os dados |
---|
| 4854 | //para o arquivamento de mensagens em pastas locais. |
---|
| 4855 | var url_src = mail_archive_protocol + '://' + mail_archive_host + ':' + mail_archive_port + '/arcserv/import?prt=' + mail_archive_protocol + '&por=' + mail_archive_port+ '&fid='+ encodeURIComponent(fdata) + '&sid=' + expresso_mail_archive.session.id; |
---|
| 4856 | var _html = DataLayer.render(url_src); |
---|
| 4857 | var regex_url = RegExp('\<iframe(.)*src=\"([^\"]*)"(.)*\>'); |
---|
| 4858 | var obj_params = $.parseQuery( regex_url.exec(_html)[2].split('?')[1] || '' ); |
---|
| 4859 | $(formSend).append('<input id="ma_import_flat" type="checkbox" value="false" name="flat" style="display:none"> ' + |
---|
| 4860 | '<input id="sessionId" type="hidden" value="'+obj_params['sessvalue']+'" name="sessionId">' + |
---|
| 4861 | '<input id="base" type="hidden" value="'+obj_params['basevalue']+'" name="base">' + |
---|
| 4862 | '<input id="lang" type="hidden" value="'+obj_params['langvalue']+'" name="lang">'); |
---|
| 4863 | |
---|
| 4864 | var importEmailsLocalDialog = $('#importEmailsLocal'); |
---|
| 4865 | importEmailsLocalDialog.css("overflow","hidden"); |
---|
| 4866 | importEmailsLocalDialog.dialog( |
---|
| 4867 | { |
---|
| 4868 | autoOpen : false, |
---|
| 4869 | height : 200, |
---|
| 4870 | width : 350, |
---|
| 4871 | resizable : false, |
---|
| 4872 | title : get_lang('Local Archive'), |
---|
| 4873 | modal : true, |
---|
| 4874 | buttons : [ |
---|
| 4875 | { |
---|
| 4876 | text : get_lang("Close"), |
---|
| 4877 | click : function() |
---|
| 4878 | { |
---|
| 4879 | importEmailsLocalDialog.dialog("close").dialog("destroy"); |
---|
| 4880 | } |
---|
| 4881 | } |
---|
| 4882 | ] |
---|
| 4883 | }); |
---|
| 4884 | |
---|
| 4885 | importEmailsLocalDialog.html('<iframe frameborder="0" scrolling="no" id="frameResult" name="frameResult" ></iframe>') |
---|
| 4886 | $(formSend).attr("action", mail_archive_protocol + '://' + mail_archive_host + ':' + mail_archive_port + '/arcserv/import'); |
---|
| 4887 | $(formSend).attr("target", "frameResult"); |
---|
| 4888 | $(formSend).submit(); |
---|
| 4889 | importEmailsLocalDialog.dialog( "open" ); |
---|
| 4890 | if(typeof(shortcut) != 'undefined') |
---|
| 4891 | shortcut.disabled = false; |
---|
| 4892 | } else { |
---|
| 4893 | cExecuteForm('$this.imap_functions.import_msgs', formSend , handler_return ); |
---|
| 4894 | } |
---|
| 4895 | |
---|
[5858] | 4896 | } |
---|
| 4897 | } |
---|
| 4898 | } |
---|
| 4899 | } |
---|
[6910] | 4900 | ], |
---|
| 4901 | open: function(event, ui) |
---|
| 4902 | { |
---|
| 4903 | if(typeof(shortcut) != 'undefined') shortcut.disabled = true; |
---|
| 4904 | }, |
---|
| 4905 | close: function(event, ui) |
---|
| 4906 | { |
---|
| 4907 | if(typeof(shortcut) != 'undefined') shortcut.disabled = false; |
---|
[7563] | 4908 | }, |
---|
| 4909 | destroy: function(event,ui) |
---|
| 4910 | { |
---|
| 4911 | if(typeof(shortcut) != 'undefined') shortcut.disabled = false; |
---|
[6910] | 4912 | } |
---|
[5858] | 4913 | }); |
---|
| 4914 | |
---|
| 4915 | importEmails.css("overflow","hidden"); |
---|
| 4916 | |
---|
| 4917 | importEmails.find("input[type=file]").change(function() |
---|
| 4918 | { |
---|
| 4919 | var deniedExtension = true; |
---|
| 4920 | var fileExtension = ["eml","zip"]; |
---|
| 4921 | var fileName = importEmails.find("input[type=file]").attr('value'); |
---|
| 4922 | fileName = fileName.split("."); |
---|
| 4923 | |
---|
| 4924 | if( fileName[1] ) |
---|
| 4925 | { |
---|
| 4926 | for( var i in fileExtension ) |
---|
| 4927 | { |
---|
| 4928 | if( fileExtension[i].toUpperCase() === fileName[1].toUpperCase() ) |
---|
| 4929 | { |
---|
| 4930 | deniedExtension = false; |
---|
| 4931 | break; |
---|
| 4932 | } |
---|
| 4933 | } |
---|
| 4934 | } |
---|
| 4935 | |
---|
| 4936 | if( deniedExtension ) |
---|
| 4937 | { |
---|
| 4938 | $.Zebra_Dialog( get_lang('File extension forbidden or invalid file') , { |
---|
| 4939 | 'type' : 'warning', |
---|
[7612] | 4940 | 'overlay_opacity' : '0.5', |
---|
[7744] | 4941 | 'custom_class': 'custom-zebra-filter', |
---|
| 4942 | 'buttons' : [get_lang("Close")], |
---|
[5858] | 4943 | }); |
---|
| 4944 | } |
---|
| 4945 | |
---|
| 4946 | $("#lblFileName").html( ( !deniedExtension ) ? importEmails.find("input[type=file]").attr('value') : "" ); |
---|
| 4947 | |
---|
| 4948 | }); |
---|
| 4949 | |
---|
| 4950 | $("#importMessageAccordion").accordion(); |
---|
| 4951 | |
---|
| 4952 | var foldersTree = jQuery("#foldertree-container-importMessage") |
---|
| 4953 | .removeClass('empty-container') |
---|
[8113] | 4954 | .html(DataLayer.render(BASE_PATH + 'api/templates/foldertree.ejs', {folders: [cp_tree1, cp_tree2, cp_tree3, [] ]})) |
---|
[5858] | 4955 | .find("#foldertree").treeview() |
---|
| 4956 | .click(function(event) |
---|
| 4957 | { |
---|
| 4958 | //request new selected folder messages |
---|
| 4959 | var target = $(event.target); |
---|
| 4960 | |
---|
| 4961 | if( target.is('.collapsable-hitarea, .expandable-hitarea, .lastCollapsable, .lastExpandable, .treeview') ) |
---|
| 4962 | return; |
---|
| 4963 | |
---|
| 4964 | if( !target.attr('id') ) |
---|
| 4965 | target = target.parent(); |
---|
| 4966 | |
---|
| 4967 | if (target.attr('id') == "foldertree") return; |
---|
| 4968 | |
---|
[5887] | 4969 | folder.id = target.attr('id'); |
---|
| 4970 | folder.child = target.find('.folder'); |
---|
| 4971 | folder.caption = target.find('span').attr('title'); |
---|
[5858] | 4972 | |
---|
[7242] | 4973 | $('#foldertree-container-importMessage .filetree span.folder.selected').removeClass('selected'); |
---|
[5858] | 4974 | if(!target.is('#foldertree > .expandable, #foldertree > .collapsable')) |
---|
| 4975 | $(target).children('.folder').addClass('selected'); |
---|
| 4976 | |
---|
| 4977 | selectedFolder = { |
---|
[5887] | 4978 | id: folder.id, |
---|
| 4979 | name: folder.child.attr('title'), |
---|
| 4980 | 'class': folder.child.attr('class') |
---|
[5858] | 4981 | }; |
---|
| 4982 | |
---|
[5887] | 4983 | importEmails.find("input[name=folder]").attr("value", folder.id); |
---|
[5858] | 4984 | }); |
---|
[5273] | 4985 | |
---|
[5858] | 4986 | $("#lblFileName").prev().css("margin-left", "10px"); |
---|
| 4987 | $("#lblFileName").prev().css("font-weight", "bold"); |
---|
[660] | 4988 | } |
---|
| 4989 | |
---|
[5887] | 4990 | function return_import_msgs(data, folder) |
---|
| 4991 | { |
---|
[660] | 4992 | if(data && data.error){ |
---|
| 4993 | write_msg(data.error); |
---|
| 4994 | } |
---|
[5887] | 4995 | else |
---|
| 4996 | { |
---|
[660] | 4997 | if(data == 'Post-Content-Length') |
---|
[3018] | 4998 | 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] | 4999 | else |
---|
| 5000 | { /* |
---|
[1000] | 5001 | * @author Rommel Cysne (rommel.cysne@serpro.gov.br) |
---|
| 5002 | * @date 2009/05/15 |
---|
| 5003 | * Foi colocado um teste para verificar se a pasta selecionada, passada como parametro, |
---|
| 5004 | * eh uma pasta local (qualquer uma) |
---|
| 5005 | */ |
---|
| 5006 | var er = /^local_/; |
---|
[5887] | 5007 | if ( er.test(folder.id) ) |
---|
[1000] | 5008 | { |
---|
[5134] | 5009 | alert( "Mensagens não podem ser importadas em pastas locais" ); |
---|
| 5010 | //archive_msgs('INBOX/Lixeira/tmpMoveToLocal',wfolders_tree._selected.id,data); |
---|
| 5011 | //cExecute('$this.imap_functions.delete_mailbox',function(){},'del_past=INBOX/Lixeira/tmpMoveToLocal'); |
---|
[660] | 5012 | } |
---|
[5887] | 5013 | else |
---|
| 5014 | { |
---|
| 5015 | if( openTab.imapBox[0] == folder.id ) |
---|
[1000] | 5016 | { |
---|
| 5017 | openTab.imapBox[0] = ''; |
---|
[5887] | 5018 | change_folder(folder.id, folder.caption); |
---|
[1000] | 5019 | } |
---|
[5887] | 5020 | |
---|
| 5021 | refresh(); |
---|
[660] | 5022 | } |
---|
[5887] | 5023 | } |
---|
[660] | 5024 | } |
---|
[1000] | 5025 | |
---|
[660] | 5026 | } |
---|
| 5027 | |
---|
[6996] | 5028 | //Normalização dos dados evita ter que reemplementar toda as funcionalidades do calendar |
---|
| 5029 | function decodeCreateSchedulable(type, ID){ |
---|
| 5030 | var startEvent = new Date(); |
---|
| 5031 | if(startEvent.toString('mm') < 30) |
---|
| 5032 | startEvent.add({minutes: (30 - parseInt(startEvent.toString('mm')))}); |
---|
| 5033 | else |
---|
| 5034 | startEvent.add({hours: 1, minutes: '-'+startEvent.toString('mm')}); |
---|
| 5035 | var endEvent = function(date){ |
---|
| 5036 | if(!!User.preferences.defaultCalendar){ |
---|
| 5037 | return new Date(parseInt(date.getTime()) + |
---|
| 5038 | (!!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ? |
---|
| 5039 | (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration * 60000) : |
---|
| 5040 | (User.preferences.defaultDuration * 60000) |
---|
| 5041 | )); |
---|
| 5042 | }else |
---|
| 5043 | return new Date(parseInt(date.getTime()) + (User.preferences.defaultDuration * 60000)); |
---|
| 5044 | }; |
---|
| 5045 | |
---|
| 5046 | var emails = $("#to_values_"+ID).val().split(','); |
---|
| 5047 | |
---|
| 5048 | var schedulable = {}; |
---|
| 5049 | |
---|
| 5050 | schedulable = { |
---|
| 5051 | acl: {inviteGuests: true, organization: true ,participationRequired: false, read: true, write: true}, |
---|
| 5052 | alarms: [], |
---|
| 5053 | allDay: false, |
---|
| 5054 | attachments: [], |
---|
| 5055 | isAttendee: true, |
---|
| 5056 | attendee: '',//TODOOOOOO, |
---|
| 5057 | category: '', |
---|
| 5058 | 'class': '1', |
---|
| 5059 | delegatedFrom: {}, |
---|
| 5060 | endDate: startEvent.toString(User.preferences.dateFormat), |
---|
| 5061 | startDate: endEvent(startEvent).toString(User.preferences.dateFormat), |
---|
| 5062 | startHour: startEvent.toString(User.preferences.hourFormat), |
---|
| 5063 | endHour: endEvent(startEvent).toString(User.preferences.hourFormat), |
---|
| 5064 | timezone: User.preferences.defaultCalendar ? Calendar.signatureOf[User.preferences.defaultCalendar].calendar.timezone : User.preferences.timezone, |
---|
| 5065 | summary : $("#subject_"+ID).text(), |
---|
| 5066 | description : $("#body_" + ID).text(), |
---|
| 5067 | startTime: startEvent.getTime(), |
---|
| 5068 | endTime: endEvent(startEvent), |
---|
| 5069 | timezones: Timezone.timezones, |
---|
| 5070 | me: {name: User.me.name, mail: User.me.mail, acl: 'rowi', status: '1', delegatedFrom: '0', id: User.me.id}, |
---|
| 5071 | organizer: {name: User.me.name, mail: User.me.mail, acl: 'rowi', status: '1', delegatedFrom: '0' , id: User.me.id}, |
---|
| 5072 | statusParticipants: {accepted: 0, cancelled: 0, tentative: 0, unanswered:emails.length}, |
---|
| 5073 | location: '', |
---|
| 5074 | attendee: $.map(emails, function( mail ){ |
---|
| 5075 | var contact = false; |
---|
| 5076 | var decoded = Encoder.htmlDecode(mail); |
---|
| 5077 | var newAttendeeName = ""; |
---|
| 5078 | |
---|
| 5079 | var name = decoded.match(/"([^"]*)"/) ? decoded.match(/"([^"]*)"/)[1] : ''; |
---|
| 5080 | var mail = decoded.match(/<([^<]*)>[\s]*$/) ? decoded.match(/<([^<]*)>[\s]*$/)[1].toLowerCase() : decoded; |
---|
| 5081 | |
---|
| 5082 | |
---|
| 5083 | var user = DataLayer.get('user', ["=", "mail", mail], true); |
---|
| 5084 | |
---|
| 5085 | if( $.type(user) == "array" ) |
---|
| 5086 | user = user[0]; |
---|
| 5087 | |
---|
| 5088 | if(user != ''){ |
---|
| 5089 | //user = {name : name , mail : mail}; |
---|
| 5090 | if(User.me.mail == user.mail) |
---|
| 5091 | return(null); |
---|
| 5092 | user.isExternal = (!!user && !(!!user.isExternal)) ? 0 : 1; |
---|
| 5093 | |
---|
| 5094 | return DataLayer.merge({ |
---|
| 5095 | name: user.name, |
---|
| 5096 | mail: user.mail, |
---|
| 5097 | acl: 'r', |
---|
| 5098 | delegatedFrom: '0', |
---|
| 5099 | status: '4', |
---|
| 5100 | isExternal: user.isExternal |
---|
| 5101 | }, !!user.id ? {id : DataLayer.put('participant', {user: user.id, isExternal: user.isExternal})} : {id: DataLayer.put('participant', {user: user})}); |
---|
| 5102 | }else if(mail.match(/[\w-]+(\.[\w-]+)*@(([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}\])/)){ |
---|
| 5103 | |
---|
| 5104 | var userId = DataLayer.put('user', { |
---|
| 5105 | name: name, |
---|
| 5106 | mail: mail, |
---|
| 5107 | isExternal: '1' |
---|
| 5108 | }); |
---|
| 5109 | var newAttendeeId = DataLayer.put('participant', { |
---|
| 5110 | user: userId, |
---|
| 5111 | isExternal: '1' |
---|
| 5112 | }); |
---|
| 5113 | |
---|
| 5114 | return { |
---|
| 5115 | id: newAttendeeId, |
---|
| 5116 | name: name, |
---|
| 5117 | mail: mail, |
---|
| 5118 | acl: 'r', |
---|
| 5119 | delegatedFrom: '0', |
---|
| 5120 | status: '4', |
---|
| 5121 | isExternal: '1' |
---|
| 5122 | }; |
---|
| 5123 | |
---|
| 5124 | }else |
---|
| 5125 | return (null); |
---|
| 5126 | }) |
---|
| 5127 | }; |
---|
| 5128 | |
---|
| 5129 | schedulable = DataLayer.merge(schedulable, |
---|
| 5130 | type == 'event' ? |
---|
| 5131 | {calendar: User.preferences.defaultCalendar ? User.preferences.defaultCalendar : Calendar.calendars[0], calendars: Calendar.calendars} |
---|
[6998] | 5132 | : {group: Calendar.groups[0].id, groups: Calendar.groups, percentage: 0, isOrganizer: true} |
---|
[6996] | 5133 | ); |
---|
| 5134 | |
---|
| 5135 | return schedulable; |
---|
| 5136 | |
---|
| 5137 | |
---|
| 5138 | } |
---|
| 5139 | |
---|
[5619] | 5140 | function import_implements_calendar(){ |
---|
| 5141 | |
---|
[5622] | 5142 | if(typeof(Encoder) == "undefined"){ |
---|
| 5143 | /* |
---|
| 5144 | * Deve-se centralizar as informações do usuário logado afim de não incluir |
---|
| 5145 | * arquivos de modulos distintos para este fim. |
---|
| 5146 | */ |
---|
| 5147 | |
---|
| 5148 | //$.ajax({ url: "../expressoCalendar/index.php", async: false}); |
---|
[5729] | 5149 | //$.ajax({url: "../prototype/modules/calendar/js/calendar.date.js", async: false, beforeSend: function( xhr ) { xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[6444] | 5150 | $.ajax({url: "../prototype/modules/calendar/js/load.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5835] | 5151 | $.ajax({url: "../prototype/modules/calendar/js/map.disponibility.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
| 5152 | $.ajax({url: "../prototype/modules/calendar/js/helpers.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[6996] | 5153 | $.ajax({url: "../prototype/modules/calendar/js/task.helpers.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5622] | 5154 | //$.ajax({ url: "../prototype/modules/calendar/js/timezone.js", async: false}); |
---|
| 5155 | //$.ajax({ url: "../prototype/modules/calendar/js/calendar.codecs.js", async: false}); |
---|
[5835] | 5156 | $.ajax({url: "../prototype/plugins/encoder/encoder.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[6996] | 5157 | $.ajax({url: "../prototype/plugins/jquery.spinner/jquery.spinner.min.js", async: false, beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5729] | 5158 | //$.ajax({url: "../prototype/plugins/dateFormat/dateFormat.js", async: false, beforeSend: function( xhr ) { xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5619] | 5159 | |
---|
[5835] | 5160 | $.ajax({url: "../prototype/plugins/fullcalendar/fullcalendar.js", async: false , beforeSend: function( xhr ) {xhr.overrideMimeType('text/javascript; charset=ISO-8859-1')}}); |
---|
[5619] | 5161 | |
---|
[5636] | 5162 | |
---|
[5619] | 5163 | DataLayer.dispatchPath = "../prototype/"; |
---|
| 5164 | } |
---|
| 5165 | } |
---|
| 5166 | |
---|
| 5167 | |
---|
[660] | 5168 | function select_import_folder(){ |
---|
| 5169 | //Begin: Verify if the file extension is allowed. |
---|
| 5170 | var imgExtensions = new Array("eml","zip"); |
---|
[3035] | 5171 | var inputFile = document.form_import.file_1; |
---|
[660] | 5172 | if(!inputFile.value){ |
---|
| 5173 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 5174 | return false; |
---|
| 5175 | } |
---|
| 5176 | var fileExtension = inputFile.value.split("."); |
---|
| 5177 | fileExtension = fileExtension[(fileExtension.length-1)]; |
---|
| 5178 | var deniedExtension = true; |
---|
| 5179 | for(var i=0; i<imgExtensions.length; i++) { |
---|
| 5180 | if(imgExtensions[i].toUpperCase() == fileExtension.toUpperCase()) { |
---|
| 5181 | deniedExtension = false; |
---|
| 5182 | break; |
---|
| 5183 | } |
---|
| 5184 | } |
---|
| 5185 | if(deniedExtension) { |
---|
| 5186 | alert(get_lang('File extension forbidden or invalid file') + '.'); |
---|
| 5187 | return false; |
---|
| 5188 | } |
---|
| 5189 | arrayJSWin['import_window'].close(); |
---|
[3181] | 5190 | connector.loadScript('wfolders'); |
---|
| 5191 | |
---|
| 5192 | if ( typeof(wfolders) == "undefined" ) |
---|
| 5193 | setTimeout( 'select_import_folder()', 500 ); |
---|
| 5194 | else |
---|
| 5195 | wfolders.makeWindow('null','import'); |
---|
[673] | 5196 | } |
---|
[6996] | 5197 | //Verifica o contexto de importação |
---|
| 5198 | function decodeOwner(){ |
---|
[6331] | 5199 | owner = User.me.id; |
---|
[7695] | 5200 | var imapBox = (openTab.imapBox[currentTab].indexOf( 'user' ) >= 0 ? openTab.imapBox[currentTab].split(cyrus_delimiter) : [] ); |
---|
[6331] | 5201 | if(imapBox.length > 1){ |
---|
| 5202 | var user = DataLayer.get('user', {filter: ['=','uid',imapBox[1]]}); |
---|
| 5203 | owner = $.isArray(user) ? user[0].id : user.id; |
---|
[6860] | 5204 | } |
---|
[6331] | 5205 | return owner; |
---|
[6996] | 5206 | } |
---|
[5134] | 5207 | |
---|
[6996] | 5208 | function import_calendar(data){ |
---|
| 5209 | var import_url = '$this.db_functions.import_vcard&msg_folder='+data; |
---|
| 5210 | var logUser; |
---|
| 5211 | var up; |
---|
| 5212 | var owner; |
---|
[5134] | 5213 | |
---|
[6996] | 5214 | function handler_import_calendar(data){ |
---|
| 5215 | if(data === true){ |
---|
| 5216 | write_msg(get_lang("The event was imported successfully.")); |
---|
| 5217 | } |
---|
| 5218 | else if( data['url'] ) |
---|
| 5219 | { |
---|
| 5220 | var form = document.createElement( "form" ); |
---|
[5134] | 5221 | |
---|
[6996] | 5222 | form.setAttribute( "action", DEFAULT_URL + data['url'] + '&isPost=true' ); |
---|
| 5223 | form.setAttribute( "method", "POST" ); |
---|
| 5224 | |
---|
| 5225 | document.body.appendChild( form ); |
---|
| 5226 | |
---|
| 5227 | form.submit(); |
---|
| 5228 | } |
---|
| 5229 | else |
---|
| 5230 | write_msg(get_lang(data)); |
---|
| 5231 | } |
---|
[5804] | 5232 | if(defaultCalendar == "expressoCalendar" && $("#expressoCalendarid")[0]){ |
---|
[6996] | 5233 | import_implements_calendar(); |
---|
[5357] | 5234 | $( "#import-dialog" ).dialog({ |
---|
[6996] | 5235 | autoOpen: false, |
---|
| 5236 | height: 220, |
---|
| 5237 | modal: true, |
---|
| 5238 | resizable : false, |
---|
| 5239 | open: function(event, ui) { |
---|
| 5240 | if(typeof(shortcut) != 'undefined') shortcut.disabled = true; |
---|
| 5241 | }, |
---|
| 5242 | close: function(event, ui){ |
---|
| 5243 | event.stopPropagation(); |
---|
| 5244 | if(typeof(shortcut) != 'undefined') shortcut.disabled = false; |
---|
| 5245 | }, |
---|
| 5246 | closeOnEscape: true |
---|
[5357] | 5247 | }); |
---|
[6996] | 5248 | |
---|
[5514] | 5249 | $.ajax({ |
---|
[6996] | 5250 | url: "controller.php?action="+import_url+'&from_ajax=true&id_user='+User.me.id+'&readable=true&cirus_delimiter='+cyrus_delimiter+'&analize=true&uidAccount='+decodeOwner(), |
---|
| 5251 | async: false, |
---|
| 5252 | success: function(data){ |
---|
| 5253 | data = connector.unserialize(data); |
---|
| 5254 | var createDialog = function(typeImport, propaget){ |
---|
| 5255 | |
---|
| 5256 | if(typeof(typeImport) == "object"){ |
---|
| 5257 | var calendarIds = !!typeImport.calendar ? typeImport.calendar : Calendar[typeImport.type]; |
---|
| 5258 | typeImport = typeImport.action; |
---|
| 5259 | } |
---|
| 5260 | |
---|
| 5261 | switch(parseInt(typeImport)){ |
---|
| 5262 | case 1: |
---|
| 5263 | case 7: |
---|
| 5264 | case 10: |
---|
| 5265 | $("#select-agenda").html(''); |
---|
[5399] | 5266 | |
---|
[6996] | 5267 | var options = ''; |
---|
[5399] | 5268 | |
---|
[6996] | 5269 | if(calendarIds){ |
---|
| 5270 | for(var i = 0; i < calendarIds.length; i++) |
---|
| 5271 | options += '<option value="'+calendarIds[i]+'">'+Calendar.signatureOf[calendarIds[i]].calendar.name+'</option>' |
---|
| 5272 | } |
---|
[5399] | 5273 | |
---|
[6996] | 5274 | $("#select-agenda").append(options); |
---|
| 5275 | $("#select-agenda").css("display", "block"); |
---|
[5399] | 5276 | |
---|
[6996] | 5277 | $("#import-dialog" ).dialog({ |
---|
| 5278 | buttons: { |
---|
| 5279 | Cancel: function() { |
---|
| 5280 | $( this ).dialog( "close" ); |
---|
| 5281 | }, |
---|
| 5282 | "Importar" : function(){ |
---|
| 5283 | $.ajax({ |
---|
[7028] | 5284 | url: "controller.php?action="+import_url+'&from_ajax=true&selected='+$("#select-agenda option:selected").val()+'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner()+'&cirus_delimiter='+cyrus_delimiter, |
---|
[6996] | 5285 | success: function(msg){ |
---|
| 5286 | var alt = ( (msg = connector.unserialize(msg)) == "ok") ? "Importado com sucesso para " : "Ocorreu um erro ao importar o evento/tarefa para a agenda "; |
---|
| 5287 | alert( alt + $("#select-agenda option:selected").text() ); |
---|
[6295] | 5288 | } |
---|
[6996] | 5289 | }); |
---|
| 5290 | $( this ).dialog( "close" ); |
---|
| 5291 | } |
---|
| 5292 | } |
---|
| 5293 | }); |
---|
| 5294 | |
---|
| 5295 | if(typeImport == 7){ |
---|
| 5296 | $("#import-dialog").find('#select-status option[value=1]').attr('selected','selected').trigger('change'); |
---|
| 5297 | $("#import-dialog").find('#select-status').attr('disabled','disabled'); |
---|
| 5298 | } |
---|
| 5299 | break; |
---|
| 5300 | case 3: |
---|
| 5301 | $.ajax({ |
---|
| 5302 | url: "controller.php?action="+import_url+'&from_ajax=true&selected=true', |
---|
| 5303 | success: function(msg){ |
---|
| 5304 | alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento/tarefa foi removido " : "Ocorreu um erro ao remover o evento/tarefa" ); |
---|
| 5305 | } |
---|
| 5306 | }); |
---|
| 5307 | return; |
---|
| 5308 | break; |
---|
| 5309 | case 5: |
---|
| 5310 | $.ajax({ |
---|
[7028] | 5311 | url: 'controller.php?action='+import_url+'&from_ajax=true&selected=true&cirus_delimiter='+cyrus_delimiter, |
---|
[6996] | 5312 | success: function(msg){ |
---|
| 5313 | alert( ( ( connector.unserialize(msg)) == "ok") ? "Seu evento/tarefa foi Atualizado com sucesso" : "Ocorreu um erro ao atualizar evento/tarefa" ); |
---|
| 5314 | } |
---|
| 5315 | }); |
---|
| 5316 | return; |
---|
| 5317 | break; |
---|
| 5318 | case 6: |
---|
| 5319 | var acceptedSuggestion = confirm("Deseja atualizar o evento/tarefa de acordo com a sugestão ?"); |
---|
| 5320 | $.ajax({ |
---|
| 5321 | 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+'&uidAccount='+decodeOwner(), |
---|
| 5322 | success: function(msg){ |
---|
| 5323 | if(acceptedSuggestion) |
---|
| 5324 | alert( ( ( connector.unserialize(msg)) == "ok") ? "Evento/tarefa atualizado com sucesso " : "Ocorreu um erro ao atualizar o evento" ); |
---|
| 5325 | } |
---|
| 5326 | }); |
---|
| 5327 | return; |
---|
| 5328 | break; |
---|
[7695] | 5329 | case 4: |
---|
[6996] | 5330 | case 9: |
---|
| 5331 | alert('Seu evento/tarefa não possui alterações!'); |
---|
| 5332 | return; |
---|
| 5333 | break; |
---|
| 5334 | case 11: |
---|
| 5335 | alert('Este evento/tarefa já fora importando por algum dos particpantes e já se encontra disponível em sua agenda compartilhada!'); |
---|
| 5336 | return; |
---|
| 5337 | break; |
---|
| 5338 | default: |
---|
| 5339 | up = true; |
---|
| 5340 | $("#select-agenda").css("display", "none"); |
---|
| 5341 | $("#import-dialog" ).children("p:first-child").css("display", "none"); |
---|
| 5342 | $("#import-dialog" ).dialog({ |
---|
| 5343 | height: 160, |
---|
| 5344 | title: 'Atualizar Evento/Tarefa', |
---|
| 5345 | buttons: { |
---|
| 5346 | Cancel: function() { |
---|
| 5347 | $( this ).dialog( "close" ); |
---|
| 5348 | }, |
---|
| 5349 | "Atualizar": function() { |
---|
[5514] | 5350 | $.ajax({ |
---|
[6996] | 5351 | url: "controller.php?action="+import_url+'&from_ajax=true&cirus_delimiter='+cyrus_delimiter+'&selected='+ (parseInt(typeImport) == 2 || parseInt(typeImport) == 4 ? 'true' : $("#select-agenda option:selected").val()) +'&status='+$("#select-status option:selected").val()+'&uidAccount='+decodeOwner(), |
---|
| 5352 | success: function(msg){ |
---|
| 5353 | alert( ( (msg = connector.unserialize(msg)) == "ok") ? "Atualizado com sucesso" : "Ocorreu um erro ao atualizar o evento" ); |
---|
| 5354 | } |
---|
[5514] | 5355 | }); |
---|
[6996] | 5356 | $( this ).dialog( "close" ); |
---|
| 5357 | } |
---|
| 5358 | }, |
---|
| 5359 | close:function(event, ui) |
---|
| 5360 | { |
---|
| 5361 | if(typeof(shortcut) != 'undefined') shortcut.disabled = false; |
---|
| 5362 | }, |
---|
| 5363 | open: function(event, ui) |
---|
| 5364 | { |
---|
| 5365 | if(typeof(shortcut) != 'undefined') shortcut.disabled = true; |
---|
[5514] | 5366 | } |
---|
[6996] | 5367 | }); |
---|
| 5368 | $(".ui-dialog-buttonpane").find(".ui-button:last").children().html("Atualizar"); |
---|
| 5369 | } |
---|
| 5370 | $( "#import-dialog" ).dialog( "open" ); |
---|
| 5371 | |
---|
| 5372 | }; |
---|
| 5373 | createDialog(data, true); |
---|
| 5374 | |
---|
| 5375 | }, |
---|
| 5376 | beforeSend: function( jqXHR, settings ){ |
---|
| 5377 | connector.showProgressBar(); |
---|
| 5378 | }, |
---|
| 5379 | complete: function( jqXHR, settings ){ |
---|
| 5380 | connector.hideProgressBar(); |
---|
| 5381 | } |
---|
| 5382 | }); |
---|
| 5383 | } |
---|
| 5384 | else |
---|
| 5385 | { |
---|
[7749] | 5386 | $.Zebra_Dialog(get_lang("Do you confirm this import to your Calendar?"), { |
---|
| 5387 | 'type': 'question', |
---|
| 5388 | 'buttons': [get_lang("Yes"), get_lang("No")], |
---|
| 5389 | 'overlay_opacity' : 0.5, |
---|
| 5390 | 'custom_class': 'custom-zebra-filter', |
---|
| 5391 | 'onClose': function(caption) { |
---|
| 5392 | if(caption == get_lang("Yes")) |
---|
| 5393 | cExecute( import_url + "&from_ajax=true", handler_import_calendar); |
---|
| 5394 | } |
---|
| 5395 | }); |
---|
[6996] | 5396 | } |
---|
| 5397 | } |
---|
| 5398 | |
---|
[5134] | 5399 | function open_msg_part(data){ |
---|
| 5400 | var handler_open_msg_part = function (data) |
---|
| 5401 | { |
---|
| 5402 | if(data.append == 1) |
---|
| 5403 | { |
---|
[7768] | 5404 | proxy_mensagens.get_msg(data.msg_number,data.msg_folder,false,show_msg,false); |
---|
[5134] | 5405 | partMsgs.push(data.msg_number); |
---|
[673] | 5406 | } |
---|
[5134] | 5407 | else |
---|
| 5408 | write_msg(data.append); |
---|
| 5409 | } |
---|
[5211] | 5410 | cExecute('$this.imap_functions.ope_msg_part&msg_folder='+data+'&save_folder=INBOX'+cyrus_delimiter+special_folders['Trash'] , handler_open_msg_part); |
---|
[673] | 5411 | } |
---|
[1121] | 5412 | function hack_sent_queue(data,rowid_message) { |
---|
| 5413 | |
---|
| 5414 | if (data.success != true) { |
---|
| 5415 | queue_send_errors = true; |
---|
| 5416 | expresso_local_messages.set_problem_on_sent(rowid_message,data); |
---|
| 5417 | } |
---|
| 5418 | else { |
---|
| 5419 | expresso_local_messages.set_as_sent(rowid_message); |
---|
| 5420 | 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. |
---|
| 5421 | el =document.getElementById('_action'); |
---|
| 5422 | father = el.parentNode; |
---|
| 5423 | father.removeChild(el); |
---|
| 5424 | } |
---|
| 5425 | send_mail_from_queue(false); |
---|
| 5426 | } |
---|
| 5427 | } |
---|
| 5428 | |
---|
| 5429 | function send_mail_from_queue(first_pass) { |
---|
| 5430 | if(first_pass) |
---|
| 5431 | modal('send_queue'); |
---|
| 5432 | var num_msgs = expresso_local_messages.get_num_msgs_to_send(); |
---|
| 5433 | if (num_msgs <= 0) { |
---|
| 5434 | close_lightbox(); |
---|
| 5435 | return; |
---|
| 5436 | } |
---|
[3035] | 5437 | document.getElementById('text_send_queue').innerHTML = get_lang('Number of messages to send:')+' '+num_msgs; |
---|
[1121] | 5438 | var handler_send_queue_message = function(data,rowid_message) { |
---|
| 5439 | hack_sent_queue(data,this.ID_tmp); |
---|
| 5440 | } |
---|
| 5441 | var msg_to_send = expresso_local_messages.get_form_msg_to_send(); |
---|
| 5442 | if(!is_ie) |
---|
| 5443 | ID_tmp = msg_to_send.rowid.value; |
---|
| 5444 | else {//I.E kills me of shame... |
---|
| 5445 | for (var i=0;i<msg_to_send.length;i++) { |
---|
| 5446 | if(msg_to_send.elements[i].name=='rowid') { |
---|
| 5447 | ID_tmp = msg_to_send.elements[i].value; |
---|
| 5448 | break; |
---|
| 5449 | } |
---|
| 5450 | } |
---|
| 5451 | } |
---|
[3537] | 5452 | expresso_local_messages.set_as_sent(ID_tmp); |
---|
[1121] | 5453 | cExecuteForm("$this.imap_functions.send_mail", msg_to_send, handler_send_queue_message,"queue_"+ID_tmp); |
---|
[3537] | 5454 | send_mail_from_queue(false); |
---|
[1121] | 5455 | } |
---|
| 5456 | |
---|
| 5457 | function check_mail_in_queue() { |
---|
| 5458 | var num_msgs = expresso_local_messages.get_num_msgs_to_send(); |
---|
| 5459 | if(num_msgs>0) { |
---|
| 5460 | control = confirm(get_lang('You have messages to send. Want you to send them now?')); |
---|
| 5461 | if(control) { |
---|
| 5462 | send_mail_from_queue(true); |
---|
| 5463 | } |
---|
| 5464 | return true; |
---|
| 5465 | } |
---|
| 5466 | else { |
---|
| 5467 | return false; |
---|
| 5468 | } |
---|
| 5469 | } |
---|
| 5470 | |
---|
| 5471 | function force_check_queue() { |
---|
| 5472 | if(!check_mail_in_queue()) { |
---|
| 5473 | write_msg(get_lang("No messages to send")); |
---|
| 5474 | } |
---|
| 5475 | } |
---|
| 5476 | |
---|
[7414] | 5477 | function create_new_local_folder(parentFolderId, name){ |
---|
| 5478 | |
---|
| 5479 | parentFolderId = parentFolderId.split("_"); |
---|
| 5480 | var parentName = parentFolderId[2]; |
---|
| 5481 | |
---|
| 5482 | expresso_mail_archive.createFolder(parentName, name); |
---|
| 5483 | |
---|
| 5484 | } |
---|
| 5485 | |
---|
[5844] | 5486 | function create_new_folder(name_folder, base_path){ |
---|
[6930] | 5487 | //Limit reached folders |
---|
| 5488 | if(preferences.imap_max_folders){ |
---|
| 5489 | if(cp_tree1.length == parseInt(preferences.imap_max_folders)){ |
---|
| 5490 | $(".folders-loading").removeClass("folders-loading"); |
---|
| 5491 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 5492 | return write_msg(get_lang("Limit reached folders")); |
---|
| 5493 | } |
---|
| 5494 | } |
---|
| 5495 | |
---|
[5844] | 5496 | $.ajax({ |
---|
| 5497 | url : "controller.php?action=$this.imap_functions.create_mailbox", |
---|
| 5498 | type : "POST", |
---|
| 5499 | async : false, |
---|
| 5500 | data : "newp="+name_folder+"&base_path="+base_path, |
---|
| 5501 | success : function(data){ |
---|
| 5502 | data = connector.unserialize(data); |
---|
| 5503 | if(data == "Mailbox already exists"){ |
---|
| 5504 | write_msg(get_lang("Mailbox already exists")); |
---|
[6930] | 5505 | }else if(data.substring(data.indexOf("Permission"), data.length) == "Permission denied"){ |
---|
| 5506 | $(".folders-loading").removeClass("folders-loading"); |
---|
| 5507 | cExecute("$this.imap_functions.get_folders_list&onload=true", update_menu); |
---|
| 5508 | return write_msg(get_lang("Permission denied")); |
---|
[5844] | 5509 | } |
---|
[7635] | 5510 | cExecute("$this.imap_functions.get_folders_list&onload=true", force_update_menu); |
---|
[6587] | 5511 | }, |
---|
| 5512 | beforeSend: function( jqXHR, settings ){ |
---|
| 5513 | connector.showProgressBar(); |
---|
| 5514 | }, |
---|
| 5515 | complete: function( jqXHR, settings ){ |
---|
| 5516 | connector.hideProgressBar(); |
---|
[5844] | 5517 | } |
---|
| 5518 | }); |
---|
| 5519 | } |
---|
| 5520 | |
---|
[3227] | 5521 | function searchEmail(emailString){ |
---|
[1121] | 5522 | var arrayInvalidEmails = new Array(); |
---|
[3035] | 5523 | arrayInvalidEmails[1] = ''; |
---|
[1121] | 5524 | var email; |
---|
| 5525 | var arrayEmailsFull = new Array(); |
---|
| 5526 | arrayEmailsFull = emailString.split(','); |
---|
[3227] | 5527 | var er_Email = new RegExp("<(.*?)>"); |
---|
| 5528 | // TODO Use validateEmail of common functions ! |
---|
[5134] | 5529 | 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] | 5530 | |
---|
| 5531 | for (i=0; i < arrayEmailsFull.length; i++){ |
---|
| 5532 | email = er_Email.exec(arrayEmailsFull[i]); |
---|
| 5533 | tempEmail = email == null ? arrayEmailsFull[i]:email[1]; |
---|
| 5534 | tempEmail = tempEmail.replace(/^\s+|\s+$/g,""); |
---|
[5134] | 5535 | |
---|
[1121] | 5536 | if (tempEmail != '') { |
---|
| 5537 | singleEmail = er_ValidaEmail.exec(tempEmail); |
---|
| 5538 | if (singleEmail == null) { |
---|
| 5539 | arrayInvalidEmails[0] = true; |
---|
[5134] | 5540 | arrayInvalidEmails[1] += (email == null ? arrayEmailsFull[i] : email[1]) + ""; |
---|
[1121] | 5541 | } |
---|
[3035] | 5542 | } |
---|
[1121] | 5543 | } |
---|
[3035] | 5544 | |
---|
[1121] | 5545 | return arrayInvalidEmails; |
---|
[1754] | 5546 | } |
---|
[4830] | 5547 | |
---|
[7601] | 5548 | /* Funçãoo que chama a tela para o usuário reportar um erro no email. */ |
---|
[4830] | 5549 | function reports_window(currentTab){ |
---|
| 5550 | ID_msg = currentTab.substr(0,currentTab.indexOf("_")); |
---|
| 5551 | report_wind.make_report_window(ID_msg); |
---|
| 5552 | } |
---|
| 5553 | |
---|
[5604] | 5554 | |
---|
| 5555 | DataLayer.codec( "message", "detail", { |
---|
| 5556 | |
---|
| 5557 | decoder:function( form ){ |
---|
| 5558 | var border_id = form.abaID; |
---|
[5784] | 5559 | //Defininindo pasta a ser salva mensagem |
---|
[5945] | 5560 | var user_selected = $('#content_id_'+border_id).find('.from-select option:selected').text(); |
---|
[5784] | 5561 | var str_begin_name = user_selected.indexOf('<') + 1; |
---|
| 5562 | var str_end_name = user_selected.indexOf('@'); |
---|
| 5563 | var user_selected_name = user_selected.substring(str_begin_name, str_end_name); |
---|
[5791] | 5564 | |
---|
| 5565 | if(user_selected.length > 0) |
---|
| 5566 | var user_selected_email = user_selected.match(/<([^<]*)>[\s]*$/)[1]; |
---|
| 5567 | else |
---|
| 5568 | var user_selected_email = User.me.mail; |
---|
| 5569 | |
---|
[5784] | 5570 | if(user_selected_email == User.me.mail){ |
---|
| 5571 | var prefix = 'INBOX'; |
---|
| 5572 | }else{ |
---|
[5844] | 5573 | var prefix = 'user' + cyrus_delimiter+user_selected_name; |
---|
[7771] | 5574 | var has_folder = false;//Folder.get( (prefix + cyrus_delimiter + draftsfolder), false ); |
---|
| 5575 | var folders = DataLayer.get("folder"); |
---|
| 5576 | $.each(folders,function(index,value){ |
---|
| 5577 | if(value && value.id == prefix) |
---|
| 5578 | has_folder = true; |
---|
| 5579 | }); |
---|
[7738] | 5580 | if(!has_folder){ |
---|
[5844] | 5581 | create_new_folder(draftsfolder, prefix); |
---|
| 5582 | } |
---|
[5784] | 5583 | } |
---|
[5844] | 5584 | |
---|
[5784] | 5585 | var folder_id = (openTab.imapBox[border_id] && openTab.type[border_id] < 6) ? openTab.imapBox[border_id]: prefix + cyrus_delimiter + draftsfolder; |
---|
[5604] | 5586 | form.folder = folder_id; |
---|
| 5587 | form.body = RichTextEditor.getData("body_"+border_id); |
---|
[5784] | 5588 | form.type = RichTextEditor.plain[border_id] ? 'plain' : 'html'; |
---|
[5754] | 5589 | form.attachments = listAttachment(border_id); |
---|
[5604] | 5590 | form.uidsSave = uidsSave[border_id].toString(); |
---|
| 5591 | return( form ); |
---|
| 5592 | |
---|
| 5593 | }, |
---|
| 5594 | |
---|
| 5595 | encoder:function( pref ){ |
---|
| 5596 | |
---|
| 5597 | return( pref ); |
---|
| 5598 | } |
---|
| 5599 | |
---|
| 5600 | }); |
---|
| 5601 | |
---|
| 5602 | DataLayer.codec( "mailAttachment", "detail", { |
---|
| 5603 | |
---|
| 5604 | decoder: function(evtObj){ |
---|
| 5605 | |
---|
| 5606 | if( notArray = $.type(evtObj) !== "array" ) |
---|
| 5607 | evtObj = [ evtObj ]; |
---|
| 5608 | |
---|
| 5609 | var res = $.map(evtObj, function( form){ |
---|
| 5610 | return [$.map(form.files , function( files){ |
---|
[5620] | 5611 | return {source: files , disposition : form['attDisposition'+form.abaID]}; |
---|
[5604] | 5612 | })]; |
---|
| 5613 | }); |
---|
| 5614 | return notArray ? res[0] : res; |
---|
| 5615 | }, |
---|
| 5616 | |
---|
| 5617 | encoder: function(){} |
---|
| 5618 | |
---|
| 5619 | |
---|
[5614] | 5620 | }); |
---|
[5626] | 5621 | |
---|
| 5622 | function formatBytes(bytes) { |
---|
| 5623 | if (bytes >= 1000000000) { |
---|
| 5624 | return (bytes / 1000000000).toFixed(2) + ' GB'; |
---|
| 5625 | } |
---|
| 5626 | if (bytes >= 1000000) { |
---|
| 5627 | return (bytes / 1000000).toFixed(2) + ' MB'; |
---|
| 5628 | } |
---|
| 5629 | if (bytes >= 1000) { |
---|
| 5630 | return (bytes / 1000).toFixed(2) + ' KB'; |
---|
| 5631 | } |
---|
| 5632 | return bytes + ' B'; |
---|
[5922] | 5633 | }; |
---|
[6085] | 5634 | |
---|
[6487] | 5635 | function truncate(text, size){ |
---|
| 5636 | var result = text; |
---|
| 5637 | if(text.length > size){ |
---|
| 5638 | result = text.substring(0,size) + '...'; |
---|
| 5639 | } |
---|
| 5640 | return result; |
---|
| 5641 | } |
---|
| 5642 | |
---|
[6882] | 5643 | /* |
---|
| 5644 | * @author Marcos Luiz Wilhelm (marcoswilhelm@gmail.com) |
---|
| 5645 | * @date 2012/07/17 |
---|
| 5646 | * @brief Break out emails only with comma out of quote marks |
---|
| 5647 | */ |
---|
| 5648 | function break_comma (originalText){ |
---|
| 5649 | var quotesMarks = false; |
---|
| 5650 | var completeString = ""; |
---|
| 5651 | var brokenEmails = new Array(); |
---|
| 5652 | originalText+=","; |
---|
| 5653 | for(i=0; i<originalText.length; i++){ |
---|
| 5654 | var character = originalText.substr(i,1); |
---|
| 5655 | if(character == "\""){ |
---|
| 5656 | quotesMarks = !quotesMarks; |
---|
| 5657 | } |
---|
| 5658 | if(!quotesMarks){ |
---|
| 5659 | if(character == ","){ |
---|
| 5660 | brokenEmails.push(completeString); |
---|
| 5661 | completeString = ""; |
---|
| 5662 | } |
---|
| 5663 | else |
---|
| 5664 | completeString+=character; |
---|
| 5665 | } |
---|
| 5666 | else |
---|
| 5667 | completeString+=character; |
---|
| 5668 | } |
---|
| 5669 | return brokenEmails; |
---|
| 5670 | } |
---|
| 5671 | |
---|
[7568] | 5672 | /* |
---|
| 5673 | * @author Marcos Luiz Wilhelm (marcoswilhelm@gmail.com) |
---|
| 5674 | * @date 2012/11/26 |
---|
| 5675 | * @Remove HTML tags in the email body when the simple editor is used. |
---|
| 5676 | */ |
---|
| 5677 | function remove_tags (body){ |
---|
| 5678 | var div = $("<div>").attr("display", "none"); |
---|
| 5679 | div.html(body); |
---|
| 5680 | div.html($.trim(div.text().replace(/[\t]+/g, '').replace(/[\n]+/g, '\n'))); |
---|
| 5681 | return div.text(); |
---|
| 5682 | } |
---|
| 5683 | |
---|
[6085] | 5684 | DataLayer.links('message'); |
---|
| 5685 | DataLayer.poll('message',30); |
---|
| 5686 | |
---|
[7414] | 5687 | //MAILARCHIVER-04 |
---|
| 5688 | function services_retry(){ |
---|
| 5689 | try{ |
---|
| 5690 | connector.purgeCache(); |
---|
| 5691 | //window.alert('expresso var dump:\nenabled = ' + expresso_mail_archive.enabled + '\ntimer = ' + expresso_mail_archive.timer +'\ncounter = ' + expresso_mail_archive.counter); |
---|
[6085] | 5692 | |
---|
[7414] | 5693 | if ((expresso_mail_archive.enabled == null) && (expresso_mail_archive.timer == null) && (expresso_mail_archive.counter > 0)){ |
---|
| 5694 | connector.hideProgressBar(); |
---|
| 5695 | //connector.resetProgressBarText(); |
---|
| 5696 | write_msg(get_lang('Sorry, but you need to reload this web page. Click at reload page at web browsing top navigation.')); |
---|
| 5697 | return; |
---|
| 5698 | } |
---|
| 5699 | |
---|
| 5700 | if (arguments.length == 0){ |
---|
| 5701 | write_msg(get_lang('Trying to communicate with Mail Archiver...')); |
---|
| 5702 | } |
---|
| 5703 | |
---|
| 5704 | connector.showProgressBar(); |
---|
| 5705 | var head = document.getElementById('send_queue'); |
---|
| 5706 | |
---|
| 5707 | var script_xdr= document.createElement('script'); |
---|
| 5708 | var script_xdr_tag_id = 'mail_archiver_retry_xdr'; |
---|
| 5709 | |
---|
| 5710 | var script_request= document.createElement('script'); |
---|
| 5711 | var script_request_tag_id = 'mail_archiver_retry_request'; |
---|
| 5712 | |
---|
| 5713 | var script_cors= document.createElement('script'); |
---|
| 5714 | var script_cors_tag_id = 'mail_archiver_retry_cors'; |
---|
| 5715 | |
---|
| 5716 | var script_utils= document.createElement('script'); |
---|
| 5717 | var script_utils_tag_id = 'mail_archiver_retry_utils'; |
---|
| 5718 | |
---|
| 5719 | if(document.getElementById(script_xdr_tag_id)){ |
---|
| 5720 | document.getElementById(script_xdr_tag_id).parentNode.removeChild(document.getElementById(script_xdr_tag_id)); |
---|
| 5721 | } |
---|
| 5722 | |
---|
| 5723 | if(document.getElementById(script_request_tag_id)){ |
---|
| 5724 | document.getElementById(script_request_tag_id).parentNode.removeChild(document.getElementById(script_request_tag_id)); |
---|
| 5725 | } |
---|
| 5726 | |
---|
| 5727 | if(document.getElementById(script_cors_tag_id)){ |
---|
| 5728 | document.getElementById(script_cors_tag_id).parentNode.removeChild(document.getElementById(script_cors_tag_id)); |
---|
| 5729 | } |
---|
| 5730 | |
---|
| 5731 | if(document.getElementById(script_utils_tag_id)){ |
---|
| 5732 | document.getElementById(script_utils_tag_id).parentNode.removeChild(document.getElementById(script_utils_tag_id)); |
---|
| 5733 | } |
---|
| 5734 | |
---|
| 5735 | //IE XDR ADAPTER |
---|
| 5736 | script_xdr.type= 'text/javascript'; |
---|
| 5737 | script_xdr.src= mail_archive_protocol + '://' + mail_archive_host + ':' + mail_archive_port + '/arcservutil/cxf-addon-xdr-adapter.js'; |
---|
| 5738 | script_xdr.id= script_xdr_tag_id; |
---|
| 5739 | head.appendChild(script_xdr); |
---|
| 5740 | |
---|
| 5741 | //CXF TRANSPORT OBJECT |
---|
| 5742 | script_request.type= 'text/javascript'; |
---|
| 5743 | script_request.src= mail_archive_protocol + '://' + mail_archive_host + ':' + mail_archive_port + '/arcservutil/cxf-addon-cors-request-object.js'; |
---|
| 5744 | script_request.id= script_request_tag_id; |
---|
| 5745 | head.appendChild(script_request); |
---|
| 5746 | |
---|
| 5747 | //CXF CORS OBJECT |
---|
| 5748 | script_cors.type= 'text/javascript'; |
---|
| 5749 | script_cors.src= mail_archive_protocol + '://' + mail_archive_host + ':' + mail_archive_port + '/arcservutil/cxf-addon-cors-utils.js'; |
---|
| 5750 | script_cors.id= script_cors_tag_id; |
---|
| 5751 | head.appendChild(script_cors); |
---|
| 5752 | |
---|
| 5753 | //CXF CORE |
---|
| 5754 | script_utils.type= 'text/javascript'; |
---|
| 5755 | script_utils.src= mail_archive_protocol + '://' + mail_archive_host + ':' + mail_archive_port + '/arcserv/ArchiveServices?js&nojsutils'; |
---|
| 5756 | script_utils.id= script_utils_tag_id; |
---|
| 5757 | head.appendChild(script_utils); |
---|
| 5758 | |
---|
| 5759 | ttintval = window.setTimeout('check_services_restart()', 1000); |
---|
| 5760 | } |
---|
| 5761 | catch (e){ |
---|
| 5762 | write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!')); |
---|
| 5763 | connector.hideProgressBar(); |
---|
| 5764 | //connector.resetProgressBarText(); |
---|
| 5765 | check_services_tryouts = 1; |
---|
| 5766 | } |
---|
| 5767 | } |
---|
| 5768 | |
---|
| 5769 | //MAILARCHIVER-05 |
---|
| 5770 | function check_services_restart(){ |
---|
| 5771 | try{ |
---|
| 5772 | write_msg(get_lang('Wait: attempt %1 from %2...', check_services_tryouts, check_services_tryouts_limit)); |
---|
| 5773 | if(check_services_tryouts <= 5){ |
---|
| 5774 | try{ |
---|
| 5775 | ArchiveServices = new web_service_mailarchiver_serpro__ArchiveServices(); |
---|
| 5776 | ArchiveServices.url = mail_archive_protocol + "://" + mail_archive_host + ":" + mail_archive_port + "/arcserv/ArchiveServices"; |
---|
| 5777 | window.clearInterval(ttintval); |
---|
| 5778 | expresso_mail_archive.Restart(expresso_mail_archive); |
---|
| 5779 | } |
---|
| 5780 | catch (e){ |
---|
| 5781 | check_services_tryouts++; |
---|
| 5782 | window.clearInterval(ttintval); |
---|
| 5783 | ttintval = window.setTimeout('services_retry(true)',1); |
---|
| 5784 | } |
---|
| 5785 | } |
---|
| 5786 | else{ |
---|
| 5787 | write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!')); |
---|
| 5788 | connector.hideProgressBar(); |
---|
| 5789 | //connector.resetProgressBarText(); |
---|
| 5790 | check_services_tryouts = 1; |
---|
| 5791 | } |
---|
| 5792 | } |
---|
| 5793 | catch (e){ |
---|
| 5794 | write_msg(get_lang('Sorry, but Mail Archiver still seems to be sleeping. Check out your system services!')); |
---|
| 5795 | connector.hideProgressBar(); |
---|
| 5796 | //connector.resetProgressBarText(); |
---|
| 5797 | check_services_tryouts = 1; |
---|
| 5798 | } |
---|
| 5799 | } |
---|
| 5800 | |
---|