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