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');
135 if(document.getElementById('saveButton')) {
136 document.getElementById('saveButton').disabled = false;
140 handleReplyForward : function(o) {
141 var a = JSON.parse(o.responseText);
143 var idx = SUGAR.email2.composeLayout.currentInstanceId;
145 document.getElementById('email_id' + idx).value = a.uid;
146 document.getElementById('emailSubject' + idx).value = a.name;
147 document.getElementById('addressTO' + idx).value = a.from;
148 document.getElementById('uid' + idx).value = a.uid;
150 document.getElementById('addressCC' + idx).value = a.cc;
151 SE.composeLayout.showHiddenAddress('cc', idx);
155 document.getElementById('type' + idx).value = a.type;
158 // apply attachment values
159 SUGAR.email2.composeLayout.loadAttachments(a.attachments);
161 setTimeout("callbackReplyForward.finish(globalA);", 500);
164 handleReplyForwardForDraft : function(o) {
165 var a = JSON.parse(o.responseText);
167 var idx = SUGAR.email2.composeLayout.currentInstanceId;
169 document.getElementById('email_id' + idx).value = a.uid;
170 document.getElementById('emailSubject' + idx).value = a.name;
171 document.getElementById('addressTO' + idx).value = a.to;
174 document.getElementById('addressCC' + idx).value = a.cc;
175 SUGAR.email2.composeLayout.showHiddenAddress('cc',idx);
179 document.getElementById('addressBCC' + idx).value = a.bcc;
180 SUGAR.email2.composeLayout.showHiddenAddress('bcc',idx);
185 document.getElementById('type' + idx).value = a.type;
189 // apply attachment values
190 SUGAR.email2.composeLayout.loadAttachments(a.attachments);
192 setTimeout("callbackReplyForward.finish(globalA);", 500);
197 handleSuccess : function(o) {
198 document.getElementById(this.target).innerHTML = o.responseText;
204 ieDeleteSuccess : function(o) {
207 var ret = JSON.parse(o.responseText);
209 SUGAR.email2.accounts.refreshInboundAccountTable();
210 alert(app_strings.LBL_EMAIL_IE_DELETE_SUCCESSFUL);
211 SUGAR.email2.accounts.rebuildFolderList();
217 ieSaveSuccess : function(o) {
218 document.getElementById('saveButton').disabled = false;
219 var a = JSON.parse(o.responseText);
222 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_CHECK_IE_SETTINGS, 'alert');
223 SUGAR.email2.accounts.ieAccountError(SUGAR.email2.accounts.errorStyle);
225 resp = JSON.parse(o.responseText);
226 SUGAR.email2.accounts.refreshInboundAccountTable();
227 SUGAR.email2.accounts.refreshOuboundAccountTable();
228 SUGAR.email2.folders.startEmailCheckOneAccount(resp.id, true);
229 SUGAR.email2.accounts.inboundAccountEditDialog.hide();
233 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_SAVE_ACCOUNT, 'alert');
240 loadAttachments : function(o) {
241 var result = JSON.parse(o.responseText);
243 SUGAR.email2.composeLayout.loadAttachments(result);
248 loadSignature : function(o) {
249 var ret = JSON.parse(o.responseText);
250 SUGAR.email2.signatures[ret.id] = ret.signature_html;
251 SUGAR.email2.composeLayout.setSignature(SUGAR.email2.signatures.targetInstance);
255 * Follow up to mark email read|unread|flagged
257 markEmailCleanup : function(o) {
258 var ret = JSON.parse(o.responseText);
259 if (!ret['status']) {
261 overlay(app_strings.LBL_EMAIL_ERROR_DESC, ret['message'], 'alert');
263 SUGAR.email2.contextMenus.markEmailCleanup();
269 rebuildShowFolders : function(o) {
270 var t = JSON.parse(o.responseText);
271 var show = document.getElementById('ieAccountListShow');
273 SUGAR.email2.util.emptySelectOptions(show);
275 for(i=0; i<t.length; i++) { // iterate through assoc array
276 var opt = new Option(t[i].text, t[i].value, t[i].selected);
277 opt.selected = t[i].selected;
278 show.options.add(opt);
281 SUGAR.email2.accounts.renderTree();
285 saveListViewSortOrderPart2 : function() {
286 // create the JSON string the func expects
287 focusFolderPath = '[ "Home", "' + ieName + '"';
289 var f = new String(focusFolder);
290 var fEx = f.split('.');
292 for(i=0; i<fEx.length; i++) {
293 focusFolderPath += ', "' + fEx[i] +'"'
296 focusFolderPath += ']';
298 YAHOO.namespace('frameFolders').selectednode = SUGAR.email2.folders.getNodeFromMboxPath(focusFolderPath);
299 SUGAR.email2.listView.populateListFrame(YAHOO.namespace('frameFolders').selectednode, ieId, 'true');
305 sendEmailCleanUp : function(o) {
307 var ret = JSON.parse(o.responseText);
309 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
310 //SUGAR.email2.addressBook.showContactMatches(ret.possibleMatches);
311 } else if (o.responseText) {
312 overlay(mod_strings.LBL_SEND_EMAIL_FAIL_TITLE, o.responseText, 'alert');
315 if (typeof(SE.grid) != 'undefined')
316 SE.listView.refreshGrid();
317 //Disabled while address book is disabled
319 //If this call back was initiated by quick compose from a Detail View page, refresh the
320 //history subpanel. If it was initiated by quickcreate from shortcut bar, then
321 //close the shortcut bar menu
322 if ( (typeof(action_sugar_grp1) != 'undefined')) {
323 if(action_sugar_grp1 == 'DetailView') {
324 showSubPanel('history',null,true);
325 } else if(action_sugar_grp1 == 'quickcreate') {
332 ieSendSuccess : function(o) {
334 overlay(app_strings.LBL_EMAIL_TEST_OUTBOUND_SETTINGS_SENT, app_strings.LBL_EMAIL_TEST_NOTIFICATION_SENT, 'plain');
339 settingsFolderRefresh : function(o) {
340 //SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
341 var ret = JSON.parse(o.responseText);
342 var user = document.getElementById('userFolders');
344 SUGAR.email2.util.emptySelectOptions(user);
346 for(i=0; i<ret.userFolders.length; i++) {
347 var display = ret.userFolders[i].name;
348 var value = ret.userFolders[i].id;
349 var selected = (ret.userFolders[i].selected != "") ? true : false;
350 var opt = new Option(display, value, selected);
351 opt.selected = selected;
352 user.options.add(opt);
358 startRequest : function(callback, args, forceAbort) {
359 if(this.currentRequestObject != null) {
360 if(this.forceAbort == true) {
361 YAHOO.util.Connect.abort(this.currentRequestObject, null, false);
364 this.currentRequestObject = YAHOO.util.Connect.asyncRequest('POST', "./index.php", callback, args);
368 requestInProgress : function() {
369 return (YAHOO.util.Connect.isCallInProgress(this.currentRequestObject));
374 updateFolderSubscriptions : function() {
375 SUGAR.email2.folders.lazyLoadSettings(); // refresh view in Settings overlay
376 SUGAR.email2.folders.setSugarFolders(1000);// refresh view in TreeView
382 updateFrameFolder : function() {
383 SUGAR.email2.folders.checkEmailAccounts();
388 updateUserPrefs : function(o) {
389 SUGAR.email2.userPrefs = JSON.parse(o.responseText);
390 SUGAR.email2.folders.startCheckTimer(); // starts the auto-check interval
395 uploadAttachmentSuccessful : function(o) {
397 document.getElementById('email_attachment').value = '';
399 var ret = JSON.parse(o.responseText);
400 var idx = SUGAR.email2.composeLayout.currentInstanceId;
401 var overall = document.getElementById('addedFiles' + idx);
402 var index = overall.childNodes.length;
404 "<div id='email_attachment_bucket" + idx + index + "'>" +
406 "<img src='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=minus.gif' " +
407 "style='cursor:pointer' align='absmiddle' onclick='SUGAR.email2.composeLayout.deleteUploadAttachment(\"" +
408 idx + index + "\",\"" + ret.guid + ret.name + "\");'/>" +
410 "<img src='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=attachment.gif' " +
411 "id='email_attachmentImage'" + idx + index + "align='absmiddle' />" +
413 "<input type='hidden' value='" + ret.guid + ret.name + "' name='email_attachment" + index + "' id='email_attachment" + idx + index + "' />" +
415 ((ret.nameForDisplay != null) ? ret.nameForDisplay + " " : ret.name + " ") +
418 overall.innerHTML += out;
419 if(SUGAR.email2.util.isIe()) {
420 document.getElementById('addedFiles' + idx).innerHTML = document.getElementById('addedFiles' + idx).innerHTML;
424 SUGAR.email2.addFileDialog.hide();
426 SUGAR.email2.composeLayout.showAttachmentPanel(idx);
431 ///////////////////////////////////////////////////////////////////////////
432 //// PER MODULE CALLBACK OBJECTS
433 AjaxObject.accounts = {
434 saveOutboundCleanup : function(o) {
435 SUGAR.email2.accounts.refreshOuboundAccountTable();
436 SUGAR.email2.accounts.outboundDialog.hide();
437 var id = o.responseText;
438 SUGAR.email2.accounts.newAddedOutboundId = id;
440 saveDefaultOutboundCleanup: function(o){
443 callbackEditOutbound : {
444 success : function(o)
446 var ret = JSON.parse(o.responseText);
448 SUGAR.email2.accounts.showAddSmtp();
451 document.getElementById("mail_id").value = ret.id;
452 document.getElementById("type").value = ret.type;
453 document.getElementById("mail_sendtype").value = ret.mail_sendtype;
454 document.getElementById("mail_name").value = ret.name;
455 document.getElementById("mail_smtpserver").value = ret.mail_smtpserver;
456 document.getElementById("outboundEmailForm").mail_smtptype.value = ret.mail_smtptype;
457 document.getElementById("mail_smtpport").value = ret.mail_smtpport;
458 document.getElementById("mail_smtpuser").value = ret.mail_smtpuser;
459 //document.getElementById("mail_smtppass").value = ret.mail_smtppass;
460 document.getElementById("mail_smtpauth_req").checked = (ret.mail_smtpauth_req == 1) ? true : false;
461 SUGAR.email2.accounts.smtp_authenticate_field_display();
462 document.getElementById("mail_smtpssl").options[ret.mail_smtpssl].selected = true;
464 if(ret.type == 'system-override') {
465 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(true);
466 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,true);
469 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(false);
470 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,false);
475 failure : AjaxObject.handleFailure,
476 timeout : AjaxObject.timeout,
479 callbackDeleteOutbound : {
480 success : function(o) {
481 var ret = JSON.parse(o.responseText);
484 if(confirm(ret.error_message))
486 overlay(app_strings.LBL_EMAIL_IE_DELETE, app_strings.LBL_EMAIL_ONE_MOMENT);
487 AjaxObject.startRequest(AjaxObject.accounts.callbackDeleteOutbound, urlStandard + "&emailUIAction=deleteOutbound&confirm=true&outbound_email=" + ret.outbound_email);
495 SUGAR.email2.accounts.refreshOuboundAccountTable();
499 failure : AjaxObject.handleFailure,
500 timeout : AjaxObject.timeout,
504 callbackCheckMailProgress : {
505 success : function(o) {
506 if (typeof(SUGAR.email2.accounts.totalMsgCount) == "undefined") {
507 SUGAR.email2.accounts.totalMsgCount = -1;
510 //Check for server timeout / errors
511 var ret = JSON.parse(o.responseText);
514 if (typeof(o.responseText) == 'undefined' || o.responseText == "" || ret == false) {
516 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
517 SUGAR.email2.accounts.totalMsgCount = -1;
518 //SUGAR.email2.folders.rebuildFolders();
522 var currIeId = ret['ieid'];
525 var serverCount = ret.count;
527 if (ret['status'] == 'done') {
528 for(i=0; i < SUGAR.email2.accounts.ieIds.length; i++) {
529 if (i == SUGAR.email2.accounts.ieIds.length - 1) {
533 } else if (SUGAR.email2.accounts.ieIds[i] == currIeId) {
535 currIeId = SUGAR.email2.accounts.ieIds[i+1];
537 SUGAR.email2.accounts.totalMsgCount = -1;
542 else if (ret.mbox && ret.totalcount && ret.count) {
543 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
544 if (ret.count >= ret.totalcount) {
547 } else if (SUGAR.email2.accounts.totalMsgCount < 0 && ret.totalcount) {
548 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
551 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
552 SUGAR.email2.accounts.totalMsgCount = -1;
557 SUGAR.email2.accounts.totalMsgCount = -1;
559 SUGAR.email2.folders.rebuildFolders();
560 SE.listView.refreshGrid();
561 } else if (SUGAR.email2.accounts.totalMsgCount < 0) {
562 YAHOO.SUGAR.MessageBox.updateProgress(0, mod_strings.LBL_CHECKING_ACCOUNT + ' '+ (i + 2) + ' '+ mod_strings.LBL_OF + ' ' + SUGAR.email2.accounts.ieIds.length);
563 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
564 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=0&synch=" + ret.synch);
566 YAHOO.SUGAR.MessageBox.updateProgress((ret.count / SUGAR.email2.accounts.totalMsgCount) * 100,
567 app_strings.LBL_EMAIL_DOWNLOAD_STATUS.replace(/\[\[count\]\]/, ret.count).replace(/\[\[total\]\]/, SUGAR.email2.accounts.totalMsgCount));
568 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
569 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=" + serverCount +
570 '&mbox=' + ret.mbox + '&synch=' + ret.synch + '&totalcount=' + SUGAR.email2.accounts.totalMsgCount);
573 failure : AjaxObject.handleFailure,
574 timeout : AjaxObject.timeout,
579 ///////////////////////////////////////////////////////////////////////////////
581 AjaxObject.composeLayout = {
583 * Populates the record id
585 saveDraftCleanup : function(o) {
587 var ret = JSON.parse(o.responseText);
589 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
590 else if (o.responseText)
591 overlay(mod_strings.LBL_ERROR_SAVING_DRAFT, o.responseText, 'alert');
595 AjaxObject.composeLayout.callback = {
597 success : AjaxObject.composeLayout.saveDraftCleanup,
598 failure : AjaxObject.handleFailure,
599 timeout : AjaxObject.timeout,
604 AjaxObject.detailView = {
606 * Pops-up a printable view of an email
608 displayPrintable : function(o) {
609 var ret = JSON.parse(o.responseText);
610 var displayTemplate = new YAHOO.SUGAR.Template(SUGAR.email2.templates['viewPrintable']);
611 // 2 below must be in global context
613 meta['panelId'] = SUGAR.email2.util.getPanelId();
614 email = ret.meta.email;
615 if (typeof(email.cc) == 'undefined') {
619 var out = displayTemplate.exec({
620 'app_strings' : app_strings,
628 var popup = window.open('modules/Emails/templates/_blank.html', 'printwin' ,
629 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
631 popup.document.write(out);
632 popup.document.close();
636 * Takes formatted response and creates a modal pop-over containing a title and content
638 displayView : function(o) {
639 var SED = SUGAR.email2.detailView;
640 var ret = JSON.parse(o.responseText);
642 if(!SED.viewDialog) {
643 SED.viewDialog = new YAHOO.widget.Dialog("viewDialog", {
647 constraintoviewport: true,
650 SED.viewDialog.renderEvent.subscribe(function() {
651 var content = this.body.firstChild;
652 var viewH = YAHOO.util.Dom.getViewportHeight();
654 this.body.style.overflow = "auto";
655 this.body.style.width = "800px";
656 this.body.style.height = (viewH - 75 > content.clientHeight ? (content.clientHeight) : (viewH - 75)) + "px";
660 SED.viewDialog.setHeader(ret.title);
661 SED.viewDialog.setBody(ret.html);
662 SED.viewDialog.render();
663 SED.viewDialog.show();
667 * Generates a modal popup to populate with the contents of bean's full EditView
669 showQuickCreateForm : function(o) {
670 var SED = SUGAR.email2.detailView;
671 var ret = JSON.parse(o.responseText);
673 if(!SED.quickCreateDialog) {
674 SED.quickCreateDialog = new YAHOO.widget.Dialog("quickCreate", {
678 constraintoviewport: true,
682 SED.quickCreateDialog.renderEvent.subscribe(function() {
683 var viewH = YAHOO.util.Dom.getViewportHeight();
685 for (var i in this.body.childNodes) {
686 if (this.body.childNodes[i].clientHeight) {
687 contH += this.body.childNodes[i].clientHeight;
688 } else if (this.body.childNodes[i].offsetHeight) {
689 contH += this.body.childNodes[i].offsetHeight;
692 this.body.style.width = "800px";
693 this.body.style.height = (viewH - 75 > contH ? (contH + 10) : (viewH - 75)) + "px";
694 this.body.style.overflow = "auto";
695 }, SED.quickCreateDialog);
697 SED.quickCreateDialog.hideEvent.subscribe(function(){
698 var qsFields = YAHOO.util.Dom.getElementsByClassName('.sqsEnabled', null, this.body);
699 /*for(var qsField in qsFields){
700 if (typeof QSFieldsArray[qsFields[qsField].id] != 'undefined')
701 Ext.getCmp('combobox_'+qsFields[qsField].id).destroy();
704 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_QUICK_CREATE);
707 ret.html = ret.html.replace('<script type="text/javascript" src="include/SugarEmailAddress/SugarEmailAddress.js"></script>', "");
709 SED.quickCreateDialog.setBody(ret.html ? ret.html : " ");
710 SED.quickCreateDialog.render();
711 SUGAR.util.evalScript(ret.html + '<script language="javascript">enableQS(true);</script>');
713 SED.quickCreateDialog.ieId = ret.ieId;
714 SED.quickCreateDialog.uid = ret.uid;
715 SED.quickCreateDialog.mbox = ret.mbox;
716 SED.quickCreateDialog.qcmodule = ret.module;
718 SED.quickCreateDialog.show();
720 var editForm = document.getElementById('form_EmailQCView_' + ret.module);
722 editForm.module.value = 'Emails';
723 var count = SUGAR.EmailAddressWidget.count[ret.module] ? SUGAR.EmailAddressWidget.count[ret.module] : 0;
724 var tableId = YAHOO.util.Dom.getElementsByClassName('emailaddresses', 'table', editForm)[0].id;
725 var instId = ret.module + count;
726 SED.quickCreateEmailsToAdd = ret.emailAddress;
727 SED.quickCreateEmailCallback = function(instId, tableId) {
728 var eaw = SUGAR.EmailAddressWidget.instances[instId];
729 if (typeof(eaw) == "undefined")
730 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
731 + instId + "','" + tableId + "');", 100);
732 eaw.prefillEmailAddresses(tableId, SUGAR.email2.detailView.quickCreateEmailsToAdd);
734 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
735 + instId + "','" + tableId + "');", 100);
739 saveQuickCreateForm : function(o) {
741 SUGAR.email2.detailView.quickCreateDialog.hide();
742 validate['EditView'] = [ ];
745 saveQuickCreateFormAndReply : function(o) {
747 var ret = JSON.parse(o.responseText);
748 SUGAR.email2.detailView.quickCreateDialog.hide();
749 var qcd = SUGAR.email2.detailView.quickCreateDialog;
750 var type = (qcd.qcmodule == 'Cases') ? 'replyCase' : 'reply';
752 var emailID = ret.id;
753 SUGAR.email2.composeLayout.c0_replyForwardEmail(null, ret.id, 'sugar::Emails', type);
755 SUGAR.email2.composeLayout.c0_replyForwardEmail(qcd.ieId, qcd.uid, qcd.mbox, type);
757 //Cean the validate cache to prevent errors on the next call
758 validate['EditView'] = [ ];
761 saveQuickCreateFormAndAddToAddressBook : function(o) {
763 SUGAR.email2.detailView.quickCreateDialog.hide();
764 SUGAR.email2.complexLayout.findPanel('contactsTab').show();
765 validate['EditView'] = [ ];
768 handleAssignmentDialogAssignAction : function() {
771 var assign_user_id = window.document.forms['Distribute'].elements['assigned_user_id'].value;
777 var found_teams = false;
778 var warning_message = mod_strings.LBL_WARN_NO_USERS;
779 if(!found_teams && assign_user_id == '' )
781 alert(warning_message);
785 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
787 for(i=0; i<emailUids.length; i++) {
789 uids += app_strings.LBL_EMAIL_DELIMITER;
791 uids += emailUids[i];
794 var row = SUGAR.email2.grid.getSelectedRows()[0];
795 var data = SUGAR.email2.grid.getRecord(row).getData();
796 var ieid = data.ieId;
797 var mbox = data.mbox;
798 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentAssign&uids=" + uids + "&ieId=" + ieid + "&folder=" + mbox + "&distribute_method=" + dist + "&users=" +assign_user_id + get);
799 SUGAR.email2.contextMenus.assignToDialogue.hide();
800 overlay('Assignment', app_strings.LBL_EMAIL_ONE_MOMENT);
804 handleAssignmentDialogDeleteAction : function() {
805 // TO pass list of UIDS/emailIds
806 var uids = SUGAR.email2.listView.getUidsFromSelection();
807 var row = SUGAR.email2.grid.getSelections()[0];
808 var ieid = row.data.ieId;
809 var mbox = row.data.mbox;
810 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentDelete&uids=" + uids + "&ieId=" + ieId + "&folder=" + mbox);
811 SUGAR.email2.contextMenus.assignmentDialog.hide();
812 overlay(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
818 showEmailDetailView : function(o) {
820 var SED = SUGAR.email2.detailView;
821 var ret = JSON.parse(o.responseText);
823 if(!SED.quickCreateDialog) {
824 SED.quickCreateDialog = new YAHOO.widget.Dialog("emailDetailDialog", {
828 constraintoviewport: true,
830 autofillheight: "body",
833 SED.quickCreateDialog.renderEvent.subscribe(function() {
834 var viewHeight = YAHOO.util.Dom.getViewportHeight();
836 for (var i in this.body.childNodes) {
837 if (this.body.childNodes[i].offsetHeight)
838 contH += this.body.childNodes[i].offsetHeight;
840 this.body.style.overflow = "auto";
841 this.body.style.width = "800px";
842 this.body.style.height = (viewHeight - 75 > contH ? (contH + 10) : (viewHeight - 75)) + "px";
844 }, SED.quickCreateDialog);
846 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_RECORD);
847 SED.quickCreateDialog.setBody(ret.html);
848 SED.quickCreateDialog.render();
849 SUGAR.util.evalScript(ret.html);
850 SED.quickCreateDialog.show();
853 showAssignmentDialogWithData : function(o) {
854 var SEC = SUGAR.email2.contextMenus;
856 var ret = JSON.parse(o.responseText);
857 if (!SEC.assignmentDialog) {
858 SEC.assignmentDialog = new YAHOO.widget.Dialog("assignmentDialog", {
861 constraintoviewport: true,
864 SEC.assignmentDialog.setBody("");
865 SEC.assignmentDialog.setHeader(app_strings.LBL_EMAIL_ASSIGNMENT);
866 SEC.assignmentDialog.renderEvent.subscribe(function() {
867 var iev = YAHOO.util.Dom.get("Distribute");
869 this.body.style.width = "700px";
871 }, SEC.assignmentDialog);
872 SEC.assignmentDialog.render();
874 SEC.assignmentDialog.setBody(ret);
875 SEC.assignmentDialog.render();
877 SEC.assignmentDialog.show();
878 SUGAR.util.evalScript(ret);
881 showImportForm : function(o) {
882 var SED = SUGAR.email2.detailView;
883 var ret = JSON.parse(o.responseText);
885 document.getElementById('quickCreateContent').innerHTML = "";
891 if(!SED.importDialog) {
892 SED.importDialog = new YAHOO.widget.Dialog("importDialog", {
896 constraintoviewport: true,
898 text: app_strings.LBL_EMAIL_ARCHIVE_TO_SUGAR, isDefault: true, handler: function(){
899 AjaxObject.detailView.getImportAction(SED.importDialog.ret); }
903 SED.importDialog.setHeader(app_strings.LBL_EMAIL_IMPORT_SETTINGS);
904 SED.importDialog.setBody("");
905 SED.importDialog.hideEvent.subscribe(function(){
906 for(var i in QSFieldsArray) {
907 if (QSFieldsArray[i] != null && typeof(QSFieldsArray[i]) == "object") {
908 QSFieldsArray[i].destroy();
909 delete QSFieldsArray[i];
911 if (QSProcessedFieldsArray[i]) {
912 QSProcessedFieldsArray[i] = false;
916 SED.importDialog.renderEvent.subscribe(function() {
917 var iev = YAHOO.util.Dom.get("ImportEditView");
919 //this.body.style.height = (iev.clientHeight + 10) + "px";
920 this.body.style.width = "600px";
922 }, SED.importDialog);
923 SED.importDialog.render();
925 SED.importDialog.setBody(ret.html);
926 SED.importDialog.ret = ret;
927 SUGAR.util.evalScript(ret.html);
928 SED.importDialog.render();
930 SED.importDialog.show();
931 SED.importDialog.focusFirstButton();
933 getImportAction : function(ret) {
934 if (!check_form('ImportEditView')) return false;
935 if (!SUGAR.collection.prototype.validateTemSet('ImportEditView', 'team_name')) {
936 alert(mod_strings.LBL_EMAILS_NO_PRIMARY_TEAM_SPECIFIED);
940 var editView = document.getElementById('ImportEditView');
941 if (editView.assigned_user_id != null) {
942 get = get + "&user_id=" + editView.assigned_user_id.value
943 //var user_id = editView.assigned_user_id.value;
945 var parent_id = editView.parent_id.value;
946 var parent_type = editView.parent_type.value;
947 var row = SUGAR.email2.grid.getSelectedRows()[0];
948 row = SUGAR.email2.grid.getRecord(row);
949 var data = row.getData();
950 var ieId = data.ieId;
951 var mbox = data.mbox;
952 var serverDelete = editView.serverDelete.checked;
953 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
955 for(i=0; i<emailUids.length; i++) {
957 uids += app_strings.LBL_EMAIL_DELIMITER;
959 uids += emailUids[i];
962 var action = 'importEmail&uid=';
964 action = 'moveEmails';
965 action = action + '&sourceFolder=' + ret['srcFolder'];
966 action = action + '&sourceIeId=' + ret['srcIeId'];
967 action = action + '&destinationFolder=' + ret['dstFolder'];
968 action = action + '&destinationIeId=' + ret['dstIeId'];
969 action = action + '&emailUids=';
971 if (action.search(/importEmail/) != -1) {
972 overlay(app_strings.LBL_EMAIL_IMPORTING_EMAIL, app_strings.LBL_EMAIL_ONE_MOMENT);
974 overlay("Moving Email(s)", app_strings.LBL_EMAIL_ONE_MOMENT);
977 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=' + action + uids + "&ieId=" + ieId + "&mbox=" + mbox +
978 get + "&parent_id=" + parent_id + "&parent_type=" + parent_type + '&delete=' + serverDelete);
979 SUGAR.email2.detailView.importDialog.hide();
980 document.getElementById('importDialogContent').innerHTML = "";
983 showRelateForm : function(o) {
984 var SED = SUGAR.email2.detailView;
985 var ret = JSON.parse(o.responseText);
986 document.getElementById('quickCreateContent').innerHTML = "";
991 dialog_loaded = true;
993 if(!SED.relateDialog) {
994 SED.relateDialog = new YAHOO.widget.Dialog('relateDialog', {
999 constraintoviewport: true,
1001 text: app_strings.LBL_EMAIL_RELATE_TO, isDefault: true, handler: function(){
1002 if (!check_form('RelateEditView')) return false;
1004 var editView = document.getElementById('RelateEditView');
1005 var parent_id = editView.parent_id.value;
1006 var parent_type = editView.parent_type.value;
1007 var row = SUGAR.email2.grid.getSelectedRows()[0];
1008 row = SUGAR.email2.grid.getRecord(row);
1009 var ieId = row.getData().ieId;
1010 var mbox = row.getData().mbox;
1011 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
1013 for(i=0; i<emailUids.length; i++) {
1015 uids += app_strings.LBL_EMAIL_DELIMITER;
1017 uids += emailUids[i];
1019 overlay(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
1020 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=relateEmails&uid=' + uids
1021 + "&ieId=" + ieId + "&mbox=" + mbox + "&parent_id=" + parent_id + "&parent_type=" + parent_type);
1022 SED.relateDialog.hide();
1023 document.getElementById('relateDialogContent').innerHTML = "";
1028 SED.relateDialog.hideEvent.subscribe(function(){
1029 if (QSFieldsArray['ImportEditView_parent_name'] != null) {
1030 QSFieldsArray['ImportEditView_parent_name'].destroy();
1031 delete QSFieldsArray['ImportEditView_parent_name'];
1033 if (QSProcessedFieldsArray['ImportEditView_parent_name']) {
1034 QSProcessedFieldsArray['ImportEditView_parent_name'] = false;
1038 SED.relateDialog.renderEvent.subscribe(function() {
1039 var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
1041 for (var i in this.body.childNodes) {
1042 if (this.body.childNodes[i].clientHeight)
1043 contH += this.body.childNodes[i].clientHeight;
1045 }, SED.relateDialog);
1046 SED.relateDialog.setHeader(app_strings.LBL_EMAIL_RELATE_EMAIL);
1049 SED.relateDialog.setBody(ret.html);
1050 SED.relateDialog.render();
1051 SUGAR.util.evalScript(ret.html);
1052 SED.relateDialog.show();
1056 * DetailView callbacks
1058 AjaxObject.detailView.callback = {
1060 success : function(o) {
1062 var ret = JSON.parse(o.responseText);
1063 SUGAR.email2.detailView.consumeMetaDetail(ret);
1065 argument: [targetDiv],
1066 failure : AjaxObject.handleFailure,
1071 success : function(o) {
1073 var ret = JSON.parse(o.responseText);
1074 SUGAR.email2.detailView.consumeMetaPreview(ret);
1076 failure : AjaxObject.handleFailure,
1081 success : AjaxObject.detailView.displayPrintable,
1082 failure : AjaxObject.handleFailure,
1083 timeout : AjaxObject.timeout,
1087 success : AjaxObject.detailView.displayView,
1088 failure : AjaxObject.handleFailure,
1089 timeout : AjaxObject.timeout,
1098 AjaxObject.folders = {
1100 * check-mail post actions
1102 checkMailCleanup : function(o) {
1104 AjaxObject.folders.rebuildFolders(o); // rebuild TreeView
1106 // refresh focus ListView
1107 SE.listView.refreshGrid();
1108 SUGAR.email2.folders.startCheckTimer(); // resets the timer
1113 rebuildFolders : function(o) {
1116 var data = JSON.parse(o.responseText);
1118 email2treeinit(SUGAR.email2.tree, data.tree_data, 'frameFolders', data.param);
1119 SUGAR.email2.folders.setSugarFolders();
1122 AjaxObject.folders.callback = {
1124 success : AjaxObject.folders.checkMailCleanup,
1125 failure : AjaxObject.handleFailure,
1126 timeout : 600000, // 5 mins
1131 AjaxObject.rules = {
1132 loadRulesForSettings : function(o) {
1133 document.getElementById("rulesListCell").innerHTML = o.responseText;
1134 // assume we have the class we need
1135 SUGAR.routing.getStrings();
1136 SUGAR.routing.getDependentDropdowns();
1139 //// END PER MODULE CALLBACK OBJECTS
1140 ///////////////////////////////////////////////////////////////////////////
1144 success : AjaxObject.handleSuccess,
1145 failure : AjaxObject.handleFailure,
1146 timeout : AjaxObject.timeout,
1149 var callbackAccount = {
1150 success : AjaxObject.ieSaveSuccess,
1151 failure : AjaxObject.handleFailure,
1152 timeout : AjaxObject.timeout,
1155 var callbackAccountDelete = {
1156 success : AjaxObject.ieDeleteSuccess,
1157 failure : AjaxObject.handleFailure,
1158 timeout : AjaxObject.timeout,
1161 var callbackOutboundTest = {
1162 success : AjaxObject.ieSendSuccess,
1163 failure : AjaxObject.handleFailure,
1164 timeout : AjaxObject.timeout,
1170 var callbackTeamInfoForSettings = {
1171 success : function (o) {
1172 var data = JSON.parse(o.responseText);
1173 document.getElementById('EditViewGroupFolderTeamTD').innerHTML = data.defaultgroupfolder;
1175 failure : AjaxObject.handleFailure,
1176 timeout : AjaxObject.timeout,
1181 var callbackStatusForImport = {
1182 success : function (o) {
1184 if (o.responseText != "") {
1185 var statusString = "";
1186 var data = JSON.parse(o.responseText);
1187 for(i=0; i<data.length; i++) {
1188 statusString = statusString + data[i] + '<br/>';
1190 overlay(SUGAR.language.get('Emails','LBL_IMPORT_STATUS_TITLE'), statusString, 'alert');
1192 SE.listView.refreshGrid();
1195 failure : AjaxObject.handleFailure,
1196 timeout : AjaxObject.timeout,
1200 var callbackComposeCache = {
1201 success : AjaxObject.composeCache,
1202 failure : AjaxObject.handleFailure,
1203 timeout : AjaxObject.timeout,
1206 var callbackDelete = {
1207 success : AjaxObject.handleDeleteReturn,
1208 failure : AjaxObject.handleFailure,
1209 timeout : AjaxObject.timeout,
1212 var callbackEmailDetailMultiple = {
1213 success : function(o) {
1215 var retMulti = JSON.parse(o.responseText);
1216 var ret = new Object();
1218 for(var i=0; i<retMulti.length; i++) {
1221 SUGAR.email2._setDetailCache(ret);
1222 SUGAR.email2.detailView.populateDetailView(ret.meta.uid, ret.meta.mbox, ret.meta.ieId, true, SUGAR.email2.innerLayout);
1225 failure : AjaxObject.handleFailure,
1229 var callbackListViewSortOrderChange = {
1230 success : AjaxObject.saveListViewSortOrderPart2,
1231 failure : AjaxObject.handleFailure,
1232 timeout : AjaxObject.timeout,
1234 argument : [ieId, ieName, focusFolder]
1236 var callbackEmptyTrash = {
1237 success : function(o) {
1239 AjaxObject.folderRenameCleanup;
1241 failure : AjaxObject.handleFailure,
1242 timeout : AjaxObject.timeout,
1245 var callbackClearCacheFiles = {
1246 success : function(o) {
1249 failure : AjaxObject.handleFailure,
1250 timeout : AjaxObject.timeout,
1253 var callbackFolderRename = {
1254 success : function(o) {hideOverlay();SUGAR.email2.folders.rebuildFolders();},
1255 failure : AjaxObject.handleFailure,
1256 timeout : AjaxObject.timeout,
1259 var callbackFolderDelete = {
1260 success : function(o) {
1261 var ret = JSON.parse(o.responseText);
1263 if (ret.folder_id) {
1264 var node = SUGAR.email2.folders.getNodeFromId(ret.folder_id);
1266 SUGAR.email2.tree.removeNode(node, true);
1267 } else if (ret.ieId && ret.mbox) {
1268 var node = SUGAR.email2.folders.getNodeFromIeIdAndMailbox(ret.ieId, ret.mbox);
1270 SUGAR.email2.tree.removeNode(node, true);
1273 //SUGAR.email2.folders.loadSettingFolder();
1276 overlay(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorMessage, 'alert');
1279 failure : AjaxObject.handleFailure,
1280 timeout : AjaxObject.timeout,
1283 var callbackFolderSave = {
1284 success : function(o) {
1285 var ret = JSON.parse(o.responseText);
1287 switch(ret.action) {
1288 case 'newFolderSave':
1289 SUGAR.email2.folders.rebuildFolders();
1293 failure : AjaxObject.handleFailure,
1294 timeout : AjaxObject.timeout,
1297 var callbackFolderSubscriptions = {
1298 success : AjaxObject.updateFolderSubscriptions,
1299 failure : AjaxObject.handleFailure,
1300 timeout : AjaxObject.timeout,
1303 var callbackFolderUpdate = {
1304 success : AjaxObject.updateFrameFolder,
1305 failure : AjaxObject.handleFailure,
1306 timeout : AjaxObject.timeout,
1309 var callbackFolders = {
1310 success : AjaxObject.folders.rebuildFolders,
1311 //success : void(true),
1312 failure : AjaxObject.handleFailure,
1313 timeout : AjaxObject.timeout,
1316 var callbackFullSync = {
1317 success : AjaxObject.fullSyncCleanup,
1318 failure : AjaxObject.handleFailure,
1319 timeout : 9999999999999,
1322 var callbackGeneric = {
1323 success : function() {
1326 failure : AjaxObject.handleFailure,
1327 timeout : AjaxObject.timeout,
1330 var callbackIeAccountRetrieve = {
1331 success : function(o) {
1332 // return JSON encoding
1334 SUGAR.email2.accounts.fillIeAccount(o.responseText);
1335 SUGAR.email2.accounts.showEditInboundAccountDialogue(false);
1337 failure : AjaxObject.handleFailure,
1338 timeout : AjaxObject.timeout,
1341 var callbackImportOneEmail = {
1342 success : AjaxObject.detailView.showImportForm,
1343 failure : AjaxObject.handleFailure,
1344 timeout : AjaxObject.timeout,
1347 var callbackRelateEmail = {
1348 success : AjaxObject.detailView.showRelateForm,
1349 failure : AjaxObject.handleFailure,
1350 timeout : AjaxObject.timeout,
1353 var callbackEmailDetailView = {
1354 success : AjaxObject.detailView.showEmailDetailView,
1355 failure : AjaxObject.handleFailure,
1356 timeout : AjaxObject.timeout,
1359 var callbackAssignmentDialog = {
1360 success : AjaxObject.detailView.showAssignmentDialogWithData,
1361 failure : AjaxObject.handleFailure,
1362 timeout : AjaxObject.timeout,
1365 var callbackAssignmentAction = {
1366 success : function(o) {
1367 SE.listView.refreshGrid();
1369 if(o.responseText != '') {
1370 overlay('Assignment action result', o.responseText, 'alert');
1373 failure : AjaxObject.handleFailure,
1374 timeout : AjaxObject.timeout,
1377 var callbackMoveEmails = {
1378 success : function(o) {
1379 SE.listView.refreshGrid();
1381 if(o.responseText != '') {
1382 overlay(app_strings.LBL_EMAIL_ERROR_DESC, o.responseText, 'alert');
1385 failure : AjaxObject.handleFailure,
1386 timeout : AjaxObject.timeout,
1389 var callbackLoadAttachments = {
1390 success : AjaxObject.loadAttachments,
1391 failure : AjaxObject.handleFailure,
1392 timeout : AjaxObject.timeout,
1395 var callbackLoadRules = {
1396 success : AjaxObject.rules.loadRulesForSettings,
1397 failure : AjaxObject.handleFailure,
1398 timeout : AjaxObject.timeout,
1401 var callbackLoadSignature = {
1402 success : AjaxObject.loadSignature,
1403 failure : AjaxObject.handleFailure,
1404 timeout : AjaxObject.timeout,
1407 var callbackDeleteSignature = {
1408 success : AjaxObject.handleDeleteSignature,
1409 failure : AjaxObject.handleFailure,
1410 timeout : AjaxObject.timeout,
1413 /*var callbackMoveEmails = {
1414 success : function(o) { SUGAR.email2.listView.moveEmailsCleanup(o) },
1415 failure : AjaxObject.handleFailure,
1416 timeout : AjaxObject.timeout,
1419 var callbackOutboundSave = {
1420 success : AjaxObject.accounts.saveOutboundCleanup,
1421 failure : AjaxObject.handleFailure,
1422 timeout : AjaxObject.timeout,
1425 var callbackDefaultOutboundSave = {
1426 success : AjaxObject.accounts.saveDefaultOutboundCleanup,
1427 failure : AjaxObject.handleFailure,
1428 timeout : AjaxObject.timeout,
1431 var callbackQuickCreate = {
1432 success : AjaxObject.detailView.showQuickCreateForm,
1433 failure : AjaxObject.handleFailure,
1434 timeout : AjaxObject.timeout,
1437 var callbackQuickCreateSave = {
1438 success : AjaxObject.detailView.saveQuickCreateForm,
1439 failure : AjaxObject.handleFailure,
1440 timeout : AjaxObject.timeout,
1443 var callbackQuickCreateSaveAndAddToAddressBook = {
1444 success : AjaxObject.detailView.saveQuickCreateFormAndAddToAddressBook,
1445 failure : AjaxObject.handleFailure,
1446 timeout : AjaxObject.timeout,
1449 var callbackQuickCreateSaveAndReply = {
1450 success : AjaxObject.detailView.saveQuickCreateFormAndReply,
1451 failure : AjaxObject.handleFailure,
1452 timeout : AjaxObject.timeout,
1455 var callbackQuickCreateSaveAndReplyCase = {
1456 success : AjaxObject.detailView.saveQuickCreateFormAndReplyCase,
1457 failure : AjaxObject.handleFailure,
1458 timeout : AjaxObject.timeout,
1461 var callbackRebuildShowAccountList = {
1462 success : AjaxObject.rebuildShowFolders,
1463 failure : AjaxObject.handleFailure,
1464 timeout : AjaxObject.timeout,
1468 var callbackRefreshSugarFolders = {
1469 success : function(o) {
1470 var t = JSON.parse(o.responseText);
1471 SUGAR.email2.folders.setSugarFoldersEnd(t);
1473 failure : AjaxObject.handleFailure,
1474 timeout : AjaxObject.timeout,
1477 var callbackReplyForward = {
1478 success : AjaxObject.handleReplyForward,
1479 finish : function(a, retryCount) {
1480 if (typeof(retryCount) == 'undefined') {
1485 var idx = SUGAR.email2.composeLayout.currentInstanceId;
1486 var t = tinyMCE.getInstanceById('htmleditor' + idx);
1488 var html = t.getContent();
1490 if (a.type != 'draft') {
1491 if(SUGAR.email2.userPrefs.signatures.signature_prepend == 'true') {
1492 html += " <div><hr></div>" + a.description;
1494 html = " <div><hr></div>" + a.description + html;
1497 html = a.description;
1500 t.setContent(html);//
1503 if (retryCount < 5) {
1504 setTimeout("callbackReplyForward.finish(globalA, " + retryCount + ");", 500);
1508 var tabArray = SUGAR.email2.innerLayout.get("tabs");
1509 if (tabArray != null && tabArray.length > 0) {
1510 for (i = 0 ; i < tabArray.length ; i++) {
1511 var tabObject = tabArray[i];
1512 if (tabObject.get("id") == ("composeTab" + idx)) {
1513 var tabLabel = a.name;
1514 if (tabLabel != null && tabLabel.length > 25) {
1515 tabLabel = tabLabel.substring(0, 25) + "...";
1517 tabObject.get("labelEl").firstChild.data = tabLabel;
1523 //SUGAR.email2.innerLayout.regions.center.getPanel('composeLayout' + idx).setTitle(a.name);
1524 if (a.parent_name != null && a.parent_name != "") {
1525 document.getElementById('data_parent_name' + idx).value = a.parent_name;
1527 if (a.parent_type != null && a.parent_type != "") {
1528 document.getElementById('data_parent_type' + idx).value = a.parent_type;
1530 if (a.parent_id != null && a.parent_id != "") {
1531 document.getElementById('data_parent_id' + idx).value = a.parent_id;
1533 if (a.fromAccounts.status) {
1534 var addressFrom = document.getElementById('addressFrom' + idx);
1535 SUGAR.email2.util.emptySelectOptions(addressFrom);
1536 var fromAccountOpts = a.fromAccounts.data;
1537 for(i=0; i<fromAccountOpts.length; i++) {
1538 var key = fromAccountOpts[i].value;
1539 var display = fromAccountOpts[i].text;
1540 var opt = new Option(display, key);
1541 if (fromAccountOpts[i].selected) {
1542 opt.selected = true;
1544 addressFrom.options.add(opt);
1550 failure : AjaxObject.handleFailure,
1551 timeout : AjaxObject.timeout,
1553 argument : [sendType]
1555 var callbackSendEmail = {
1556 success : AjaxObject.sendEmailCleanUp,
1557 failure : AjaxObject.handleFailure,
1558 timeout : AjaxObject.timeout,
1561 var callbackSettings = {
1562 success : AjaxObject.updateUserPrefs,
1563 failure : AjaxObject.handleFailure,
1564 timeout : AjaxObject.timeout,
1567 var callbackSettingsFolderRefresh = {
1568 success : AjaxObject.settingsFolderRefresh,
1569 failure : AjaxObject.handleFailure,
1570 timeout : AjaxObject.timeout,
1573 var callbackLoadSettingFolder = {
1574 success : function(o) {
1575 AjaxObject.settingsFolderRefresh(o);
1576 SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
1578 failure : AjaxObject.handleFailure,
1579 timeout : AjaxObject.timeout,
1583 var callbackUploadAttachment = {
1584 success : AjaxObject.uploadAttachmentSuccessful,
1585 upload : AjaxObject.uploadAttachmentSuccessful,
1586 failure : AjaxObject.handleFailure,
1587 timeout : AjaxObject.timeout,
1590 var callbackUserPrefs = {
1591 success : function(o) {
1592 SUGAR.email2.userPrefs = JSON.parse(o.responseText);
1594 failure : AjaxObject.handleFailure,
1595 timeout : AjaxObject.timeout,
1599 var callbackContextmenus = {
1601 success : AjaxObject.markEmailCleanup,
1602 failure : AjaxObject.handleFailure,
1603 timeout : AjaxObject.timeout,
1608 var callbackCheckEmail2 = {
1609 success : function(o) {
1610 var ret = JSON.parse(o.responseText);
1611 overlay(app_strings.LBL_EMAIL_CHECKING_NEW, ret.text);
1615 failure : AjaxObject.handleFailure,
1616 timeout : AjaxObject.timeout,