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