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 = YAHOO.lang.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 SUGAR.showMessageBox(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 SUGAR.showMessageBox(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) {
104 SUGAR.hideMessageBox();
105 var ret = YAHOO.lang.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
121 SUGAR.hideMessageBox();
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 SUGAR.showMessageBox('Exception occurred...', o.statusText, 'alert');
135 if(document.getElementById('saveButton')) {
136 document.getElementById('saveButton').disabled = false;
140 handleReplyForward : function(o) {
141 var a = YAHOO.lang.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 = YAHOO.lang.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;
199 SUGAR.hideMessageBox();
204 ieDeleteSuccess : function(o) {
205 SUGAR.hideMessageBox();
206 SUGAR.email2.accounts.refreshInboundAccountTable();
207 alert(app_strings.LBL_EMAIL_IE_DELETE_SUCCESSFUL);
208 SUGAR.email2.accounts.rebuildFolderList();
213 ieSaveSuccess : function(o) {
214 document.getElementById('saveButton').disabled = false;
215 var a = YAHOO.lang.JSON.parse(o.responseText);
218 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_CHECK_IE_SETTINGS, 'alert');
219 SUGAR.email2.accounts.ieAccountError(SUGAR.email2.accounts.errorStyle);
221 resp = YAHOO.lang.JSON.parse(o.responseText);
222 SUGAR.email2.accounts.refreshInboundAccountTable();
223 SUGAR.email2.accounts.refreshOuboundAccountTable();
224 SUGAR.email2.folders.startEmailCheckOneAccount(resp.id, true);
225 SUGAR.email2.accounts.inboundAccountEditDialog.hide();
228 SUGAR.hideMessageBox();
229 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_SAVE_ACCOUNT, 'alert');
236 loadAttachments : function(o) {
237 var result = YAHOO.lang.JSON.parse(o.responseText);
239 SUGAR.email2.composeLayout.loadAttachments(result);
244 loadSignature : function(o) {
245 var ret = YAHOO.lang.JSON.parse(o.responseText);
246 SUGAR.email2.signatures[ret.id] = ret.signature_html;
247 SUGAR.email2.composeLayout.setSignature(SUGAR.email2.signatures.targetInstance);
251 * Follow up to mark email read|unread|flagged
253 markEmailCleanup : function(o) {
254 var ret = YAHOO.lang.JSON.parse(o.responseText);
255 if (!ret['status']) {
256 SUGAR.hideMessageBox();
257 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, ret['message'], 'alert');
259 SUGAR.email2.contextMenus.markEmailCleanup();
265 rebuildShowFolders : function(o) {
266 var t = YAHOO.lang.JSON.parse(o.responseText);
267 var show = document.getElementById('ieAccountListShow');
269 SUGAR.email2.util.emptySelectOptions(show);
271 for(i=0; i<t.length; i++) { // iterate through assoc array
272 var opt = new Option(t[i].text, t[i].value, t[i].selected);
273 opt.selected = t[i].selected;
274 show.options.add(opt);
277 SUGAR.email2.accounts.renderTree();
281 saveListViewSortOrderPart2 : function() {
282 // create the JSON string the func expects
283 focusFolderPath = '[ "Home", "' + ieName + '"';
285 var f = new String(focusFolder);
286 var fEx = f.split('.');
288 for(i=0; i<fEx.length; i++) {
289 focusFolderPath += ', "' + fEx[i] +'"'
292 focusFolderPath += ']';
294 YAHOO.namespace('frameFolders').selectednode = SUGAR.email2.folders.getNodeFromMboxPath(focusFolderPath);
295 SUGAR.email2.listView.populateListFrame(YAHOO.namespace('frameFolders').selectednode, ieId, 'true');
301 sendEmailCleanUp : function(o) {
303 SUGAR.hideMessageBox();
306 ret = YAHOO.lang.JSON.parse(o.responseText);
307 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
308 //SUGAR.email2.addressBook.showContactMatches(ret.possibleMatches);
310 if (o.responseText) {
311 SUGAR.showMessageBox(mod_strings.LBL_SEND_EMAIL_FAIL_TITLE, o.responseText, 'alert');
313 // Else we have an error here.
316 if (typeof(SE.grid) != 'undefined')
317 SE.listView.refreshGrid();
318 //Disabled while address book is disabled
320 //If this call back was initiated by quick compose from a Detail View page, refresh the
321 //history subpanel. If it was initiated by quickcreate from shortcut bar, then
322 //close the shortcut bar menu
323 if ( (typeof(action_sugar_grp1) != 'undefined')) {
324 if(action_sugar_grp1 == 'DetailView') {
325 showSubPanel('history',null,true);
326 } else if(action_sugar_grp1 == 'quickcreate') {
333 ieSendSuccess : function(o) {
334 SUGAR.hideMessageBox();
335 SUGAR.showMessageBox(app_strings.LBL_EMAIL_TEST_OUTBOUND_SETTINGS_SENT, app_strings.LBL_EMAIL_TEST_NOTIFICATION_SENT, 'plain');
340 settingsFolderRefresh : function(o) {
341 //SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
342 var ret = YAHOO.lang.JSON.parse(o.responseText);
343 var user = document.getElementById('userFolders');
345 SUGAR.email2.util.emptySelectOptions(user);
347 for(i=0; i<ret.userFolders.length; i++) {
348 var display = ret.userFolders[i].name;
349 var value = ret.userFolders[i].id;
350 var selected = (ret.userFolders[i].selected != "") ? true : false;
351 var opt = new Option(display, value, selected);
352 opt.selected = selected;
353 user.options.add(opt);
359 startRequest : function(callback, args, forceAbort) {
360 if(this.currentRequestObject != null) {
361 if(this.forceAbort == true) {
362 YAHOO.util.Connect.abort(this.currentRequestObject, null, false);
365 this.currentRequestObject = YAHOO.util.Connect.asyncRequest('POST', "./index.php", callback, args);
369 requestInProgress : function() {
370 return (YAHOO.util.Connect.isCallInProgress(this.currentRequestObject));
375 updateFolderSubscriptions : function() {
376 SUGAR.email2.folders.lazyLoadSettings(); // refresh view in Settings overlay
377 SUGAR.email2.folders.setSugarFolders(1000);// refresh view in TreeView
378 SUGAR.hideMessageBox();
383 updateFrameFolder : function() {
384 SUGAR.email2.folders.checkEmailAccounts();
389 updateUserPrefs : function(o) {
390 SUGAR.email2.userPrefs = YAHOO.lang.JSON.parse(o.responseText);
391 SUGAR.email2.folders.startCheckTimer(); // starts the auto-check interval
396 uploadAttachmentSuccessful : function(o) {
398 document.getElementById('email_attachment').value = '';
400 var ret = YAHOO.lang.JSON.parse(o.responseText);
401 var idx = SUGAR.email2.composeLayout.currentInstanceId;
402 var overall = document.getElementById('addedFiles' + idx);
403 var index = overall.childNodes.length;
405 "<div id='email_attachment_bucket" + idx + index + "'>" +
407 "<img src='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=minus.gif' " +
408 "style='cursor:pointer' align='absmiddle' onclick='SUGAR.email2.composeLayout.deleteUploadAttachment(\"" +
409 idx + index + "\",\"" + ret.guid + ret.name + "\");'/>" +
411 "<img src='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=attachment.gif' " +
412 "id='email_attachmentImage'" + idx + index + "align='absmiddle' />" +
414 "<input type='hidden' value='" + ret.guid + ret.name + "' name='email_attachment" + index + "' id='email_attachment" + idx + index + "' />" +
416 ((ret.nameForDisplay != null) ? ret.nameForDisplay + " " : ret.name + " ") +
419 overall.innerHTML += out;
420 if(SUGAR.email2.util.isIe()) {
421 document.getElementById('addedFiles' + idx).innerHTML = document.getElementById('addedFiles' + idx).innerHTML;
425 SUGAR.email2.addFileDialog.hide();
427 SUGAR.email2.composeLayout.showAttachmentPanel(idx);
432 ///////////////////////////////////////////////////////////////////////////
433 //// PER MODULE CALLBACK OBJECTS
434 AjaxObject.accounts = {
435 saveOutboundCleanup : function(o) {
436 SUGAR.email2.accounts.refreshOuboundAccountTable();
437 SUGAR.email2.accounts.outboundDialog.hide();
438 var id = o.responseText;
439 SUGAR.email2.accounts.newAddedOutboundId = id;
441 saveDefaultOutboundCleanup: function(o){
444 callbackEditOutbound : {
445 success : function(o)
447 var ret = YAHOO.lang.JSON.parse(o.responseText);
449 SUGAR.email2.accounts.showAddSmtp();
452 document.getElementById("mail_id").value = ret.id;
453 document.getElementById("type").value = ret.type;
454 document.getElementById("mail_sendtype").value = ret.mail_sendtype;
455 document.getElementById("mail_name").value = ret.name;
456 document.getElementById("mail_smtpserver").value = ret.mail_smtpserver;
457 document.getElementById("outboundEmailForm").mail_smtptype.value = ret.mail_smtptype;
458 document.getElementById("mail_smtpport").value = ret.mail_smtpport;
459 document.getElementById("mail_smtpuser").value = ret.mail_smtpuser;
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);
472 SUGAR.util.setEmailPasswordDisplay('mail_smtppass', ret.has_password);
475 failure : AjaxObject.handleFailure,
476 timeout : AjaxObject.timeout,
479 callbackDeleteOutbound : {
480 success : function(o) {
481 var ret = YAHOO.lang.JSON.parse(o.responseText);
484 if(confirm(ret.error_message))
486 SUGAR.showMessageBox(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);
490 SUGAR.hideMessageBox();
494 SUGAR.hideMessageBox();
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 = YAHOO.lang.JSON.parse(o.responseText);
514 if (typeof(o.responseText) == 'undefined' || o.responseText == "" || ret == false) {
515 SUGAR.hideMessageBox();
516 SUGAR.showMessageBox(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;
550 SUGAR.hideMessageBox();
551 SUGAR.showMessageBox(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;
558 SUGAR.hideMessageBox();
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 SUGAR.hideMessageBox();
590 ret = YAHOO.lang.JSON.parse(o.responseText);
591 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
593 if (o.responseText) {
594 SUGAR.showMessageBox(mod_strings.LBL_ERROR_SAVING_DRAFT, o.responseText, 'alert');
600 AjaxObject.composeLayout.callback = {
602 success : AjaxObject.composeLayout.saveDraftCleanup,
603 failure : AjaxObject.handleFailure,
604 timeout : AjaxObject.timeout,
609 AjaxObject.detailView = {
611 * Pops-up a printable view of an email
613 displayPrintable : function(o) {
614 var ret = YAHOO.lang.JSON.parse(o.responseText);
615 var displayTemplate = new YAHOO.SUGAR.Template(SUGAR.email2.templates['viewPrintable']);
616 // 2 below must be in global context
618 meta['panelId'] = SUGAR.email2.util.getPanelId();
619 email = ret.meta.email;
620 if (typeof(email.cc) == 'undefined') {
624 var out = displayTemplate.exec({
625 'app_strings' : app_strings,
633 var popup = window.open('modules/Emails/templates/_blank.html', 'printwin' ,
634 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
636 popup.document.write(out);
637 popup.document.close();
641 * Takes formatted response and creates a modal pop-over containing a title and content
643 displayView : function(o) {
644 var SED = SUGAR.email2.detailView;
645 var ret = YAHOO.lang.JSON.parse(o.responseText);
647 if(!SED.viewDialog) {
648 SED.viewDialog = new YAHOO.widget.Dialog("viewDialog", {
652 constraintoviewport: true,
655 SED.viewDialog.renderEvent.subscribe(function() {
656 var content = this.body.firstChild;
657 var viewH = YAHOO.util.Dom.getViewportHeight();
659 this.body.style.overflow = "auto";
660 this.body.style.width = "800px";
661 this.body.style.height = (viewH - 75 > content.clientHeight ? (content.clientHeight) : (viewH - 75)) + "px";
665 SED.viewDialog.setHeader(ret.title);
666 SED.viewDialog.setBody(ret.html);
667 SED.viewDialog.render();
668 SED.viewDialog.show();
672 * Generates a modal popup to populate with the contents of bean's full EditView
674 showQuickCreateForm : function(o) {
675 var SED = SUGAR.email2.detailView;
676 var ret = YAHOO.lang.JSON.parse(o.responseText);
678 if(!SED.quickCreateDialog) {
679 SED.quickCreateDialog = new YAHOO.widget.Dialog("quickCreate", {
683 constraintoviewport: true,
687 SED.quickCreateDialog.renderEvent.subscribe(function() {
688 var viewH = YAHOO.util.Dom.getViewportHeight();
690 for (var i in this.body.childNodes) {
691 if (this.body.childNodes[i].clientHeight) {
692 contH += this.body.childNodes[i].clientHeight;
693 } else if (this.body.childNodes[i].offsetHeight) {
694 contH += this.body.childNodes[i].offsetHeight;
697 this.body.style.width = "800px";
698 this.body.style.height = (viewH - 75 > contH ? (contH + 10) : (viewH - 75)) + "px";
699 this.body.style.overflow = "auto";
700 }, SED.quickCreateDialog);
702 SED.quickCreateDialog.hideEvent.subscribe(function(){
703 var qsFields = YAHOO.util.Dom.getElementsByClassName('.sqsEnabled', null, this.body);
704 /*for(var qsField in qsFields){
705 if (typeof QSFieldsArray[qsFields[qsField].id] != 'undefined')
706 Ext.getCmp('combobox_'+qsFields[qsField].id).destroy();
709 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_QUICK_CREATE);
712 ret.html = ret.html.replace('<script type="text/javascript" src="include/SugarEmailAddress/SugarEmailAddress.js"></script>', "");
714 SED.quickCreateDialog.setBody(ret.html ? ret.html : " ");
715 SED.quickCreateDialog.render();
716 SUGAR.util.evalScript(ret.html + '<script language="javascript">enableQS(true);</script>');
718 SED.quickCreateDialog.ieId = ret.ieId;
719 SED.quickCreateDialog.uid = ret.uid;
720 SED.quickCreateDialog.mbox = ret.mbox;
721 SED.quickCreateDialog.qcmodule = ret.module;
723 SED.quickCreateDialog.show();
725 var editForm = document.getElementById('form_EmailQCView_' + ret.module);
727 editForm.module.value = 'Emails';
728 var count = SUGAR.EmailAddressWidget.count[ret.module] ? SUGAR.EmailAddressWidget.count[ret.module] : 0;
729 var tableId = YAHOO.util.Dom.getElementsByClassName('emailaddresses', 'table', editForm)[0].id;
730 var instId = ret.module + count;
731 SED.quickCreateEmailsToAdd = ret.emailAddress;
732 SED.quickCreateEmailCallback = function(instId, tableId) {
733 var eaw = SUGAR.EmailAddressWidget.instances[instId];
734 if (typeof(eaw) == "undefined")
735 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
736 + instId + "','" + tableId + "');", 100);
737 eaw.prefillEmailAddresses(tableId, SUGAR.email2.detailView.quickCreateEmailsToAdd);
739 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
740 + instId + "','" + tableId + "');", 100);
744 saveQuickCreateForm : function(o) {
745 SUGAR.hideMessageBox();
746 SUGAR.email2.detailView.quickCreateDialog.hide();
747 validate['EditView'] = [ ];
750 saveQuickCreateFormAndReply : function(o) {
751 SUGAR.hideMessageBox();
752 var ret = YAHOO.lang.JSON.parse(o.responseText);
753 SUGAR.email2.detailView.quickCreateDialog.hide();
754 var qcd = SUGAR.email2.detailView.quickCreateDialog;
755 var type = (qcd.qcmodule == 'Cases') ? 'replyCase' : 'reply';
757 var emailID = ret.id;
758 SUGAR.email2.composeLayout.c0_replyForwardEmail(null, ret.id, 'sugar::Emails', type);
760 SUGAR.email2.composeLayout.c0_replyForwardEmail(qcd.ieId, qcd.uid, qcd.mbox, type);
762 //Cean the validate cache to prevent errors on the next call
763 validate['EditView'] = [ ];
766 saveQuickCreateFormAndAddToAddressBook : function(o) {
767 SUGAR.hideMessageBox();
768 SUGAR.email2.detailView.quickCreateDialog.hide();
769 SUGAR.email2.complexLayout.findPanel('contactsTab').show();
770 validate['EditView'] = [ ];
773 handleAssignmentDialogAssignAction : function() {
776 var assign_user_id = window.document.forms['Distribute'].elements['assigned_user_id'].value;
782 var found_teams = false;
783 var warning_message = mod_strings.LBL_WARN_NO_USERS;
784 if(!found_teams && assign_user_id == '' )
786 alert(warning_message);
790 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
792 for(i=0; i<emailUids.length; i++) {
794 uids += app_strings.LBL_EMAIL_DELIMITER;
796 uids += emailUids[i];
799 var row = SUGAR.email2.grid.getSelectedRows()[0];
800 var data = SUGAR.email2.grid.getRecord(row).getData();
801 var ieid = data.ieId;
802 var mbox = data.mbox;
803 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentAssign&uids=" + uids + "&ieId=" + ieid + "&folder=" + mbox + "&distribute_method=" + dist + "&users=" +assign_user_id + get);
804 SUGAR.email2.contextMenus.assignToDialogue.hide();
805 SUGAR.showMessageBox('Assignment', app_strings.LBL_EMAIL_ONE_MOMENT);
809 handleAssignmentDialogDeleteAction : function() {
810 // TO pass list of UIDS/emailIds
811 var uids = SUGAR.email2.listView.getUidsFromSelection();
812 var row = SUGAR.email2.grid.getSelections()[0];
813 var ieid = row.data.ieId;
814 var mbox = row.data.mbox;
815 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentDelete&uids=" + uids + "&ieId=" + ieId + "&folder=" + mbox);
816 SUGAR.email2.contextMenus.assignmentDialog.hide();
817 SUGAR.showMessageBox(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
823 showEmailDetailView : function(o) {
824 SUGAR.hideMessageBox();
825 var SED = SUGAR.email2.detailView;
826 var ret = YAHOO.lang.JSON.parse(o.responseText);
828 if(!SED.quickCreateDialog) {
829 SED.quickCreateDialog = new YAHOO.widget.Dialog("emailDetailDialog", {
833 constraintoviewport: true,
835 autofillheight: "body",
838 SED.quickCreateDialog.renderEvent.subscribe(function() {
839 var viewHeight = YAHOO.util.Dom.getViewportHeight();
841 for (var i in this.body.childNodes) {
842 if (this.body.childNodes[i].offsetHeight)
843 contH += this.body.childNodes[i].offsetHeight;
845 this.body.style.overflow = "auto";
846 this.body.style.width = "800px";
847 this.body.style.height = (viewHeight - 75 > contH ? (contH + 10) : (viewHeight - 75)) + "px";
849 }, SED.quickCreateDialog);
851 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_RECORD);
852 SED.quickCreateDialog.setBody(ret.html);
853 SED.quickCreateDialog.render();
854 SUGAR.util.evalScript(ret.html);
855 SED.quickCreateDialog.show();
858 showAssignmentDialogWithData : function(o) {
859 var SEC = SUGAR.email2.contextMenus;
860 SUGAR.hideMessageBox();
861 var ret = YAHOO.lang.JSON.parse(o.responseText);
862 if (!SEC.assignmentDialog) {
863 SEC.assignmentDialog = new YAHOO.widget.Dialog("assignmentDialog", {
866 constraintoviewport: true,
869 SEC.assignmentDialog.setBody("");
870 SEC.assignmentDialog.setHeader(app_strings.LBL_EMAIL_ASSIGNMENT);
871 SEC.assignmentDialog.renderEvent.subscribe(function() {
872 var iev = YAHOO.util.Dom.get("Distribute");
874 this.body.style.width = "700px";
876 }, SEC.assignmentDialog);
877 SEC.assignmentDialog.render();
879 SEC.assignmentDialog.setBody(ret);
880 SEC.assignmentDialog.render();
882 SEC.assignmentDialog.show();
883 SUGAR.util.evalScript(ret);
886 showImportForm : function(o) {
887 var SED = SUGAR.email2.detailView;
888 var ret = YAHOO.lang.JSON.parse(o.responseText);
890 document.getElementById('quickCreateContent').innerHTML = "";
891 SUGAR.hideMessageBox();
896 if(!SED.importDialog) {
897 SED.importDialog = new YAHOO.widget.Dialog("importDialog", {
901 constraintoviewport: true,
903 text: app_strings.LBL_EMAIL_ARCHIVE_TO_SUGAR, isDefault: true, handler: function(){
904 AjaxObject.detailView.getImportAction(SED.importDialog.ret); }
908 SED.importDialog.setHeader(app_strings.LBL_EMAIL_IMPORT_SETTINGS);
909 SED.importDialog.setBody("");
910 SED.importDialog.hideEvent.subscribe(function(){
911 for(var i in QSFieldsArray) {
912 if (QSFieldsArray[i] != null && typeof(QSFieldsArray[i]) == "object") {
913 QSFieldsArray[i].destroy();
914 delete QSFieldsArray[i];
916 if (QSProcessedFieldsArray[i]) {
917 QSProcessedFieldsArray[i] = false;
921 SED.importDialog.renderEvent.subscribe(function() {
922 var iev = YAHOO.util.Dom.get("ImportEditView");
924 //this.body.style.height = (iev.clientHeight + 10) + "px";
925 this.body.style.width = "600px";
927 }, SED.importDialog);
928 SED.importDialog.render();
930 SED.importDialog.setBody(ret.html);
931 SED.importDialog.ret = ret;
932 SUGAR.util.evalScript(ret.html);
933 SED.importDialog.render();
935 SED.importDialog.show();
936 SED.importDialog.focusFirstButton();
938 getImportAction : function(ret) {
939 if (!check_form('ImportEditView')) return false;
940 if (!SUGAR.collection.prototype.validateTemSet('ImportEditView', 'team_name')) {
941 alert(mod_strings.LBL_EMAILS_NO_PRIMARY_TEAM_SPECIFIED);
945 var editView = document.getElementById('ImportEditView');
946 if (editView.assigned_user_id != null) {
947 get = get + "&user_id=" + editView.assigned_user_id.value
948 //var user_id = editView.assigned_user_id.value;
950 var parent_id = editView.parent_id.value;
951 var parent_type = editView.parent_type.value;
952 var row = SUGAR.email2.grid.getSelectedRows()[0];
953 row = SUGAR.email2.grid.getRecord(row);
954 var data = row.getData();
955 var ieId = data.ieId;
956 var mbox = data.mbox;
957 var serverDelete = editView.serverDelete.checked;
958 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
960 for(i=0; i<emailUids.length; i++) {
962 uids += app_strings.LBL_EMAIL_DELIMITER;
964 uids += emailUids[i];
967 var action = 'importEmail&uid=';
969 action = 'moveEmails';
970 action = action + '&sourceFolder=' + ret['srcFolder'];
971 action = action + '&sourceIeId=' + ret['srcIeId'];
972 action = action + '&destinationFolder=' + ret['dstFolder'];
973 action = action + '&destinationIeId=' + ret['dstIeId'];
974 action = action + '&emailUids=';
976 if (action.search(/importEmail/) != -1) {
977 SUGAR.showMessageBox(app_strings.LBL_EMAIL_IMPORTING_EMAIL, app_strings.LBL_EMAIL_ONE_MOMENT);
979 SUGAR.showMessageBox("Moving Email(s)", app_strings.LBL_EMAIL_ONE_MOMENT);
982 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=' + action + uids + "&ieId=" + ieId + "&mbox=" + mbox +
983 get + "&parent_id=" + parent_id + "&parent_type=" + parent_type + '&delete=' + serverDelete);
984 SUGAR.email2.detailView.importDialog.hide();
985 document.getElementById('importDialogContent').innerHTML = "";
988 showRelateForm : function(o) {
989 var SED = SUGAR.email2.detailView;
990 var ret = YAHOO.lang.JSON.parse(o.responseText);
991 document.getElementById('quickCreateContent').innerHTML = "";
992 SUGAR.hideMessageBox();
996 dialog_loaded = true;
998 if(!SED.relateDialog) {
999 SED.relateDialog = new YAHOO.widget.Dialog('relateDialog', {
1004 constraintoviewport: true,
1006 text: app_strings.LBL_EMAIL_RELATE_TO, isDefault: true, handler: function(){
1007 if (!check_form('RelateEditView')) return false;
1009 var editView = document.getElementById('RelateEditView');
1010 var parent_id = editView.parent_id.value;
1011 var parent_type = editView.parent_type.value;
1012 var row = SUGAR.email2.grid.getSelectedRows()[0];
1013 row = SUGAR.email2.grid.getRecord(row);
1014 var ieId = row.getData().ieId;
1015 var mbox = row.getData().mbox;
1016 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
1018 for(i=0; i<emailUids.length; i++) {
1020 uids += app_strings.LBL_EMAIL_DELIMITER;
1022 uids += emailUids[i];
1024 SUGAR.showMessageBox(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
1025 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=relateEmails&uid=' + uids
1026 + "&ieId=" + ieId + "&mbox=" + mbox + "&parent_id=" + parent_id + "&parent_type=" + parent_type);
1027 SED.relateDialog.hide();
1028 document.getElementById('relateDialogContent').innerHTML = "";
1033 SED.relateDialog.hideEvent.subscribe(function(){
1034 if (QSFieldsArray['ImportEditView_parent_name'] != null) {
1035 QSFieldsArray['ImportEditView_parent_name'].destroy();
1036 delete QSFieldsArray['ImportEditView_parent_name'];
1038 if (QSProcessedFieldsArray['ImportEditView_parent_name']) {
1039 QSProcessedFieldsArray['ImportEditView_parent_name'] = false;
1043 SED.relateDialog.renderEvent.subscribe(function() {
1044 var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
1046 for (var i in this.body.childNodes) {
1047 if (this.body.childNodes[i].clientHeight)
1048 contH += this.body.childNodes[i].clientHeight;
1050 }, SED.relateDialog);
1051 SED.relateDialog.setHeader(app_strings.LBL_EMAIL_RELATE_EMAIL);
1054 SED.relateDialog.setBody(ret.html);
1055 SED.relateDialog.render();
1056 SUGAR.util.evalScript(ret.html);
1057 SED.relateDialog.show();
1061 * DetailView callbacks
1063 AjaxObject.detailView.callback = {
1065 success : function(o) {
1067 var ret = YAHOO.lang.JSON.parse(o.responseText);
1068 SUGAR.email2.detailView.consumeMetaDetail(ret);
1070 argument: [targetDiv],
1071 failure : AjaxObject.handleFailure,
1076 success : function(o) {
1078 var ret = YAHOO.lang.JSON.parse(o.responseText);
1079 SUGAR.email2.detailView.consumeMetaPreview(ret);
1081 failure : AjaxObject.handleFailure,
1086 success : AjaxObject.detailView.displayPrintable,
1087 failure : AjaxObject.handleFailure,
1088 timeout : AjaxObject.timeout,
1092 success : AjaxObject.detailView.displayView,
1093 failure : AjaxObject.handleFailure,
1094 timeout : AjaxObject.timeout,
1103 AjaxObject.folders = {
1105 * check-mail post actions
1107 checkMailCleanup : function(o) {
1108 SUGAR.hideMessageBox();
1109 AjaxObject.folders.rebuildFolders(o); // rebuild TreeView
1111 // refresh focus ListView
1112 SE.listView.refreshGrid();
1113 SUGAR.email2.folders.startCheckTimer(); // resets the timer
1118 rebuildFolders : function(o) {
1119 SUGAR.hideMessageBox();
1121 var data = YAHOO.lang.JSON.parse(o.responseText);
1123 email2treeinit(SUGAR.email2.tree, data.tree_data, 'frameFolders', data.param);
1124 SUGAR.email2.folders.setSugarFolders();
1127 AjaxObject.folders.callback = {
1129 success : AjaxObject.folders.checkMailCleanup,
1130 failure : AjaxObject.handleFailure,
1131 timeout : 600000, // 5 mins
1136 AjaxObject.rules = {
1137 loadRulesForSettings : function(o) {
1138 document.getElementById("rulesListCell").innerHTML = o.responseText;
1139 // assume we have the class we need
1140 SUGAR.routing.getStrings();
1141 SUGAR.routing.getDependentDropdowns();
1144 //// END PER MODULE CALLBACK OBJECTS
1145 ///////////////////////////////////////////////////////////////////////////
1149 success : AjaxObject.handleSuccess,
1150 failure : AjaxObject.handleFailure,
1151 timeout : AjaxObject.timeout,
1154 var callbackAccount = {
1155 success : AjaxObject.ieSaveSuccess,
1156 failure : AjaxObject.handleFailure,
1157 timeout : AjaxObject.timeout,
1160 var callbackAccountDelete = {
1161 success : AjaxObject.ieDeleteSuccess,
1162 failure : AjaxObject.handleFailure,
1163 timeout : AjaxObject.timeout,
1166 var callbackOutboundTest = {
1167 success : AjaxObject.ieSendSuccess,
1168 failure : AjaxObject.handleFailure,
1169 timeout : AjaxObject.timeout,
1175 var callbackTeamInfoForSettings = {
1176 success : function (o) {
1177 var data = YAHOO.lang.JSON.parse(o.responseText);
1178 document.getElementById('EditViewGroupFolderTeamTD').innerHTML = data.defaultgroupfolder;
1180 failure : AjaxObject.handleFailure,
1181 timeout : AjaxObject.timeout,
1186 var callbackStatusForImport = {
1187 success : function (o) {
1188 SUGAR.hideMessageBox();
1189 if (o.responseText != "") {
1190 var statusString = "";
1191 var data = YAHOO.lang.JSON.parse(o.responseText);
1192 for(i=0; i<data.length; i++) {
1193 statusString = statusString + data[i] + '<br/>';
1195 SUGAR.showMessageBox(SUGAR.language.get('Emails','LBL_IMPORT_STATUS_TITLE'), statusString, 'alert');
1197 SE.listView.refreshGrid();
1200 failure : AjaxObject.handleFailure,
1201 timeout : AjaxObject.timeout,
1205 var callbackComposeCache = {
1206 success : AjaxObject.composeCache,
1207 failure : AjaxObject.handleFailure,
1208 timeout : AjaxObject.timeout,
1211 var callbackDelete = {
1212 success : AjaxObject.handleDeleteReturn,
1213 failure : AjaxObject.handleFailure,
1214 timeout : AjaxObject.timeout,
1217 var callbackEmailDetailMultiple = {
1218 success : function(o) {
1219 SUGAR.hideMessageBox();
1220 var retMulti = YAHOO.lang.JSON.parse(o.responseText);
1221 var ret = new Object();
1223 for(var i=0; i<retMulti.length; i++) {
1226 SUGAR.email2._setDetailCache(ret);
1227 SUGAR.email2.detailView.populateDetailView(ret.meta.uid, ret.meta.mbox, ret.meta.ieId, true, SUGAR.email2.innerLayout);
1230 failure : AjaxObject.handleFailure,
1234 var callbackListViewSortOrderChange = {
1235 success : AjaxObject.saveListViewSortOrderPart2,
1236 failure : AjaxObject.handleFailure,
1237 timeout : AjaxObject.timeout,
1239 argument : [ieId, ieName, focusFolder]
1241 var callbackEmptyTrash = {
1242 success : function(o) {
1243 SUGAR.hideMessageBox();
1244 AjaxObject.folderRenameCleanup;
1246 failure : AjaxObject.handleFailure,
1247 timeout : AjaxObject.timeout,
1250 var callbackClearCacheFiles = {
1251 success : function(o) {
1252 SUGAR.hideMessageBox();
1254 failure : AjaxObject.handleFailure,
1255 timeout : AjaxObject.timeout,
1258 var callbackFolderRename = {
1259 success : function(o) {SUGAR.hideMessageBox();SUGAR.email2.folders.rebuildFolders();},
1260 failure : AjaxObject.handleFailure,
1261 timeout : AjaxObject.timeout,
1264 var callbackFolderDelete = {
1265 success : function(o) {
1266 var ret = YAHOO.lang.JSON.parse(o.responseText);
1268 if (ret.folder_id) {
1269 var node = SUGAR.email2.folders.getNodeFromId(ret.folder_id);
1271 SUGAR.email2.tree.removeNode(node, true);
1272 } else if (ret.ieId && ret.mbox) {
1273 var node = SUGAR.email2.folders.getNodeFromIeIdAndMailbox(ret.ieId, ret.mbox);
1275 SUGAR.email2.tree.removeNode(node, true);
1277 SUGAR.hideMessageBox();
1278 //SUGAR.email2.folders.loadSettingFolder();
1280 SUGAR.hideMessageBox();
1281 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorMessage, 'alert');
1284 failure : AjaxObject.handleFailure,
1285 timeout : AjaxObject.timeout,
1288 var callbackFolderSave = {
1289 success : function(o) {
1290 var ret = YAHOO.lang.JSON.parse(o.responseText);
1292 switch(ret.action) {
1293 case 'newFolderSave':
1294 SUGAR.email2.folders.rebuildFolders();
1298 failure : AjaxObject.handleFailure,
1299 timeout : AjaxObject.timeout,
1302 var callbackFolderSubscriptions = {
1303 success : AjaxObject.updateFolderSubscriptions,
1304 failure : AjaxObject.handleFailure,
1305 timeout : AjaxObject.timeout,
1308 var callbackFolderUpdate = {
1309 success : AjaxObject.updateFrameFolder,
1310 failure : AjaxObject.handleFailure,
1311 timeout : AjaxObject.timeout,
1314 var callbackFolders = {
1315 success : AjaxObject.folders.rebuildFolders,
1316 //success : void(true),
1317 failure : AjaxObject.handleFailure,
1318 timeout : AjaxObject.timeout,
1321 var callbackFullSync = {
1322 success : AjaxObject.fullSyncCleanup,
1323 failure : AjaxObject.handleFailure,
1324 timeout : 9999999999999,
1327 var callbackGeneric = {
1328 success : function() {
1329 SUGAR.hideMessageBox();
1331 failure : AjaxObject.handleFailure,
1332 timeout : AjaxObject.timeout,
1335 var callbackIeAccountRetrieve = {
1336 success : function(o) {
1337 // return JSON encoding
1338 SUGAR.hideMessageBox();
1339 SUGAR.email2.accounts.fillIeAccount(o.responseText);
1340 SUGAR.email2.accounts.showEditInboundAccountDialogue(false);
1342 failure : AjaxObject.handleFailure,
1343 timeout : AjaxObject.timeout,
1346 var callbackImportOneEmail = {
1347 success : AjaxObject.detailView.showImportForm,
1348 failure : AjaxObject.handleFailure,
1349 timeout : AjaxObject.timeout,
1352 var callbackRelateEmail = {
1353 success : AjaxObject.detailView.showRelateForm,
1354 failure : AjaxObject.handleFailure,
1355 timeout : AjaxObject.timeout,
1358 var callbackEmailDetailView = {
1359 success : AjaxObject.detailView.showEmailDetailView,
1360 failure : AjaxObject.handleFailure,
1361 timeout : AjaxObject.timeout,
1364 var callbackAssignmentDialog = {
1365 success : AjaxObject.detailView.showAssignmentDialogWithData,
1366 failure : AjaxObject.handleFailure,
1367 timeout : AjaxObject.timeout,
1370 var callbackAssignmentAction = {
1371 success : function(o) {
1372 SE.listView.refreshGrid();
1373 SUGAR.hideMessageBox();
1374 if(o.responseText != '') {
1375 SUGAR.showMessageBox('Assignment action result', o.responseText, 'alert');
1378 failure : AjaxObject.handleFailure,
1379 timeout : AjaxObject.timeout,
1382 var callbackMoveEmails = {
1383 success : function(o) {
1384 SE.listView.refreshGrid();
1385 SUGAR.hideMessageBox();
1386 if(o.responseText != '') {
1387 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, o.responseText, 'alert');
1390 failure : AjaxObject.handleFailure,
1391 timeout : AjaxObject.timeout,
1394 var callbackLoadAttachments = {
1395 success : AjaxObject.loadAttachments,
1396 failure : AjaxObject.handleFailure,
1397 timeout : AjaxObject.timeout,
1400 var callbackLoadRules = {
1401 success : AjaxObject.rules.loadRulesForSettings,
1402 failure : AjaxObject.handleFailure,
1403 timeout : AjaxObject.timeout,
1406 var callbackLoadSignature = {
1407 success : AjaxObject.loadSignature,
1408 failure : AjaxObject.handleFailure,
1409 timeout : AjaxObject.timeout,
1412 var callbackDeleteSignature = {
1413 success : AjaxObject.handleDeleteSignature,
1414 failure : AjaxObject.handleFailure,
1415 timeout : AjaxObject.timeout,
1418 /*var callbackMoveEmails = {
1419 success : function(o) { SUGAR.email2.listView.moveEmailsCleanup(o) },
1420 failure : AjaxObject.handleFailure,
1421 timeout : AjaxObject.timeout,
1424 var callbackOutboundSave = {
1425 success : AjaxObject.accounts.saveOutboundCleanup,
1426 failure : AjaxObject.handleFailure,
1427 timeout : AjaxObject.timeout,
1430 var callbackDefaultOutboundSave = {
1431 success : AjaxObject.accounts.saveDefaultOutboundCleanup,
1432 failure : AjaxObject.handleFailure,
1433 timeout : AjaxObject.timeout,
1436 var callbackQuickCreate = {
1437 success : AjaxObject.detailView.showQuickCreateForm,
1438 failure : AjaxObject.handleFailure,
1439 timeout : AjaxObject.timeout,
1442 var callbackQuickCreateSave = {
1443 success : AjaxObject.detailView.saveQuickCreateForm,
1444 failure : AjaxObject.handleFailure,
1445 timeout : AjaxObject.timeout,
1448 var callbackQuickCreateSaveAndAddToAddressBook = {
1449 success : AjaxObject.detailView.saveQuickCreateFormAndAddToAddressBook,
1450 failure : AjaxObject.handleFailure,
1451 timeout : AjaxObject.timeout,
1454 var callbackQuickCreateSaveAndReply = {
1455 success : AjaxObject.detailView.saveQuickCreateFormAndReply,
1456 failure : AjaxObject.handleFailure,
1457 timeout : AjaxObject.timeout,
1460 var callbackQuickCreateSaveAndReplyCase = {
1461 success : AjaxObject.detailView.saveQuickCreateFormAndReplyCase,
1462 failure : AjaxObject.handleFailure,
1463 timeout : AjaxObject.timeout,
1466 var callbackRebuildShowAccountList = {
1467 success : AjaxObject.rebuildShowFolders,
1468 failure : AjaxObject.handleFailure,
1469 timeout : AjaxObject.timeout,
1473 var callbackRefreshSugarFolders = {
1474 success : function(o) {
1475 var t = YAHOO.lang.JSON.parse(o.responseText);
1476 SUGAR.email2.folders.setSugarFoldersEnd(t);
1478 failure : AjaxObject.handleFailure,
1479 timeout : AjaxObject.timeout,
1482 var callbackReplyForward = {
1483 success : AjaxObject.handleReplyForward,
1484 finish : function(a, retryCount) {
1485 if (typeof(retryCount) == 'undefined') {
1490 var idx = SUGAR.email2.composeLayout.currentInstanceId;
1491 var t = tinyMCE.getInstanceById('htmleditor' + idx);
1493 var html = t.getContent();
1495 if(typeof a.type != 'undefined' && a.type == 'draft'){
1496 html = a.description;
1499 html = " <br><div><hr></div>" + a.description;
1503 t.setContent(html);//
1505 if (a.type != 'draft') {
1506 // Next step, attach signature
1507 SUGAR.email2.composeLayout.resizeEditorSetSignature(idx,true);
1511 if (retryCount < 5) {
1512 setTimeout("callbackReplyForward.finish(globalA, " + retryCount + ");", 500);
1516 var tabArray = SUGAR.email2.innerLayout.get("tabs");
1517 if (tabArray != null && tabArray.length > 0) {
1518 for (i = 0 ; i < tabArray.length ; i++) {
1519 var tabObject = tabArray[i];
1520 if (tabObject.get("id") == ("composeTab" + idx)) {
1521 var tabLabel = a.name;
1522 if (tabLabel != null && tabLabel.length > 25) {
1523 tabLabel = tabLabel.substring(0, 25) + "...";
1525 tabObject.get("labelEl").firstChild.data = tabLabel;
1531 //SUGAR.email2.innerLayout.regions.center.getPanel('composeLayout' + idx).setTitle(a.name);
1532 if (a.parent_name != null && a.parent_name != "") {
1533 document.getElementById('data_parent_name' + idx).value = a.parent_name;
1535 if (a.parent_type != null && a.parent_type != "") {
1536 document.getElementById('data_parent_type' + idx).value = a.parent_type;
1538 if (a.parent_id != null && a.parent_id != "") {
1539 document.getElementById('data_parent_id' + idx).value = a.parent_id;
1541 if (a.fromAccounts.status) {
1542 var addressFrom = document.getElementById('addressFrom' + idx);
1543 SUGAR.email2.util.emptySelectOptions(addressFrom);
1544 var fromAccountOpts = a.fromAccounts.data;
1545 for(i=0; i<fromAccountOpts.length; i++) {
1546 var key = fromAccountOpts[i].value;
1547 var display = fromAccountOpts[i].text;
1548 var opt = new Option(display, key);
1549 if (fromAccountOpts[i].selected) {
1550 opt.selected = true;
1552 addressFrom.options.add(opt);
1555 SUGAR.hideMessageBox();
1558 failure : AjaxObject.handleFailure,
1559 timeout : AjaxObject.timeout,
1561 argument : [sendType]
1563 var callbackSendEmail = {
1564 success : AjaxObject.sendEmailCleanUp,
1565 failure : AjaxObject.handleFailure,
1566 timeout : AjaxObject.timeout,
1569 var callbackSettings = {
1570 success : AjaxObject.updateUserPrefs,
1571 failure : AjaxObject.handleFailure,
1572 timeout : AjaxObject.timeout,
1575 var callbackSettingsFolderRefresh = {
1576 success : AjaxObject.settingsFolderRefresh,
1577 failure : AjaxObject.handleFailure,
1578 timeout : AjaxObject.timeout,
1581 var callbackLoadSettingFolder = {
1582 success : function(o) {
1583 AjaxObject.settingsFolderRefresh(o);
1584 SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
1586 failure : AjaxObject.handleFailure,
1587 timeout : AjaxObject.timeout,
1591 var callbackUploadAttachment = {
1592 success : AjaxObject.uploadAttachmentSuccessful,
1593 upload : AjaxObject.uploadAttachmentSuccessful,
1594 failure : AjaxObject.handleFailure,
1595 timeout : AjaxObject.timeout,
1598 var callbackUserPrefs = {
1599 success : function(o) {
1600 SUGAR.email2.userPrefs = YAHOO.lang.JSON.parse(o.responseText);
1602 failure : AjaxObject.handleFailure,
1603 timeout : AjaxObject.timeout,
1607 var callbackContextmenus = {
1609 success : AjaxObject.markEmailCleanup,
1610 failure : AjaxObject.handleFailure,
1611 timeout : AjaxObject.timeout,
1616 var callbackCheckEmail2 = {
1617 success : function(o) {
1618 var ret = YAHOO.lang.JSON.parse(o.responseText);
1619 SUGAR.showMessageBox(app_strings.LBL_EMAIL_CHECKING_NEW, ret.text);
1623 failure : AjaxObject.handleFailure,
1624 timeout : AjaxObject.timeout,