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_smtppass").value = ret.mail_smtppass;
457 document.getElementById("mail_smtpauth_req").checked = (ret.mail_smtpauth_req == 1) ? true : false;
458 SUGAR.email2.accounts.smtp_authenticate_field_display();
459 document.getElementById("mail_smtpssl").options[ret.mail_smtpssl].selected = true;
461 if(ret.type == 'system-override') {
462 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(true);
463 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,true);
466 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(false);
467 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,false);
472 failure : AjaxObject.handleFailure,
473 timeout : AjaxObject.timeout,
476 callbackDeleteOutbound : {
477 success : function(o) {
478 var ret = JSON.parse(o.responseText);
481 if(confirm(ret.error_message))
483 overlay(app_strings.LBL_EMAIL_IE_DELETE, app_strings.LBL_EMAIL_ONE_MOMENT);
484 AjaxObject.startRequest(AjaxObject.accounts.callbackDeleteOutbound, urlStandard + "&emailUIAction=deleteOutbound&confirm=true&outbound_email=" + ret.outbound_email);
492 SUGAR.email2.accounts.refreshOuboundAccountTable();
496 failure : AjaxObject.handleFailure,
497 timeout : AjaxObject.timeout,
501 callbackCheckMailProgress : {
502 success : function(o) {
503 if (typeof(SUGAR.email2.accounts.totalMsgCount) == "undefined") {
504 SUGAR.email2.accounts.totalMsgCount = -1;
507 //Check for server timeout / errors
508 var ret = JSON.parse(o.responseText);
511 if (typeof(o.responseText) == 'undefined' || o.responseText == "" || ret == false) {
513 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
514 SUGAR.email2.accounts.totalMsgCount = -1;
515 //SUGAR.email2.folders.rebuildFolders();
519 var currIeId = ret['ieid'];
522 var serverCount = ret.count;
524 if (ret['status'] == 'done') {
525 for(i=0; i < SUGAR.email2.accounts.ieIds.length; i++) {
526 if (i == SUGAR.email2.accounts.ieIds.length - 1) {
530 } else if (SUGAR.email2.accounts.ieIds[i] == currIeId) {
532 currIeId = SUGAR.email2.accounts.ieIds[i+1];
534 SUGAR.email2.accounts.totalMsgCount = -1;
539 else if (ret.mbox && ret.totalcount && ret.count) {
540 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
541 if (ret.count >= ret.totalcount) {
544 } else if (SUGAR.email2.accounts.totalMsgCount < 0 && ret.totalcount) {
545 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
548 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
549 SUGAR.email2.accounts.totalMsgCount = -1;
554 SUGAR.email2.accounts.totalMsgCount = -1;
556 SUGAR.email2.folders.rebuildFolders();
557 SE.listView.refreshGrid();
558 } else if (SUGAR.email2.accounts.totalMsgCount < 0) {
559 YAHOO.SUGAR.MessageBox.updateProgress(0, mod_strings.LBL_CHECKING_ACCOUNT + ' '+ (i + 2) + ' '+ mod_strings.LBL_OF + ' ' + SUGAR.email2.accounts.ieIds.length);
560 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
561 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=0&synch=" + ret.synch);
563 YAHOO.SUGAR.MessageBox.updateProgress((ret.count / SUGAR.email2.accounts.totalMsgCount) * 100,
564 app_strings.LBL_EMAIL_DOWNLOAD_STATUS.replace(/\[\[count\]\]/, ret.count).replace(/\[\[total\]\]/, SUGAR.email2.accounts.totalMsgCount));
565 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
566 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=" + serverCount +
567 '&mbox=' + ret.mbox + '&synch=' + ret.synch + '&totalcount=' + SUGAR.email2.accounts.totalMsgCount);
570 failure : AjaxObject.handleFailure,
571 timeout : AjaxObject.timeout,
576 ///////////////////////////////////////////////////////////////////////////////
578 AjaxObject.composeLayout = {
580 * Populates the record id
582 saveDraftCleanup : function(o) {
584 var ret = JSON.parse(o.responseText);
586 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
587 else if (o.responseText)
588 overlay(mod_strings.LBL_ERROR_SAVING_DRAFT, o.responseText, 'alert');
592 AjaxObject.composeLayout.callback = {
594 success : AjaxObject.composeLayout.saveDraftCleanup,
595 failure : AjaxObject.handleFailure,
596 timeout : AjaxObject.timeout,
601 AjaxObject.detailView = {
603 * Pops-up a printable view of an email
605 displayPrintable : function(o) {
606 var ret = JSON.parse(o.responseText);
607 var displayTemplate = new YAHOO.SUGAR.Template(SUGAR.email2.templates['viewPrintable']);
608 // 2 below must be in global context
610 meta['panelId'] = SUGAR.email2.util.getPanelId();
611 email = ret.meta.email;
612 if (typeof(email.cc) == 'undefined') {
616 var out = displayTemplate.exec({
617 'app_strings' : app_strings,
625 var popup = window.open('modules/Emails/templates/_blank.html', 'printwin' ,
626 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
628 popup.document.write(out);
629 popup.document.close();
633 * Takes formatted response and creates a modal pop-over containing a title and content
635 displayView : function(o) {
636 var SED = SUGAR.email2.detailView;
637 var ret = JSON.parse(o.responseText);
639 if(!SED.viewDialog) {
640 SED.viewDialog = new YAHOO.widget.Dialog("viewDialog", {
644 constraintoviewport: true,
647 SED.viewDialog.renderEvent.subscribe(function() {
648 var content = this.body.firstChild;
649 var viewH = YAHOO.util.Dom.getViewportHeight();
651 this.body.style.overflow = "auto";
652 this.body.style.width = "800px";
653 this.body.style.height = (viewH - 75 > content.clientHeight ? (content.clientHeight) : (viewH - 75)) + "px";
657 SED.viewDialog.setHeader(ret.title);
658 SED.viewDialog.setBody(ret.html);
659 SED.viewDialog.render();
660 SED.viewDialog.show();
664 * Generates a modal popup to populate with the contents of bean's full EditView
666 showQuickCreateForm : function(o) {
667 var SED = SUGAR.email2.detailView;
668 var ret = JSON.parse(o.responseText);
670 if(!SED.quickCreateDialog) {
671 SED.quickCreateDialog = new YAHOO.widget.Dialog("quickCreate", {
675 constraintoviewport: true,
679 SED.quickCreateDialog.renderEvent.subscribe(function() {
680 var viewH = YAHOO.util.Dom.getViewportHeight();
682 for (var i in this.body.childNodes) {
683 if (this.body.childNodes[i].clientHeight) {
684 contH += this.body.childNodes[i].clientHeight;
685 } else if (this.body.childNodes[i].offsetHeight) {
686 contH += this.body.childNodes[i].offsetHeight;
689 this.body.style.width = "800px";
690 this.body.style.height = (viewH - 75 > contH ? (contH + 10) : (viewH - 75)) + "px";
691 this.body.style.overflow = "auto";
692 }, SED.quickCreateDialog);
694 SED.quickCreateDialog.hideEvent.subscribe(function(){
695 var qsFields = YAHOO.util.Dom.getElementsByClassName('.sqsEnabled', null, this.body);
696 /*for(var qsField in qsFields){
697 if (typeof QSFieldsArray[qsFields[qsField].id] != 'undefined')
698 Ext.getCmp('combobox_'+qsFields[qsField].id).destroy();
701 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_QUICK_CREATE);
704 ret.html = ret.html.replace('<script type="text/javascript" src="include/SugarEmailAddress/SugarEmailAddress.js"></script>', "");
706 SED.quickCreateDialog.setBody(ret.html ? ret.html : " ");
707 SED.quickCreateDialog.render();
708 SUGAR.util.evalScript(ret.html + '<script language="javascript">enableQS(true);</script>');
710 SED.quickCreateDialog.ieId = ret.ieId;
711 SED.quickCreateDialog.uid = ret.uid;
712 SED.quickCreateDialog.mbox = ret.mbox;
713 SED.quickCreateDialog.qcmodule = ret.module;
715 SED.quickCreateDialog.show();
717 var editForm = document.getElementById('form_EmailQCView_' + ret.module);
719 editForm.module.value = 'Emails';
720 var count = SUGAR.EmailAddressWidget.count[ret.module] ? SUGAR.EmailAddressWidget.count[ret.module] : 0;
721 var tableId = YAHOO.util.Dom.getElementsByClassName('emailaddresses', 'table', editForm)[0].id;
722 var instId = ret.module + count;
723 SED.quickCreateEmailsToAdd = ret.emailAddress;
724 SED.quickCreateEmailCallback = function(instId, tableId) {
725 var eaw = SUGAR.EmailAddressWidget.instances[instId];
726 if (typeof(eaw) == "undefined")
727 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
728 + instId + "','" + tableId + "');", 100);
729 eaw.prefillEmailAddresses(tableId, SUGAR.email2.detailView.quickCreateEmailsToAdd);
731 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
732 + instId + "','" + tableId + "');", 100);
736 saveQuickCreateForm : function(o) {
738 SUGAR.email2.detailView.quickCreateDialog.hide();
739 validate['EditView'] = [ ];
742 saveQuickCreateFormAndReply : function(o) {
744 var ret = JSON.parse(o.responseText);
745 SUGAR.email2.detailView.quickCreateDialog.hide();
746 var qcd = SUGAR.email2.detailView.quickCreateDialog;
747 var type = (qcd.qcmodule == 'Cases') ? 'replyCase' : 'reply';
749 var emailID = ret.id;
750 SUGAR.email2.composeLayout.c0_replyForwardEmail(null, ret.id, 'sugar::Emails', type);
752 SUGAR.email2.composeLayout.c0_replyForwardEmail(qcd.ieId, qcd.uid, qcd.mbox, type);
754 //Cean the validate cache to prevent errors on the next call
755 validate['EditView'] = [ ];
758 saveQuickCreateFormAndAddToAddressBook : function(o) {
760 SUGAR.email2.detailView.quickCreateDialog.hide();
761 SUGAR.email2.complexLayout.findPanel('contactsTab').show();
762 validate['EditView'] = [ ];
765 handleAssignmentDialogAssignAction : function() {
768 var assign_user_id = window.document.forms['Distribute'].elements['assigned_user_id'].value;
774 var found_teams = false;
775 var warning_message = mod_strings.LBL_WARN_NO_USERS;
776 if(!found_teams && assign_user_id == '' )
778 alert(warning_message);
782 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
784 for(i=0; i<emailUids.length; i++) {
786 uids += app_strings.LBL_EMAIL_DELIMITER;
788 uids += emailUids[i];
791 var row = SUGAR.email2.grid.getSelectedRows()[0];
792 var data = SUGAR.email2.grid.getRecord(row).getData();
793 var ieid = data.ieId;
794 var mbox = data.mbox;
795 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentAssign&uids=" + uids + "&ieId=" + ieid + "&folder=" + mbox + "&distribute_method=" + dist + "&users=" +assign_user_id + get);
796 SUGAR.email2.contextMenus.assignToDialogue.hide();
797 overlay('Assignment', app_strings.LBL_EMAIL_ONE_MOMENT);
801 handleAssignmentDialogDeleteAction : function() {
802 // TO pass list of UIDS/emailIds
803 var uids = SUGAR.email2.listView.getUidsFromSelection();
804 var row = SUGAR.email2.grid.getSelections()[0];
805 var ieid = row.data.ieId;
806 var mbox = row.data.mbox;
807 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentDelete&uids=" + uids + "&ieId=" + ieId + "&folder=" + mbox);
808 SUGAR.email2.contextMenus.assignmentDialog.hide();
809 overlay(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
815 showEmailDetailView : function(o) {
817 var SED = SUGAR.email2.detailView;
818 var ret = JSON.parse(o.responseText);
820 if(!SED.quickCreateDialog) {
821 SED.quickCreateDialog = new YAHOO.widget.Dialog("emailDetailDialog", {
825 constraintoviewport: true,
827 autofillheight: "body",
830 SED.quickCreateDialog.renderEvent.subscribe(function() {
831 var viewHeight = YAHOO.util.Dom.getViewportHeight();
833 for (var i in this.body.childNodes) {
834 if (this.body.childNodes[i].offsetHeight)
835 contH += this.body.childNodes[i].offsetHeight;
837 this.body.style.overflow = "auto";
838 this.body.style.width = "800px";
839 this.body.style.height = (viewHeight - 75 > contH ? (contH + 10) : (viewHeight - 75)) + "px";
841 }, SED.quickCreateDialog);
843 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_RECORD);
844 SED.quickCreateDialog.setBody(ret.html);
845 SED.quickCreateDialog.render();
846 SUGAR.util.evalScript(ret.html);
847 SED.quickCreateDialog.show();
850 showAssignmentDialogWithData : function(o) {
851 var SEC = SUGAR.email2.contextMenus;
853 var ret = JSON.parse(o.responseText);
854 if (!SEC.assignmentDialog) {
855 SEC.assignmentDialog = new YAHOO.widget.Dialog("assignmentDialog", {
858 constraintoviewport: true,
861 SEC.assignmentDialog.setBody("");
862 SEC.assignmentDialog.setHeader(app_strings.LBL_EMAIL_ASSIGNMENT);
863 SEC.assignmentDialog.renderEvent.subscribe(function() {
864 var iev = YAHOO.util.Dom.get("Distribute");
866 this.body.style.width = "700px";
868 }, SEC.assignmentDialog);
869 SEC.assignmentDialog.render();
871 SEC.assignmentDialog.setBody(ret);
872 SEC.assignmentDialog.render();
874 SEC.assignmentDialog.show();
875 SUGAR.util.evalScript(ret);
878 showImportForm : function(o) {
879 var SED = SUGAR.email2.detailView;
880 var ret = JSON.parse(o.responseText);
882 document.getElementById('quickCreateContent').innerHTML = "";
888 if(!SED.importDialog) {
889 SED.importDialog = new YAHOO.widget.Dialog("importDialog", {
893 constraintoviewport: true,
895 text: app_strings.LBL_EMAIL_ARCHIVE_TO_SUGAR, isDefault: true, handler: function(){
896 AjaxObject.detailView.getImportAction(SED.importDialog.ret); }
900 SED.importDialog.setHeader(app_strings.LBL_EMAIL_IMPORT_SETTINGS);
901 SED.importDialog.setBody("");
902 SED.importDialog.hideEvent.subscribe(function(){
903 for(var i in QSFieldsArray) {
904 if (QSFieldsArray[i] != null && typeof(QSFieldsArray[i]) == "object") {
905 QSFieldsArray[i].destroy();
906 delete QSFieldsArray[i];
908 if (QSProcessedFieldsArray[i]) {
909 QSProcessedFieldsArray[i] = false;
913 SED.importDialog.renderEvent.subscribe(function() {
914 var iev = YAHOO.util.Dom.get("ImportEditView");
916 //this.body.style.height = (iev.clientHeight + 10) + "px";
917 this.body.style.width = "600px";
919 }, SED.importDialog);
920 SED.importDialog.render();
922 SED.importDialog.setBody(ret.html);
923 SED.importDialog.ret = ret;
924 SUGAR.util.evalScript(ret.html);
925 SED.importDialog.render();
927 SED.importDialog.show();
928 SED.importDialog.focusFirstButton();
930 getImportAction : function(ret) {
931 if (!check_form('ImportEditView')) return false;
932 if (!SUGAR.collection.prototype.validateTemSet('ImportEditView', 'team_name')) {
933 alert(mod_strings.LBL_EMAILS_NO_PRIMARY_TEAM_SPECIFIED);
937 var editView = document.getElementById('ImportEditView');
938 if (editView.assigned_user_id != null) {
939 get = get + "&user_id=" + editView.assigned_user_id.value
940 //var user_id = editView.assigned_user_id.value;
942 var parent_id = editView.parent_id.value;
943 var parent_type = editView.parent_type.value;
944 var row = SUGAR.email2.grid.getSelectedRows()[0];
945 row = SUGAR.email2.grid.getRecord(row);
946 var data = row.getData();
947 var ieId = data.ieId;
948 var mbox = data.mbox;
949 var serverDelete = editView.serverDelete.checked;
950 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
952 for(i=0; i<emailUids.length; i++) {
954 uids += app_strings.LBL_EMAIL_DELIMITER;
956 uids += emailUids[i];
959 var action = 'importEmail&uid=';
961 action = 'moveEmails';
962 action = action + '&sourceFolder=' + ret['srcFolder'];
963 action = action + '&sourceIeId=' + ret['srcIeId'];
964 action = action + '&destinationFolder=' + ret['dstFolder'];
965 action = action + '&destinationIeId=' + ret['dstIeId'];
966 action = action + '&emailUids=';
968 if (action.search(/importEmail/) != -1) {
969 overlay(app_strings.LBL_EMAIL_IMPORTING_EMAIL, app_strings.LBL_EMAIL_ONE_MOMENT);
971 overlay("Moving Email(s)", app_strings.LBL_EMAIL_ONE_MOMENT);
974 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=' + action + uids + "&ieId=" + ieId + "&mbox=" + mbox +
975 get + "&parent_id=" + parent_id + "&parent_type=" + parent_type + '&delete=' + serverDelete);
976 SUGAR.email2.detailView.importDialog.hide();
977 document.getElementById('importDialogContent').innerHTML = "";
980 showRelateForm : function(o) {
981 var SED = SUGAR.email2.detailView;
982 var ret = JSON.parse(o.responseText);
983 document.getElementById('quickCreateContent').innerHTML = "";
988 dialog_loaded = true;
990 if(!SED.relateDialog) {
991 SED.relateDialog = new YAHOO.widget.Dialog('relateDialog', {
996 constraintoviewport: true,
998 text: app_strings.LBL_EMAIL_RELATE_TO, isDefault: true, handler: function(){
999 if (!check_form('RelateEditView')) return false;
1001 var editView = document.getElementById('RelateEditView');
1002 var parent_id = editView.parent_id.value;
1003 var parent_type = editView.parent_type.value;
1004 var row = SUGAR.email2.grid.getSelectedRows()[0];
1005 row = SUGAR.email2.grid.getRecord(row);
1006 var ieId = row.getData().ieId;
1007 var mbox = row.getData().mbox;
1008 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
1010 for(i=0; i<emailUids.length; i++) {
1012 uids += app_strings.LBL_EMAIL_DELIMITER;
1014 uids += emailUids[i];
1016 overlay(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
1017 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=relateEmails&uid=' + uids
1018 + "&ieId=" + ieId + "&mbox=" + mbox + "&parent_id=" + parent_id + "&parent_type=" + parent_type);
1019 SED.relateDialog.hide();
1020 document.getElementById('relateDialogContent').innerHTML = "";
1025 SED.relateDialog.hideEvent.subscribe(function(){
1026 if (QSFieldsArray['ImportEditView_parent_name'] != null) {
1027 QSFieldsArray['ImportEditView_parent_name'].destroy();
1028 delete QSFieldsArray['ImportEditView_parent_name'];
1030 if (QSProcessedFieldsArray['ImportEditView_parent_name']) {
1031 QSProcessedFieldsArray['ImportEditView_parent_name'] = false;
1035 SED.relateDialog.renderEvent.subscribe(function() {
1036 var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
1038 for (var i in this.body.childNodes) {
1039 if (this.body.childNodes[i].clientHeight)
1040 contH += this.body.childNodes[i].clientHeight;
1042 }, SED.relateDialog);
1043 SED.relateDialog.setHeader(app_strings.LBL_EMAIL_RELATE_EMAIL);
1046 SED.relateDialog.setBody(ret.html);
1047 SED.relateDialog.render();
1048 SUGAR.util.evalScript(ret.html);
1049 SED.relateDialog.show();
1053 * DetailView callbacks
1055 AjaxObject.detailView.callback = {
1057 success : function(o) {
1059 var ret = JSON.parse(o.responseText);
1060 SUGAR.email2.detailView.consumeMetaDetail(ret);
1062 argument: [targetDiv],
1063 failure : AjaxObject.handleFailure,
1068 success : function(o) {
1070 var ret = JSON.parse(o.responseText);
1071 SUGAR.email2.detailView.consumeMetaPreview(ret);
1073 failure : AjaxObject.handleFailure,
1078 success : AjaxObject.detailView.displayPrintable,
1079 failure : AjaxObject.handleFailure,
1080 timeout : AjaxObject.timeout,
1084 success : AjaxObject.detailView.displayView,
1085 failure : AjaxObject.handleFailure,
1086 timeout : AjaxObject.timeout,
1095 AjaxObject.folders = {
1097 * check-mail post actions
1099 checkMailCleanup : function(o) {
1101 AjaxObject.folders.rebuildFolders(o); // rebuild TreeView
1103 // refresh focus ListView
1104 SE.listView.refreshGrid();
1105 SUGAR.email2.folders.startCheckTimer(); // resets the timer
1110 rebuildFolders : function(o) {
1113 var data = JSON.parse(o.responseText);
1115 email2treeinit(SUGAR.email2.tree, data.tree_data, 'frameFolders', data.param);
1116 SUGAR.email2.folders.setSugarFolders();
1119 AjaxObject.folders.callback = {
1121 success : AjaxObject.folders.checkMailCleanup,
1122 failure : AjaxObject.handleFailure,
1123 timeout : 600000, // 5 mins
1128 AjaxObject.rules = {
1129 loadRulesForSettings : function(o) {
1130 document.getElementById("rulesListCell").innerHTML = o.responseText;
1131 // assume we have the class we need
1132 SUGAR.routing.getStrings();
1133 SUGAR.routing.getDependentDropdowns();
1136 //// END PER MODULE CALLBACK OBJECTS
1137 ///////////////////////////////////////////////////////////////////////////
1141 success : AjaxObject.handleSuccess,
1142 failure : AjaxObject.handleFailure,
1143 timeout : AjaxObject.timeout,
1146 var callbackAccount = {
1147 success : AjaxObject.ieSaveSuccess,
1148 failure : AjaxObject.handleFailure,
1149 timeout : AjaxObject.timeout,
1152 var callbackAccountDelete = {
1153 success : AjaxObject.ieDeleteSuccess,
1154 failure : AjaxObject.handleFailure,
1155 timeout : AjaxObject.timeout,
1158 var callbackOutboundTest = {
1159 success : AjaxObject.ieSendSuccess,
1160 failure : AjaxObject.handleFailure,
1161 timeout : AjaxObject.timeout,
1167 var callbackTeamInfoForSettings = {
1168 success : function (o) {
1169 var data = JSON.parse(o.responseText);
1170 document.getElementById('EditViewGroupFolderTeamTD').innerHTML = data.defaultgroupfolder;
1172 failure : AjaxObject.handleFailure,
1173 timeout : AjaxObject.timeout,
1178 var callbackStatusForImport = {
1179 success : function (o) {
1181 if (o.responseText != "") {
1182 var statusString = "";
1183 var data = JSON.parse(o.responseText);
1184 for(i=0; i<data.length; i++) {
1185 statusString = statusString + data[i] + '<br/>';
1187 overlay(SUGAR.language.get('Emails','LBL_IMPORT_STATUS_TITLE'), statusString, 'alert');
1189 SE.listView.refreshGrid();
1192 failure : AjaxObject.handleFailure,
1193 timeout : AjaxObject.timeout,
1197 var callbackComposeCache = {
1198 success : AjaxObject.composeCache,
1199 failure : AjaxObject.handleFailure,
1200 timeout : AjaxObject.timeout,
1203 var callbackDelete = {
1204 success : AjaxObject.handleDeleteReturn,
1205 failure : AjaxObject.handleFailure,
1206 timeout : AjaxObject.timeout,
1209 var callbackEmailDetailMultiple = {
1210 success : function(o) {
1212 var retMulti = JSON.parse(o.responseText);
1213 var ret = new Object();
1215 for(var i=0; i<retMulti.length; i++) {
1218 SUGAR.email2._setDetailCache(ret);
1219 SUGAR.email2.detailView.populateDetailView(ret.meta.uid, ret.meta.mbox, ret.meta.ieId, true, SUGAR.email2.innerLayout);
1222 failure : AjaxObject.handleFailure,
1226 var callbackListViewSortOrderChange = {
1227 success : AjaxObject.saveListViewSortOrderPart2,
1228 failure : AjaxObject.handleFailure,
1229 timeout : AjaxObject.timeout,
1231 argument : [ieId, ieName, focusFolder]
1233 var callbackEmptyTrash = {
1234 success : function(o) {
1236 AjaxObject.folderRenameCleanup;
1238 failure : AjaxObject.handleFailure,
1239 timeout : AjaxObject.timeout,
1242 var callbackClearCacheFiles = {
1243 success : function(o) {
1246 failure : AjaxObject.handleFailure,
1247 timeout : AjaxObject.timeout,
1250 var callbackFolderRename = {
1251 success : function(o) {hideOverlay();SUGAR.email2.folders.rebuildFolders();},
1252 failure : AjaxObject.handleFailure,
1253 timeout : AjaxObject.timeout,
1256 var callbackFolderDelete = {
1257 success : function(o) {
1258 var ret = JSON.parse(o.responseText);
1260 if (ret.folder_id) {
1261 var node = SUGAR.email2.folders.getNodeFromId(ret.folder_id);
1263 SUGAR.email2.tree.removeNode(node, true);
1264 } else if (ret.ieId && ret.mbox) {
1265 var node = SUGAR.email2.folders.getNodeFromIeIdAndMailbox(ret.ieId, ret.mbox);
1267 SUGAR.email2.tree.removeNode(node, true);
1270 //SUGAR.email2.folders.loadSettingFolder();
1273 overlay(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorMessage, 'alert');
1276 failure : AjaxObject.handleFailure,
1277 timeout : AjaxObject.timeout,
1280 var callbackFolderSave = {
1281 success : function(o) {
1282 var ret = JSON.parse(o.responseText);
1284 switch(ret.action) {
1285 case 'newFolderSave':
1286 SUGAR.email2.folders.rebuildFolders();
1290 failure : AjaxObject.handleFailure,
1291 timeout : AjaxObject.timeout,
1294 var callbackFolderSubscriptions = {
1295 success : AjaxObject.updateFolderSubscriptions,
1296 failure : AjaxObject.handleFailure,
1297 timeout : AjaxObject.timeout,
1300 var callbackFolderUpdate = {
1301 success : AjaxObject.updateFrameFolder,
1302 failure : AjaxObject.handleFailure,
1303 timeout : AjaxObject.timeout,
1306 var callbackFolders = {
1307 success : AjaxObject.folders.rebuildFolders,
1308 //success : void(true),
1309 failure : AjaxObject.handleFailure,
1310 timeout : AjaxObject.timeout,
1313 var callbackFullSync = {
1314 success : AjaxObject.fullSyncCleanup,
1315 failure : AjaxObject.handleFailure,
1316 timeout : 9999999999999,
1319 var callbackGeneric = {
1320 success : function() {
1323 failure : AjaxObject.handleFailure,
1324 timeout : AjaxObject.timeout,
1327 var callbackIeAccountRetrieve = {
1328 success : function(o) {
1329 // return JSON encoding
1331 SUGAR.email2.accounts.fillIeAccount(o.responseText);
1332 SUGAR.email2.accounts.showEditInboundAccountDialogue(false);
1334 failure : AjaxObject.handleFailure,
1335 timeout : AjaxObject.timeout,
1338 var callbackImportOneEmail = {
1339 success : AjaxObject.detailView.showImportForm,
1340 failure : AjaxObject.handleFailure,
1341 timeout : AjaxObject.timeout,
1344 var callbackRelateEmail = {
1345 success : AjaxObject.detailView.showRelateForm,
1346 failure : AjaxObject.handleFailure,
1347 timeout : AjaxObject.timeout,
1350 var callbackEmailDetailView = {
1351 success : AjaxObject.detailView.showEmailDetailView,
1352 failure : AjaxObject.handleFailure,
1353 timeout : AjaxObject.timeout,
1356 var callbackAssignmentDialog = {
1357 success : AjaxObject.detailView.showAssignmentDialogWithData,
1358 failure : AjaxObject.handleFailure,
1359 timeout : AjaxObject.timeout,
1362 var callbackAssignmentAction = {
1363 success : function(o) {
1364 SE.listView.refreshGrid();
1366 if(o.responseText != '') {
1367 overlay('Assignment action result', o.responseText, 'alert');
1370 failure : AjaxObject.handleFailure,
1371 timeout : AjaxObject.timeout,
1374 var callbackMoveEmails = {
1375 success : function(o) {
1376 SE.listView.refreshGrid();
1378 if(o.responseText != '') {
1379 overlay(app_strings.LBL_EMAIL_ERROR_DESC, o.responseText, 'alert');
1382 failure : AjaxObject.handleFailure,
1383 timeout : AjaxObject.timeout,
1386 var callbackLoadAttachments = {
1387 success : AjaxObject.loadAttachments,
1388 failure : AjaxObject.handleFailure,
1389 timeout : AjaxObject.timeout,
1392 var callbackLoadRules = {
1393 success : AjaxObject.rules.loadRulesForSettings,
1394 failure : AjaxObject.handleFailure,
1395 timeout : AjaxObject.timeout,
1398 var callbackLoadSignature = {
1399 success : AjaxObject.loadSignature,
1400 failure : AjaxObject.handleFailure,
1401 timeout : AjaxObject.timeout,
1404 var callbackDeleteSignature = {
1405 success : AjaxObject.handleDeleteSignature,
1406 failure : AjaxObject.handleFailure,
1407 timeout : AjaxObject.timeout,
1410 /*var callbackMoveEmails = {
1411 success : function(o) { SUGAR.email2.listView.moveEmailsCleanup(o) },
1412 failure : AjaxObject.handleFailure,
1413 timeout : AjaxObject.timeout,
1416 var callbackOutboundSave = {
1417 success : AjaxObject.accounts.saveOutboundCleanup,
1418 failure : AjaxObject.handleFailure,
1419 timeout : AjaxObject.timeout,
1422 var callbackDefaultOutboundSave = {
1423 success : AjaxObject.accounts.saveDefaultOutboundCleanup,
1424 failure : AjaxObject.handleFailure,
1425 timeout : AjaxObject.timeout,
1428 var callbackQuickCreate = {
1429 success : AjaxObject.detailView.showQuickCreateForm,
1430 failure : AjaxObject.handleFailure,
1431 timeout : AjaxObject.timeout,
1434 var callbackQuickCreateSave = {
1435 success : AjaxObject.detailView.saveQuickCreateForm,
1436 failure : AjaxObject.handleFailure,
1437 timeout : AjaxObject.timeout,
1440 var callbackQuickCreateSaveAndAddToAddressBook = {
1441 success : AjaxObject.detailView.saveQuickCreateFormAndAddToAddressBook,
1442 failure : AjaxObject.handleFailure,
1443 timeout : AjaxObject.timeout,
1446 var callbackQuickCreateSaveAndReply = {
1447 success : AjaxObject.detailView.saveQuickCreateFormAndReply,
1448 failure : AjaxObject.handleFailure,
1449 timeout : AjaxObject.timeout,
1452 var callbackQuickCreateSaveAndReplyCase = {
1453 success : AjaxObject.detailView.saveQuickCreateFormAndReplyCase,
1454 failure : AjaxObject.handleFailure,
1455 timeout : AjaxObject.timeout,
1458 var callbackRebuildShowAccountList = {
1459 success : AjaxObject.rebuildShowFolders,
1460 failure : AjaxObject.handleFailure,
1461 timeout : AjaxObject.timeout,
1465 var callbackRefreshSugarFolders = {
1466 success : function(o) {
1467 var t = JSON.parse(o.responseText);
1468 SUGAR.email2.folders.setSugarFoldersEnd(t);
1470 failure : AjaxObject.handleFailure,
1471 timeout : AjaxObject.timeout,
1474 var callbackReplyForward = {
1475 success : AjaxObject.handleReplyForward,
1476 finish : function(a, retryCount) {
1477 if (typeof(retryCount) == 'undefined') {
1482 var idx = SUGAR.email2.composeLayout.currentInstanceId;
1483 var t = tinyMCE.getInstanceById('htmleditor' + idx);
1485 var html = t.getContent();
1487 if (a.type != 'draft') {
1488 if(SUGAR.email2.userPrefs.signatures.signature_prepend == 'true') {
1489 html += " <div><hr></div>" + a.description;
1491 html = " <div><hr></div>" + a.description + html;
1494 html = a.description;
1497 t.setContent(html);//
1500 if (retryCount < 5) {
1501 setTimeout("callbackReplyForward.finish(globalA, " + retryCount + ");", 500);
1505 var tabArray = SUGAR.email2.innerLayout.get("tabs");
1506 if (tabArray != null && tabArray.length > 0) {
1507 for (i = 0 ; i < tabArray.length ; i++) {
1508 var tabObject = tabArray[i];
1509 if (tabObject.get("id") == ("composeTab" + idx)) {
1510 var tabLabel = a.name;
1511 if (tabLabel != null && tabLabel.length > 25) {
1512 tabLabel = tabLabel.substring(0, 25) + "...";
1514 tabObject.get("labelEl").firstChild.data = tabLabel;
1520 //SUGAR.email2.innerLayout.regions.center.getPanel('composeLayout' + idx).setTitle(a.name);
1521 if (a.parent_name != null && a.parent_name != "") {
1522 document.getElementById('data_parent_name' + idx).value = a.parent_name;
1524 if (a.parent_type != null && a.parent_type != "") {
1525 document.getElementById('data_parent_type' + idx).value = a.parent_type;
1527 if (a.parent_id != null && a.parent_id != "") {
1528 document.getElementById('data_parent_id' + idx).value = a.parent_id;
1530 if (a.fromAccounts.status) {
1531 var addressFrom = document.getElementById('addressFrom' + idx);
1532 SUGAR.email2.util.emptySelectOptions(addressFrom);
1533 var fromAccountOpts = a.fromAccounts.data;
1534 for(i=0; i<fromAccountOpts.length; i++) {
1535 var key = fromAccountOpts[i].value;
1536 var display = fromAccountOpts[i].text;
1537 var opt = new Option(display, key);
1538 if (fromAccountOpts[i].selected) {
1539 opt.selected = true;
1541 addressFrom.options.add(opt);
1547 failure : AjaxObject.handleFailure,
1548 timeout : AjaxObject.timeout,
1550 argument : [sendType]
1552 var callbackSendEmail = {
1553 success : AjaxObject.sendEmailCleanUp,
1554 failure : AjaxObject.handleFailure,
1555 timeout : AjaxObject.timeout,
1558 var callbackSettings = {
1559 success : AjaxObject.updateUserPrefs,
1560 failure : AjaxObject.handleFailure,
1561 timeout : AjaxObject.timeout,
1564 var callbackSettingsFolderRefresh = {
1565 success : AjaxObject.settingsFolderRefresh,
1566 failure : AjaxObject.handleFailure,
1567 timeout : AjaxObject.timeout,
1570 var callbackLoadSettingFolder = {
1571 success : function(o) {
1572 AjaxObject.settingsFolderRefresh(o);
1573 SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
1575 failure : AjaxObject.handleFailure,
1576 timeout : AjaxObject.timeout,
1580 var callbackUploadAttachment = {
1581 success : AjaxObject.uploadAttachmentSuccessful,
1582 upload : AjaxObject.uploadAttachmentSuccessful,
1583 failure : AjaxObject.handleFailure,
1584 timeout : AjaxObject.timeout,
1587 var callbackUserPrefs = {
1588 success : function(o) {
1589 SUGAR.email2.userPrefs = JSON.parse(o.responseText);
1591 failure : AjaxObject.handleFailure,
1592 timeout : AjaxObject.timeout,
1596 var callbackContextmenus = {
1598 success : AjaxObject.markEmailCleanup,
1599 failure : AjaxObject.handleFailure,
1600 timeout : AjaxObject.timeout,
1605 var callbackCheckEmail2 = {
1606 success : function(o) {
1607 var ret = JSON.parse(o.responseText);
1608 overlay(app_strings.LBL_EMAIL_CHECKING_NEW, ret.text);
1612 failure : AjaxObject.handleFailure,
1613 timeout : AjaxObject.timeout,