]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/UserEditView.js
Release 6.4.0
[Github/sugarcrm.git] / modules / Users / UserEditView.js
1 /*********************************************************************************
2  * SugarCRM Community Edition is a customer relationship management program developed by
3  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
4  *
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.
11  *
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
15  * details.
16  *
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
20  * 02110-1301 USA.
21  *
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.
24  *
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.
28  *
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  ********************************************************************************/
35 function setSymbolValue(id){document.getElementById('symbol').value=currencies[id];}
36 function user_status_display(field){if(typeof field.form.is_admin=='undefined')
37 {var input=document.createElement("input");input.setAttribute("id","is_admin");input.setAttribute("type","hidden");input.setAttribute("name","is_admin");input.setAttribute("value","");field.form.appendChild(input);}
38 if(typeof field.form.is_group=='undefined')
39 {var input=document.createElement("input");input.setAttribute("id","is_group");input.setAttribute("type","hidden");input.setAttribute("name","is_group");input.setAttribute("value","");field.form.appendChild(input);}
40 if(typeof field.form.portal_only=='undefined')
41 {var input=document.createElement("input");input.setAttribute("id","portal_only");input.setAttribute("type","hidden");input.setAttribute("name","portal_only");input.setAttribute("value","");field.form.appendChild(input);}
42 switch(field.value){case'Administrator':document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_ADMIN_DESC");document.getElementById('is_admin').value='1';break;case'RegularUser':document.getElementById('is_admin').value='0';document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_REGULAR_DESC");break;case'UserAdministrator':document.getElementById('is_admin').value='0';document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_USER_ADMIN_DESC");break;case'GROUP':document.getElementById('is_admin').value='0';document.getElementById('is_group').value='1';document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users',"LBL_GROUP_DESC");break;case'PORTAL_ONLY':document.getElementById('is_admin').value='0';document.getElementById('is_group').value='0';document.getElementById('portal_only').value='1';document.getElementById('UserTypeDesc').innerHTML=SUGAR.language.get('Users','LBL_PORTAL_ONLY_DESC');break;}}
43 function startOutBoundEmailSettingsTest()
44 {var loader=new YAHOO.util.YUILoader({require:["element","sugarwidgets"],loadOptional:true,skin:{base:'blank',defaultSkin:''},onSuccess:testOutboundSettings,allowRollup:true,base:"include/javascript/yui/build/"});loader.addModule({name:"sugarwidgets",type:"js",fullpath:"include/javascript/sugarwidgets/SugarYUIWidgets.js",varName:"YAHOO.SUGAR",requires:["datatable","dragdrop","treeview","tabview"]});loader.insert();}
45 function testOutboundSettings()
46 {var errorMessage='';var isError=false;var fromAddress=document.getElementById("outboundtest_from_address").value;var errorMessage='';var isError=false;var smtpServer=document.getElementById('mail_smtpserver').value;var mailsmtpauthreq=document.getElementById('mail_smtpauth_req');if(trim(smtpServer)==''||trim(mail_smtpport)=='')
47 {isError=true;errorMessage+=SUGAR.language.get('Users',"LBL_MISSING_DEFAULT_OUTBOUND_SMTP_SETTINGS")+"<br/>";overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"),errorMessage,'alert');return false;}
48 if(document.getElementById('mail_smtpuser')&&trim(document.getElementById('mail_smtpuser').value)=='')
49 {isError=true;errorMessage+=SUGAR.language.get('app_strings',"LBL_EMAIL_ACCOUNTS_SMTPUSER")+"<br/>";}
50 if(isError){overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"),errorMessage,'alert');return false;}
51 testOutboundSettingsDialog();}
52 function sendTestEmail()
53 {var toAddress=document.getElementById("outboundtest_from_address").value;var fromAddress=document.getElementById("outboundtest_from_address").value;if(trim(fromAddress)=="")
54 {overlay(SUGAR.language.get('app_strings',"ERR_MISSING_REQUIRED_FIELDS"),SUGAR.language.get('app_strings',"LBL_EMAIL_SETTINGS_FROM_TO_EMAIL_ADDR"),'alert');return;}
55 else if(!isValidEmail(fromAddress)){overlay(SUGAR.language.get('app_strings',"ERR_INVALID_REQUIRED_FIELDS"),SUGAR.language.get('app_strings',"LBL_EMAIL_SETTINGS_FROM_TO_EMAIL_ADDR"),'alert');return;}
56 EmailMan.testOutboundDialog.hide();overlay(SUGAR.language.get('app_strings',"LBL_EMAIL_PERFORMING_TASK"),SUGAR.language.get('app_strings',"LBL_EMAIL_ONE_MOMENT"),'alert');var callbackOutboundTest={success:function(o){hideOverlay();overlay(SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_OUTBOUND_SETTINGS"),SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_NOTIFICATION_SENT"),'alert');}};var smtpServer=document.getElementById('mail_smtpserver').value;if(document.getElementById('mail_smtpuser')&&document.getElementById('mail_smtppass')){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;}
57 else{var postDataString='mail_sendtype=SMTP&mail_smtpserver='+smtpServer+"&mail_smtpport="+mail_smtpport+"&mail_smtpssl="+mail_smtpssl+"&outboundtest_from_address="+fromAddress+"&outboundtest_to_address="+toAddress;}
58 YAHOO.util.Connect.asyncRequest("POST","index.php?action=testOutboundEmail&mail_name=system&module=EmailMan&to_pdf=true&sugar_body_only=true",callbackOutboundTest,postDataString);}
59 function testOutboundSettingsDialog(){if(!EmailMan.testOutboundDialog){EmailMan.testOutboundDialog=new YAHOO.widget.Dialog("testOutboundDialog",{modal:true,visible:true,fixedcenter:true,constraintoviewport:true,width:600,shadow:false});EmailMan.testOutboundDialog.setHeader(SUGAR.language.get('app_strings',"LBL_EMAIL_TEST_OUTBOUND_SETTINGS"));YAHOO.util.Dom.removeClass("testOutboundDialog","yui-hidden");}
60 EmailMan.testOutboundDialog.render();EmailMan.testOutboundDialog.show();}
61 function overlay(reqtitle,body,type){var config={};config.type=type;config.title=reqtitle;config.msg=body;YAHOO.SUGAR.MessageBox.show(config);}
62 function hideOverlay(){YAHOO.SUGAR.MessageBox.hide();}
63 function verify_data(form)
64 {var isError=!check_form("EditView");if(trim(form.last_name.value)==""){add_error_style('EditView',form.last_name.name,SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS')+SUGAR.language.get('Users','LBL_LIST_NAME'));isError=true;}
65 if(trim(form.user_name.value)==""){add_error_style('EditView',form.user_name.name,SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS')+SUGAR.language.get('Users','LBL_USER_NAME'));isError=true;}
66 if(document.getElementById("required_password").value=='1'&&document.getElementById("new_password").value==""){add_error_style('EditView',form.new_password.name,SUGAR.language.get('app_strings','ERR_MISSING_REQUIRED_FIELDS')+SUGAR.language.get('Users','LBL_NEW_PASSWORD'));isError=true;}
67 if(isError==true){return false;}
68 if(document.EditView.return_id.value!=''&&(typeof(form.reports_to_id)!="undefined")&&(document.EditView.return_id.value==form.reports_to_id.value)){alert(SUGAR.language.get('app_strings','ERR_SELF_REPORTING'));return false;}
69 if(document.EditView.dec_sep.value!=''&&(document.EditView.dec_sep.value=="'")){alert(SUGAR.language.get('app_strings','ERR_NO_SINGLE_QUOTE')+SUGAR.language.get('Users','LBL_DECIMAL_SEP'));return false;}
70 if(document.EditView.num_grp_sep.value!=''&&(document.EditView.num_grp_sep.value=="'")){alert(SUGAR.language.get('app_strings','ERR_NO_SINGLE_QUOTE')+SUGAR.language.get('Users','LBL_NUMBER_GROUPING_SEP'));return false;}
71 if(document.EditView.num_grp_sep.value==document.EditView.dec_sep.value){alert(SUGAR.language.get('app_strings','ERR_DECIMAL_SEP_EQ_THOUSANDS_SEP'));return false;}
72 if(document.getElementById("portal_only")&&document.getElementById("portal_only")=='1'&&typeof(document.getElementById("new_password"))!="undefined"&&typeof(document.getElementById("new_password").value)!="undefined"){if(document.getElementById("new_password").value!=''||document.getElementById("confirm_pwd").value!=''){if(document.getElementById("new_password").value!=document.getElementById("confirm_pwd").value){alert(SUGAR.language.get('Users','ERR_PASSWORD_MISMATCH'));return false;}}}
73 return true;}
74 function set_chooser()
75 {var display_tabs_def='';var hide_tabs_def='';var remove_tabs_def='';var display_td=document.getElementById('display_tabs_td');var hide_td=document.getElementById('hide_tabs_td');var remove_td=document.getElementById('remove_tabs_td');var display_ref=display_td.getElementsByTagName('select')[0];for(i=0;i<display_ref.options.length;i++)
76 {display_tabs_def+="display_tabs[]="+display_ref.options[i].value+"&";}
77 if(hide_td!=null)
78 {var hide_ref=hide_td.getElementsByTagName('select')[0];for(i=0;i<hide_ref.options.length;i++)
79 {hide_tabs_def+="hide_tabs[]="+hide_ref.options[i].value+"&";}}
80 if(remove_td!=null)
81 {var remove_ref=remove_td.getElementsByTagName('select')[0];for(i=0;i<remove_ref.options.length;i++)
82 {remove_tabs_def+="remove_tabs[]="+remove_ref.options[i].value+"&";}}
83 document.EditView.display_tabs_def.value=display_tabs_def;document.EditView.hide_tabs_def.value=hide_tabs_def;document.EditView.remove_tabs_def.value=remove_tabs_def;}
84 function add_checks(f){return true;}
85 function onUserEditView(){YAHOO.util.Event.onContentReady('user_theme_picker',function(){document.getElementById('user_theme_picker').onchange=function(){document.getElementById('themePreview').src="index.php?entryPoint=getImage&themeName="+document.getElementById('user_theme_picker').value+"&imageName=themePreview.png";if(typeof themeGroupList[document.getElementById('user_theme_picker').value]!='undefined'&&themeGroupList[document.getElementById('user_theme_picker').value]){document.getElementById('use_group_tabs_row').style.display='';}else{document.getElementById('use_group_tabs_row').style.display='none';}}});setSymbolValue(document.getElementById('currency_select').options[document.getElementById('currency_select').selectedIndex].value);setSigDigits();user_status_display(document.getElementById('UserType'));}