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