]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/Forms.php
Release 6.2.0
[Github/sugarcrm.git] / modules / Users / Forms.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description:  Contains a variety of utility functions used to display UI
41  * components such as form headers and footers.  Intended to be modified on a per
42  * theme basis.
43  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
44  * All Rights Reserved.
45  * Contributor(s): ______________________________________..
46  ********************************************************************************/
47
48 /**
49  * Create javascript to validate the data entered into a record.
50  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
51  * All Rights Reserved.
52  * Contributor(s): ______________________________________..
53  */
54 function user_get_validate_record_js () {
55 global $mod_strings;
56 global $app_strings;
57
58 $lbl_email = $mod_strings['LBL_EMAIL']; 
59 $lbl_last_name = $mod_strings['LBL_LIST_LAST_NAME'];
60 $lbl_password = $mod_strings['LBL_LIST_PASSWORD'];
61 $lbl_user_name = $mod_strings['LBL_LIST_USER_NAME'];
62 $err_missing_required_fields = $app_strings['ERR_MISSING_REQUIRED_FIELDS'];
63 $err_invalid_required_fields = $app_strings['ERR_INVALID_REQUIRED_FIELDS'];
64 //$err_invalid_email_address = $app_strings['ERR_INVALID_EMAIL_ADDRESS'];
65 $err_self_reporting = $app_strings['ERR_SELF_REPORTING'];
66 $err_password_mismatch = $mod_strings['ERR_PASSWORD_MISMATCH'];
67 $err_password_missing = $mod_strings['ERR_INVALID_PASSWORD'];
68
69 $the_script  = <<<EOQ
70
71 <script type="text/javascript" language="Javascript">
72 function verify_data(form)
73 {
74     // handles any errors in the email widget
75     var isError = !check_form("EditView");
76         
77     if (trim(form.last_name.value) == "") {
78                 add_error_style('EditView',form.last_name.name,
79             '{$app_strings['ERR_MISSING_REQUIRED_FIELDS']} {$mod_strings['LBL_LIST_NAME']}' );
80         isError = true;
81         }
82         if (trim(form.sugar_user_name.value) == "") {
83                 add_error_style('EditView',form.sugar_user_name.name,
84             '{$app_strings['ERR_MISSING_REQUIRED_FIELDS']} {$mod_strings['LBL_USER_NAME']}' );
85         isError = true;
86         }
87         
88     if (document.getElementById("required_password").value=='1' 
89                 && document.getElementById("new_password").value == "") {
90                 add_error_style('EditView',form.new_password.name,
91             '{$app_strings['ERR_MISSING_REQUIRED_FIELDS']} {$mod_strings['LBL_NEW_PASSWORD']}' );
92         isError = true;
93         }
94         
95         if (isError == true) {
96         return false;
97     }
98                 
99         if (document.EditView.return_id.value != '' && (document.EditView.return_id.value == form.reports_to_id.value)) {
100                 alert('$err_self_reporting');
101                 return false;
102         }
103         
104         if (document.EditView.dec_sep.value != '' && (document.EditView.dec_sep.value == "'")) {
105                 alert("{$app_strings['ERR_NO_SINGLE_QUOTE']} {$mod_strings['LBL_DECIMAL_SEP']}");
106                 return false;
107         }
108
109         if (document.EditView.num_grp_sep.value != '' && (document.EditView.num_grp_sep.value == "'")) {
110                 alert("{$app_strings['ERR_NO_SINGLE_QUOTE']} {$mod_strings['LBL_NUMBER_GROUPING_SEP']}");
111                 return false;
112         }
113
114         if (document.EditView.num_grp_sep.value == document.EditView.dec_sep.value) {
115                 alert("{$app_strings['ERR_DECIMAL_SEP_EQ_THOUSANDS_SEP']}");
116                 return false;
117         }
118         if( document.getElementById("portal_only") && document.getElementById("portal_only")=='1' &&
119                 typeof(document.getElementById("new_password")) != "undefined" && typeof(document.getElementById("new_password").value) != "undefined") {
120                 if(document.getElementById("new_password").value != '' || document.getElementById("confirm_pwd").value != '') {
121                         if(document.getElementById("new_password").value != document.getElementById("confirm_pwd").value) {
122                                 alert('$err_password_mismatch');
123                                 return false;
124                         }
125                 }
126         }
127                 
128         return true;
129 }
130 </script>
131
132 EOQ;
133
134 return $the_script;
135 }
136
137 function user_get_chooser_js()
138 {
139 $the_script  = <<<EOQ
140
141 <script type="text/javascript" language="Javascript">
142 <!--  to hide script contents from old browsers
143
144 function set_chooser()
145 {
146
147
148
149 var display_tabs_def = '';
150 var hide_tabs_def = '';
151 var remove_tabs_def = '';
152
153 var display_td = document.getElementById('display_tabs_td');
154 var hide_td    = document.getElementById('hide_tabs_td');
155 var remove_td  = document.getElementById('remove_tabs_td');
156
157 var display_ref = display_td.getElementsByTagName('select')[0];
158
159 for(i=0; i < display_ref.options.length ;i++)
160 {
161          display_tabs_def += "display_tabs[]="+display_ref.options[i].value+"&";
162 }
163
164 if(hide_td != null)
165 {
166         var hide_ref = hide_td.getElementsByTagName('select')[0];
167     
168     for(i=0; i < hide_ref.options.length ;i++)
169         {
170          hide_tabs_def += "hide_tabs[]="+hide_ref.options[i].value+"&";
171         }
172 }
173
174 if(remove_td != null)
175 {
176     var remove_ref = remove_td.getElementsByTagName('select')[0];
177     
178     for(i=0; i < remove_ref.options.length ;i++)
179         {
180          remove_tabs_def += "remove_tabs[]="+remove_ref.options[i].value+"&";
181         }
182         
183 }
184
185 document.EditView.display_tabs_def.value = display_tabs_def;
186 document.EditView.hide_tabs_def.value = hide_tabs_def;
187 document.EditView.remove_tabs_def.value = remove_tabs_def;
188
189
190
191 }
192 // end hiding contents from old browsers  -->
193 </script>
194 EOQ;
195
196 return $the_script;
197 }
198
199 function user_get_confsettings_js() {
200   global $mod_strings;
201   global $app_strings;
202
203   $lbl_last_name = $mod_strings['LBL_MAIL_FROMADDRESS'];
204   $err_missing_required_fields = $app_strings['ERR_MISSING_REQUIRED_FIELDS'];
205
206   return <<<EOQ
207
208 <script type="text/javascript" language="Javascript">
209 <!--  to hide script contents from old browsers
210
211 function add_checks(f) {
212   return true;
213 }
214
215 // end hiding contents from old browsers  -->
216 </script>
217
218 EOQ;
219 }
220
221
222
223 ?>