1 /*********************************************************************************
2 * SugarCRM is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by the
7 * Free Software Foundation with the addition of the following permission added
8 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * You should have received a copy of the GNU Affero General Public License along with
18 * this program; if not, see http://www.gnu.org/licenses or write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32 * technical reasons, the Appropriate Legal Notices must display the words
33 * "Powered by SugarCRM".
34 ********************************************************************************/
37 if (typeof console == "undefined")
38 console = { log: function(o) {alert(o)} };
42 currentRequestObject : null,
43 //timeout : 30000, // 30 second timeout default
44 timeout : 9999999999, // 30 second timeout default
52 this.forceAbort = false;
55 folderRenameCleanup : function() {
56 SUGAR.email2.folders.setSugarFolders();
59 fullSyncCleanup : function(o) {
60 this.folders.checkMailCleanup(o);
61 SUGAR.email2.settings.settingsDialog.hide();
66 composeCache : function(o) {
67 var idx = SUGAR.email2.composeLayout.currentInstanceId; // post instance increment
68 // get email templates and user signatures
69 var ret = JSON.parse(o.responseText);
71 SUGAR.email2.composeLayout.emailTemplates = ret.emailTemplates;
72 SUGAR.email2.composeLayout.signatures = ret.signatures;
73 SUGAR.email2.composeLayout.fromAccounts = ret.fromAccounts;
75 SUGAR.email2.composeLayout.setComposeOptions(idx);
77 //Set the error array so we can notify the user when they try to hit send if any errors
78 //are present. We will also notify them now (after hitting compose button).
79 SUGAR.email2.composeLayout.outboundAccountErrors = ret.errorArray;
82 //if error element is returning an array, then check the length to make sure we have error messages
83 if (typeof(ret.errorArray)=='object' && ret.errorArray instanceof Array && ret.errorArray.length > 0){
84 //add error messages for display
85 for(i in ret.errorArray)
86 overlay(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorArray[i], 'alert');
87 }else if (typeof(ret.errorArray)=='object' && ret.errorArray!=null && ret.errorArray!='' ) {
88 //if error element is returning an object, and the object value is not empty or null, then display error message
89 for(i in ret.errorArray)
90 overlay(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorArray[i], 'alert');
93 //YUI bug with IE6 - Wont restore visibility property for nested select elements.
95 var overlayPanel = YAHOO.SUGAR.MessageBox.panel;
97 overlayPanel.subscribe('hide',function() { YAHOO.util.Dom.setStyle('addressFrom' + idx,'visibility','');});
103 handleDeleteSignature : function(o) {
105 var ret = JSON.parse(o.responseText);
106 SUGAR.email2.composeLayout.signatures = ret.signatures;
107 var field = document.getElementById('signature_id');
108 SUGAR.email2.util.emptySelectOptions(field);
110 for(var i in ret.signatures) { // iterate through assoc array
111 var opt = new Option(ret.signatures[i], i);
112 field.options.add(opt);
114 setSigEditButtonVisibility();
119 handleDeleteReturn : function(o) {
120 // force refresh ListView
122 if(document.getElementById('focusEmailMbox')) {
123 YAHOO.namespace('frameFolders').selectednode = SUGAR.email2.folders.getNodeFromMboxPath(document.getElementById('focusEmailMbox').innerHTML);
126 // need to display success message before calling next async call?
127 document.getElementById(this.target).innerHTML = o.responseText;
132 handleFailure : function(o) {
134 overlay('Exception occurred...', o.statusText, 'alert');
137 handleReplyForward : function(o) {
138 var a = JSON.parse(o.responseText);
140 var idx = SUGAR.email2.composeLayout.currentInstanceId;
142 document.getElementById('email_id' + idx).value = a.uid;
143 document.getElementById('emailSubject' + idx).value = a.name;
144 document.getElementById('addressTO' + idx).value = a.from;
145 document.getElementById('uid' + idx).value = a.uid;
147 document.getElementById('addressCC' + idx).value = a.cc;
148 SE.composeLayout.showHiddenAddress('cc', idx);
152 document.getElementById('type' + idx).value = a.type;
155 // apply attachment values
156 SUGAR.email2.composeLayout.loadAttachments(a.attachments);
158 setTimeout("callbackReplyForward.finish(globalA);", 500);
161 handleReplyForwardForDraft : function(o) {
162 var a = JSON.parse(o.responseText);
164 var idx = SUGAR.email2.composeLayout.currentInstanceId;
166 document.getElementById('email_id' + idx).value = a.uid;
167 document.getElementById('emailSubject' + idx).value = a.name;
168 document.getElementById('addressTO' + idx).value = a.to;
171 document.getElementById('addressCC' + idx).value = a.cc;
172 SUGAR.email2.composeLayout.showHiddenAddress('cc',idx);
176 document.getElementById('addressBCC' + idx).value = a.bcc;
177 SUGAR.email2.composeLayout.showHiddenAddress('bcc',idx);
182 document.getElementById('type' + idx).value = a.type;
186 // apply attachment values
187 SUGAR.email2.composeLayout.loadAttachments(a.attachments);
189 setTimeout("callbackReplyForward.finish(globalA);", 500);
194 handleSuccess : function(o) {
195 document.getElementById(this.target).innerHTML = o.responseText;
201 ieDeleteSuccess : function(o) {
204 var ret = JSON.parse(o.responseText);
206 SUGAR.email2.accounts.refreshInboundAccountTable();
207 alert(app_strings.LBL_EMAIL_IE_DELETE_SUCCESSFUL);
208 SUGAR.email2.accounts.rebuildFolderList();
214 ieSaveSuccess : function(o) {
215 document.getElementById('saveButton').disabled = false;
216 var a = JSON.parse(o.responseText);
219 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_CHECK_IE_SETTINGS, 'alert');
220 SUGAR.email2.accounts.ieAccountError(SUGAR.email2.accounts.errorStyle);
222 resp = JSON.parse(o.responseText);
223 SUGAR.email2.accounts.refreshInboundAccountTable();
224 SUGAR.email2.accounts.refreshOuboundAccountTable();
225 SUGAR.email2.folders.startEmailCheckOneAccount(resp.id, true);
226 SUGAR.email2.accounts.inboundAccountEditDialog.hide();
230 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_SAVE_ACCOUNT, 'alert');
237 loadAttachments : function(o) {
238 var result = JSON.parse(o.responseText);
240 SUGAR.email2.composeLayout.loadAttachments(result);
245 loadSignature : function(o) {
246 var ret = JSON.parse(o.responseText);
247 SUGAR.email2.signatures[ret.id] = ret.signature_html;
248 SUGAR.email2.composeLayout.setSignature(SUGAR.email2.signatures.targetInstance);
252 * Follow up to mark email read|unread|flagged
254 markEmailCleanup : function(o) {
255 var ret = JSON.parse(o.responseText);
256 if (!ret['status']) {
258 overlay(app_strings.LBL_EMAIL_ERROR_DESC, ret['message'], 'alert');
260 SUGAR.email2.contextMenus.markEmailCleanup();
266 rebuildShowFolders : function(o) {
267 var t = JSON.parse(o.responseText);
268 var show = document.getElementById('ieAccountListShow');
270 SUGAR.email2.util.emptySelectOptions(show);
272 for(i=0; i<t.length; i++) { // iterate through assoc array
273 var opt = new Option(t[i].text, t[i].value, t[i].selected);
274 opt.selected = t[i].selected;
275 show.options.add(opt);
278 SUGAR.email2.accounts.renderTree();
282 saveListViewSortOrderPart2 : function() {
283 // create the JSON string the func expects
284 focusFolderPath = '[ "Home", "' + ieName + '"';
286 var f = new String(focusFolder);
287 var fEx = f.split('.');
289 for(i=0; i<fEx.length; i++) {
290 focusFolderPath += ', "' + fEx[i] +'"'
293 focusFolderPath += ']';
295 YAHOO.namespace('frameFolders').selectednode = SUGAR.email2.folders.getNodeFromMboxPath(focusFolderPath);
296 SUGAR.email2.listView.populateListFrame(YAHOO.namespace('frameFolders').selectednode, ieId, 'true');
302 sendEmailCleanUp : function(o) {
304 var ret = JSON.parse(o.responseText);
306 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
307 //SUGAR.email2.addressBook.showContactMatches(ret.possibleMatches);
308 } else if (o.responseText) {
309 overlay(mod_strings.LBL_SEND_EMAIL_FAIL_TITLE, o.responseText, 'alert');
312 if (typeof(SE.grid) != 'undefined')
313 SE.listView.refreshGrid();
314 //Disabled while address book is disabled
316 //If this call back was initiated by quick compose from a Detail View page, refresh the
317 //history subpanel. If it was initiated by quickcreate from shortcut bar, then
318 //close the shortcut bar menu
319 if ( (typeof(action_sugar_grp1) != 'undefined')) {
320 if(action_sugar_grp1 == 'DetailView') {
321 showSubPanel('history',null,true);
322 } else if(action_sugar_grp1 == 'quickcreate') {
329 ieSendSuccess : function(o) {
331 overlay(app_strings.LBL_EMAIL_TEST_OUTBOUND_SETTINGS_SENT, app_strings.LBL_EMAIL_TEST_NOTIFICATION_SENT, 'plain');
336 settingsFolderRefresh : function(o) {
337 //SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
338 var ret = JSON.parse(o.responseText);
339 var user = document.getElementById('userFolders');
341 SUGAR.email2.util.emptySelectOptions(user);
343 for(i=0; i<ret.userFolders.length; i++) {
344 var display = ret.userFolders[i].name;
345 var value = ret.userFolders[i].id;
346 var selected = (ret.userFolders[i].selected != "") ? true : false;
347 var opt = new Option(display, value, selected);
348 opt.selected = selected;
349 user.options.add(opt);
355 startRequest : function(callback, args, forceAbort) {
356 if(this.currentRequestObject != null) {
357 if(this.forceAbort == true) {
358 YAHOO.util.Connect.abort(this.currentRequestObject, null, false);
361 this.currentRequestObject = YAHOO.util.Connect.asyncRequest('POST', "./index.php", callback, args);
365 requestInProgress : function() {
366 return (YAHOO.util.Connect.isCallInProgress(this.currentRequestObject));
371 updateFolderSubscriptions : function() {
372 SUGAR.email2.folders.lazyLoadSettings(); // refresh view in Settings overlay
373 SUGAR.email2.folders.setSugarFolders(1000);// refresh view in TreeView
379 updateFrameFolder : function() {
380 SUGAR.email2.folders.checkEmailAccounts();
385 updateUserPrefs : function(o) {
386 SUGAR.email2.userPrefs = JSON.parse(o.responseText);
387 SUGAR.email2.folders.startCheckTimer(); // starts the auto-check interval
392 uploadAttachmentSuccessful : function(o) {
394 document.getElementById('email_attachment').value = '';
396 var ret = JSON.parse(o.responseText);
397 var idx = SUGAR.email2.composeLayout.currentInstanceId;
398 var overall = document.getElementById('addedFiles' + idx);
399 var index = overall.childNodes.length;
401 "<div id='email_attachment_bucket" + idx + index + "'>" +
403 "<img src='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=minus.gif' " +
404 "style='cursor:pointer' align='absmiddle' onclick='SUGAR.email2.composeLayout.deleteUploadAttachment(\"" +
405 idx + index + "\",\"" + ret.guid + ret.name + "\");'/>" +
407 "<img src='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=attachment.gif' " +
408 "id='email_attachmentImage'" + idx + index + "align='absmiddle' />" +
410 "<input type='hidden' value='" + ret.guid + ret.name + "' name='email_attachment" + index + "' id='email_attachment" + idx + index + "' />" +
412 ((ret.nameForDisplay != null) ? ret.nameForDisplay + " " : ret.name + " ") +
415 overall.innerHTML += out;
416 if(SUGAR.email2.util.isIe()) {
417 document.getElementById('addedFiles' + idx).innerHTML = document.getElementById('addedFiles' + idx).innerHTML;
421 SUGAR.email2.addFileDialog.hide();
423 SUGAR.email2.composeLayout.showAttachmentPanel(idx);
428 ///////////////////////////////////////////////////////////////////////////
429 //// PER MODULE CALLBACK OBJECTS
430 AjaxObject.accounts = {
431 saveOutboundCleanup : function(o) {
432 SUGAR.email2.accounts.refreshOuboundAccountTable();
433 SUGAR.email2.accounts.outboundDialog.hide();
434 var id = o.responseText;
435 SUGAR.email2.accounts.newAddedOutboundId = id;
437 saveDefaultOutboundCleanup: function(o){
440 callbackEditOutbound : {
441 success : function(o)
443 var ret = JSON.parse(o.responseText);
445 SUGAR.email2.accounts.showAddSmtp();
448 document.getElementById("mail_id").value = ret.id;
449 document.getElementById("type").value = ret.type;
450 document.getElementById("mail_sendtype").value = ret.mail_sendtype;
451 document.getElementById("mail_name").value = ret.name;
452 document.getElementById("mail_smtpserver").value = ret.mail_smtpserver;
453 document.getElementById("outboundEmailForm").mail_smtptype.value = ret.mail_smtptype;
454 document.getElementById("mail_smtpport").value = ret.mail_smtpport;
455 document.getElementById("mail_smtpuser").value = ret.mail_smtpuser;
456 document.getElementById("mail_smtpauth_req").checked = (ret.mail_smtpauth_req == 1) ? true : false;
457 SUGAR.email2.accounts.smtp_authenticate_field_display();
458 document.getElementById("mail_smtpssl").options[ret.mail_smtpssl].selected = true;
460 if(ret.type == 'system-override') {
461 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(true);
462 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,true);
465 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(false);
466 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,false);
468 SUGAR.util.setEmailPasswordDisplay('mail_smtppass', ret.has_password);
471 failure : AjaxObject.handleFailure,
472 timeout : AjaxObject.timeout,
475 callbackDeleteOutbound : {
476 success : function(o) {
477 var ret = JSON.parse(o.responseText);
480 if(confirm(ret.error_message))
482 overlay(app_strings.LBL_EMAIL_IE_DELETE, app_strings.LBL_EMAIL_ONE_MOMENT);
483 AjaxObject.startRequest(AjaxObject.accounts.callbackDeleteOutbound, urlStandard + "&emailUIAction=deleteOutbound&confirm=true&outbound_email=" + ret.outbound_email);
491 SUGAR.email2.accounts.refreshOuboundAccountTable();
495 failure : AjaxObject.handleFailure,
496 timeout : AjaxObject.timeout,
500 callbackCheckMailProgress : {
501 success : function(o) {
502 if (typeof(SUGAR.email2.accounts.totalMsgCount) == "undefined") {
503 SUGAR.email2.accounts.totalMsgCount = -1;
506 //Check for server timeout / errors
507 var ret = JSON.parse(o.responseText);
510 if (typeof(o.responseText) == 'undefined' || o.responseText == "" || ret == false) {
512 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
513 SUGAR.email2.accounts.totalMsgCount = -1;
514 //SUGAR.email2.folders.rebuildFolders();
518 var currIeId = ret['ieid'];
521 var serverCount = ret.count;
523 if (ret['status'] == 'done') {
524 for(i=0; i < SUGAR.email2.accounts.ieIds.length; i++) {
525 if (i == SUGAR.email2.accounts.ieIds.length - 1) {
529 } else if (SUGAR.email2.accounts.ieIds[i] == currIeId) {
531 currIeId = SUGAR.email2.accounts.ieIds[i+1];
533 SUGAR.email2.accounts.totalMsgCount = -1;
538 else if (ret.mbox && ret.totalcount && ret.count) {
539 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
540 if (ret.count >= ret.totalcount) {
543 } else if (SUGAR.email2.accounts.totalMsgCount < 0 && ret.totalcount) {
544 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
547 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
548 SUGAR.email2.accounts.totalMsgCount = -1;
553 SUGAR.email2.accounts.totalMsgCount = -1;
555 SUGAR.email2.folders.rebuildFolders();
556 SE.listView.refreshGrid();
557 } else if (SUGAR.email2.accounts.totalMsgCount < 0) {
558 YAHOO.SUGAR.MessageBox.updateProgress(0, mod_strings.LBL_CHECKING_ACCOUNT + ' '+ (i + 2) + ' '+ mod_strings.LBL_OF + ' ' + SUGAR.email2.accounts.ieIds.length);
559 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
560 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=0&synch=" + ret.synch);
562 YAHOO.SUGAR.MessageBox.updateProgress((ret.count / SUGAR.email2.accounts.totalMsgCount) * 100,
563 app_strings.LBL_EMAIL_DOWNLOAD_STATUS.replace(/\[\[count\]\]/, ret.count).replace(/\[\[total\]\]/, SUGAR.email2.accounts.totalMsgCount));
564 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
565 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=" + serverCount +
566 '&mbox=' + ret.mbox + '&synch=' + ret.synch + '&totalcount=' + SUGAR.email2.accounts.totalMsgCount);
569 failure : AjaxObject.handleFailure,
570 timeout : AjaxObject.timeout,
575 ///////////////////////////////////////////////////////////////////////////////
577 AjaxObject.composeLayout = {
579 * Populates the record id
581 saveDraftCleanup : function(o) {
583 var ret = JSON.parse(o.responseText);
585 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
586 else if (o.responseText)
587 overlay(mod_strings.LBL_ERROR_SAVING_DRAFT, o.responseText, 'alert');
591 AjaxObject.composeLayout.callback = {
593 success : AjaxObject.composeLayout.saveDraftCleanup,
594 failure : AjaxObject.handleFailure,
595 timeout : AjaxObject.timeout,
600 AjaxObject.detailView = {
602 * Pops-up a printable view of an email
604 displayPrintable : function(o) {
605 var ret = JSON.parse(o.responseText);
606 var displayTemplate = new YAHOO.SUGAR.Template(SUGAR.email2.templates['viewPrintable']);
607 // 2 below must be in global context
609 meta['panelId'] = SUGAR.email2.util.getPanelId();
610 email = ret.meta.email;
611 if (typeof(email.cc) == 'undefined') {
615 var out = displayTemplate.exec({
616 'app_strings' : app_strings,
624 var popup = window.open('modules/Emails/templates/_blank.html', 'printwin' ,
625 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
627 popup.document.write(out);
628 popup.document.close();
632 * Takes formatted response and creates a modal pop-over containing a title and content
634 displayView : function(o) {
635 var SED = SUGAR.email2.detailView;
636 var ret = JSON.parse(o.responseText);
638 if(!SED.viewDialog) {
639 SED.viewDialog = new YAHOO.widget.Dialog("viewDialog", {
643 constraintoviewport: true,
646 SED.viewDialog.renderEvent.subscribe(function() {
647 var content = this.body.firstChild;
648 var viewH = YAHOO.util.Dom.getViewportHeight();
650 this.body.style.overflow = "auto";
651 this.body.style.width = "800px";
652 this.body.style.height = (viewH - 75 > content.clientHeight ? (content.clientHeight) : (viewH - 75)) + "px";
656 SED.viewDialog.setHeader(ret.title);
657 SED.viewDialog.setBody(ret.html);
658 SED.viewDialog.render();
659 SED.viewDialog.show();
663 * Generates a modal popup to populate with the contents of bean's full EditView
665 showQuickCreateForm : function(o) {
666 var SED = SUGAR.email2.detailView;
667 var ret = JSON.parse(o.responseText);
669 if(!SED.quickCreateDialog) {
670 SED.quickCreateDialog = new YAHOO.widget.Dialog("quickCreate", {
674 constraintoviewport: true,
678 SED.quickCreateDialog.renderEvent.subscribe(function() {
679 var viewH = YAHOO.util.Dom.getViewportHeight();
681 for (var i in this.body.childNodes) {
682 if (this.body.childNodes[i].clientHeight) {
683 contH += this.body.childNodes[i].clientHeight;
684 } else if (this.body.childNodes[i].offsetHeight) {
685 contH += this.body.childNodes[i].offsetHeight;
688 this.body.style.width = "800px";
689 this.body.style.height = (viewH - 75 > contH ? (contH + 10) : (viewH - 75)) + "px";
690 this.body.style.overflow = "auto";
691 }, SED.quickCreateDialog);
693 SED.quickCreateDialog.hideEvent.subscribe(function(){
694 var qsFields = YAHOO.util.Dom.getElementsByClassName('.sqsEnabled', null, this.body);
695 /*for(var qsField in qsFields){
696 if (typeof QSFieldsArray[qsFields[qsField].id] != 'undefined')
697 Ext.getCmp('combobox_'+qsFields[qsField].id).destroy();
700 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_QUICK_CREATE);
703 ret.html = ret.html.replace('<script type="text/javascript" src="include/SugarEmailAddress/SugarEmailAddress.js"></script>', "");
705 SED.quickCreateDialog.setBody(ret.html ? ret.html : " ");
706 SED.quickCreateDialog.render();
707 SUGAR.util.evalScript(ret.html + '<script language="javascript">enableQS(true);</script>');
709 SED.quickCreateDialog.ieId = ret.ieId;
710 SED.quickCreateDialog.uid = ret.uid;
711 SED.quickCreateDialog.mbox = ret.mbox;
712 SED.quickCreateDialog.qcmodule = ret.module;
714 SED.quickCreateDialog.show();
716 var editForm = document.getElementById('form_EmailQCView_' + ret.module);
718 editForm.module.value = 'Emails';
719 var count = SUGAR.EmailAddressWidget.count[ret.module] ? SUGAR.EmailAddressWidget.count[ret.module] : 0;
720 var tableId = YAHOO.util.Dom.getElementsByClassName('emailaddresses', 'table', editForm)[0].id;
721 var instId = ret.module + count;
722 SED.quickCreateEmailsToAdd = ret.emailAddress;
723 SED.quickCreateEmailCallback = function(instId, tableId) {
724 var eaw = SUGAR.EmailAddressWidget.instances[instId];
725 if (typeof(eaw) == "undefined")
726 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
727 + instId + "','" + tableId + "');", 100);
728 eaw.prefillEmailAddresses(tableId, SUGAR.email2.detailView.quickCreateEmailsToAdd);
730 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
731 + instId + "','" + tableId + "');", 100);
735 saveQuickCreateForm : function(o) {
737 SUGAR.email2.detailView.quickCreateDialog.hide();
738 validate['EditView'] = [ ];
741 saveQuickCreateFormAndReply : function(o) {
743 var ret = JSON.parse(o.responseText);
744 SUGAR.email2.detailView.quickCreateDialog.hide();
745 var qcd = SUGAR.email2.detailView.quickCreateDialog;
746 var type = (qcd.qcmodule == 'Cases') ? 'replyCase' : 'reply';
748 var emailID = ret.id;
749 SUGAR.email2.composeLayout.c0_replyForwardEmail(null, ret.id, 'sugar::Emails', type);
751 SUGAR.email2.composeLayout.c0_replyForwardEmail(qcd.ieId, qcd.uid, qcd.mbox, type);
753 //Cean the validate cache to prevent errors on the next call
754 validate['EditView'] = [ ];
757 saveQuickCreateFormAndAddToAddressBook : function(o) {
759 SUGAR.email2.detailView.quickCreateDialog.hide();
760 SUGAR.email2.complexLayout.findPanel('contactsTab').show();
761 validate['EditView'] = [ ];
764 handleAssignmentDialogAssignAction : function() {
767 var assign_user_id = window.document.forms['Distribute'].elements['assigned_user_id'].value;
773 var found_teams = false;
774 var warning_message = mod_strings.LBL_WARN_NO_USERS;
775 if(!found_teams && assign_user_id == '' )
777 alert(warning_message);
781 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
783 for(i=0; i<emailUids.length; i++) {
785 uids += app_strings.LBL_EMAIL_DELIMITER;
787 uids += emailUids[i];
790 var row = SUGAR.email2.grid.getSelectedRows()[0];
791 var data = SUGAR.email2.grid.getRecord(row).getData();
792 var ieid = data.ieId;
793 var mbox = data.mbox;
794 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentAssign&uids=" + uids + "&ieId=" + ieid + "&folder=" + mbox + "&distribute_method=" + dist + "&users=" +assign_user_id + get);
795 SUGAR.email2.contextMenus.assignToDialogue.hide();
796 overlay('Assignment', app_strings.LBL_EMAIL_ONE_MOMENT);
800 handleAssignmentDialogDeleteAction : function() {
801 // TO pass list of UIDS/emailIds
802 var uids = SUGAR.email2.listView.getUidsFromSelection();
803 var row = SUGAR.email2.grid.getSelections()[0];
804 var ieid = row.data.ieId;
805 var mbox = row.data.mbox;
806 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentDelete&uids=" + uids + "&ieId=" + ieId + "&folder=" + mbox);
807 SUGAR.email2.contextMenus.assignmentDialog.hide();
808 overlay(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
814 showEmailDetailView : function(o) {
816 var SED = SUGAR.email2.detailView;
817 var ret = JSON.parse(o.responseText);
819 if(!SED.quickCreateDialog) {
820 SED.quickCreateDialog = new YAHOO.widget.Dialog("emailDetailDialog", {
824 constraintoviewport: true,
826 autofillheight: "body",
829 SED.quickCreateDialog.renderEvent.subscribe(function() {
830 var viewHeight = YAHOO.util.Dom.getViewportHeight();
832 for (var i in this.body.childNodes) {
833 if (this.body.childNodes[i].offsetHeight)
834 contH += this.body.childNodes[i].offsetHeight;
836 this.body.style.overflow = "auto";
837 this.body.style.width = "800px";
838 this.body.style.height = (viewHeight - 75 > contH ? (contH + 10) : (viewHeight - 75)) + "px";
840 }, SED.quickCreateDialog);
842 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_RECORD);
843 SED.quickCreateDialog.setBody(ret.html);
844 SED.quickCreateDialog.render();
845 SUGAR.util.evalScript(ret.html);
846 SED.quickCreateDialog.show();
849 showAssignmentDialogWithData : function(o) {
850 var SEC = SUGAR.email2.contextMenus;
852 var ret = JSON.parse(o.responseText);
853 if (!SEC.assignmentDialog) {
854 SEC.assignmentDialog = new YAHOO.widget.Dialog("assignmentDialog", {
857 constraintoviewport: true,
860 SEC.assignmentDialog.setBody("");
861 SEC.assignmentDialog.setHeader(app_strings.LBL_EMAIL_ASSIGNMENT);
862 SEC.assignmentDialog.renderEvent.subscribe(function() {
863 var iev = YAHOO.util.Dom.get("Distribute");
865 this.body.style.width = "700px";
867 }, SEC.assignmentDialog);
868 SEC.assignmentDialog.render();
870 SEC.assignmentDialog.setBody(ret);
871 SEC.assignmentDialog.render();
873 SEC.assignmentDialog.show();
874 SUGAR.util.evalScript(ret);
877 showImportForm : function(o) {
878 var SED = SUGAR.email2.detailView;
879 var ret = JSON.parse(o.responseText);
881 document.getElementById('quickCreateContent').innerHTML = "";
887 if(!SED.importDialog) {
888 SED.importDialog = new YAHOO.widget.Dialog("importDialog", {
892 constraintoviewport: true,
894 text: app_strings.LBL_EMAIL_ARCHIVE_TO_SUGAR, isDefault: true, handler: function(){
895 AjaxObject.detailView.getImportAction(SED.importDialog.ret); }
899 SED.importDialog.setHeader(app_strings.LBL_EMAIL_IMPORT_SETTINGS);
900 SED.importDialog.setBody("");
901 SED.importDialog.hideEvent.subscribe(function(){
902 for(var i in QSFieldsArray) {
903 if (QSFieldsArray[i] != null && typeof(QSFieldsArray[i]) == "object") {
904 QSFieldsArray[i].destroy();
905 delete QSFieldsArray[i];
907 if (QSProcessedFieldsArray[i]) {
908 QSProcessedFieldsArray[i] = false;
912 SED.importDialog.renderEvent.subscribe(function() {
913 var iev = YAHOO.util.Dom.get("ImportEditView");
915 //this.body.style.height = (iev.clientHeight + 10) + "px";
916 this.body.style.width = "600px";
918 }, SED.importDialog);
919 SED.importDialog.render();
921 SED.importDialog.setBody(ret.html);
922 SED.importDialog.ret = ret;
923 SUGAR.util.evalScript(ret.html);
924 SED.importDialog.render();
926 SED.importDialog.show();
927 SED.importDialog.focusFirstButton();
929 getImportAction : function(ret) {
930 if (!check_form('ImportEditView')) return false;
931 if (!SUGAR.collection.prototype.validateTemSet('ImportEditView', 'team_name')) {
932 alert(mod_strings.LBL_EMAILS_NO_PRIMARY_TEAM_SPECIFIED);
936 var editView = document.getElementById('ImportEditView');
937 if (editView.assigned_user_id != null) {
938 get = get + "&user_id=" + editView.assigned_user_id.value
939 //var user_id = editView.assigned_user_id.value;
941 var parent_id = editView.parent_id.value;
942 var parent_type = editView.parent_type.value;
943 var row = SUGAR.email2.grid.getSelectedRows()[0];
944 row = SUGAR.email2.grid.getRecord(row);
945 var data = row.getData();
946 var ieId = data.ieId;
947 var mbox = data.mbox;
948 var serverDelete = editView.serverDelete.checked;
949 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
951 for(i=0; i<emailUids.length; i++) {
953 uids += app_strings.LBL_EMAIL_DELIMITER;
955 uids += emailUids[i];
958 var action = 'importEmail&uid=';
960 action = 'moveEmails';
961 action = action + '&sourceFolder=' + ret['srcFolder'];
962 action = action + '&sourceIeId=' + ret['srcIeId'];
963 action = action + '&destinationFolder=' + ret['dstFolder'];
964 action = action + '&destinationIeId=' + ret['dstIeId'];
965 action = action + '&emailUids=';
967 if (action.search(/importEmail/) != -1) {
968 overlay(app_strings.LBL_EMAIL_IMPORTING_EMAIL, app_strings.LBL_EMAIL_ONE_MOMENT);
970 overlay("Moving Email(s)", app_strings.LBL_EMAIL_ONE_MOMENT);
973 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=' + action + uids + "&ieId=" + ieId + "&mbox=" + mbox +
974 get + "&parent_id=" + parent_id + "&parent_type=" + parent_type + '&delete=' + serverDelete);
975 SUGAR.email2.detailView.importDialog.hide();
976 document.getElementById('importDialogContent').innerHTML = "";
979 showRelateForm : function(o) {
980 var SED = SUGAR.email2.detailView;
981 var ret = JSON.parse(o.responseText);
982 document.getElementById('quickCreateContent').innerHTML = "";
987 dialog_loaded = true;
989 if(!SED.relateDialog) {
990 SED.relateDialog = new YAHOO.widget.Dialog('relateDialog', {
995 constraintoviewport: true,
997 text: app_strings.LBL_EMAIL_RELATE_TO, isDefault: true, handler: function(){
998 if (!check_form('RelateEditView')) return false;
1000 var editView = document.getElementById('RelateEditView');
1001 var parent_id = editView.parent_id.value;
1002 var parent_type = editView.parent_type.value;
1003 var row = SUGAR.email2.grid.getSelectedRows()[0];
1004 row = SUGAR.email2.grid.getRecord(row);
1005 var ieId = row.getData().ieId;
1006 var mbox = row.getData().mbox;
1007 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
1009 for(i=0; i<emailUids.length; i++) {
1011 uids += app_strings.LBL_EMAIL_DELIMITER;
1013 uids += emailUids[i];
1015 overlay(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
1016 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=relateEmails&uid=' + uids
1017 + "&ieId=" + ieId + "&mbox=" + mbox + "&parent_id=" + parent_id + "&parent_type=" + parent_type);
1018 SED.relateDialog.hide();
1019 document.getElementById('relateDialogContent').innerHTML = "";
1024 SED.relateDialog.hideEvent.subscribe(function(){
1025 if (QSFieldsArray['ImportEditView_parent_name'] != null) {
1026 QSFieldsArray['ImportEditView_parent_name'].destroy();
1027 delete QSFieldsArray['ImportEditView_parent_name'];
1029 if (QSProcessedFieldsArray['ImportEditView_parent_name']) {
1030 QSProcessedFieldsArray['ImportEditView_parent_name'] = false;
1034 SED.relateDialog.renderEvent.subscribe(function() {
1035 var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
1037 for (var i in this.body.childNodes) {
1038 if (this.body.childNodes[i].clientHeight)
1039 contH += this.body.childNodes[i].clientHeight;
1041 }, SED.relateDialog);
1042 SED.relateDialog.setHeader(app_strings.LBL_EMAIL_RELATE_EMAIL);
1045 SED.relateDialog.setBody(ret.html);
1046 SED.relateDialog.render();
1047 SUGAR.util.evalScript(ret.html);
1048 SED.relateDialog.show();
1052 * DetailView callbacks
1054 AjaxObject.detailView.callback = {
1056 success : function(o) {
1058 var ret = JSON.parse(o.responseText);
1059 SUGAR.email2.detailView.consumeMetaDetail(ret);
1061 argument: [targetDiv],
1062 failure : AjaxObject.handleFailure,
1067 success : function(o) {
1069 var ret = JSON.parse(o.responseText);
1070 SUGAR.email2.detailView.consumeMetaPreview(ret);
1072 failure : AjaxObject.handleFailure,
1077 success : AjaxObject.detailView.displayPrintable,
1078 failure : AjaxObject.handleFailure,
1079 timeout : AjaxObject.timeout,
1083 success : AjaxObject.detailView.displayView,
1084 failure : AjaxObject.handleFailure,
1085 timeout : AjaxObject.timeout,
1094 AjaxObject.folders = {
1096 * check-mail post actions
1098 checkMailCleanup : function(o) {
1100 AjaxObject.folders.rebuildFolders(o); // rebuild TreeView
1102 // refresh focus ListView
1103 SE.listView.refreshGrid();
1104 SUGAR.email2.folders.startCheckTimer(); // resets the timer
1109 rebuildFolders : function(o) {
1112 var data = JSON.parse(o.responseText);
1114 email2treeinit(SUGAR.email2.tree, data.tree_data, 'frameFolders', data.param);
1115 SUGAR.email2.folders.setSugarFolders();
1118 AjaxObject.folders.callback = {
1120 success : AjaxObject.folders.checkMailCleanup,
1121 failure : AjaxObject.handleFailure,
1122 timeout : 600000, // 5 mins
1127 AjaxObject.rules = {
1128 loadRulesForSettings : function(o) {
1129 document.getElementById("rulesListCell").innerHTML = o.responseText;
1130 // assume we have the class we need
1131 SUGAR.routing.getStrings();
1132 SUGAR.routing.getDependentDropdowns();
1135 //// END PER MODULE CALLBACK OBJECTS
1136 ///////////////////////////////////////////////////////////////////////////
1140 success : AjaxObject.handleSuccess,
1141 failure : AjaxObject.handleFailure,
1142 timeout : AjaxObject.timeout,
1145 var callbackAccount = {
1146 success : AjaxObject.ieSaveSuccess,
1147 failure : AjaxObject.handleFailure,
1148 timeout : AjaxObject.timeout,
1151 var callbackAccountDelete = {
1152 success : AjaxObject.ieDeleteSuccess,
1153 failure : AjaxObject.handleFailure,
1154 timeout : AjaxObject.timeout,
1157 var callbackOutboundTest = {
1158 success : AjaxObject.ieSendSuccess,
1159 failure : AjaxObject.handleFailure,
1160 timeout : AjaxObject.timeout,
1166 var callbackTeamInfoForSettings = {
1167 success : function (o) {
1168 var data = JSON.parse(o.responseText);
1169 document.getElementById('EditViewGroupFolderTeamTD').innerHTML = data.defaultgroupfolder;
1171 failure : AjaxObject.handleFailure,
1172 timeout : AjaxObject.timeout,
1177 var callbackStatusForImport = {
1178 success : function (o) {
1180 if (o.responseText != "") {
1181 var statusString = "";
1182 var data = JSON.parse(o.responseText);
1183 for(i=0; i<data.length; i++) {
1184 statusString = statusString + data[i] + '<br/>';
1186 overlay(SUGAR.language.get('Emails','LBL_IMPORT_STATUS_TITLE'), statusString, 'alert');
1188 SE.listView.refreshGrid();
1191 failure : AjaxObject.handleFailure,
1192 timeout : AjaxObject.timeout,
1196 var callbackComposeCache = {
1197 success : AjaxObject.composeCache,
1198 failure : AjaxObject.handleFailure,
1199 timeout : AjaxObject.timeout,
1202 var callbackDelete = {
1203 success : AjaxObject.handleDeleteReturn,
1204 failure : AjaxObject.handleFailure,
1205 timeout : AjaxObject.timeout,
1208 var callbackEmailDetailMultiple = {
1209 success : function(o) {
1211 var retMulti = JSON.parse(o.responseText);
1212 var ret = new Object();
1214 for(var i=0; i<retMulti.length; i++) {
1217 SUGAR.email2._setDetailCache(ret);
1218 SUGAR.email2.detailView.populateDetailView(ret.meta.uid, ret.meta.mbox, ret.meta.ieId, true, SUGAR.email2.innerLayout);
1221 failure : AjaxObject.handleFailure,
1225 var callbackListViewSortOrderChange = {
1226 success : AjaxObject.saveListViewSortOrderPart2,
1227 failure : AjaxObject.handleFailure,
1228 timeout : AjaxObject.timeout,
1230 argument : [ieId, ieName, focusFolder]
1232 var callbackEmptyTrash = {
1233 success : function(o) {
1235 AjaxObject.folderRenameCleanup;
1237 failure : AjaxObject.handleFailure,
1238 timeout : AjaxObject.timeout,
1241 var callbackClearCacheFiles = {
1242 success : function(o) {
1245 failure : AjaxObject.handleFailure,
1246 timeout : AjaxObject.timeout,
1249 var callbackFolderRename = {
1250 success : function(o) {hideOverlay();SUGAR.email2.folders.rebuildFolders();},
1251 failure : AjaxObject.handleFailure,
1252 timeout : AjaxObject.timeout,
1255 var callbackFolderDelete = {
1256 success : function(o) {
1257 var ret = JSON.parse(o.responseText);
1259 if (ret.folder_id) {
1260 var node = SUGAR.email2.folders.getNodeFromId(ret.folder_id);
1262 SUGAR.email2.tree.removeNode(node, true);
1263 } else if (ret.ieId && ret.mbox) {
1264 var node = SUGAR.email2.folders.getNodeFromIeIdAndMailbox(ret.ieId, ret.mbox);
1266 SUGAR.email2.tree.removeNode(node, true);
1269 //SUGAR.email2.folders.loadSettingFolder();
1272 overlay(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorMessage, 'alert');
1275 failure : AjaxObject.handleFailure,
1276 timeout : AjaxObject.timeout,
1279 var callbackFolderSave = {
1280 success : function(o) {
1281 var ret = JSON.parse(o.responseText);
1283 switch(ret.action) {
1284 case 'newFolderSave':
1285 SUGAR.email2.folders.rebuildFolders();
1289 failure : AjaxObject.handleFailure,
1290 timeout : AjaxObject.timeout,
1293 var callbackFolderSubscriptions = {
1294 success : AjaxObject.updateFolderSubscriptions,
1295 failure : AjaxObject.handleFailure,
1296 timeout : AjaxObject.timeout,
1299 var callbackFolderUpdate = {
1300 success : AjaxObject.updateFrameFolder,
1301 failure : AjaxObject.handleFailure,
1302 timeout : AjaxObject.timeout,
1305 var callbackFolders = {
1306 success : AjaxObject.folders.rebuildFolders,
1307 //success : void(true),
1308 failure : AjaxObject.handleFailure,
1309 timeout : AjaxObject.timeout,
1312 var callbackFullSync = {
1313 success : AjaxObject.fullSyncCleanup,
1314 failure : AjaxObject.handleFailure,
1315 timeout : 9999999999999,
1318 var callbackGeneric = {
1319 success : function() {
1322 failure : AjaxObject.handleFailure,
1323 timeout : AjaxObject.timeout,
1326 var callbackIeAccountRetrieve = {
1327 success : function(o) {
1328 // return JSON encoding
1330 SUGAR.email2.accounts.fillIeAccount(o.responseText);
1331 SUGAR.email2.accounts.showEditInboundAccountDialogue(false);
1333 failure : AjaxObject.handleFailure,
1334 timeout : AjaxObject.timeout,
1337 var callbackImportOneEmail = {
1338 success : AjaxObject.detailView.showImportForm,
1339 failure : AjaxObject.handleFailure,
1340 timeout : AjaxObject.timeout,
1343 var callbackRelateEmail = {
1344 success : AjaxObject.detailView.showRelateForm,
1345 failure : AjaxObject.handleFailure,
1346 timeout : AjaxObject.timeout,
1349 var callbackEmailDetailView = {
1350 success : AjaxObject.detailView.showEmailDetailView,
1351 failure : AjaxObject.handleFailure,
1352 timeout : AjaxObject.timeout,
1355 var callbackAssignmentDialog = {
1356 success : AjaxObject.detailView.showAssignmentDialogWithData,
1357 failure : AjaxObject.handleFailure,
1358 timeout : AjaxObject.timeout,
1361 var callbackAssignmentAction = {
1362 success : function(o) {
1363 SE.listView.refreshGrid();
1365 if(o.responseText != '') {
1366 overlay('Assignment action result', o.responseText, 'alert');
1369 failure : AjaxObject.handleFailure,
1370 timeout : AjaxObject.timeout,
1373 var callbackMoveEmails = {
1374 success : function(o) {
1375 SE.listView.refreshGrid();
1377 if(o.responseText != '') {
1378 overlay(app_strings.LBL_EMAIL_ERROR_DESC, o.responseText, 'alert');
1381 failure : AjaxObject.handleFailure,
1382 timeout : AjaxObject.timeout,
1385 var callbackLoadAttachments = {
1386 success : AjaxObject.loadAttachments,
1387 failure : AjaxObject.handleFailure,
1388 timeout : AjaxObject.timeout,
1391 var callbackLoadRules = {
1392 success : AjaxObject.rules.loadRulesForSettings,
1393 failure : AjaxObject.handleFailure,
1394 timeout : AjaxObject.timeout,
1397 var callbackLoadSignature = {
1398 success : AjaxObject.loadSignature,
1399 failure : AjaxObject.handleFailure,
1400 timeout : AjaxObject.timeout,
1403 var callbackDeleteSignature = {
1404 success : AjaxObject.handleDeleteSignature,
1405 failure : AjaxObject.handleFailure,
1406 timeout : AjaxObject.timeout,
1409 /*var callbackMoveEmails = {
1410 success : function(o) { SUGAR.email2.listView.moveEmailsCleanup(o) },
1411 failure : AjaxObject.handleFailure,
1412 timeout : AjaxObject.timeout,
1415 var callbackOutboundSave = {
1416 success : AjaxObject.accounts.saveOutboundCleanup,
1417 failure : AjaxObject.handleFailure,
1418 timeout : AjaxObject.timeout,
1421 var callbackDefaultOutboundSave = {
1422 success : AjaxObject.accounts.saveDefaultOutboundCleanup,
1423 failure : AjaxObject.handleFailure,
1424 timeout : AjaxObject.timeout,
1427 var callbackQuickCreate = {
1428 success : AjaxObject.detailView.showQuickCreateForm,
1429 failure : AjaxObject.handleFailure,
1430 timeout : AjaxObject.timeout,
1433 var callbackQuickCreateSave = {
1434 success : AjaxObject.detailView.saveQuickCreateForm,
1435 failure : AjaxObject.handleFailure,
1436 timeout : AjaxObject.timeout,
1439 var callbackQuickCreateSaveAndAddToAddressBook = {
1440 success : AjaxObject.detailView.saveQuickCreateFormAndAddToAddressBook,
1441 failure : AjaxObject.handleFailure,
1442 timeout : AjaxObject.timeout,
1445 var callbackQuickCreateSaveAndReply = {
1446 success : AjaxObject.detailView.saveQuickCreateFormAndReply,
1447 failure : AjaxObject.handleFailure,
1448 timeout : AjaxObject.timeout,
1451 var callbackQuickCreateSaveAndReplyCase = {
1452 success : AjaxObject.detailView.saveQuickCreateFormAndReplyCase,
1453 failure : AjaxObject.handleFailure,
1454 timeout : AjaxObject.timeout,
1457 var callbackRebuildShowAccountList = {
1458 success : AjaxObject.rebuildShowFolders,
1459 failure : AjaxObject.handleFailure,
1460 timeout : AjaxObject.timeout,
1464 var callbackRefreshSugarFolders = {
1465 success : function(o) {
1466 var t = JSON.parse(o.responseText);
1467 SUGAR.email2.folders.setSugarFoldersEnd(t);
1469 failure : AjaxObject.handleFailure,
1470 timeout : AjaxObject.timeout,
1473 var callbackReplyForward = {
1474 success : AjaxObject.handleReplyForward,
1475 finish : function(a, retryCount) {
1476 if (typeof(retryCount) == 'undefined') {
1481 var idx = SUGAR.email2.composeLayout.currentInstanceId;
1482 var t = tinyMCE.getInstanceById('htmleditor' + idx);
1484 var html = t.getContent();
1486 if (a.type != 'draft') {
1487 if(SUGAR.email2.userPrefs.signatures.signature_prepend == 'true') {
1488 html += " <div><hr></div>" + a.description;
1490 html = " <div><hr></div>" + a.description + html;
1493 html = a.description;
1496 t.setContent(html);//
1499 if (retryCount < 5) {
1500 setTimeout("callbackReplyForward.finish(globalA, " + retryCount + ");", 500);
1504 var tabArray = SUGAR.email2.innerLayout.get("tabs");
1505 if (tabArray != null && tabArray.length > 0) {
1506 for (i = 0 ; i < tabArray.length ; i++) {
1507 var tabObject = tabArray[i];
1508 if (tabObject.get("id") == ("composeTab" + idx)) {
1509 var tabLabel = a.name;
1510 if (tabLabel != null && tabLabel.length > 25) {
1511 tabLabel = tabLabel.substring(0, 25) + "...";
1513 tabObject.get("labelEl").firstChild.data = tabLabel;
1519 //SUGAR.email2.innerLayout.regions.center.getPanel('composeLayout' + idx).setTitle(a.name);
1520 if (a.parent_name != null && a.parent_name != "") {
1521 document.getElementById('data_parent_name' + idx).value = a.parent_name;
1523 if (a.parent_type != null && a.parent_type != "") {
1524 document.getElementById('data_parent_type' + idx).value = a.parent_type;
1526 if (a.parent_id != null && a.parent_id != "") {
1527 document.getElementById('data_parent_id' + idx).value = a.parent_id;
1529 if (a.fromAccounts.status) {
1530 var addressFrom = document.getElementById('addressFrom' + idx);
1531 SUGAR.email2.util.emptySelectOptions(addressFrom);
1532 var fromAccountOpts = a.fromAccounts.data;
1533 for(i=0; i<fromAccountOpts.length; i++) {
1534 var key = fromAccountOpts[i].value;
1535 var display = fromAccountOpts[i].text;
1536 var opt = new Option(display, key);
1537 if (fromAccountOpts[i].selected) {
1538 opt.selected = true;
1540 addressFrom.options.add(opt);
1546 failure : AjaxObject.handleFailure,
1547 timeout : AjaxObject.timeout,
1549 argument : [sendType]
1551 var callbackSendEmail = {
1552 success : AjaxObject.sendEmailCleanUp,
1553 failure : AjaxObject.handleFailure,
1554 timeout : AjaxObject.timeout,
1557 var callbackSettings = {
1558 success : AjaxObject.updateUserPrefs,
1559 failure : AjaxObject.handleFailure,
1560 timeout : AjaxObject.timeout,
1563 var callbackSettingsFolderRefresh = {
1564 success : AjaxObject.settingsFolderRefresh,
1565 failure : AjaxObject.handleFailure,
1566 timeout : AjaxObject.timeout,
1569 var callbackLoadSettingFolder = {
1570 success : function(o) {
1571 AjaxObject.settingsFolderRefresh(o);
1572 SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
1574 failure : AjaxObject.handleFailure,
1575 timeout : AjaxObject.timeout,
1579 var callbackUploadAttachment = {
1580 success : AjaxObject.uploadAttachmentSuccessful,
1581 upload : AjaxObject.uploadAttachmentSuccessful,
1582 failure : AjaxObject.handleFailure,
1583 timeout : AjaxObject.timeout,
1586 var callbackUserPrefs = {
1587 success : function(o) {
1588 SUGAR.email2.userPrefs = JSON.parse(o.responseText);
1590 failure : AjaxObject.handleFailure,
1591 timeout : AjaxObject.timeout,
1595 var callbackContextmenus = {
1597 success : AjaxObject.markEmailCleanup,
1598 failure : AjaxObject.handleFailure,
1599 timeout : AjaxObject.timeout,
1604 var callbackCheckEmail2 = {
1605 success : function(o) {
1606 var ret = JSON.parse(o.responseText);
1607 overlay(app_strings.LBL_EMAIL_CHECKING_NEW, ret.text);
1611 failure : AjaxObject.handleFailure,
1612 timeout : AjaxObject.timeout,