1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2012 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("quickCreate", {
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';
729 var count = SUGAR.EmailAddressWidget.count[ret.module] ? SUGAR.EmailAddressWidget.count[ret.module] : 0;
730 var tableId = YAHOO.util.Dom.getElementsByClassName('emailaddresses', 'table', editForm)[0].id;
731 var instId = ret.module + count;
732 SED.quickCreateEmailsToAdd = ret.emailAddress;
733 SED.quickCreateEmailCallback = function(instId, tableId) {
734 var eaw = new SUGAR.EmailAddressWidget(instId);
735 if (typeof(eaw) == "undefined")
736 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
737 + instId + "','" + tableId + "');", 100);
738 eaw.prefillEmailAddresses(tableId, SUGAR.email2.detailView.quickCreateEmailsToAdd);
740 window.setTimeout("SUGAR.email2.detailView.quickCreateEmailCallback('"
741 + instId + "','" + tableId + "');", 100);
745 saveQuickCreateForm : function(o) {
746 SUGAR.hideMessageBox();
747 SUGAR.email2.detailView.quickCreateDialog.hide();
748 validate['EditView'] = [ ];
751 saveQuickCreateFormAndReply : function(o) {
752 SUGAR.hideMessageBox();
753 var ret = YAHOO.lang.JSON.parse(o.responseText);
754 SUGAR.email2.detailView.quickCreateDialog.hide();
755 var qcd = SUGAR.email2.detailView.quickCreateDialog;
756 var type = (qcd.qcmodule == 'Cases') ? 'replyCase' : 'reply';
758 var emailID = ret.id;
759 SUGAR.email2.composeLayout.c0_replyForwardEmail(null, ret.id, 'sugar::Emails', type);
761 SUGAR.email2.composeLayout.c0_replyForwardEmail(qcd.ieId, qcd.uid, qcd.mbox, type);
763 //Cean the validate cache to prevent errors on the next call
764 validate['EditView'] = [ ];
767 saveQuickCreateFormAndAddToAddressBook : function(o) {
768 SUGAR.hideMessageBox();
769 SUGAR.email2.detailView.quickCreateDialog.hide();
770 SUGAR.email2.complexLayout.findPanel('contactsTab').show();
771 validate['EditView'] = [ ];
774 handleAssignmentDialogAssignAction : function() {
777 var assign_user_id = window.document.forms['Distribute'].elements['assigned_user_id'].value;
783 var found_teams = false;
784 var warning_message = mod_strings.LBL_WARN_NO_USERS;
785 if(!found_teams && assign_user_id == '' )
787 alert(warning_message);
791 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
793 for(i=0; i<emailUids.length; i++) {
795 uids += app_strings.LBL_EMAIL_DELIMITER;
797 uids += emailUids[i];
800 var row = SUGAR.email2.grid.getSelectedRows()[0];
801 var data = SUGAR.email2.grid.getRecord(row).getData();
802 var ieid = data.ieId;
803 var mbox = data.mbox;
804 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentAssign&uids=" + uids + "&ieId=" + ieid + "&folder=" + mbox + "&distribute_method=" + dist + "&users=" +assign_user_id + get);
805 SUGAR.email2.contextMenus.assignToDialogue.hide();
806 SUGAR.showMessageBox('Assignment', app_strings.LBL_EMAIL_ONE_MOMENT);
810 handleAssignmentDialogDeleteAction : function() {
811 // TO pass list of UIDS/emailIds
812 var uids = SUGAR.email2.listView.getUidsFromSelection();
813 var row = SUGAR.email2.grid.getSelections()[0];
814 var ieid = row.data.ieId;
815 var mbox = row.data.mbox;
816 AjaxObject.startRequest(callbackAssignmentAction, urlStandard + '&emailUIAction=' + "doAssignmentDelete&uids=" + uids + "&ieId=" + ieId + "&folder=" + mbox);
817 SUGAR.email2.contextMenus.assignmentDialog.hide();
818 SUGAR.showMessageBox(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
824 showEmailDetailView : function(o) {
825 SUGAR.hideMessageBox();
826 var SED = SUGAR.email2.detailView;
827 var ret = YAHOO.lang.JSON.parse(o.responseText);
829 if(!SED.quickCreateDialog) {
830 SED.quickCreateDialog = new YAHOO.widget.Dialog("emailDetailDialog", {
834 constraintoviewport: true,
836 autofillheight: "body",
839 SED.quickCreateDialog.renderEvent.subscribe(function() {
840 var viewHeight = YAHOO.util.Dom.getViewportHeight();
842 for (var i in this.body.childNodes) {
843 if (this.body.childNodes[i].offsetHeight)
844 contH += this.body.childNodes[i].offsetHeight;
846 this.body.style.overflow = "auto";
847 this.body.style.width = "800px";
848 this.body.style.height = (viewHeight - 75 > contH ? (contH + 10) : (viewHeight - 75)) + "px";
850 }, SED.quickCreateDialog);
852 SED.quickCreateDialog.setHeader(app_strings.LBL_EMAIL_RECORD);
853 SED.quickCreateDialog.setBody(ret.html);
854 SED.quickCreateDialog.render();
855 SUGAR.util.evalScript(ret.html);
856 SED.quickCreateDialog.show();
859 showAssignmentDialogWithData : function(o) {
860 var SEC = SUGAR.email2.contextMenus;
861 SUGAR.hideMessageBox();
862 var ret = YAHOO.lang.JSON.parse(o.responseText);
863 if (!SEC.assignmentDialog) {
864 SEC.assignmentDialog = new YAHOO.widget.Dialog("assignmentDialog", {
867 constraintoviewport: true,
870 SEC.assignmentDialog.setBody("");
871 SEC.assignmentDialog.setHeader(app_strings.LBL_EMAIL_ASSIGNMENT);
872 SEC.assignmentDialog.renderEvent.subscribe(function() {
873 var iev = YAHOO.util.Dom.get("Distribute");
875 this.body.style.width = "700px";
877 }, SEC.assignmentDialog);
878 SEC.assignmentDialog.render();
880 SEC.assignmentDialog.setBody(ret);
881 SEC.assignmentDialog.render();
883 SEC.assignmentDialog.show();
884 SUGAR.util.evalScript(ret);
887 showImportForm : function(o) {
888 var SED = SUGAR.email2.detailView;
889 var ret = YAHOO.lang.JSON.parse(o.responseText);
891 document.getElementById('quickCreateContent').innerHTML = "";
892 SUGAR.hideMessageBox();
897 if(!SED.importDialog) {
898 SED.importDialog = new YAHOO.widget.Dialog("importDialog", {
902 constraintoviewport: true,
904 text: app_strings.LBL_EMAIL_ARCHIVE_TO_SUGAR, isDefault: true, handler: function(){
905 AjaxObject.detailView.getImportAction(SED.importDialog.ret); }
909 SED.importDialog.setHeader(app_strings.LBL_EMAIL_IMPORT_SETTINGS);
910 SED.importDialog.setBody("");
911 SED.importDialog.hideEvent.subscribe(function(){
912 for(var i in QSFieldsArray) {
913 if (QSFieldsArray[i] != null && typeof(QSFieldsArray[i]) == "object") {
914 QSFieldsArray[i].destroy();
915 delete QSFieldsArray[i];
917 if (QSProcessedFieldsArray[i]) {
918 QSProcessedFieldsArray[i] = false;
922 SED.importDialog.renderEvent.subscribe(function() {
923 var iev = YAHOO.util.Dom.get("ImportEditView");
925 //this.body.style.height = (iev.clientHeight + 10) + "px";
926 this.body.style.width = "600px";
928 }, SED.importDialog);
929 SED.importDialog.render();
931 SED.importDialog.setBody(ret.html);
932 SED.importDialog.ret = ret;
933 SUGAR.util.evalScript(ret.html);
934 SED.importDialog.render();
936 SED.importDialog.show();
937 SED.importDialog.focusFirstButton();
939 getImportAction : function(ret) {
940 if (!check_form('ImportEditView')) return false;
941 if (!SUGAR.collection.prototype.validateTemSet('ImportEditView', 'team_name')) {
942 alert(mod_strings.LBL_EMAILS_NO_PRIMARY_TEAM_SPECIFIED);
946 var editView = document.getElementById('ImportEditView');
947 if (editView.assigned_user_id != null) {
948 get = get + "&user_id=" + editView.assigned_user_id.value
949 //var user_id = editView.assigned_user_id.value;
951 var parent_id = editView.parent_id.value;
952 var parent_type = editView.parent_type.value;
953 var row = SUGAR.email2.grid.getSelectedRows()[0];
954 row = SUGAR.email2.grid.getRecord(row);
955 var data = row.getData();
956 var ieId = data.ieId;
957 var mbox = data.mbox;
958 var serverDelete = editView.serverDelete.checked;
959 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
961 for(i=0; i<emailUids.length; i++) {
963 uids += app_strings.LBL_EMAIL_DELIMITER;
965 uids += emailUids[i];
968 var action = 'importEmail&uid=';
970 action = 'moveEmails';
971 action = action + '&sourceFolder=' + ret['srcFolder'];
972 action = action + '&sourceIeId=' + ret['srcIeId'];
973 action = action + '&destinationFolder=' + ret['dstFolder'];
974 action = action + '&destinationIeId=' + ret['dstIeId'];
975 action = action + '&emailUids=';
977 if (action.search(/importEmail/) != -1) {
978 SUGAR.showMessageBox(app_strings.LBL_EMAIL_IMPORTING_EMAIL, app_strings.LBL_EMAIL_ONE_MOMENT);
980 SUGAR.showMessageBox("Moving Email(s)", app_strings.LBL_EMAIL_ONE_MOMENT);
983 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=' + action + uids + "&ieId=" + ieId + "&mbox=" + mbox +
984 get + "&parent_id=" + parent_id + "&parent_type=" + parent_type + '&delete=' + serverDelete);
985 SUGAR.email2.detailView.importDialog.hide();
986 document.getElementById('importDialogContent').innerHTML = "";
989 showRelateForm : function(o) {
990 var SED = SUGAR.email2.detailView;
991 var ret = YAHOO.lang.JSON.parse(o.responseText);
992 document.getElementById('quickCreateContent').innerHTML = "";
993 SUGAR.hideMessageBox();
997 dialog_loaded = true;
999 if(!SED.relateDialog) {
1000 SED.relateDialog = new YAHOO.widget.Dialog('relateDialog', {
1005 constraintoviewport: true,
1007 text: app_strings.LBL_EMAIL_RELATE_TO, isDefault: true, handler: function(){
1008 if (!check_form('RelateEditView')) return false;
1010 var editView = document.getElementById('RelateEditView');
1011 var parent_id = editView.parent_id.value;
1012 var parent_type = editView.parent_type.value;
1013 var row = SUGAR.email2.grid.getSelectedRows()[0];
1014 row = SUGAR.email2.grid.getRecord(row);
1015 var ieId = row.getData().ieId;
1016 var mbox = row.getData().mbox;
1017 var emailUids = SUGAR.email2.listView.getUidsFromSelection();
1019 for(i=0; i<emailUids.length; i++) {
1021 uids += app_strings.LBL_EMAIL_DELIMITER;
1023 uids += emailUids[i];
1025 SUGAR.showMessageBox(app_strings.LBL_EMAIL_PERFORMING_TASK, app_strings.LBL_EMAIL_ONE_MOMENT);
1026 AjaxObject.startRequest(callbackStatusForImport, urlStandard + '&emailUIAction=relateEmails&uid=' + uids
1027 + "&ieId=" + ieId + "&mbox=" + mbox + "&parent_id=" + parent_id + "&parent_type=" + parent_type);
1028 SED.relateDialog.hide();
1029 document.getElementById('relateDialogContent').innerHTML = "";
1034 SED.relateDialog.hideEvent.subscribe(function(){
1035 if (QSFieldsArray['ImportEditView_parent_name'] != null) {
1036 QSFieldsArray['ImportEditView_parent_name'].destroy();
1037 delete QSFieldsArray['ImportEditView_parent_name'];
1039 if (QSProcessedFieldsArray['ImportEditView_parent_name']) {
1040 QSProcessedFieldsArray['ImportEditView_parent_name'] = false;
1044 SED.relateDialog.renderEvent.subscribe(function() {
1045 var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
1047 for (var i in this.body.childNodes) {
1048 if (this.body.childNodes[i].clientHeight)
1049 contH += this.body.childNodes[i].clientHeight;
1051 }, SED.relateDialog);
1052 SED.relateDialog.setHeader(app_strings.LBL_EMAIL_RELATE_EMAIL);
1055 SED.relateDialog.setBody(ret.html);
1056 SED.relateDialog.render();
1057 SUGAR.util.evalScript(ret.html);
1058 SED.relateDialog.show();
1062 * DetailView callbacks
1064 AjaxObject.detailView.callback = {
1066 success : function(o) {
1068 var ret = YAHOO.lang.JSON.parse(o.responseText);
1069 SUGAR.email2.detailView.consumeMetaDetail(ret);
1071 argument: [targetDiv],
1072 failure : AjaxObject.handleFailure,
1077 success : function(o) {
1079 var ret = YAHOO.lang.JSON.parse(o.responseText);
1080 SUGAR.email2.detailView.consumeMetaPreview(ret);
1082 failure : AjaxObject.handleFailure,
1087 success : AjaxObject.detailView.displayPrintable,
1088 failure : AjaxObject.handleFailure,
1089 timeout : AjaxObject.timeout,
1093 success : AjaxObject.detailView.displayView,
1094 failure : AjaxObject.handleFailure,
1095 timeout : AjaxObject.timeout,
1104 AjaxObject.folders = {
1106 * check-mail post actions
1108 checkMailCleanup : function(o) {
1109 SUGAR.hideMessageBox();
1110 AjaxObject.folders.rebuildFolders(o); // rebuild TreeView
1112 // refresh focus ListView
1113 SE.listView.refreshGrid();
1114 SUGAR.email2.folders.startCheckTimer(); // resets the timer
1119 rebuildFolders : function(o) {
1120 SUGAR.hideMessageBox();
1122 var data = YAHOO.lang.JSON.parse(o.responseText);
1124 email2treeinit(SUGAR.email2.tree, data.tree_data, 'frameFolders', data.param);
1125 SUGAR.email2.folders.setSugarFolders();
1128 AjaxObject.folders.callback = {
1130 success : AjaxObject.folders.checkMailCleanup,
1131 failure : AjaxObject.handleFailure,
1132 timeout : 600000, // 5 mins
1137 AjaxObject.rules = {
1138 loadRulesForSettings : function(o) {
1139 document.getElementById("rulesListCell").innerHTML = o.responseText;
1140 // assume we have the class we need
1141 SUGAR.routing.getStrings();
1142 SUGAR.routing.getDependentDropdowns();
1145 //// END PER MODULE CALLBACK OBJECTS
1146 ///////////////////////////////////////////////////////////////////////////
1150 success : AjaxObject.handleSuccess,
1151 failure : AjaxObject.handleFailure,
1152 timeout : AjaxObject.timeout,
1155 var callbackAccount = {
1156 success : AjaxObject.ieSaveSuccess,
1157 failure : AjaxObject.handleFailure,
1158 timeout : AjaxObject.timeout,
1161 var callbackAccountDelete = {
1162 success : AjaxObject.ieDeleteSuccess,
1163 failure : AjaxObject.handleFailure,
1164 timeout : AjaxObject.timeout,
1167 var callbackOutboundTest = {
1168 success : AjaxObject.ieSendSuccess,
1169 failure : AjaxObject.handleFailure,
1170 timeout : AjaxObject.timeout,
1176 var callbackTeamInfoForSettings = {
1177 success : function (o) {
1178 var data = YAHOO.lang.JSON.parse(o.responseText);
1179 document.getElementById('EditViewGroupFolderTeamTD').innerHTML = data.defaultgroupfolder;
1181 failure : AjaxObject.handleFailure,
1182 timeout : AjaxObject.timeout,
1187 var callbackStatusForImport = {
1188 success : function (o) {
1189 SUGAR.hideMessageBox();
1190 if (o.responseText != "") {
1191 var statusString = "";
1192 var data = YAHOO.lang.JSON.parse(o.responseText);
1193 for(i=0; i<data.length; i++) {
1194 statusString = statusString + data[i] + '<br/>';
1196 SUGAR.showMessageBox(SUGAR.language.get('Emails','LBL_IMPORT_STATUS_TITLE'), statusString, 'alert');
1198 SE.listView.refreshGrid();
1201 failure : AjaxObject.handleFailure,
1202 timeout : AjaxObject.timeout,
1206 var callbackComposeCache = {
1207 success : AjaxObject.composeCache,
1208 failure : AjaxObject.handleFailure,
1209 timeout : AjaxObject.timeout,
1212 var callbackDelete = {
1213 success : AjaxObject.handleDeleteReturn,
1214 failure : AjaxObject.handleFailure,
1215 timeout : AjaxObject.timeout,
1218 var callbackEmailDetailMultiple = {
1219 success : function(o) {
1220 SUGAR.hideMessageBox();
1221 var retMulti = YAHOO.lang.JSON.parse(o.responseText);
1222 var ret = new Object();
1224 for(var i=0; i<retMulti.length; i++) {
1227 SUGAR.email2._setDetailCache(ret);
1228 SUGAR.email2.detailView.populateDetailView(ret.meta.uid, ret.meta.mbox, ret.meta.ieId, true, SUGAR.email2.innerLayout);
1231 failure : AjaxObject.handleFailure,
1235 var callbackListViewSortOrderChange = {
1236 success : AjaxObject.saveListViewSortOrderPart2,
1237 failure : AjaxObject.handleFailure,
1238 timeout : AjaxObject.timeout,
1240 argument : [ieId, ieName, focusFolder]
1242 var callbackEmptyTrash = {
1243 success : function(o) {
1244 SUGAR.hideMessageBox();
1245 AjaxObject.folderRenameCleanup;
1247 failure : AjaxObject.handleFailure,
1248 timeout : AjaxObject.timeout,
1251 var callbackClearCacheFiles = {
1252 success : function(o) {
1253 SUGAR.hideMessageBox();
1255 failure : AjaxObject.handleFailure,
1256 timeout : AjaxObject.timeout,
1259 var callbackFolderRename = {
1260 success : function(o) {SUGAR.hideMessageBox();SUGAR.email2.folders.rebuildFolders();},
1261 failure : AjaxObject.handleFailure,
1262 timeout : AjaxObject.timeout,
1265 var callbackFolderDelete = {
1266 success : function(o) {
1267 var ret = YAHOO.lang.JSON.parse(o.responseText);
1269 if (ret.folder_id) {
1270 var node = SUGAR.email2.folders.getNodeFromId(ret.folder_id);
1272 SUGAR.email2.tree.removeNode(node, true);
1273 } else if (ret.ieId && ret.mbox) {
1274 var node = SUGAR.email2.folders.getNodeFromIeIdAndMailbox(ret.ieId, ret.mbox);
1276 SUGAR.email2.tree.removeNode(node, true);
1278 SUGAR.hideMessageBox();
1279 //SUGAR.email2.folders.loadSettingFolder();
1281 SUGAR.hideMessageBox();
1282 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, ret.errorMessage, 'alert');
1285 failure : AjaxObject.handleFailure,
1286 timeout : AjaxObject.timeout,
1289 var callbackFolderSave = {
1290 success : function(o) {
1291 var ret = YAHOO.lang.JSON.parse(o.responseText);
1293 switch(ret.action) {
1294 case 'newFolderSave':
1295 SUGAR.email2.folders.rebuildFolders();
1299 failure : AjaxObject.handleFailure,
1300 timeout : AjaxObject.timeout,
1303 var callbackFolderSubscriptions = {
1304 success : AjaxObject.updateFolderSubscriptions,
1305 failure : AjaxObject.handleFailure,
1306 timeout : AjaxObject.timeout,
1309 var callbackFolderUpdate = {
1310 success : AjaxObject.updateFrameFolder,
1311 failure : AjaxObject.handleFailure,
1312 timeout : AjaxObject.timeout,
1315 var callbackFolders = {
1316 success : AjaxObject.folders.rebuildFolders,
1317 //success : void(true),
1318 failure : AjaxObject.handleFailure,
1319 timeout : AjaxObject.timeout,
1322 var callbackFullSync = {
1323 success : AjaxObject.fullSyncCleanup,
1324 failure : AjaxObject.handleFailure,
1325 timeout : 9999999999999,
1328 var callbackGeneric = {
1329 success : function() {
1330 SUGAR.hideMessageBox();
1332 failure : AjaxObject.handleFailure,
1333 timeout : AjaxObject.timeout,
1336 var callbackIeAccountRetrieve = {
1337 success : function(o) {
1338 // return JSON encoding
1339 SUGAR.hideMessageBox();
1340 SUGAR.email2.accounts.fillIeAccount(o.responseText);
1341 SUGAR.email2.accounts.showEditInboundAccountDialogue(false);
1343 failure : AjaxObject.handleFailure,
1344 timeout : AjaxObject.timeout,
1347 var callbackImportOneEmail = {
1348 success : AjaxObject.detailView.showImportForm,
1349 failure : AjaxObject.handleFailure,
1350 timeout : AjaxObject.timeout,
1353 var callbackRelateEmail = {
1354 success : AjaxObject.detailView.showRelateForm,
1355 failure : AjaxObject.handleFailure,
1356 timeout : AjaxObject.timeout,
1359 var callbackEmailDetailView = {
1360 success : AjaxObject.detailView.showEmailDetailView,
1361 failure : AjaxObject.handleFailure,
1362 timeout : AjaxObject.timeout,
1365 var callbackAssignmentDialog = {
1366 success : AjaxObject.detailView.showAssignmentDialogWithData,
1367 failure : AjaxObject.handleFailure,
1368 timeout : AjaxObject.timeout,
1371 var callbackAssignmentAction = {
1372 success : function(o) {
1373 SE.listView.refreshGrid();
1374 SUGAR.hideMessageBox();
1375 if(o.responseText != '') {
1376 SUGAR.showMessageBox('Assignment action result', o.responseText, 'alert');
1379 failure : AjaxObject.handleFailure,
1380 timeout : AjaxObject.timeout,
1383 var callbackMoveEmails = {
1384 success : function(o) {
1385 SE.listView.refreshGrid();
1386 SUGAR.hideMessageBox();
1387 if(o.responseText != '') {
1388 SUGAR.showMessageBox(app_strings.LBL_EMAIL_ERROR_DESC, o.responseText, 'alert');
1391 failure : AjaxObject.handleFailure,
1392 timeout : AjaxObject.timeout,
1395 var callbackLoadAttachments = {
1396 success : AjaxObject.loadAttachments,
1397 failure : AjaxObject.handleFailure,
1398 timeout : AjaxObject.timeout,
1401 var callbackLoadRules = {
1402 success : AjaxObject.rules.loadRulesForSettings,
1403 failure : AjaxObject.handleFailure,
1404 timeout : AjaxObject.timeout,
1407 var callbackLoadSignature = {
1408 success : AjaxObject.loadSignature,
1409 failure : AjaxObject.handleFailure,
1410 timeout : AjaxObject.timeout,
1413 var callbackDeleteSignature = {
1414 success : AjaxObject.handleDeleteSignature,
1415 failure : AjaxObject.handleFailure,
1416 timeout : AjaxObject.timeout,
1419 /*var callbackMoveEmails = {
1420 success : function(o) { SUGAR.email2.listView.moveEmailsCleanup(o) },
1421 failure : AjaxObject.handleFailure,
1422 timeout : AjaxObject.timeout,
1425 var callbackOutboundSave = {
1426 success : AjaxObject.accounts.saveOutboundCleanup,
1427 failure : AjaxObject.handleFailure,
1428 timeout : AjaxObject.timeout,
1431 var callbackDefaultOutboundSave = {
1432 success : AjaxObject.accounts.saveDefaultOutboundCleanup,
1433 failure : AjaxObject.handleFailure,
1434 timeout : AjaxObject.timeout,
1437 var callbackQuickCreate = {
1438 success : AjaxObject.detailView.showQuickCreateForm,
1439 failure : AjaxObject.handleFailure,
1440 timeout : AjaxObject.timeout,
1443 var callbackQuickCreateSave = {
1444 success : AjaxObject.detailView.saveQuickCreateForm,
1445 failure : AjaxObject.handleFailure,
1446 timeout : AjaxObject.timeout,
1449 var callbackQuickCreateSaveAndAddToAddressBook = {
1450 success : AjaxObject.detailView.saveQuickCreateFormAndAddToAddressBook,
1451 failure : AjaxObject.handleFailure,
1452 timeout : AjaxObject.timeout,
1455 var callbackQuickCreateSaveAndReply = {
1456 success : AjaxObject.detailView.saveQuickCreateFormAndReply,
1457 failure : AjaxObject.handleFailure,
1458 timeout : AjaxObject.timeout,
1461 var callbackQuickCreateSaveAndReplyCase = {
1462 success : AjaxObject.detailView.saveQuickCreateFormAndReplyCase,
1463 failure : AjaxObject.handleFailure,
1464 timeout : AjaxObject.timeout,
1467 var callbackRebuildShowAccountList = {
1468 success : AjaxObject.rebuildShowFolders,
1469 failure : AjaxObject.handleFailure,
1470 timeout : AjaxObject.timeout,
1474 var callbackRefreshSugarFolders = {
1475 success : function(o) {
1476 var t = YAHOO.lang.JSON.parse(o.responseText);
1477 SUGAR.email2.folders.setSugarFoldersEnd(t);
1479 failure : AjaxObject.handleFailure,
1480 timeout : AjaxObject.timeout,
1483 var callbackReplyForward = {
1484 success : AjaxObject.handleReplyForward,
1485 finish : function(a, retryCount,isReOrFwDraft) {
1486 if (typeof(retryCount) == 'undefined') {
1491 if (typeof(isReOrFwDraft) == 'undefined') {
1494 var idx = SUGAR.email2.composeLayout.currentInstanceId;
1495 var t = tinyMCE.getInstanceById('htmleditor' + idx);
1497 var html = t.getContent();
1500 //add hr tag if this is not a reply draft or forward draft
1502 html += "<div><hr></div>";
1504 html += a.description;
1506 t.setContent(html);//
1508 if (a.type != 'draft') {
1509 // Next step, attach signature
1510 SUGAR.email2.composeLayout.resizeEditorSetSignature(idx,true);
1514 if (retryCount < 5) {
1515 setTimeout("callbackReplyForward.finish(globalA, " + retryCount + ");", 500);
1519 var tabArray = SUGAR.email2.innerLayout.get("tabs");
1520 if (tabArray != null && tabArray.length > 0) {
1521 for (i = 0 ; i < tabArray.length ; i++) {
1522 var tabObject = tabArray[i];
1523 if (tabObject.get("id") == ("composeTab" + idx)) {
1524 var tabLabel = a.name;
1525 if (tabLabel != null && tabLabel.length > 25) {
1526 tabLabel = tabLabel.substring(0, 25) + "...";
1528 tabObject.get("labelEl").firstChild.data = tabLabel;
1534 //SUGAR.email2.innerLayout.regions.center.getPanel('composeLayout' + idx).setTitle(a.name);
1535 if (a.parent_name != null && a.parent_name != "") {
1536 document.getElementById('data_parent_name' + idx).value = a.parent_name;
1538 if (a.parent_type != null && a.parent_type != "") {
1539 document.getElementById('data_parent_type' + idx).value = a.parent_type;
1541 if (a.parent_id != null && a.parent_id != "") {
1542 document.getElementById('data_parent_id' + idx).value = a.parent_id;
1544 if (a.fromAccounts.status) {
1545 var addressFrom = document.getElementById('addressFrom' + idx);
1546 SUGAR.email2.util.emptySelectOptions(addressFrom);
1547 var fromAccountOpts = a.fromAccounts.data;
1548 for(i=0; i<fromAccountOpts.length; i++) {
1549 var key = fromAccountOpts[i].value;
1550 var display = fromAccountOpts[i].text;
1551 var opt = new Option(display, key);
1552 if (fromAccountOpts[i].selected) {
1553 opt.selected = true;
1555 addressFrom.options.add(opt);
1558 SUGAR.hideMessageBox();
1561 failure : AjaxObject.handleFailure,
1562 timeout : AjaxObject.timeout,
1564 argument : [sendType]
1566 var callbackSendEmail = {
1567 success : AjaxObject.sendEmailCleanUp,
1568 failure : AjaxObject.handleFailure,
1569 timeout : AjaxObject.timeout,
1572 var callbackSettings = {
1573 success : AjaxObject.updateUserPrefs,
1574 failure : AjaxObject.handleFailure,
1575 timeout : AjaxObject.timeout,
1578 var callbackSettingsFolderRefresh = {
1579 success : AjaxObject.settingsFolderRefresh,
1580 failure : AjaxObject.handleFailure,
1581 timeout : AjaxObject.timeout,
1584 var callbackLoadSettingFolder = {
1585 success : function(o) {
1586 AjaxObject.settingsFolderRefresh(o);
1587 SUGAR.email2.accounts.rebuildFolderList(); // refresh frameFolder
1589 failure : AjaxObject.handleFailure,
1590 timeout : AjaxObject.timeout,
1594 var callbackUploadAttachment = {
1595 success : AjaxObject.uploadAttachmentSuccessful,
1596 upload : AjaxObject.uploadAttachmentSuccessful,
1597 failure : AjaxObject.handleFailure,
1598 timeout : AjaxObject.timeout,
1601 var callbackUserPrefs = {
1602 success : function(o) {
1603 SUGAR.email2.userPrefs = YAHOO.lang.JSON.parse(o.responseText);
1605 failure : AjaxObject.handleFailure,
1606 timeout : AjaxObject.timeout,
1610 var callbackContextmenus = {
1612 success : AjaxObject.markEmailCleanup,
1613 failure : AjaxObject.handleFailure,
1614 timeout : AjaxObject.timeout,
1619 var callbackCheckEmail2 = {
1620 success : function(o) {
1621 var ret = YAHOO.lang.JSON.parse(o.responseText);
1622 SUGAR.showMessageBox(app_strings.LBL_EMAIL_CHECKING_NEW, ret.text);
1626 failure : AjaxObject.handleFailure,
1627 timeout : AjaxObject.timeout,