Changeset 7907 for trunk/expressoMail1_2/js/main.js
- Timestamp:
- 02/22/13 12:37:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/js/main.js
r7899 r7907 1027 1027 1028 1028 var userTrashFolder = ''; 1029 1030 if (arguments.length <= 6 ) show_success_msg = true;1029 1030 if (arguments.length <= 6 && typeof(show_success_msg) == "undefined") show_success_msg = true; 1031 1031 if (folder == 'null') folder = current_folder; 1032 1032 … … 1164 1164 params_to_delete += "&search_box_type="+search_box_type; 1165 1165 params_to_delete += "&sort_box_reverse="+sort_box_reverse; 1166 1166 1167 cExecute ("$this.imap_functions.delete_msgs", handler_delete_msgs, params_to_delete); 1167 1168 } … … 3533 3534 mailData.input_from = $(content).find('select[name="input_from"]').val(); 3534 3535 3535 3536 if(stringEmail != ""){ 3537 $.ajax({ 3538 url: "controller.php?action=$this.imap_functions.send_mail", 3539 data: mailData, 3540 type: 'POST', 3541 3542 beforeSend: function(jqXHR, settings){ 3543 3544 write_msg( get_lang( 'Sending the message...' ) ); 3545 $(content).find('button.send').button('option', 'disabled', true); 3546 3547 3548 }, 3549 success: function(data){ 3550 send_message_return(connector.unserialize(data),ID); 3551 }, 3552 error: function(){ 3553 write_msg(get_lang( 'Error trying to send the message. Retry in a few seconds...' ) ); 3554 $(content).find('button.send').button('option', 'disabled', false); 3555 var interval = setInterval(function(){ 3556 send_valided_message(ID,folder,folder_name); 3557 clearInterval(interval); 3558 },15000); 3559 return; 3560 } 3561 }); 3562 }else{ 3563 write_msg(get_lang("message without receiver")); 3564 return; 3565 } 3566 3536 // VERIFY IF EXISTS MESSAGE TO ATTACH 3537 if(typeof mailData.attachments == "object"){ 3538 3539 // VERIFY IF EXISTS MESSAGE OF ARCHIVE 3540 if(mailData.attachments.archiver.length){ 3541 3542 // CREATE ONE VARIABLE TO STORE ALL THE MESSAGES INFORMATION 3543 var archiver = new Array(); 3544 3545 // UNARCHIEVE ALL THE MESSAGES TO IMAP TRASH 3546 $.each(mailData.attachments.archiver, function(i, each){ 3547 expresso_mail_archive.unarchieveToAttach(each.folder,"INBOX/Trash",each.uid); 3548 }); 3549 3550 // FIX THE PROBLEM WITH ASYNC 3551 // noReady is calling always that the variable is not complete with all the messages ids 3552 notReady = function(){ 3553 setTimeout(function(){ 3554 if(mailData.attachments.archiver.length == expresso_mail_archive.idMsgsToAttach.length){ 3555 // THIS FUNCTION IS FOR TO GET THE INFORMATION OF THE MESSAGE NEWLY UNARCHIVED 3556 readyToFetch(); 3557 // THIS FUNCTION IS FOR TO SEND THE MESSAGE WITH ATTACHMENT 3558 readyToSend(); 3559 } else { 3560 // IF THE ARRAY DON'T HAVE ALL THE MESSAGES IDS, OKAY, NO PROBLEM... CALL THIS FUNCTION AGAIN! 3561 noReady(); 3562 } 3563 },30); 3564 }; 3565 notReady(); 3566 3567 // THIS FUNCTION IS FOR TO GET THE INFORMATION OF THE MESSAGE NEWLY UNARCHIVED 3568 readyToFetch = function(){ 3569 $.ajax({ 3570 url: "controller.php?action=$this.imap_functions.get_info_msg_archiver", 3571 data: {"idMsgs":expresso_mail_archive.idMsgsToAttach}, 3572 type: 'POST', 3573 async: false, 3574 success: function(data){ 3575 data = connector.unserialize(data); 3576 archiver.push(data); 3577 }, 3578 }); 3579 3580 // HERE, THE MESSAGES IMAP ARE READY FOR TO SEND... 3581 mailData.attachments = mailData.attachments.imap; 3582 3583 // BUT, I NEED TO PREPARE THE MESSAGE ARCHIVE FOR TO SEND. 3584 archiver = $.parseJSON(archiver[0]); 3585 if(archiver.length){ 3586 $.each(archiver, function(i, each){ 3587 mailData.attachments.push(JSON.stringify(archiver[i])); 3588 }); 3589 } 3590 3591 // GOOD, NOW THE ATTACHMENTS ARE READY TO SEND! 3592 mailData.attachments = JSON.stringify(mailData.attachments); 3593 }; 3594 } else { 3595 // IF THIS MESSAGE JUST HAVE IMAP MESSAGES 3596 mailData.attachments = JSON.stringify(mailData.attachments.imap); 3597 setTimeout(function(){ readyToSend() }, 30); 3598 } 3599 } else { 3600 // IF THIS MESSAGE DON'T HAVE ATTACHMENT, CALL READYTOSEND. 3601 setTimeout(function(){ readyToSend() }, 30); 3602 mailData.attachments = []; 3603 } 3604 3605 // THIS FUNCTION IS FOR TO SEND THE MESSAGE WITH ATTACHMENT OR NOT. 3606 readyToSend = function(){ 3607 3608 if(stringEmail != ""){ 3609 $.ajax({ 3610 url: "controller.php?action=$this.imap_functions.send_mail", 3611 data: mailData, 3612 type: 'POST', 3613 async: false, 3614 beforeSend: function(jqXHR, settings){ 3615 write_msg( get_lang( 'Sending the message...' ) ); 3616 $(content).find('button.send').button('option', 'disabled', true); 3617 }, 3618 success: function(data){ 3619 send_message_return(connector.unserialize(data),ID); 3620 // HERE, I NEED TO DELETE THE MESSAGES THAT WERE UNARCHIVE FROM ARCHIVE. 3621 delete_msgs("INBOX/Trash",expresso_mail_archive.idMsgsToAttach, false, false); 3622 }, 3623 error: function(){ 3624 write_msg(get_lang( 'Error trying to send the message. Retry in a few seconds...' ) ); 3625 $(content).find('button.send').button('option', 'disabled', false); 3626 var interval = setInterval(function(){ 3627 send_valided_message(ID,folder,folder_name); 3628 clearInterval(interval); 3629 },15000); 3630 return; 3631 } 3632 }); 3633 }else{ 3634 write_msg(get_lang("message without receiver")); 3635 return; 3636 } 3637 delete(expresso_mail_archive.idMsgsToAttach); 3638 }; 3567 3639 3568 3640 }
Note: See TracChangeset
for help on using the changeset viewer.