1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by the
7 * Free Software Foundation with the addition of the following permission added
8 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * You should have received a copy of the GNU Affero General Public License along with
18 * this program; if not, see http://www.gnu.org/licenses or write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32 * technical reasons, the Appropriate Legal Notices must display the words
33 * "Powered by SugarCRM".
34 ********************************************************************************/
36 function setSymbolValue(id) {
37 document.getElementById('symbol').value = currencies[id];
40 function user_status_display(field){
43 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_ADMIN_DESC");
44 document.getElementById('is_admin').value='1';
47 document.getElementById('is_admin').value='0';
48 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_REGULAR_DESC");
50 case 'UserAdministrator':
51 document.getElementById('is_admin').value='0';
52 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_USER_ADMIN_DESC");
55 document.getElementById('is_admin').value='0';
56 document.getElementById('is_group').value='1';
57 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_GROUP_DESC");
60 document.getElementById('is_admin').value='0';
61 document.getElementById('is_group').value='0';
62 document.getElementById('portal_only').value='1';
63 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users','LBL_PORTAL_ONLY_DESC');
69 function startOutBoundEmailSettingsTest()
71 var loader = new YAHOO.util.YUILoader({
72 require : ["element","sugarwidgets"],
74 skin: { base: 'blank', defaultSkin: '' },
75 onSuccess: testOutboundSettings,
77 base: "include/javascript/yui/build/"
82 fullpath: "include/javascript/sugarwidgets/SugarYUIWidgets.js",
83 varName: "YAHOO.SUGAR",
84 requires: ["datatable", "dragdrop", "treeview", "tabview"]
90 function testOutboundSettings()
92 var errorMessage = '';
94 var fromAddress = document.getElementById("outboundtest_from_address").value;
95 var errorMessage = '';
97 var smtpServer = document.getElementById('mail_smtpserver').value;
99 var mailsmtpauthreq = document.getElementById('mail_smtpauth_req');
100 if(trim(smtpServer) == '' || trim(mail_smtpport) == '')
103 errorMessage += SUGAR.language.get('Users',"LBL_MISSING_DEFAULT_OUTBOUND_SMTP_SETTINGS") + "<br/>";
104 overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"), errorMessage, 'alert');
109 if(document.getElementById('mail_smtpuser') && trim(document.getElementById('mail_smtpuser').value) == '')
112 errorMessage += SUGAR.language.get('app_strings',"LBL_EMAIL_ACCOUNTS_SMTPUSER") + "<br/>";
117 overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"), errorMessage, 'alert');
121 testOutboundSettingsDialog();
124 function sendTestEmail()
126 var toAddress = document.getElementById("outboundtest_from_address").value;
127 var fromAddress = document.getElementById("outboundtest_from_address").value;
129 if (trim(fromAddress) == "")
131 overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"), SUGAR.language.get('app_strings',"LBL_EMAIL_SETTINGS_FROM_TO_EMAIL_ADDR"), 'alert');
134 else if (!isValidEmail(fromAddress)) {
135 overlay(SUGAR.language.get('app_strings',"ERR_INVALID_REQUIRED_FIELDS"), SUGAR.language.get('app_strings',"LBL_EMAIL_SETTINGS_FROM_TO_EMAIL_ADDR"), 'alert');
139 //Hide the email address window and show a message notifying the user that the test email is being sent.
140 EmailMan.testOutboundDialog.hide();
141 overlay(SUGAR.language.get('app_strings',"LBL_EMAIL_PERFORMING_TASK"), SUGAR.language.get('app_strings',"LBL_EMAIL_ONE_MOMENT"), 'alert');
143 var callbackOutboundTest = {
144 success : function(o) {
146 overlay(SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_OUTBOUND_SETTINGS"), SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_NOTIFICATION_SENT"), 'alert');
149 var smtpServer = document.getElementById('mail_smtpserver').value;
151 if(document.getElementById('mail_smtpuser') && document.getElementById('mail_smtppass')){
152 var postDataString = 'mail_sendtype=SMTP&mail_smtpserver=' + smtpServer + "&mail_smtpport=" + mail_smtpport + "&mail_smtpssl=" + mail_smtpssl + "&mail_smtpauth_req=true&mail_smtpuser=" + trim(document.getElementById('mail_smtpuser').value) + "&mail_smtppass=" + trim(document.getElementById('mail_smtppass').value) + "&outboundtest_from_address=" + fromAddress + "&outboundtest_to_address=" + toAddress;
155 var postDataString = 'mail_sendtype=SMTP&mail_smtpserver=' + smtpServer + "&mail_smtpport=" + mail_smtpport + "&mail_smtpssl=" + mail_smtpssl + "&outboundtest_from_address=" + fromAddress + "&outboundtest_to_address=" + toAddress;
157 YAHOO.util.Connect.asyncRequest("POST", "index.php?action=testOutboundEmail&mail_name=system&module=EmailMan&to_pdf=true&sugar_body_only=true", callbackOutboundTest, postDataString);
159 function testOutboundSettingsDialog() {
160 // lazy load dialogue
161 if(!EmailMan.testOutboundDialog) {
162 EmailMan.testOutboundDialog = new YAHOO.widget.Dialog("testOutboundDialog", {
166 constraintoviewport: true,
170 EmailMan.testOutboundDialog.setHeader(SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_OUTBOUND_SETTINGS"));
171 YAHOO.util.Dom.removeClass("testOutboundDialog", "yui-hidden");
174 EmailMan.testOutboundDialog.render();
175 EmailMan.testOutboundDialog.show();
178 function overlay(reqtitle, body, type) {
181 config.title = reqtitle;
183 YAHOO.SUGAR.MessageBox.show(config);
186 function hideOverlay() {
187 YAHOO.SUGAR.MessageBox.hide();
192 function verify_data(form)
194 // handles any errors in the email widget
195 var isError = !check_form("EditView");
197 if (trim(form.last_name.value) == "") {
198 add_error_style('EditView',form.last_name.name,
199 SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS') + SUGAR.language.get('Users','LBL_LIST_NAME') );
202 if (trim(form.user_name.value) == "") {
203 add_error_style('EditView',form.user_name.name,
204 SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS') + SUGAR.language.get('Users','LBL_USER_NAME') );
208 if (document.getElementById("required_password").value=='1'
209 && document.getElementById("new_password").value == "") {
210 add_error_style('EditView',form.new_password.name,
211 SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS') + SUGAR.language.get('Users','LBL_NEW_PASSWORD') );
215 if (isError == true) {
219 if (document.EditView.return_id.value != '' && (document.EditView.return_id.value == form.reports_to_id.value)) {
220 alert(SUGAR.language.get('app_strings','ERR_SELF_REPORTING'));
224 if (document.EditView.dec_sep.value != '' && (document.EditView.dec_sep.value == "'")) {
225 alert(SUGAR.language.get('app_strings','ERR_NO_SINGLE_QUOTE') + SUGAR.language.get('Users','LBL_DECIMAL_SEP'));
229 if (document.EditView.num_grp_sep.value != '' && (document.EditView.num_grp_sep.value == "'")) {
230 alert(SUGAR.language.get('app_strings','ERR_NO_SINGLE_QUOTE') + SUGAR.language.get('Users','LBL_NUMBER_GROUPING_SEP'));
234 if (document.EditView.num_grp_sep.value == document.EditView.dec_sep.value) {
235 alert(SUGAR.language.get('app_strings','ERR_DECIMAL_SEP_EQ_THOUSANDS_SEP'));
238 if( document.getElementById("portal_only") && document.getElementById("portal_only")=='1' &&
239 typeof(document.getElementById("new_password")) != "undefined" && typeof(document.getElementById("new_password").value) != "undefined") {
240 if(document.getElementById("new_password").value != '' || document.getElementById("confirm_pwd").value != '') {
241 if(document.getElementById("new_password").value != document.getElementById("confirm_pwd").value) {
242 alert(SUGAR.language.get('Users','ERR_PASSWORD_MISMATCH'));
252 function set_chooser()
254 var display_tabs_def = '';
255 var hide_tabs_def = '';
256 var remove_tabs_def = '';
258 var display_td = document.getElementById('display_tabs_td');
259 var hide_td = document.getElementById('hide_tabs_td');
260 var remove_td = document.getElementById('remove_tabs_td');
262 var display_ref = display_td.getElementsByTagName('select')[0];
264 for(i=0; i < display_ref.options.length ;i++)
266 display_tabs_def += "display_tabs[]="+display_ref.options[i].value+"&";
271 var hide_ref = hide_td.getElementsByTagName('select')[0];
273 for(i=0; i < hide_ref.options.length ;i++)
275 hide_tabs_def += "hide_tabs[]="+hide_ref.options[i].value+"&";
279 if(remove_td != null)
281 var remove_ref = remove_td.getElementsByTagName('select')[0];
283 for(i=0; i < remove_ref.options.length ;i++)
285 remove_tabs_def += "remove_tabs[]="+remove_ref.options[i].value+"&";
290 document.EditView.display_tabs_def.value = display_tabs_def;
291 document.EditView.hide_tabs_def.value = hide_tabs_def;
292 document.EditView.remove_tabs_def.value = remove_tabs_def;
295 // Brought this over from Forms.php, pretty sure it's not needed.
296 function add_checks(f) {
302 function onUserEditView() {
303 YAHOO.util.Event.onContentReady('user_theme_picker',function() {
304 document.getElementById('user_theme_picker').onchange = function() {
305 document.getElementById('themePreview').src =
306 "index.php?entryPoint=getImage&themeName=" + document.getElementById('user_theme_picker').value + "&imageName=themePreview.png";
307 if (typeof themeGroupList[document.getElementById('user_theme_picker').value] != 'undefined' &&
308 themeGroupList[document.getElementById('user_theme_picker').value] ) {
309 document.getElementById('use_group_tabs_row').style.display = '';
311 document.getElementById('use_group_tabs_row').style.display = 'none';
316 setSymbolValue(document.getElementById('currency_select').options[document.getElementById('currency_select').selectedIndex].value);
318 user_status_display(document.getElementById('UserType'));