1 /*********************************************************************************
2 * SugarCRM Community Edition 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_smtpauth_req").checked = (ret.mail_smtpauth_req == 1) ? true : false;
460 SUGAR.email2.accounts.smtp_authenticate_field_display();
461 document.getElementById("mail_smtpssl").options[ret.mail_smtpssl].selected = true;
463 if(ret.type == 'system-override') {
464 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(true);
465 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,true);
468 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(false);
469 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,false);
471 SUGAR.util.setEmailPasswordDisplay('mail_smtppass', ret.has_password);
474 failure : AjaxObject.handleFailure,
475 timeout : AjaxObject.timeout,
478 callbackDeleteOutbound : {
479 success : function(o) {
480 var ret = JSON.parse(o.responseText);
483 if(confirm(ret.error_message))
485 overlay(app_strings.LBL_EMAIL_IE_DELETE, app_strings.LBL_EMAIL_ONE_MOMENT);
486 AjaxObject.startRequest(AjaxObject.accounts.callbackDeleteOutbound, urlStandard + "&emailUIAction=deleteOutbound&confirm=true&outbound_email=" + ret.outbound_email);
494 SUGAR.email2.accounts.refreshOuboundAccountTable();
498 failure : AjaxObject.handleFailure,
499 timeout : AjaxObject.timeout,
503 callbackCheckMailProgress : {
504 success : function(o) {
505 if (typeof(SUGAR.email2.accounts.totalMsgCount) == "undefined") {
506 SUGAR.email2.accounts.totalMsgCount = -1;
509 //Check for server timeout / errors
510 var ret = JSON.parse(o.responseText);
513 if (typeof(o.responseText) == 'undefined' || o.responseText == "" || ret == false) {
515 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
516 SUGAR.email2.accounts.totalMsgCount = -1;
517 //SUGAR.email2.folders.rebuildFolders();
521 var currIeId = ret['ieid'];
524 var serverCount = ret.count;
526 if (ret['status'] == 'done') {
527 for(i=0; i < SUGAR.email2.accounts.ieIds.length; i++) {
528 if (i == SUGAR.email2.accounts.ieIds.length - 1) {
532 } else if (SUGAR.email2.accounts.ieIds[i] == currIeId) {
534 currIeId = SUGAR.email2.accounts.ieIds[i+1];
536 SUGAR.email2.accounts.totalMsgCount = -1;
541 else if (ret.mbox && ret.totalcount && ret.count) {
542 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
543 if (ret.count >= ret.totalcount) {
546 } else if (SUGAR.email2.accounts.totalMsgCount < 0 && ret.totalcount) {
547 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
550 overlay(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
551 SUGAR.email2.accounts.totalMsgCount = -1;
556 SUGAR.email2.accounts.totalMsgCount = -1;
558 SUGAR.email2.folders.rebuildFolders();
559 SE.listView.refreshGrid();
560 } else if (SUGAR.email2.accounts.totalMsgCount < 0) {
561 YAHOO.SUGAR.MessageBox.updateProgress(0, mod_strings.LBL_CHECKING_ACCOUNT + ' '+ (i + 2) + ' '+ mod_strings.LBL_OF + ' ' + SUGAR.email2.accounts.ieIds.length);
562 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
563 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=0&synch=" + ret.synch);
565 YAHOO.SUGAR.MessageBox.updateProgress((ret.count / SUGAR.email2.accounts.totalMsgCount) * 100,
566 app_strings.LBL_EMAIL_DOWNLOAD_STATUS.replace(/\[\[count\]\]/, ret.count).replace(/\[\[total\]\]/, SUGAR.email2.accounts.totalMsgCount));
567 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
568 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=" + serverCount +
569 '&mbox=' + ret.mbox + '&synch=' + ret.synch + '&totalcount=' + SUGAR.email2.accounts.totalMsgCount);
572 failure : AjaxObject.handleFailure,
573 timeout : AjaxObject.timeout,
578 ///////////////////////////////////////////////////////////////////////////////
580 AjaxObject.composeLayout = {
582 * Populates the record id
584 saveDraftCleanup : function(o) {
586 var ret = JSON.parse(o.responseText);
588 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
589 else if (o.responseText)
590 overlay(mod_strings.LBL_ERROR_SAVING_DRAFT, o.responseText, 'alert');
594 AjaxObject.composeLayout.callback = {
596 success : AjaxObject.composeLayout.saveDraftCleanup,
597 failure : AjaxObject.handleFailure,
598 timeout : AjaxObject.timeout,
603 AjaxObject.detailView = {
605 * Pops-up a printable view of an email
607 displayPrintable : function(o) {
608 var ret = JSON.parse(o.responseText);
609 var displayTemplate = new YAHOO.SUGAR.Template(SUGAR.email2.templates['viewPrintable']);
610 // 2 below must be in global context
612 meta['panelId'] = SUGAR.email2.util.getPanelId();
613 email = ret.meta.email;
614 if (typeof(email.cc) == 'undefined') {
618 var out = displayTemplate.exec({
619 'app_strings' : app_strings,
627 var popup = window.open('modules/Emails/templates/_blank.html', 'printwin' ,
628 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
630 popup.document.write(out);
631 popup.document.close();
635 * Takes formatted response and creates a modal pop-over containing a title and content
637 displayView : function(o) {
638 var SED = SUGAR.email2.detailView;
639 var ret = JSON.parse(o.responseText);
641 if(!SED.viewDialog) {
642 SED.viewDialog = new YAHOO.widget.Dialog("viewDialog", {
646 constraintoviewport: true,
649 SED.viewDialog.renderEvent.subscribe(function() {
650 var content = this.body.firstChild;
651 var viewH = YAHOO.util.Dom.getViewportHeight();
653 this.body.style.overflow = "auto";
654 this.body.style.width = "800px";
655 this.body.style.height = (viewH - 75 > content.clientHeight ? (content.clientHeight) : (viewH - 75)) + "px";
659 SED.viewDialog.setHeader(ret.title);
660 SED.viewDialog.setBody(ret.html);
661 SED.viewDialog.render();
662 SED.viewDialog.show();
666 * Generates a modal popup to populate with the contents of bean's full EditView
668 showQuickCreateForm : function(o) {
669 var SED = SUGAR.email2.detailView;
670 var ret = JSON.parse(o.responseText);
672 if(!SED.quickCreateDialog) {
673 SED.quickCreateDialog = new YAHOO.widget.Dialog("quickCreate", {
677 constraintoviewport: true,
681 SED.quickCreateDialog.renderEvent.subscribe(function() {
682 var viewH = YAHOO.util.Dom.getViewportHeight();
684 for (var i in this.body.childNodes) {
685 if (this.body.childNodes[i].clientHeight) {
686 contH += this.body.childNodes[i].clientHeight;
687 } else if (this.body.childNodes[i].offsetHeight) {
688 contH += this.body.childNodes[i].offsetHeight;
691 this.body.style.width = "800px";
692 this.body.style.height = (viewH - 75 > contH ? (contH + 10) : (viewH - 75)) + "px";
693 this.body.style.overflow = "auto";
694 }, SED.quickCreateDialog);
696 SED.quickCreateDialog.hideEvent.subscribe(function(){
697 var qsFields = YAHOO.util.Dom.getElementsByClassName('.sqsEnabled', null, this.body);
698 /*for(var qsField in qsFields){
699 if (typeof QSFieldsArray[qsFields[qsField].id] != 'undefined')
700 Ext.getCmp('combobox_'+qsFields[qsField].id).destroy();
703 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_QUICK_CREATE);
706 ret.html = ret.html.replace('<script type="text/javascript" src="include/SugarEmailAddress/SugarEmailAddress.js"></script>', "");
708 SED.quickCreateDialog.setBody(ret.html ? ret.html : " ");
709 SED.quickCreateDialog.render();
710 SUGAR.util.evalScript(ret.html + '<script language="javascript">enableQS(true);</script>');
712 SED.quickCreateDialog.ieId = ret.ieId;
713 SED.quickCreateDialog.uid = ret.uid;
714 SED.quickCreateDialog.mbox = ret.mbox;
715 SED.quickCreateDialog.qcmodule = ret.module;
717 SED.quickCreateDialog.show();
719 var editForm = document.getElementById('form_EmailQCView_' + ret.module);
721 editForm.module.value = 'Emails';
722 var count = SUGAR.EmailAddressWidget.count[ret.module] ? SUGAR.EmailAddressWidget.count[ret.module] : 0;
723 var tableId = YAHOO.util.Dom.getElementsByClassName('emailaddresses', 'table', editForm)[0].id;
724 var instId = ret.module + count;
725 SED.quickCreateEmailsToAdd = ret.emailAddress;
726 SED.quickCreateEmailCallback = function(instId, tableId) {
727 var eaw = SUGAR.EmailAddressWidget.instances[instId];
728 if (typeof(eaw) == "undefined")
729 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
730 + instId + "','" + tableId + "');", 100);
731 eaw.prefillEmailAddresses(tableId, SUGAR.email2.detailView.quickCreateEmailsToAdd);
733 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
734 + instId + "','" + tableId + "');", 100);
738 saveQuickCreateForm : function(o) {
740 SUGAR.email2.detailView.quickCreateDialog.hide();
741 validate['EditView'] = [ ];
744 saveQuickCreateFormAndReply : function(o) {
746 var ret = JSON.parse(o.responseText);
747 SUGAR.email2.detailView.quickCreateDialog.hide();
748 var qcd = SUGAR.email2.detailView.quickCreateDialog;
749 var type = (qcd.qcmodule == 'Cases') ? 'replyCase' : 'reply';
751 var emailID = ret.id;
752 SUGAR.email2.composeLayout.c0_replyForwardEmail(null, ret.id, 'sugar::Emails', type);
754 SUGAR.email2.composeLayout.c0_replyForwardEmail(qcd.ieId, qcd.uid, qcd.mbox, type);
756 //Cean the validate cache to prevent errors on the next call
757 validate['EditView'] = [ ];
760 saveQuickCreateFormAndAddToAddressBook : function(o) {
762 SUGAR.email2.detailView.quickCreateDialog.hide();
763 SUGAR.email2.complexLayout.findPanel('contactsTab').show();
764 validate['EditView'] = [ ];
767 handleAssignmentDialogAssignAction : function() {
770 var assign_user_id = window.document.forms['Distribute'].elements['assigned_user_id'].value;
776 var found_teams = false;
777 var warning_message = mod_strings.LBL_WARN_NO_USERS;
778 if(!found_teams && assign_user_id == '' )
780 alert(warning_message);
784 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
786 for(i=0; i<emailUids.length; i++) {
788 uids += app_strings.LBL_EMAIL_DELIMITER;
790 uids += emailUids[i];
793 var row = SUGAR.email2.grid.getSelectedRows()[0];
794 var data = SUGAR.email2.grid.getRecord(row).getData();
795 var ieid = data.ieId;
796 var mbox = data.mbox;
797 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentAssign&uids=" + uids + "&ieId=" + ieid + "&folder=" + mbox + "&distribute_method=" + dist + "&users=" +assign_user_id + get);
798 SUGAR.email2.contextMenus.assignToDialogue.hide();
799 overlay('Assignment', app_strings.LBL_EMAIL_ONE_MOMENT);
803 handleAssignmentDialogDeleteAction : function() {
804 // TO pass list of UIDS/emailIds
805 var uids = SUGAR.email2.listView.getUidsFromSelection();
806 var row = SUGAR.email2.grid.getSelections()[0];
807 var ieid = row.data.ieId;
808 var mbox = row.data.mbox;
809 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentDelete&uids=" + uids + "&ieId=" + ieId + "&folder=" + mbox);
810 SUGAR.email2.contextMenus.assignmentDialog.hide();
811 overlay(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
817 showEmailDetailView : function(o) {
819 var SED = SUGAR.email2.detailView;
820 var ret = JSON.parse(o.responseText);
822 if(!SED.quickCreateDialog) {
823 SED.quickCreateDialog = new YAHOO.widget.Dialog("emailDetailDialog", {
827 constraintoviewport: true,
829 autofillheight: "body",
832 SED.quickCreateDialog.renderEvent.subscribe(function() {
833 var viewHeight = YAHOO.util.Dom.getViewportHeight();
835 for (var i in this.body.childNodes) {
836 if (this.body.childNodes[i].offsetHeight)
837 contH += this.body.childNodes[i].offsetHeight;
839 this.body.style.overflow = "auto";
840 this.body.style.width = "800px";
841 this.body.style.height = (viewHeight - 75 > contH ? (contH + 10) : (viewHeight - 75)) + "px";
843 }, SED.quickCreateDialog);
845 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_RECORD);
846 SED.quickCreateDialog.setBody(ret.html);
847 SED.quickCreateDialog.render();
848 SUGAR.util.evalScript(ret.html);
849 SED.quickCreateDialog.show();
852 showAssignmentDialogWithData : function(o) {
853 var SEC = SUGAR.email2.contextMenus;
855 var ret = JSON.parse(o.responseText);
856 if (!SEC.assignmentDialog) {
857 SEC.assignmentDialog = new YAHOO.widget.Dialog("assignmentDialog", {
860 constraintoviewport: true,
863 SEC.assignmentDialog.setBody("");
864 SEC.assignmentDialog.setHeader(app_strings.LBL_EMAIL_ASSIGNMENT);
865 SEC.assignmentDialog.renderEvent.subscribe(function() {
866 var iev = YAHOO.util.Dom.get("Distribute");
868 this.body.style.width = "700px";
870 }, SEC.assignmentDialog);
871 SEC.assignmentDialog.render();
873 SEC.assignmentDialog.setBody(ret);
874 SEC.assignmentDialog.render();
876 SEC.assignmentDialog.show();
877 SUGAR.util.evalScript(ret);
880 showImportForm : function(o) {
881 var SED = SUGAR.email2.detailView;
882 var ret = JSON.parse(o.responseText);
884 document.getElementById('quickCreateContent').innerHTML = "";
890 if(!SED.importDialog) {
891 SED.importDialog = new YAHOO.widget.Dialog("importDialog", {
895 constraintoviewport: true,
897 text: app_strings.LBL_EMAIL_ARCHIVE_TO_SUGAR, isDefault: true, handler: function(){
898 AjaxObject.detailView.getImportAction(SED.importDialog.ret); }
902 SED.importDialog.setHeader(app_strings.LBL_EMAIL_IMPORT_SETTINGS);
903 SED.importDialog.setBody("");
904 SED.importDialog.hideEvent.subscribe(function(){
905 for(var i in QSFieldsArray) {
906 if (QSFieldsArray[i] != null && typeof(QSFieldsArray[i]) == "object") {
907 QSFieldsArray[i].destroy();
908 delete QSFieldsArray[i];
910 if (QSProcessedFieldsArray[i]) {
911 QSProcessedFieldsArray[i] = false;
915 SED.importDialog.renderEvent.subscribe(function() {
916 var iev = YAHOO.util.Dom.get("ImportEditView");
918 //this.body.style.height = (iev.clientHeight + 10) + "px";
919 this.body.style.width = "600px";
921 }, SED.importDialog);
922 SED.importDialog.render();
924 SED.importDialog.setBody(ret.html);
925 SED.importDialog.ret = ret;
926 SUGAR.util.evalScript(ret.html);
927 SED.importDialog.render();
929 SED.importDialog.show();
930 SED.importDialog.focusFirstButton();
932 getImportAction : function(ret) {
933 if (!check_form('ImportEditView')) return false;
934 if (!SUGAR.collection.prototype.validateTemSet('ImportEditView', 'team_name')) {
935 alert(mod_strings.LBL_EMAILS_NO_PRIMARY_TEAM_SPECIFIED);
939 var editView = document.getElementById('ImportEditView');
940 if (editView.assigned_user_id != null) {
941 get = get + "&user_id=" + editView.assigned_user_id.value
942 //var user_id = editView.assigned_user_id.value;
944 var parent_id = editView.parent_id.value;
945 var parent_type = editView.parent_type.value;
946 var row = SUGAR.email2.grid.getSelectedRows()[0];
947 row = SUGAR.email2.grid.getRecord(row);
948 var data = row.getData();
949 var ieId = data.ieId;
950 var mbox = data.mbox;
951 var serverDelete = editView.serverDelete.checked;
952 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
954 for(i=0; i<emailUids.length; i++) {
956 uids += app_strings.LBL_EMAIL_DELIMITER;
958 uids += emailUids[i];
961 var action = 'importEmail&uid=';
963 action = 'moveEmails';
964 action = action + '&sourceFolder=' + ret['srcFolder'];
965 action = action + '&sourceIeId=' + ret['srcIeId'];
966 action = action + '&destinationFolder=' + ret['dstFolder'];
967 action = action + '&destinationIeId=' + ret['dstIeId'];
968 action = action + '&emailUids=';
970 if (action.search(/importEmail/) != -1) {
971 overlay(app_strings.LBL_EMAIL_IMPORTING_EMAIL, app_strings.LBL_EMAIL_ONE_MOMENT);
973 overlay("Moving Email(s)", app_strings.LBL_EMAIL_ONE_MOMENT);
976 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=' + action + uids + "&ieId=" + ieId + "&mbox=" + mbox +
977 get + "&parent_id=" + parent_id + "&parent_type=" + parent_type + '&delete=' + serverDelete);
978 SUGAR.email2.detailView.importDialog.hide();
979 document.getElementById('importDialogContent').innerHTML = "";
982 showRelateForm : function(o) {
983 var SED = SUGAR.email2.detailView;
984 var ret = JSON.parse(o.responseText);
985 document.getElementById('quickCreateContent').innerHTML = "";
990 dialog_loaded = true;
992 if(!SED.relateDialog) {
993 SED.relateDialog = new YAHOO.widget.Dialog('relateDialog', {
998 constraintoviewport: true,
1000 text: app_strings.LBL_EMAIL_RELATE_TO, isDefault: true, handler: function(){
1001 if (!check_form('RelateEditView')) return false;
1003 var editView = document.getElementById('RelateEditView');
1004 var parent_id = editView.parent_id.value;
1005 var parent_type = editView.parent_type.value;
1006 var row = SUGAR.email2.grid.getSelectedRows()[0];
1007 row = SUGAR.email2.grid.getRecord(row);
1008 var ieId = row.getData().ieId;
1009 var mbox = row.getData().mbox;
1010 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
1012 for(i=0; i<emailUids.length; i++) {
1014 uids += app_strings.LBL_EMAIL_DELIMITER;
1016 uids += emailUids[i];
1018 overlay(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
1019 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=relateEmails&uid=' + uids
1020 + "&ieId=" + ieId + "&mbox=" + mbox + "&parent_id=" + parent_id + "&parent_type=" + parent_type);
1021 SED.relateDialog.hide();
1022 document.getElementById('relateDialogContent').innerHTML = "";
1027 SED.relateDialog.hideEvent.subscribe(function(){
1028 if (QSFieldsArray['ImportEditView_parent_name'] != null) {
1029 QSFieldsArray['ImportEditView_parent_name'].destroy();
1030 delete QSFieldsArray['ImportEditView_parent_name'];
1032 if (QSProcessedFieldsArray['ImportEditView_parent_name']) {
1033 QSProcessedFieldsArray['ImportEditView_parent_name'] = false;
1037 SED.relateDialog.renderEvent.subscribe(function() {
1038 var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
1040 for (var i in this.body.childNodes) {
1041 if (this.body.childNodes[i].clientHeight)
1042 contH += this.body.childNodes[i].clientHeight;
1044 }, SED.relateDialog);
1045 SED.relateDialog.setHeader(app_strings.LBL_EMAIL_RELATE_EMAIL);
1048 SED.relateDialog.setBody(ret.html);
1049 SED.relateDialog.render();
1050 SUGAR.util.evalScript(ret.html);
1051 SED.relateDialog.show();
1055 * DetailView callbacks
1057 AjaxObject.detailView.callback = {
1059 success : function(o) {
1061 var ret = JSON.parse(o.responseText);
1062 SUGAR.email2.detailView.consumeMetaDetail(ret);
1064 argument: [targetDiv],
1065 failure : AjaxObject.handleFailure,
1070 success : function(o) {
1072 var ret = JSON.parse(o.responseText);
1073 SUGAR.email2.detailView.consumeMetaPreview(ret);
1075 failure : AjaxObject.handleFailure,
1080 success : AjaxObject.detailView.displayPrintable,
1081 failure : AjaxObject.handleFailure,
1082 timeout : AjaxObject.timeout,
1086 success : AjaxObject.detailView.displayView,
1087 failure : AjaxObject.handleFailure,
1088 timeout : AjaxObject.timeout,
1097 AjaxObject.folders = {
1099 * check-mail post actions
1101 checkMailCleanup : function(o) {
1103 AjaxObject.folders.rebuildFolders(o); // rebuild TreeView
1105 // refresh focus ListView
1106 SE.listView.refreshGrid();
1107 SUGAR.email2.folders.startCheckTimer(); // resets the timer
1112 rebuildFolders : function(o) {
1115 var data = JSON.parse(o.responseText);
1117 email2treeinit(SUGAR.email2.tree, data.tree_data, 'frameFolders', data.param);
1118 SUGAR.email2.folders.setSugarFolders();
1121 AjaxObject.folders.callback = {
1123 success : AjaxObject.folders.checkMailCleanup,
1124 failure : AjaxObject.handleFailure,
1125 timeout : 600000, // 5 mins
1130 AjaxObject.rules = {
1131 loadRulesForSettings : function(o) {
1132 document.getElementById("rulesListCell").innerHTML = o.responseText;
1133 // assume we have the class we need
1134 SUGAR.routing.getStrings();
1135 SUGAR.routing.getDependentDropdowns();
1138 //// END PER MODULE CALLBACK OBJECTS
1139 ///////////////////////////////////////////////////////////////////////////
1143 success : AjaxObject.handleSuccess,
1144 failure : AjaxObject.handleFailure,
1145 timeout : AjaxObject.timeout,
1148 var callbackAccount = {
1149 success : AjaxObject.ieSaveSuccess,
1150 failure : AjaxObject.handleFailure,
1151 timeout : AjaxObject.timeout,
1154 var callbackAccountDelete = {
1155 success : AjaxObject.ieDeleteSuccess,
1156 failure : AjaxObject.handleFailure,
1157 timeout : AjaxObject.timeout,
1160 var callbackOutboundTest = {
1161 success : AjaxObject.ieSendSuccess,
1162 failure : AjaxObject.handleFailure,
1163 timeout : AjaxObject.timeout,
1169 var callbackTeamInfoForSettings = {
1170 success : function (o) {
1171 var data = JSON.parse(o.responseText);
1172 document.getElementById('EditViewGroupFolderTeamTD').innerHTML = data.defaultgroupfolder;
1174 failure : AjaxObject.handleFailure,
1175 timeout : AjaxObject.timeout,
1180 var callbackStatusForImport = {
1181 success : function (o) {
1183 if (o.responseText != "") {
1184 var statusString = "";
1185 var data = JSON.parse(o.responseText);
1186 for(i=0; i<data.length; i++) {
1187 statusString = statusString + data[i] + '<br/>';
1189 overlay(SUGAR.language.get('Emails','LBL_IMPORT_STATUS_TITLE'), statusString, 'alert');
1191 SE.listView.refreshGrid();
1194 failure : AjaxObject.handleFailure,
1195 timeout : AjaxObject.timeout,
1199 var callbackComposeCache = {
1200 success : AjaxObject.composeCache,
1201 failure : AjaxObject.handleFailure,
1202 timeout : AjaxObject.timeout,
1205 var callbackDelete = {
1206 success : AjaxObject.handleDeleteReturn,
1207 failure : AjaxObject.handleFailure,
1208 timeout : AjaxObject.timeout,
1211 var callbackEmailDetailMultiple = {
1212 success : function(o) {
1214 var retMulti = JSON.parse(o.responseText);
1215 var ret = new Object();
1217 for(var i=0; i<retMulti.length; i++) {
1220 SUGAR.email2._setDetailCache(ret);
1221 SUGAR.email2.detailView.populateDetailView(ret.meta.uid, ret.meta.mbox, ret.meta.ieId, true, SUGAR.email2.innerLayout);
1224 failure : AjaxObject.handleFailure,
1228 var callbackListViewSortOrderChange = {
1229 success : AjaxObject.saveListViewSortOrderPart2,
1230 failure : AjaxObject.handleFailure,
1231 timeout : AjaxObject.timeout,
1233 argument : [ieId, ieName, focusFolder]
1235 var callbackEmptyTrash = {
1236 success : function(o) {
1238 AjaxObject.folderRenameCleanup;
1240 failure : AjaxObject.handleFailure,
1241 timeout : AjaxObject.timeout,
1244 var callbackClearCacheFiles = {
1245 success : function(o) {
1248 failure : AjaxObject.handleFailure,
1249 timeout : AjaxObject.timeout,
1252 var callbackFolderRename = {
1253 success : function(o) {hideOverlay();SUGAR.email2.folders.rebuildFolders();},
1254 failure : AjaxObject.handleFailure,
1255 timeout : AjaxObject.timeout,
1258 var callbackFolderDelete = {
1259 success : function(o) {
1260 var ret = JSON.parse(o.responseText);
1262 if (ret.folder_id) {
1263 var node = SUGAR.email2.folders.getNodeFromId(ret.folder_id);
1265 SUGAR.email2.tree.removeNode(node, true);
1266 } else if (ret.ieId && ret.mbox) {
1267 var node = SUGAR.email2.folders.getNodeFromIeIdAndMailbox(ret.ieId, ret.mbox);
1269 SUGAR.email2.tree.removeNode(node, true);
1272 //SUGAR.email2.folders.loadSettingFolder();
1275 overlay(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorMessage, 'alert');
1278 failure : AjaxObject.handleFailure,
1279 timeout : AjaxObject.timeout,
1282 var callbackFolderSave = {
1283 success : function(o) {
1284 var ret = JSON.parse(o.responseText);
1286 switch(ret.action) {
1287 case 'newFolderSave':
1288 SUGAR.email2.folders.rebuildFolders();
1292 failure : AjaxObject.handleFailure,
1293 timeout : AjaxObject.timeout,
1296 var callbackFolderSubscriptions = {
1297 success : AjaxObject.updateFolderSubscriptions,
1298 failure : AjaxObject.handleFailure,
1299 timeout : AjaxObject.timeout,
1302 var callbackFolderUpdate = {
1303 success : AjaxObject.updateFrameFolder,
1304 failure : AjaxObject.handleFailure,
1305 timeout : AjaxObject.timeout,
1308 var callbackFolders = {
1309 success : AjaxObject.folders.rebuildFolders,
1310 //success : void(true),
1311 failure : AjaxObject.handleFailure,
1312 timeout : AjaxObject.timeout,
1315 var callbackFullSync = {
1316 success : AjaxObject.fullSyncCleanup,
1317 failure : AjaxObject.handleFailure,
1318 timeout : 9999999999999,
1321 var callbackGeneric = {
1322 success : function() {
1325 failure : AjaxObject.handleFailure,
1326 timeout : AjaxObject.timeout,
1329 var callbackIeAccountRetrieve = {
1330 success : function(o) {
1331 // return JSON encoding
1333 SUGAR.email2.accounts.fillIeAccount(o.responseText);
1334 SUGAR.email2.accounts.showEditInboundAccountDialogue(false);
1336 failure : AjaxObject.handleFailure,
1337 timeout : AjaxObject.timeout,
1340 var callbackImportOneEmail = {
1341 success : AjaxObject.detailView.showImportForm,
1342 failure : AjaxObject.handleFailure,
1343 timeout : AjaxObject.timeout,
1346 var callbackRelateEmail = {
1347 success : AjaxObject.detailView.showRelateForm,
1348 failure : AjaxObject.handleFailure,
1349 timeout : AjaxObject.timeout,
1352 var callbackEmailDetailView = {
1353 success : AjaxObject.detailView.showEmailDetailView,
1354 failure : AjaxObject.handleFailure,
1355 timeout : AjaxObject.timeout,
1358 var callbackAssignmentDialog = {
1359 success : AjaxObject.detailView.showAssignmentDialogWithData,
1360 failure : AjaxObject.handleFailure,
1361 timeout : AjaxObject.timeout,
1364 var callbackAssignmentAction = {
1365 success : function(o) {
1366 SE.listView.refreshGrid();
1368 if(o.responseText != '') {
1369 overlay('Assignment action result', o.responseText, 'alert');
1372 failure : AjaxObject.handleFailure,
1373 timeout : AjaxObject.timeout,
1376 var callbackMoveEmails = {
1377 success : function(o) {
1378 SE.listView.refreshGrid();
1380 if(o.responseText != '') {
1381 overlay(app_strings.LBL_EMAIL_ERROR_DESC, o.responseText, 'alert');
1384 failure : AjaxObject.handleFailure,
1385 timeout : AjaxObject.timeout,
1388 var callbackLoadAttachments = {
1389 success : AjaxObject.loadAttachments,
1390 failure : AjaxObject.handleFailure,
1391 timeout : AjaxObject.timeout,
1394 var callbackLoadRules = {
1395 success : AjaxObject.rules.loadRulesForSettings,
1396 failure : AjaxObject.handleFailure,
1397 timeout : AjaxObject.timeout,
1400 var callbackLoadSignature = {
1401 success : AjaxObject.loadSignature,
1402 failure : AjaxObject.handleFailure,
1403 timeout : AjaxObject.timeout,
1406 var callbackDeleteSignature = {
1407 success : AjaxObject.handleDeleteSignature,
1408 failure : AjaxObject.handleFailure,
1409 timeout : AjaxObject.timeout,
1412 /*var callbackMoveEmails = {
1413 success : function(o) { SUGAR.email2.listView.moveEmailsCleanup(o) },
1414 failure : AjaxObject.handleFailure,
1415 timeout : AjaxObject.timeout,
1418 var callbackOutboundSave = {
1419 success : AjaxObject.accounts.saveOutboundCleanup,
1420 failure : AjaxObject.handleFailure,
1421 timeout : AjaxObject.timeout,
1424 var callbackDefaultOutboundSave = {
1425 success : AjaxObject.accounts.saveDefaultOutboundCleanup,
1426 failure : AjaxObject.handleFailure,
1427 timeout : AjaxObject.timeout,
1430 var callbackQuickCreate = {
1431 success : AjaxObject.detailView.showQuickCreateForm,
1432 failure : AjaxObject.handleFailure,
1433 timeout : AjaxObject.timeout,
1436 var callbackQuickCreateSave = {
1437 success : AjaxObject.detailView.saveQuickCreateForm,
1438 failure : AjaxObject.handleFailure,
1439 timeout : AjaxObject.timeout,
1442 var callbackQuickCreateSaveAndAddToAddressBook = {
1443 success : AjaxObject.detailView.saveQuickCreateFormAndAddToAddressBook,
1444 failure : AjaxObject.handleFailure,
1445 timeout : AjaxObject.timeout,
1448 var callbackQuickCreateSaveAndReply = {
1449 success : AjaxObject.detailView.saveQuickCreateFormAndReply,
1450 failure : AjaxObject.handleFailure,
1451 timeout : AjaxObject.timeout,
1454 var callbackQuickCreateSaveAndReplyCase = {
1455 success : AjaxObject.detailView.saveQuickCreateFormAndReplyCase,
1456 failure : AjaxObject.handleFailure,
1457 timeout : AjaxObject.timeout,
1460 var callbackRebuildShowAccountList = {
1461 success : AjaxObject.rebuildShowFolders,
1462 failure : AjaxObject.handleFailure,
1463 timeout : AjaxObject.timeout,
1467 var callbackRefreshSugarFolders = {
1468 success : function(o) {
1469 var t = JSON.parse(o.responseText);
1470 SUGAR.email2.folders.setSugarFoldersEnd(t);
1472 failure : AjaxObject.handleFailure,
1473 timeout : AjaxObject.timeout,
1476 var callbackReplyForward = {
1477 success : AjaxObject.handleReplyForward,
1478 finish : function(a, retryCount) {
1479 if (typeof(retryCount) == 'undefined') {
1484 var idx = SUGAR.email2.composeLayout.currentInstanceId;
1485 var t = tinyMCE.getInstanceById('htmleditor' + idx);
1487 var html = t.getContent();
1489 if (a.type != 'draft') {
1490 if(SUGAR.email2.userPrefs.signatures.signature_prepend == 'true') {
1491 html += " <div><hr></div>" + a.description;
1493 html = " <div><hr></div>" + a.description + html;
1496 html = a.description;
1499 t.setContent(html);//
1502 if (retryCount < 5) {
1503 setTimeout("callbackReplyForward.finish(globalA, " + retryCount + ");", 500);
1507 var tabArray = SUGAR.email2.innerLayout.get("tabs");
1508 if (tabArray != null && tabArray.length > 0) {
1509 for (i = 0 ; i < tabArray.length ; i++) {
1510 var tabObject = tabArray[i];
1511 if (tabObject.get("id") == ("composeTab" + idx)) {
1512 var tabLabel = a.name;
1513 if (tabLabel != null && tabLabel.length > 25) {
1514 tabLabel = tabLabel.substring(0, 25) + "...";
1516 tabObject.get("labelEl").firstChild.data = tabLabel;
1522 //SUGAR.email2.innerLayout.regions.center.getPanel('composeLayout' + idx).setTitle(a.name);
1523 if (a.parent_name != null && a.parent_name != "") {
1524 document.getElementById('data_parent_name' + idx).value = a.parent_name;
1526 if (a.parent_type != null && a.parent_type != "") {
1527 document.getElementById('data_parent_type' + idx).value = a.parent_type;
1529 if (a.parent_id != null && a.parent_id != "") {
1530 document.getElementById('data_parent_id' + idx).value = a.parent_id;
1532 if (a.fromAccounts.status) {
1533 var addressFrom = document.getElementById('addressFrom' + idx);
1534 SUGAR.email2.util.emptySelectOptions(addressFrom);
1535 var fromAccountOpts = a.fromAccounts.data;
1536 for(i=0; i<fromAccountOpts.length; i++) {
1537 var key = fromAccountOpts[i].value;
1538 var display = fromAccountOpts[i].text;
1539 var opt = new Option(display, key);
1540 if (fromAccountOpts[i].selected) {
1541 opt.selected = true;
1543 addressFrom.options.add(opt);
1549 failure : AjaxObject.handleFailure,
1550 timeout : AjaxObject.timeout,
1552 argument : [sendType]
1554 var callbackSendEmail = {
1555 success : AjaxObject.sendEmailCleanUp,
1556 failure : AjaxObject.handleFailure,
1557 timeout : AjaxObject.timeout,
1560 var callbackSettings = {
1561 success : AjaxObject.updateUserPrefs,
1562 failure : AjaxObject.handleFailure,
1563 timeout : AjaxObject.timeout,
1566 var callbackSettingsFolderRefresh = {
1567 success : AjaxObject.settingsFolderRefresh,
1568 failure : AjaxObject.handleFailure,
1569 timeout : AjaxObject.timeout,
1572 var callbackLoadSettingFolder = {
1573 success : function(o) {
1574 AjaxObject.settingsFolderRefresh(o);
1575 SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
1577 failure : AjaxObject.handleFailure,
1578 timeout : AjaxObject.timeout,
1582 var callbackUploadAttachment = {
1583 success : AjaxObject.uploadAttachmentSuccessful,
1584 upload : AjaxObject.uploadAttachmentSuccessful,
1585 failure : AjaxObject.handleFailure,
1586 timeout : AjaxObject.timeout,
1589 var callbackUserPrefs = {
1590 success : function(o) {
1591 SUGAR.email2.userPrefs = JSON.parse(o.responseText);
1593 failure : AjaxObject.handleFailure,
1594 timeout : AjaxObject.timeout,
1598 var callbackContextmenus = {
1600 success : AjaxObject.markEmailCleanup,
1601 failure : AjaxObject.handleFailure,
1602 timeout : AjaxObject.timeout,
1607 var callbackCheckEmail2 = {
1608 success : function(o) {
1609 var ret = JSON.parse(o.responseText);
1610 overlay(app_strings.LBL_EMAIL_CHECKING_NEW, ret.text);
1614 failure : AjaxObject.handleFailure,
1615 timeout : AjaxObject.timeout,