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 ********************************************************************************/
36 function setSymbolValue(id) {
37 document.getElementById('symbol').value = currencies[id];
40 function user_status_display(field){
41 if (typeof field.form.is_admin == 'undefined')
43 var input = document.createElement("input");
44 input.setAttribute("id", "is_admin");
45 input.setAttribute("type", "hidden");
46 input.setAttribute("name", "is_admin");
47 input.setAttribute("value", "");
48 field.form.appendChild(input);
50 if (typeof field.form.is_group == 'undefined')
52 var input = document.createElement("input");
53 input.setAttribute("id", "is_group");
54 input.setAttribute("type", "hidden");
55 input.setAttribute("name", "is_group");
56 input.setAttribute("value", "");
57 field.form.appendChild(input);
59 if (typeof field.form.portal_only == 'undefined')
61 var input = document.createElement("input");
62 input.setAttribute("id", "portal_only");
63 input.setAttribute("type", "hidden");
64 input.setAttribute("name", "portal_only");
65 input.setAttribute("value", "");
66 field.form.appendChild(input);
70 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_ADMIN_DESC");
71 document.getElementById('is_admin').value='1';
74 document.getElementById('is_admin').value='0';
75 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_REGULAR_DESC");
77 case 'UserAdministrator':
78 document.getElementById('is_admin').value='0';
79 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_USER_ADMIN_DESC");
82 document.getElementById('is_admin').value='0';
83 document.getElementById('is_group').value='1';
84 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_GROUP_DESC");
87 document.getElementById('is_admin').value='0';
88 document.getElementById('is_group').value='0';
89 document.getElementById('portal_only').value='1';
90 document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users','LBL_PORTAL_ONLY_DESC');
96 function startOutBoundEmailSettingsTest()
98 var loader = new YAHOO.util.YUILoader({
99 require : ["element","sugarwidgets"],
101 skin: { base: 'blank', defaultSkin: '' },
102 onSuccess: testOutboundSettings,
104 base: "include/javascript/yui/build/"
107 name :"sugarwidgets",
109 fullpath: "include/javascript/sugarwidgets/SugarYUIWidgets.js",
110 varName: "YAHOO.SUGAR",
111 requires: ["datatable", "dragdrop", "treeview", "tabview"]
117 function testOutboundSettings()
119 var errorMessage = '';
121 var fromAddress = document.getElementById("outboundtest_from_address").value;
122 var errorMessage = '';
124 var smtpServer = document.getElementById('mail_smtpserver').value;
126 var mailsmtpauthreq = document.getElementById('mail_smtpauth_req');
127 if(trim(smtpServer) == '' || trim(mail_smtpport) == '')
130 errorMessage += SUGAR.language.get('Users',"LBL_MISSING_DEFAULT_OUTBOUND_SMTP_SETTINGS") + "<br/>";
131 overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"), errorMessage, 'alert');
136 if(document.getElementById('mail_smtpuser') && trim(document.getElementById('mail_smtpuser').value) == '')
139 errorMessage += SUGAR.language.get('app_strings',"LBL_EMAIL_ACCOUNTS_SMTPUSER") + "<br/>";
144 overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"), errorMessage, 'alert');
148 testOutboundSettingsDialog();
151 function sendTestEmail()
153 var toAddress = document.getElementById("outboundtest_from_address").value;
154 var fromAddress = document.getElementById("outboundtest_from_address").value;
156 if (trim(fromAddress) == "")
158 overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"), SUGAR.language.get('app_strings',"LBL_EMAIL_SETTINGS_FROM_TO_EMAIL_ADDR"), 'alert');
161 else if (!isValidEmail(fromAddress)) {
162 overlay(SUGAR.language.get('app_strings',"ERR_INVALID_REQUIRED_FIELDS"), SUGAR.language.get('app_strings',"LBL_EMAIL_SETTINGS_FROM_TO_EMAIL_ADDR"), 'alert');
166 //Hide the email address window and show a message notifying the user that the test email is being sent.
167 EmailMan.testOutboundDialog.hide();
168 overlay(SUGAR.language.get('app_strings',"LBL_EMAIL_PERFORMING_TASK"), SUGAR.language.get('app_strings',"LBL_EMAIL_ONE_MOMENT"), 'alert');
170 var callbackOutboundTest = {
171 success : function(o) {
173 overlay(SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_OUTBOUND_SETTINGS"), SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_NOTIFICATION_SENT"), 'alert');
176 var smtpServer = document.getElementById('mail_smtpserver').value;
178 if(document.getElementById('mail_smtpuser') && document.getElementById('mail_smtppass')){
179 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;
182 var postDataString = 'mail_sendtype=SMTP&mail_smtpserver=' + smtpServer + "&mail_smtpport=" + mail_smtpport + "&mail_smtpssl=" + mail_smtpssl + "&outboundtest_from_address=" + fromAddress + "&outboundtest_to_address=" + toAddress;
184 YAHOO.util.Connect.asyncRequest("POST", "index.php?action=testOutboundEmail&mail_name=system&module=EmailMan&to_pdf=true&sugar_body_only=true", callbackOutboundTest, postDataString);
186 function testOutboundSettingsDialog() {
187 // lazy load dialogue
188 if(!EmailMan.testOutboundDialog) {
189 EmailMan.testOutboundDialog = new YAHOO.widget.Dialog("testOutboundDialog", {
193 constraintoviewport: true,
197 EmailMan.testOutboundDialog.setHeader(SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_OUTBOUND_SETTINGS"));
198 YAHOO.util.Dom.removeClass("testOutboundDialog", "yui-hidden");
201 EmailMan.testOutboundDialog.render();
202 EmailMan.testOutboundDialog.show();
205 function overlay(reqtitle, body, type) {
208 config.title = reqtitle;
210 YAHOO.SUGAR.MessageBox.show(config);
213 function hideOverlay() {
214 YAHOO.SUGAR.MessageBox.hide();
219 function verify_data(form)
221 // handles any errors in the email widget
222 var isError = !check_form("EditView");
224 if (trim(form.last_name.value) == "") {
225 add_error_style('EditView',form.last_name.name,
226 SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS') + SUGAR.language.get('Users','LBL_LIST_NAME') );
229 if (trim(form.user_name.value) == "") {
230 add_error_style('EditView',form.user_name.name,
231 SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS') + SUGAR.language.get('Users','LBL_USER_NAME') );
235 if (document.getElementById("required_password").value=='1'
236 && document.getElementById("new_password").value == "") {
237 add_error_style('EditView',form.new_password.name,
238 SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS') + SUGAR.language.get('Users','LBL_NEW_PASSWORD') );
242 if (isError == true) {
246 if (document.EditView.return_id.value != '' && (typeof(form.reports_to_id)!="undefined") && (document.EditView.return_id.value == form.reports_to_id.value)) {
247 alert(SUGAR.language.get('app_strings','ERR_SELF_REPORTING'));
251 if (document.EditView.dec_sep.value != '' && (document.EditView.dec_sep.value == "'")) {
252 alert(SUGAR.language.get('app_strings','ERR_NO_SINGLE_QUOTE') + SUGAR.language.get('Users','LBL_DECIMAL_SEP'));
256 if (document.EditView.num_grp_sep.value != '' && (document.EditView.num_grp_sep.value == "'")) {
257 alert(SUGAR.language.get('app_strings','ERR_NO_SINGLE_QUOTE') + SUGAR.language.get('Users','LBL_NUMBER_GROUPING_SEP'));
261 if (document.EditView.num_grp_sep.value == document.EditView.dec_sep.value) {
262 alert(SUGAR.language.get('app_strings','ERR_DECIMAL_SEP_EQ_THOUSANDS_SEP'));
265 if( document.getElementById("portal_only") && document.getElementById("portal_only")=='1' &&
266 typeof(document.getElementById("new_password")) != "undefined" && typeof(document.getElementById("new_password").value) != "undefined") {
267 if(document.getElementById("new_password").value != '' || document.getElementById("confirm_pwd").value != '') {
268 if(document.getElementById("new_password").value != document.getElementById("confirm_pwd").value) {
269 alert(SUGAR.language.get('Users','ERR_PASSWORD_MISMATCH'));
279 function set_chooser()
281 var display_tabs_def = '';
282 var hide_tabs_def = '';
283 var remove_tabs_def = '';
285 var display_td = document.getElementById('display_tabs_td');
286 var hide_td = document.getElementById('hide_tabs_td');
287 var remove_td = document.getElementById('remove_tabs_td');
289 var display_ref = display_td.getElementsByTagName('select')[0];
291 for(i=0; i < display_ref.options.length ;i++)
293 display_tabs_def += "display_tabs[]="+display_ref.options[i].value+"&";
298 var hide_ref = hide_td.getElementsByTagName('select')[0];
300 for(i=0; i < hide_ref.options.length ;i++)
302 hide_tabs_def += "hide_tabs[]="+hide_ref.options[i].value+"&";
306 if(remove_td != null)
308 var remove_ref = remove_td.getElementsByTagName('select')[0];
310 for(i=0; i < remove_ref.options.length ;i++)
312 remove_tabs_def += "remove_tabs[]="+remove_ref.options[i].value+"&";
317 document.EditView.display_tabs_def.value = display_tabs_def;
318 document.EditView.hide_tabs_def.value = hide_tabs_def;
319 document.EditView.remove_tabs_def.value = remove_tabs_def;
322 // Brought this over from Forms.php, pretty sure it's not needed.
323 function add_checks(f) {
329 function onUserEditView() {
330 YAHOO.util.Event.onContentReady('user_theme_picker',function() {
331 document.getElementById('user_theme_picker').onchange = function() {
332 document.getElementById('themePreview').src =
333 "index.php?entryPoint=getImage&themeName=" + document.getElementById('user_theme_picker').value + "&imageName=themePreview.png";
334 if (typeof themeGroupList[document.getElementById('user_theme_picker').value] != 'undefined' &&
335 themeGroupList[document.getElementById('user_theme_picker').value] ) {
336 document.getElementById('use_group_tabs_row').style.display = '';
338 document.getElementById('use_group_tabs_row').style.display = 'none';
343 setSymbolValue(document.getElementById('currency_select').options[document.getElementById('currency_select').selectedIndex].value);
345 user_status_display(document.getElementById('UserType'));