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