]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/modules/Users/User.js
Release 6.4.0
[Github/sugarcrm.git] / jssource / src_files / modules / Users / User.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
36
37
38 function clearInboundSettings() {
39         var url = document.getElementById('server_url');
40         var user = document.getElementById('email_user');
41         var prot = document.getElementById('protocol');
42         var pass = document.getElementById('email_password');
43         var port = document.getElementById('port');
44         var inbox = document.getElementById('mailbox');
45         
46         url.value = '';
47         user.value ='';
48         pass.value = '';
49         port.value = '';
50         inbox.value = '';
51         
52         for(i=0; i<prot.options.length; i++) {
53                 if(prot.options[i].value == '') {
54                         prot.options[i].selected = true;
55                 }
56         }
57 }
58
59 function checkInboundEmailSettings() {
60         var url = document.getElementById('server_url');
61         var user = document.getElementById('email_user');
62         var prot = document.getElementById('protocol');
63         var pass = document.getElementById('email_password');
64         var port = document.getElementById('port');
65         var inbox = document.getElementById('mailbox');
66         var doCheck = false;
67         var IEAlert = SUGAR.language.get('Users', 'ERR_IE_MISSING_REQUIRED');
68         
69         if(url.value != '') {
70                 doCheck = true;
71         } else if(user.value != '') {
72                 doCheck = true;
73         } else if(prot.value != '') {
74                 doCheck = true;
75         } else if(pass.value != '') {
76                 doCheck = true;
77         } else if(port.value != '') {
78                 doCheck = true;
79         }
80         /* else if(inbox.value != '') {
81                 doCheck = true;
82         }*/
83
84         if(doCheck == true) {
85                 if(url.value == '' || url.value == 'undefined') {
86                         alert(IEAlert);
87                         return false;
88                 } else if(user.value == '' || user.value == 'undefined') {
89                         alert(IEAlert);
90                         return false;
91                 } else if(prot.value == '' || prot.value == 'undefined') {
92                         alert(IEAlert);
93                         return false;
94                 } else if(pass.value == '' || pass.value == 'undefined') {
95                         alert(IEAlert);
96                         return false;
97                 } else if(port.value == '' || port.value == 'undefined') {
98                         alert(IEAlert);
99                         return false;
100                 } else if(inbox.value == '' || inbox.value == 'undefined') {
101                         alert(IEAlert);
102                         return false;
103                 }
104         }
105         
106         return true;
107 }
108
109
110 function show_main() {
111         var basic = document.getElementById('basic'); basic.style.display = "";
112         var settings = document.getElementById('settings'); settings.style.display = "";
113         var info = document.getElementById('information'); info.style.display = "";
114         var address = document.getElementById('address'); address.style.display = "";
115         var calendar_options = document.getElementById('calendar_options'); calendar_options.style.display = "";
116         var edit_tabs = document.getElementById('edit_tabs'); edit_tabs.style.display = "";
117         
118         var email_options = document.getElementById('email_options'); email_options.style.display = 'none';
119         var email_inbound = document.getElementById('email_inbound'); email_inbound.style.display = 'none';
120 }
121
122 function show_email() {
123         var basic = document.getElementById('basic'); basic.style.display = "none";
124         var settings = document.getElementById('settings'); settings.style.display = "none";
125         var info = document.getElementById('information'); info.style.display = "none";
126         var address = document.getElementById('address'); address.style.display = "none";
127         var calendar_options = document.getElementById('calendar_options'); calendar_options.style.display = "none";
128         var edit_tabs = document.getElementById('edit_tabs'); edit_tabs.style.display = "none";
129         
130         var email_options = document.getElementById('email_options'); email_options.style.display = "";
131         var email_inbound = document.getElementById('email_inbound'); email_inbound.style.display = "";
132 }
133
134
135 function enable_change_password_button() {
136         var butt = document.getElementById('change_password_button');
137         if(document.EditView.record.value != "" && document.EditView.record.value != 'undefined') {
138                 butt.style.display = '';
139         }
140 }
141
142 function refresh_signature_list(signature_id, signature_name) {
143         var field=document.getElementById('signature_id');
144         var bfound=0;
145         for (var i=0; i < field.options.length; i++) {
146                         if (field.options[i].value == signature_id) {
147                                 if (field.options[i].selected==false) {
148                                         field.options[i].selected=true;
149                                 }
150                                 bfound=1;
151                         }
152         }
153         //add item to selection list.
154         if (bfound == 0) {
155                 var newElement=document.createElement('option');
156                 newElement.text=signature_name;
157                 newElement.value=signature_id;
158                 field.options.add(newElement);
159                 newElement.selected=true;
160         }       
161
162         //enable the edit button.
163         var field1=document.getElementById('edit_sig');
164         field1.style.visibility="visible";
165 }
166
167 function setSigEditButtonVisibility() {
168         var field = document.getElementById('signature_id');
169         var editButt = document.getElementById('edit_sig');
170         if(field.value != '') {
171                 editButt.style.visibility = "visible";
172         } else {
173                 editButt.style.visibility = "hidden";
174         } 
175 }
176
177 function open_email_signature_form(record, the_user_id) {
178         URL="index.php?module=Users&action=Popup";
179         if(record != "") {
180                 URL += "&record="+record;
181         }
182         if(the_user_id != "") {
183                 URL += "&the_user_id="+the_user_id;
184         }
185         windowName = 'email_signature';
186         windowFeatures = 'width=800' + ',height=600' + ',resizable=1,scrollbars=1';
187
188         win = window.open(URL, windowName, windowFeatures);
189         if(window.focus) {
190                 // put the focus on the popup if the browser supports the focus() method
191                 win.focus();
192         }
193 }
194
195 function setDefaultSigId(id) {
196         var checkbox = document.getElementById("signature_default");
197         var default_sig = document.getElementById("signatureDefault");
198         
199         if(checkbox.checked) {
200                 default_sig.value = id;
201         } else {
202                 default_sig.value = "";
203         }
204 }