1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2013 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,0,1);", 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 ret.name = escape(ret.name);
402 var idx = SUGAR.email2.composeLayout.currentInstanceId;
403 var overall = document.getElementById('addedFiles' + idx);
404 var index = overall.childNodes.length;
406 "<div id='email_attachment_bucket" + idx + index + "'>" +
408 "<img src='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=minus.gif' " +
409 "style='cursor:pointer' align='absmiddle' onclick='SUGAR.email2.composeLayout.deleteUploadAttachment(\"" +
410 idx + index + "\",\"" + ret.guid + ret.name + "\");'/>" +
412 "<img src='index.php?entryPoint=getImage&themeName=" + SUGAR.themes.theme_name + "&imageName=attachment.gif' " +
413 "id='email_attachmentImage'" + idx + index + "align='absmiddle' />" +
415 "<input type='hidden' value='" + ret.guid + ret.name + "' name='email_attachment" + index + "' id='email_attachment" + idx + index + "' />" +
417 ((ret.nameForDisplay != null) ? ret.nameForDisplay + " " : ret.name + " ") +
420 overall.innerHTML += out;
421 if(SUGAR.email2.util.isIe()) {
422 document.getElementById('addedFiles' + idx).innerHTML = document.getElementById('addedFiles' + idx).innerHTML;
426 SUGAR.email2.addFileDialog.hide();
428 SUGAR.email2.composeLayout.showAttachmentPanel(idx);
433 ///////////////////////////////////////////////////////////////////////////
434 //// PER MODULE CALLBACK OBJECTS
435 AjaxObject.accounts = {
436 saveOutboundCleanup : function(o) {
437 SUGAR.email2.accounts.refreshOuboundAccountTable();
438 SUGAR.email2.accounts.outboundDialog.hide();
439 var id = o.responseText;
440 SUGAR.email2.accounts.newAddedOutboundId = id;
442 saveDefaultOutboundCleanup: function(o){
445 callbackEditOutbound : {
446 success : function(o)
448 var ret = YAHOO.lang.JSON.parse(o.responseText);
450 SUGAR.email2.accounts.showAddSmtp();
453 document.getElementById("mail_id").value = ret.id;
454 document.getElementById("type").value = ret.type;
455 document.getElementById("mail_sendtype").value = ret.mail_sendtype;
456 document.getElementById("mail_name").value = ret.name;
457 document.getElementById("mail_smtpserver").value = ret.mail_smtpserver;
458 document.getElementById("outboundEmailForm").mail_smtptype.value = ret.mail_smtptype;
459 document.getElementById("mail_smtpport").value = ret.mail_smtpport;
460 document.getElementById("mail_smtpuser").value = ret.mail_smtpuser;
461 document.getElementById("mail_smtpauth_req").checked = (ret.mail_smtpauth_req == 1) ? true : false;
462 SUGAR.email2.accounts.smtp_authenticate_field_display();
463 document.getElementById("mail_smtpssl").options[ret.mail_smtpssl].selected = true;
465 if(ret.type == 'system-override') {
466 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(true);
467 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,true);
470 SUGAR.email2.accounts.toggleOutboundAccountDisabledFields(false);
471 SUGAR.email2.accounts.changeEmailScreenDisplay(ret.mail_smtptype,false);
473 SUGAR.util.setEmailPasswordDisplay('mail_smtppass', ret.has_password);
476 failure : AjaxObject.handleFailure,
477 timeout : AjaxObject.timeout,
480 callbackDeleteOutbound : {
481 success : function(o) {
482 var ret = YAHOO.lang.JSON.parse(o.responseText);
485 if(confirm(ret.error_message))
487 SUGAR.showMessageBox(app_strings.LBL_EMAIL_IE_DELETE, app_strings.LBL_EMAIL_ONE_MOMENT);
488 AjaxObject.startRequest(AjaxObject.accounts.callbackDeleteOutbound, urlStandard + "&emailUIAction=deleteOutbound&confirm=true&outbound_email=" + ret.outbound_email);
491 SUGAR.hideMessageBox();
495 SUGAR.hideMessageBox();
496 SUGAR.email2.accounts.refreshOuboundAccountTable();
500 failure : AjaxObject.handleFailure,
501 timeout : AjaxObject.timeout,
505 callbackCheckMailProgress : {
506 success : function(o) {
507 if (typeof(SUGAR.email2.accounts.totalMsgCount) == "undefined") {
508 SUGAR.email2.accounts.totalMsgCount = -1;
511 //Check for server timeout / errors
512 var ret = YAHOO.lang.JSON.parse(o.responseText);
515 if (typeof(o.responseText) == 'undefined' || o.responseText == "" || ret == false) {
516 SUGAR.hideMessageBox();
517 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
518 SUGAR.email2.accounts.totalMsgCount = -1;
519 //SUGAR.email2.folders.rebuildFolders();
523 var currIeId = ret['ieid'];
526 var serverCount = ret.count;
528 if (ret['status'] == 'done') {
529 for(i=0; i < SUGAR.email2.accounts.ieIds.length; i++) {
530 if (i == SUGAR.email2.accounts.ieIds.length - 1) {
534 } else if (SUGAR.email2.accounts.ieIds[i] == currIeId) {
536 currIeId = SUGAR.email2.accounts.ieIds[i+1];
538 SUGAR.email2.accounts.totalMsgCount = -1;
543 else if (ret.mbox && ret.totalcount && ret.count) {
544 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
545 if (ret.count >= ret.totalcount) {
548 } else if (SUGAR.email2.accounts.totalMsgCount < 0 && ret.totalcount) {
549 SUGAR.email2.accounts.totalMsgCount = ret.totalcount;
551 SUGAR.hideMessageBox();
552 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, app_strings.LBL_EMAIL_ERROR_TIMEOUT, 'alert');
553 SUGAR.email2.accounts.totalMsgCount = -1;
558 SUGAR.email2.accounts.totalMsgCount = -1;
559 SUGAR.hideMessageBox();
560 SUGAR.email2.folders.rebuildFolders();
561 SE.listView.refreshGrid();
562 } else if (SUGAR.email2.accounts.totalMsgCount < 0) {
563 YAHOO.SUGAR.MessageBox.updateProgress(0, mod_strings.LBL_CHECKING_ACCOUNT + ' '+ (i + 2) + ' '+ mod_strings.LBL_OF + ' ' + SUGAR.email2.accounts.ieIds.length);
564 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
565 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=0&synch=" + ret.synch);
567 YAHOO.SUGAR.MessageBox.updateProgress((ret.count / SUGAR.email2.accounts.totalMsgCount) * 100,
568 app_strings.LBL_EMAIL_DOWNLOAD_STATUS.replace(/\[\[count\]\]/, ret.count).replace(/\[\[total\]\]/, SUGAR.email2.accounts.totalMsgCount));
569 AjaxObject.startRequest(AjaxObject.accounts.callbackCheckMailProgress, urlStandard +
570 '&emailUIAction=checkEmailProgress&ieId=' + currIeId + "¤tCount=" + serverCount +
571 '&mbox=' + ret.mbox + '&synch=' + ret.synch + '&totalcount=' + SUGAR.email2.accounts.totalMsgCount);
574 failure : AjaxObject.handleFailure,
575 timeout : AjaxObject.timeout,
580 ///////////////////////////////////////////////////////////////////////////////
582 AjaxObject.composeLayout = {
584 * Populates the record id
586 saveDraftCleanup : function(o) {
588 SUGAR.hideMessageBox();
591 ret = YAHOO.lang.JSON.parse(o.responseText);
592 SUGAR.email2.composeLayout.forceCloseCompose(ret.composeLayoutId);
594 if (o.responseText) {
595 SUGAR.showMessageBox(mod_strings.LBL_ERROR_SAVING_DRAFT, o.responseText, 'alert');
601 AjaxObject.composeLayout.callback = {
603 success : AjaxObject.composeLayout.saveDraftCleanup,
604 failure : AjaxObject.handleFailure,
605 timeout : AjaxObject.timeout,
610 AjaxObject.detailView = {
612 * Pops-up a printable view of an email
614 displayPrintable : function(o) {
615 var ret = YAHOO.lang.JSON.parse(o.responseText);
616 var displayTemplate = new YAHOO.SUGAR.Template(SUGAR.email2.templates['viewPrintable']);
617 // 2 below must be in global context
619 meta['panelId'] = SUGAR.email2.util.getPanelId();
620 email = ret.meta.email;
621 if (typeof(email.cc) == 'undefined') {
625 var out = displayTemplate.exec({
626 'app_strings' : app_strings,
634 var popup = window.open('modules/Emails/templates/_blank.html', 'printwin' ,
635 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
637 popup.document.write(out);
638 popup.document.close();
642 * Takes formatted response and creates a modal pop-over containing a title and content
644 displayView : function(o) {
645 var SED = SUGAR.email2.detailView;
646 var ret = YAHOO.lang.JSON.parse(o.responseText);
648 if(!SED.viewDialog) {
649 SED.viewDialog = new YAHOO.widget.Dialog("viewDialog", {
653 constraintoviewport: true,
656 SED.viewDialog.renderEvent.subscribe(function() {
657 var content = this.body.firstChild;
658 var viewH = YAHOO.util.Dom.getViewportHeight();
660 this.body.style.overflow = "auto";
661 this.body.style.width = "800px";
662 this.body.style.height = (viewH - 75 > content.clientHeight ? (content.clientHeight) : (viewH - 75)) + "px";
666 SED.viewDialog.setHeader(ret.title);
667 SED.viewDialog.setBody(ret.html);
668 SED.viewDialog.render();
669 SED.viewDialog.show();
673 * Generates a modal popup to populate with the contents of bean's full EditView
675 showQuickCreateForm : function(o) {
676 var SED = SUGAR.email2.detailView;
677 var ret = YAHOO.lang.JSON.parse(o.responseText);
679 if(!SED.quickCreateDialog) {
680 SED.quickCreateDialog = new YAHOO.widget.Dialog("quickCreateForEmail", {
684 constraintoviewport: true,
688 SED.quickCreateDialog.renderEvent.subscribe(function() {
689 var viewH = YAHOO.util.Dom.getViewportHeight();
691 for (var i in this.body.childNodes) {
692 if (this.body.childNodes[i].clientHeight) {
693 contH += this.body.childNodes[i].clientHeight;
694 } else if (this.body.childNodes[i].offsetHeight) {
695 contH += this.body.childNodes[i].offsetHeight;
698 this.body.style.width = "800px";
699 this.body.style.height = (viewH - 75 > contH ? (contH + 10) : (viewH - 75)) + "px";
700 this.body.style.overflow = "auto";
701 }, SED.quickCreateDialog);
703 SED.quickCreateDialog.hideEvent.subscribe(function(){
704 var qsFields = YAHOO.util.Dom.getElementsByClassName('.sqsEnabled', null, this.body);
705 /*for(var qsField in qsFields){
706 if (typeof QSFieldsArray[qsFields[qsField].id] != 'undefined')
707 Ext.getCmp('combobox_'+qsFields[qsField].id).destroy();
710 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_QUICK_CREATE);
713 ret.html = ret.html.replace('<script type="text/javascript" src="include/SugarEmailAddress/SugarEmailAddress.js"></script>', "");
715 SED.quickCreateDialog.setBody(ret.html ? ret.html : " ");
716 SED.quickCreateDialog.render();
717 SUGAR.util.evalScript(ret.html + '<script language="javascript">enableQS(true);</script>');
719 SED.quickCreateDialog.ieId = ret.ieId;
720 SED.quickCreateDialog.uid = ret.uid;
721 SED.quickCreateDialog.mbox = ret.mbox;
722 SED.quickCreateDialog.qcmodule = ret.module;
724 SED.quickCreateDialog.show();
726 var editForm = document.getElementById('form_EmailQCView_' + ret.module);
728 editForm.module.value = 'Emails';
730 if (SUGAR.EmailAddressWidget.count[ret.module]) {
731 count = SUGAR.EmailAddressWidget.count[ret.module] - 1;
733 var tableId = YAHOO.util.Dom.getElementsByClassName('emailaddresses', 'table', editForm)[0];
734 tableId = tableId ? tableId.id : tableId;
735 var instId = ret.module + count;
736 SED.quickCreateEmailsToAdd = ret.emailAddress;
737 SED.quickCreateEmailCallback = function(instId, tableId) {
738 //try to fill up the email address if and only if emailwidget is existed in the form
740 var eaw = SUGAR.EmailAddressWidget.instances[instId];
742 eaw.prefillEmailAddresses(tableId, SUGAR.email2.detailView.quickCreateEmailsToAdd);
744 window.setTimeout(function() {
745 SUGAR.email2.detailView.quickCreateEmailCallback(instId, tableId);
751 window.setTimeout(function() {
752 SUGAR.email2.detailView.quickCreateEmailCallback(instId, tableId);
757 saveQuickCreateForm : function(o) {
758 SUGAR.hideMessageBox();
759 SUGAR.email2.detailView.quickCreateDialog.hide();
760 validate['EditView'] = [ ];
763 saveQuickCreateFormAndReply : function(o) {
764 SUGAR.hideMessageBox();
765 var ret = YAHOO.lang.JSON.parse(o.responseText);
766 SUGAR.email2.detailView.quickCreateDialog.hide();
767 var qcd = SUGAR.email2.detailView.quickCreateDialog;
768 var type = (qcd.qcmodule == 'Cases') ? 'replyCase' : 'reply';
770 var emailID = ret.id;
771 SUGAR.email2.composeLayout.c0_replyForwardEmail(null, ret.id, 'sugar::Emails', type);
773 SUGAR.email2.composeLayout.c0_replyForwardEmail(qcd.ieId, qcd.uid, qcd.mbox, type);
775 //Cean the validate cache to prevent errors on the next call
776 validate['EditView'] = [ ];
779 saveQuickCreateFormAndAddToAddressBook : function(o) {
780 SUGAR.hideMessageBox();
781 SUGAR.email2.detailView.quickCreateDialog.hide();
782 SUGAR.email2.complexLayout.findPanel('contactsTab').show();
783 validate['EditView'] = [ ];
786 handleAssignmentDialogAssignAction : function() {
789 var assign_user_id = window.document.forms['Distribute'].elements['assigned_user_id'].value;
795 var found_teams = false;
796 var warning_message = mod_strings.LBL_WARN_NO_USERS;
797 if(!found_teams && assign_user_id == '' )
799 alert(warning_message);
803 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
805 for(i=0; i<emailUids.length; i++) {
807 uids += app_strings.LBL_EMAIL_DELIMITER;
809 uids += emailUids[i];
812 var row = SUGAR.email2.grid.getSelectedRows()[0];
813 var data = SUGAR.email2.grid.getRecord(row).getData();
814 var ieid = data.ieId;
815 var mbox = data.mbox;
816 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentAssign&uids=" + uids + "&ieId=" + ieid + "&folder=" + mbox + "&distribute_method=" + dist + "&users=" +assign_user_id + get);
817 SUGAR.email2.contextMenus.assignToDialogue.hide();
818 SUGAR.showMessageBox('Assignment', app_strings.LBL_EMAIL_ONE_MOMENT);
822 handleAssignmentDialogDeleteAction : function() {
823 // TO pass list of UIDS/emailIds
824 var uids = SUGAR.email2.listView.getUidsFromSelection();
825 var row = SUGAR.email2.grid.getSelections()[0];
826 var ieid = row.data.ieId;
827 var mbox = row.data.mbox;
828 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentDelete&uids=" + uids + "&ieId=" + ieId + "&folder=" + mbox);
829 SUGAR.email2.contextMenus.assignmentDialog.hide();
830 SUGAR.showMessageBox(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
836 showEmailDetailView : function(o) {
837 SUGAR.hideMessageBox();
838 var SED = SUGAR.email2.detailView;
839 var ret = YAHOO.lang.JSON.parse(o.responseText);
841 if(!SED.quickCreateDialog) {
842 SED.quickCreateDialog = new YAHOO.widget.Dialog("emailDetailDialog", {
846 constraintoviewport: true,
848 autofillheight: "body",
851 SED.quickCreateDialog.renderEvent.subscribe(function() {
852 var viewHeight = YAHOO.util.Dom.getViewportHeight();
854 for (var i in this.body.childNodes) {
855 if (this.body.childNodes[i].offsetHeight)
856 contH += this.body.childNodes[i].offsetHeight;
858 this.body.style.overflow = "auto";
859 this.body.style.width = "800px";
860 this.body.style.height = (viewHeight - 75 > contH ? (contH + 10) : (viewHeight - 75)) + "px";
862 }, SED.quickCreateDialog);
864 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_RECORD);
865 SED.quickCreateDialog.setBody(ret.html);
866 SED.quickCreateDialog.render();
867 SUGAR.util.evalScript(ret.html);
868 SED.quickCreateDialog.show();
871 showAssignmentDialogWithData : function(o) {
872 var SEC = SUGAR.email2.contextMenus;
873 SUGAR.hideMessageBox();
874 var ret = YAHOO.lang.JSON.parse(o.responseText);
875 if (!SEC.assignmentDialog) {
876 SEC.assignmentDialog = new YAHOO.widget.Dialog("assignmentDialog", {
879 constraintoviewport: true,
882 SEC.assignmentDialog.setBody("");
883 SEC.assignmentDialog.setHeader(app_strings.LBL_EMAIL_ASSIGNMENT);
884 SEC.assignmentDialog.renderEvent.subscribe(function() {
885 var iev = YAHOO.util.Dom.get("Distribute");
887 this.body.style.width = "700px";
889 }, SEC.assignmentDialog);
890 SEC.assignmentDialog.render();
892 SEC.assignmentDialog.setBody(ret);
893 SEC.assignmentDialog.render();
895 SEC.assignmentDialog.show();
896 SUGAR.util.evalScript(ret);
899 showImportForm : function(o) {
900 var SED = SUGAR.email2.detailView;
901 var ret = YAHOO.lang.JSON.parse(o.responseText);
903 document.getElementById('quickCreateContent').innerHTML = "";
904 SUGAR.hideMessageBox();
909 if(!SED.importDialog) {
910 SED.importDialog = new YAHOO.widget.Dialog("importDialog", {
914 constraintoviewport: true,
916 text: app_strings.LBL_EMAIL_ARCHIVE_TO_SUGAR, isDefault: true, handler: function(){
917 AjaxObject.detailView.getImportAction(SED.importDialog.ret); }
921 SED.importDialog.setHeader(app_strings.LBL_EMAIL_IMPORT_SETTINGS);
922 SED.importDialog.setBody("");
923 SED.importDialog.hideEvent.subscribe(function(){
924 for(var i in QSFieldsArray) {
925 if (QSFieldsArray[i] != null && typeof(QSFieldsArray[i]) == "object") {
926 QSFieldsArray[i].destroy();
927 delete QSFieldsArray[i];
929 if (QSProcessedFieldsArray[i]) {
930 QSProcessedFieldsArray[i] = false;
934 SED.importDialog.renderEvent.subscribe(function() {
935 var iev = YAHOO.util.Dom.get("ImportEditView");
937 //this.body.style.height = (iev.clientHeight + 10) + "px";
938 this.body.style.width = "600px";
940 }, SED.importDialog);
941 SED.importDialog.render();
943 SED.importDialog.setBody(ret.html);
944 SED.importDialog.ret = ret;
945 SUGAR.util.evalScript(ret.html);
946 SED.importDialog.render();
948 SED.importDialog.show();
949 SED.importDialog.focusFirstButton();
951 getImportAction : function(ret) {
952 if (!check_form('ImportEditView')) return false;
953 if (!SUGAR.collection.prototype.validateTemSet('ImportEditView', 'team_name')) {
954 alert(mod_strings.LBL_EMAILS_NO_PRIMARY_TEAM_SPECIFIED);
958 var editView = document.getElementById('ImportEditView');
959 if (editView.assigned_user_id != null) {
960 get = get + "&user_id=" + editView.assigned_user_id.value
961 //var user_id = editView.assigned_user_id.value;
963 var parent_id = editView.parent_id.value;
964 var parent_type = editView.parent_type.value;
965 var row = SUGAR.email2.grid.getSelectedRows()[0];
966 row = SUGAR.email2.grid.getRecord(row);
967 var data = row.getData();
968 var ieId = data.ieId;
969 var mbox = data.mbox;
970 var serverDelete = editView.serverDelete.checked;
971 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
973 for(i=0; i<emailUids.length; i++) {
975 uids += app_strings.LBL_EMAIL_DELIMITER;
977 uids += emailUids[i];
980 var action = 'importEmail&uid=';
982 action = 'moveEmails';
983 action = action + '&sourceFolder=' + ret['srcFolder'];
984 action = action + '&sourceIeId=' + ret['srcIeId'];
985 action = action + '&destinationFolder=' + ret['dstFolder'];
986 action = action + '&destinationIeId=' + ret['dstIeId'];
987 action = action + '&emailUids=';
989 if (action.search(/importEmail/) != -1) {
990 SUGAR.showMessageBox(app_strings.LBL_EMAIL_IMPORTING_EMAIL, app_strings.LBL_EMAIL_ONE_MOMENT);
992 SUGAR.showMessageBox("Moving Email(s)", app_strings.LBL_EMAIL_ONE_MOMENT);
995 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=' + action + uids + "&ieId=" + ieId + "&mbox=" + mbox +
996 get + "&parent_id=" + parent_id + "&parent_type=" + parent_type + '&delete=' + serverDelete);
997 SUGAR.email2.detailView.importDialog.hide();
998 document.getElementById('importDialogContent').innerHTML = "";
1001 showRelateForm : function(o) {
1002 var SED = SUGAR.email2.detailView;
1003 var ret = YAHOO.lang.JSON.parse(o.responseText);
1004 document.getElementById('quickCreateContent').innerHTML = "";
1005 SUGAR.hideMessageBox();
1009 dialog_loaded = true;
1011 if(!SED.relateDialog) {
1012 SED.relateDialog = new YAHOO.widget.Dialog('relateDialog', {
1017 constraintoviewport: true,
1019 text: app_strings.LBL_EMAIL_RELATE_TO, isDefault: true, handler: function(){
1020 if (!check_form('RelateEditView')) return false;
1022 var editView = document.getElementById('RelateEditView');
1023 var parent_id = editView.parent_id.value;
1024 var parent_type = editView.parent_type.value;
1025 var row = SUGAR.email2.grid.getSelectedRows()[0];
1026 row = SUGAR.email2.grid.getRecord(row);
1027 var ieId = row.getData().ieId;
1028 var mbox = row.getData().mbox;
1029 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
1031 for(i=0; i<emailUids.length; i++) {
1033 uids += app_strings.LBL_EMAIL_DELIMITER;
1035 uids += emailUids[i];
1037 SUGAR.showMessageBox(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
1038 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=relateEmails&uid=' + uids
1039 + "&ieId=" + ieId + "&mbox=" + mbox + "&parent_id=" + parent_id + "&parent_type=" + parent_type);
1040 SED.relateDialog.hide();
1041 document.getElementById('relateDialogContent').innerHTML = "";
1046 SED.relateDialog.hideEvent.subscribe(function(){
1047 if (QSFieldsArray['ImportEditView_parent_name'] != null) {
1048 QSFieldsArray['ImportEditView_parent_name'].destroy();
1049 delete QSFieldsArray['ImportEditView_parent_name'];
1051 if (QSProcessedFieldsArray['ImportEditView_parent_name']) {
1052 QSProcessedFieldsArray['ImportEditView_parent_name'] = false;
1056 SED.relateDialog.renderEvent.subscribe(function() {
1057 var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
1059 for (var i in this.body.childNodes) {
1060 if (this.body.childNodes[i].clientHeight)
1061 contH += this.body.childNodes[i].clientHeight;
1063 }, SED.relateDialog);
1064 SED.relateDialog.setHeader(app_strings.LBL_EMAIL_RELATE_EMAIL);
1067 SED.relateDialog.setBody(ret.html);
1068 SED.relateDialog.render();
1069 SUGAR.util.evalScript(ret.html);
1070 SED.relateDialog.show();
1074 * DetailView callbacks
1076 AjaxObject.detailView.callback = {
1078 success : function(o) {
1080 var ret = YAHOO.lang.JSON.parse(o.responseText);
1081 SUGAR.email2.detailView.consumeMetaDetail(ret);
1083 argument: [targetDiv],
1084 failure : AjaxObject.handleFailure,
1089 success : function(o) {
1091 var ret = YAHOO.lang.JSON.parse(o.responseText);
1092 SUGAR.email2.detailView.consumeMetaPreview(ret);
1094 failure : AjaxObject.handleFailure,
1099 success : AjaxObject.detailView.displayPrintable,
1100 failure : AjaxObject.handleFailure,
1101 timeout : AjaxObject.timeout,
1105 success : AjaxObject.detailView.displayView,
1106 failure : AjaxObject.handleFailure,
1107 timeout : AjaxObject.timeout,
1116 AjaxObject.folders = {
1118 * check-mail post actions
1120 checkMailCleanup : function(o) {
1121 SUGAR.hideMessageBox();
1122 AjaxObject.folders.rebuildFolders(o); // rebuild TreeView
1124 // refresh focus ListView
1125 SE.listView.refreshGrid();
1126 SUGAR.email2.folders.startCheckTimer(); // resets the timer
1131 rebuildFolders : function(o) {
1132 SUGAR.hideMessageBox();
1134 var data = YAHOO.lang.JSON.parse(o.responseText);
1136 email2treeinit(SUGAR.email2.tree, data.tree_data, 'frameFolders', data.param);
1137 SUGAR.email2.folders.setSugarFolders();
1140 AjaxObject.folders.callback = {
1142 success : AjaxObject.folders.checkMailCleanup,
1143 failure : AjaxObject.handleFailure,
1144 timeout : 600000, // 5 mins
1149 AjaxObject.rules = {
1150 loadRulesForSettings : function(o) {
1151 document.getElementById("rulesListCell").innerHTML = o.responseText;
1152 // assume we have the class we need
1153 SUGAR.routing.getStrings();
1154 SUGAR.routing.getDependentDropdowns();
1157 //// END PER MODULE CALLBACK OBJECTS
1158 ///////////////////////////////////////////////////////////////////////////
1162 success : AjaxObject.handleSuccess,
1163 failure : AjaxObject.handleFailure,
1164 timeout : AjaxObject.timeout,
1167 var callbackAccount = {
1168 success : AjaxObject.ieSaveSuccess,
1169 failure : AjaxObject.handleFailure,
1170 timeout : AjaxObject.timeout,
1173 var callbackAccountDelete = {
1174 success : AjaxObject.ieDeleteSuccess,
1175 failure : AjaxObject.handleFailure,
1176 timeout : AjaxObject.timeout,
1179 var callbackOutboundTest = {
1180 success : AjaxObject.ieSendSuccess,
1181 failure : AjaxObject.handleFailure,
1182 timeout : AjaxObject.timeout,
1188 var callbackTeamInfoForSettings = {
1189 success : function (o) {
1190 var data = YAHOO.lang.JSON.parse(o.responseText);
1191 document.getElementById('EditViewGroupFolderTeamTD').innerHTML = data.defaultgroupfolder;
1193 failure : AjaxObject.handleFailure,
1194 timeout : AjaxObject.timeout,
1199 var callbackStatusForImport = {
1200 success : function (o) {
1201 SUGAR.hideMessageBox();
1202 if (o.responseText != "") {
1203 var statusString = "";
1204 var data = YAHOO.lang.JSON.parse(o.responseText);
1205 for(i=0; i<data.length; i++) {
1206 statusString = statusString + data[i] + '<br/>';
1208 SUGAR.showMessageBox(SUGAR.language.get('Emails','LBL_IMPORT_STATUS_TITLE'), statusString, 'alert');
1210 SE.listView.refreshGrid();
1213 failure : AjaxObject.handleFailure,
1214 timeout : AjaxObject.timeout,
1218 var callbackComposeCache = {
1219 success : AjaxObject.composeCache,
1220 failure : AjaxObject.handleFailure,
1221 timeout : AjaxObject.timeout,
1224 var callbackDelete = {
1225 success : AjaxObject.handleDeleteReturn,
1226 failure : AjaxObject.handleFailure,
1227 timeout : AjaxObject.timeout,
1230 var callbackEmailDetailMultiple = {
1231 success : function(o) {
1232 SUGAR.hideMessageBox();
1233 var retMulti = YAHOO.lang.JSON.parse(o.responseText);
1234 var ret = new Object();
1236 for(var i=0; i<retMulti.length; i++) {
1239 SUGAR.email2._setDetailCache(ret);
1240 SUGAR.email2.detailView.populateDetailView(ret.meta.uid, ret.meta.mbox, ret.meta.ieId, true, SUGAR.email2.innerLayout);
1243 failure : AjaxObject.handleFailure,
1247 var callbackListViewSortOrderChange = {
1248 success : AjaxObject.saveListViewSortOrderPart2,
1249 failure : AjaxObject.handleFailure,
1250 timeout : AjaxObject.timeout,
1252 argument : [ieId, ieName, focusFolder]
1254 var callbackEmptyTrash = {
1255 success : function(o) {
1256 SUGAR.hideMessageBox();
1257 AjaxObject.folderRenameCleanup;
1259 failure : AjaxObject.handleFailure,
1260 timeout : AjaxObject.timeout,
1263 var callbackClearCacheFiles = {
1264 success : function(o) {
1265 SUGAR.hideMessageBox();
1267 failure : AjaxObject.handleFailure,
1268 timeout : AjaxObject.timeout,
1271 var callbackFolderRename = {
1272 success : function(o) {SUGAR.hideMessageBox();SUGAR.email2.folders.rebuildFolders();},
1273 failure : AjaxObject.handleFailure,
1274 timeout : AjaxObject.timeout,
1277 var callbackFolderDelete = {
1278 success : function(o) {
1279 var ret = YAHOO.lang.JSON.parse(o.responseText);
1281 if (ret.folder_id) {
1282 var node = SUGAR.email2.folders.getNodeFromId(ret.folder_id);
1284 SUGAR.email2.tree.removeNode(node, true);
1285 } else if (ret.ieId && ret.mbox) {
1286 var node = SUGAR.email2.folders.getNodeFromIeIdAndMailbox(ret.ieId, ret.mbox);
1288 SUGAR.email2.tree.removeNode(node, true);
1290 SUGAR.hideMessageBox();
1291 //SUGAR.email2.folders.loadSettingFolder();
1293 SUGAR.hideMessageBox();
1294 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorMessage, 'alert');
1297 failure : AjaxObject.handleFailure,
1298 timeout : AjaxObject.timeout,
1301 var callbackFolderSave = {
1302 success : function(o) {
1303 var ret = YAHOO.lang.JSON.parse(o.responseText);
1305 switch(ret.action) {
1306 case 'newFolderSave':
1307 SUGAR.email2.folders.rebuildFolders();
1311 failure : AjaxObject.handleFailure,
1312 timeout : AjaxObject.timeout,
1315 var callbackFolderSubscriptions = {
1316 success : AjaxObject.updateFolderSubscriptions,
1317 failure : AjaxObject.handleFailure,
1318 timeout : AjaxObject.timeout,
1321 var callbackFolderUpdate = {
1322 success : AjaxObject.updateFrameFolder,
1323 failure : AjaxObject.handleFailure,
1324 timeout : AjaxObject.timeout,
1327 var callbackFolders = {
1328 success : AjaxObject.folders.rebuildFolders,
1329 //success : void(true),
1330 failure : AjaxObject.handleFailure,
1331 timeout : AjaxObject.timeout,
1334 var callbackFullSync = {
1335 success : AjaxObject.fullSyncCleanup,
1336 failure : AjaxObject.handleFailure,
1337 timeout : 9999999999999,
1340 var callbackGeneric = {
1341 success : function() {
1342 SUGAR.hideMessageBox();
1344 failure : AjaxObject.handleFailure,
1345 timeout : AjaxObject.timeout,
1348 var callbackIeAccountRetrieve = {
1349 success : function(o) {
1350 // return JSON encoding
1351 SUGAR.hideMessageBox();
1352 SUGAR.email2.accounts.fillIeAccount(o.responseText);
1353 SUGAR.email2.accounts.showEditInboundAccountDialogue(false);
1355 failure : AjaxObject.handleFailure,
1356 timeout : AjaxObject.timeout,
1359 var callbackImportOneEmail = {
1360 success : AjaxObject.detailView.showImportForm,
1361 failure : AjaxObject.handleFailure,
1362 timeout : AjaxObject.timeout,
1365 var callbackRelateEmail = {
1366 success : AjaxObject.detailView.showRelateForm,
1367 failure : AjaxObject.handleFailure,
1368 timeout : AjaxObject.timeout,
1371 var callbackEmailDetailView = {
1372 success : AjaxObject.detailView.showEmailDetailView,
1373 failure : AjaxObject.handleFailure,
1374 timeout : AjaxObject.timeout,
1377 var callbackAssignmentDialog = {
1378 success : AjaxObject.detailView.showAssignmentDialogWithData,
1379 failure : AjaxObject.handleFailure,
1380 timeout : AjaxObject.timeout,
1383 var callbackAssignmentAction = {
1384 success : function(o) {
1385 SE.listView.refreshGrid();
1386 SUGAR.hideMessageBox();
1387 if(o.responseText != '') {
1388 SUGAR.showMessageBox('Assignment action result', o.responseText, 'alert');
1391 failure : AjaxObject.handleFailure,
1392 timeout : AjaxObject.timeout,
1395 var callbackMoveEmails = {
1396 success : function(o) {
1397 SE.listView.refreshGrid();
1398 SUGAR.hideMessageBox();
1399 if(o.responseText != '') {
1400 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, o.responseText, 'alert');
1403 failure : AjaxObject.handleFailure,
1404 timeout : AjaxObject.timeout,
1407 var callbackLoadAttachments = {
1408 success : AjaxObject.loadAttachments,
1409 failure : AjaxObject.handleFailure,
1410 timeout : AjaxObject.timeout,
1413 var callbackLoadRules = {
1414 success : AjaxObject.rules.loadRulesForSettings,
1415 failure : AjaxObject.handleFailure,
1416 timeout : AjaxObject.timeout,
1419 var callbackLoadSignature = {
1420 success : AjaxObject.loadSignature,
1421 failure : AjaxObject.handleFailure,
1422 timeout : AjaxObject.timeout,
1425 var callbackDeleteSignature = {
1426 success : AjaxObject.handleDeleteSignature,
1427 failure : AjaxObject.handleFailure,
1428 timeout : AjaxObject.timeout,
1431 /*var callbackMoveEmails = {
1432 success : function(o) { SUGAR.email2.listView.moveEmailsCleanup(o) },
1433 failure : AjaxObject.handleFailure,
1434 timeout : AjaxObject.timeout,
1437 var callbackOutboundSave = {
1438 success : AjaxObject.accounts.saveOutboundCleanup,
1439 failure : AjaxObject.handleFailure,
1440 timeout : AjaxObject.timeout,
1443 var callbackDefaultOutboundSave = {
1444 success : AjaxObject.accounts.saveDefaultOutboundCleanup,
1445 failure : AjaxObject.handleFailure,
1446 timeout : AjaxObject.timeout,
1449 var callbackQuickCreate = {
1450 success : AjaxObject.detailView.showQuickCreateForm,
1451 failure : AjaxObject.handleFailure,
1452 timeout : AjaxObject.timeout,
1455 var callbackQuickCreateSave = {
1456 success : AjaxObject.detailView.saveQuickCreateForm,
1457 failure : AjaxObject.handleFailure,
1458 timeout : AjaxObject.timeout,
1461 var callbackQuickCreateSaveAndAddToAddressBook = {
1462 success : AjaxObject.detailView.saveQuickCreateFormAndAddToAddressBook,
1463 failure : AjaxObject.handleFailure,
1464 timeout : AjaxObject.timeout,
1467 var callbackQuickCreateSaveAndReply = {
1468 success : AjaxObject.detailView.saveQuickCreateFormAndReply,
1469 failure : AjaxObject.handleFailure,
1470 timeout : AjaxObject.timeout,
1473 var callbackQuickCreateSaveAndReplyCase = {
1474 success : AjaxObject.detailView.saveQuickCreateFormAndReplyCase,
1475 failure : AjaxObject.handleFailure,
1476 timeout : AjaxObject.timeout,
1479 var callbackRebuildShowAccountList = {
1480 success : AjaxObject.rebuildShowFolders,
1481 failure : AjaxObject.handleFailure,
1482 timeout : AjaxObject.timeout,
1486 var callbackRefreshSugarFolders = {
1487 success : function(o) {
1488 var t = YAHOO.lang.JSON.parse(o.responseText);
1489 SUGAR.email2.folders.setSugarFoldersEnd(t);
1491 failure : AjaxObject.handleFailure,
1492 timeout : AjaxObject.timeout,
1495 var callbackReplyForward = {
1496 success : AjaxObject.handleReplyForward,
1497 finish : function(a, retryCount,isReOrFwDraft) {
1498 if (typeof(retryCount) == 'undefined') {
1503 if (typeof(isReOrFwDraft) == 'undefined') {
1506 var idx = SUGAR.email2.composeLayout.currentInstanceId;
1507 var t = tinyMCE.getInstanceById('htmleditor' + idx);
1509 var html = t.getContent();
1512 //add hr tag if this is not a reply draft or forward draft
1514 html += "<div><hr></div>";
1516 html += a.description;
1518 t.setContent(html);//
1520 if (a.type != 'draft') {
1521 // Next step, attach signature
1522 SUGAR.email2.composeLayout.resizeEditorSetSignature(idx,true);
1526 if (retryCount < 5) {
1527 setTimeout("callbackReplyForward.finish(globalA, " + retryCount + ");", 500);
1531 var tabArray = SUGAR.email2.innerLayout.get("tabs");
1532 if (tabArray != null && tabArray.length > 0) {
1533 for (i = 0 ; i < tabArray.length ; i++) {
1534 var tabObject = tabArray[i];
1535 if (tabObject.get("id") == ("composeTab" + idx)) {
1536 var tabLabel = a.name;
1537 if (tabLabel != null && tabLabel.length > 25) {
1538 tabLabel = tabLabel.substring(0, 25) + "...";
1540 tabObject.get("labelEl").firstChild.data = tabLabel;
1546 //SUGAR.email2.innerLayout.regions.center.getPanel('composeLayout' + idx).setTitle(a.name);
1547 if (a.parent_name != null && a.parent_name != "") {
1548 document.getElementById('data_parent_name' + idx).value = a.parent_name;
1550 if (a.parent_type != null && a.parent_type != "") {
1551 document.getElementById('data_parent_type' + idx).value = a.parent_type;
1553 if (a.parent_id != null && a.parent_id != "") {
1554 document.getElementById('data_parent_id' + idx).value = a.parent_id;
1556 if (a.fromAccounts.status) {
1557 var addressFrom = document.getElementById('addressFrom' + idx);
1558 SUGAR.email2.util.emptySelectOptions(addressFrom);
1559 var fromAccountOpts = a.fromAccounts.data;
1560 for(i=0; i<fromAccountOpts.length; i++) {
1561 var key = fromAccountOpts[i].value;
1562 var display = fromAccountOpts[i].text;
1563 var opt = new Option(display, key);
1564 if (fromAccountOpts[i].selected) {
1565 opt.selected = true;
1567 addressFrom.options.add(opt);
1570 SUGAR.hideMessageBox();
1573 failure : AjaxObject.handleFailure,
1574 timeout : AjaxObject.timeout,
1576 argument : [sendType]
1578 var callbackSendEmail = {
1579 success : AjaxObject.sendEmailCleanUp,
1580 failure : AjaxObject.handleFailure,
1581 timeout : AjaxObject.timeout,
1584 var callbackSettings = {
1585 success : AjaxObject.updateUserPrefs,
1586 failure : AjaxObject.handleFailure,
1587 timeout : AjaxObject.timeout,
1590 var callbackSettingsFolderRefresh = {
1591 success : AjaxObject.settingsFolderRefresh,
1592 failure : AjaxObject.handleFailure,
1593 timeout : AjaxObject.timeout,
1596 var callbackLoadSettingFolder = {
1597 success : function(o) {
1598 AjaxObject.settingsFolderRefresh(o);
1599 SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
1601 failure : AjaxObject.handleFailure,
1602 timeout : AjaxObject.timeout,
1606 var callbackUploadAttachment = {
1607 success : AjaxObject.uploadAttachmentSuccessful,
1608 upload : AjaxObject.uploadAttachmentSuccessful,
1609 failure : AjaxObject.handleFailure,
1610 timeout : AjaxObject.timeout,
1613 var callbackUserPrefs = {
1614 success : function(o) {
1615 SUGAR.email2.userPrefs = YAHOO.lang.JSON.parse(o.responseText);
1617 failure : AjaxObject.handleFailure,
1618 timeout : AjaxObject.timeout,
1622 var callbackContextmenus = {
1624 success : AjaxObject.markEmailCleanup,
1625 failure : AjaxObject.handleFailure,
1626 timeout : AjaxObject.timeout,
1631 var callbackCheckEmail2 = {
1632 success : function(o) {
1633 var ret = YAHOO.lang.JSON.parse(o.responseText);
1634 SUGAR.showMessageBox(app_strings.LBL_EMAIL_CHECKING_NEW, ret.text);
1638 failure : AjaxObject.handleFailure,
1639 timeout : AjaxObject.timeout,