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