1 | countFiles = 1; |
---|
2 | function validate_fields(type) |
---|
3 | { |
---|
4 | if (type == 'create_user') |
---|
5 | { |
---|
6 | //UID |
---|
7 | document.forms[0].uid.value = document.forms[0].uid.value.toLowerCase(); |
---|
8 | |
---|
9 | if (document.forms[0].uid.value == ''){ |
---|
10 | alert(get_lang('LOGIN field is empty') + '.'); |
---|
11 | return; |
---|
12 | } |
---|
13 | else if (document.forms[0].uid.value.length < document.forms[0].minimumSizeLogin.value){ |
---|
14 | alert(get_lang('LOGIN field must be bigger than') + ' ' + document.forms[0].minimumSizeLogin.value + ' ' + get_lang('characters') + '.'); |
---|
15 | return; |
---|
16 | } |
---|
17 | |
---|
18 | // Verifica se o delimitador do Cyrus permite ponto (dot.) nas mailboxes; |
---|
19 | if (document.forms[0].imapDelimiter.value == '/') |
---|
20 | var reUid = /^([a-zA-Z0-9_\.\-])+$/; |
---|
21 | else |
---|
22 | var reUid = /^([a-zA-Z0-9_\-])+$/; |
---|
23 | if(!reUid.test(document.forms[0].uid.value)){ |
---|
24 | alert(get_lang('LOGIN field contains characters not allowed') + '.'); |
---|
25 | return; |
---|
26 | } |
---|
27 | |
---|
28 | //PASSWORD's |
---|
29 | if (document.forms[0].password1.value == ''){ |
---|
30 | alert(get_lang('Password field is empty') + '.'); |
---|
31 | return; |
---|
32 | } |
---|
33 | if (document.forms[0].password2.value == ''){ |
---|
34 | alert(get_lang('re-password field is empty') + '.'); |
---|
35 | return; |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | if (document.forms[0].password1.value != document.forms[0].password2.value){ |
---|
40 | alert(get_lang('password and re-password are different') + '.'); |
---|
41 | return; |
---|
42 | } |
---|
43 | |
---|
44 | // Corporative Information |
---|
45 | if (document.forms[0].corporative_information_employeenumber.value != "") |
---|
46 | { |
---|
47 | var re_employeenumber = /^([0-9])+$/; |
---|
48 | |
---|
49 | if(!re_employeenumber.test(document.forms[0].corporative_information_employeenumber.value)) |
---|
50 | { |
---|
51 | alert(get_lang('EmployeeNumber contains characters not allowed') + '. ' + get_lang('Only numbers are allowed') + '.'); |
---|
52 | document.forms[0].corporative_information_employeenumber.focus(); |
---|
53 | return; |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | //MAIL |
---|
58 | document.forms[0].mail.value = document.forms[0].mail.value.toLowerCase(); |
---|
59 | if (document.forms[0].mail.value == ''){ |
---|
60 | alert(get_lang('Email field is empty') + '.'); |
---|
61 | return; |
---|
62 | } |
---|
63 | var reEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; |
---|
64 | if(!reEmail.test(document.forms[0].mail.value)){ |
---|
65 | alert(get_lang('Email field is not valid') + '.'); |
---|
66 | return false; |
---|
67 | } |
---|
68 | |
---|
69 | //FIRSTNAME |
---|
70 | var reGivenname = /^[a-zA-Z0-9 \-\.]+$/; |
---|
71 | if(!reGivenname.test(document.forms[0].givenname.value)){ |
---|
72 | alert(get_lang('First name field contains characters not allowed') + '.'); |
---|
73 | return false; |
---|
74 | } |
---|
75 | else if (document.forms[0].givenname.value == ''){ |
---|
76 | alert(get_lang('First name field is empty') + '.'); |
---|
77 | return; |
---|
78 | } |
---|
79 | |
---|
80 | //LASTNAME |
---|
81 | var reSn = /^[a-zA-Z0-9 \-\.]+$/; |
---|
82 | if(!reSn.test(document.forms[0].sn.value)){ |
---|
83 | alert(get_lang('Last name field contains characters not allowed') + '.'); |
---|
84 | return false; |
---|
85 | } |
---|
86 | else if (document.forms[0].sn.value == ''){ |
---|
87 | alert(get_lang('Last name field is empty') + '.'); |
---|
88 | return; |
---|
89 | } |
---|
90 | |
---|
91 | //TELEPHONENUMBER |
---|
92 | if (document.forms[0].telephonenumber.value != '') |
---|
93 | { |
---|
94 | reg_tel = /\(\d{2}\)\d{4}-\d{4}$/; |
---|
95 | if (!reg_tel.exec(document.forms[0].telephonenumber.value)) |
---|
96 | { |
---|
97 | alert(get_lang('Phone field is incorrect') + '.'); |
---|
98 | return; |
---|
99 | } |
---|
100 | } |
---|
101 | |
---|
102 | //FORWAR ONLY |
---|
103 | if ((document.forms[0].deliverymode.checked) && (document.forms[0].mailforwardingaddress.value == '')){ |
---|
104 | alert(get_lang('Forward email is empty') + '.'); |
---|
105 | return; |
---|
106 | } |
---|
107 | |
---|
108 | // Email Quota |
---|
109 | if (document.forms[0].mailquota.value == ''){ |
---|
110 | alert(get_lang('User without email quota') + '.'); |
---|
111 | return; |
---|
112 | } |
---|
113 | |
---|
114 | //GROUPS |
---|
115 | if (document.getElementById('ea_select_user_groups').length < 1){ |
---|
116 | alert(get_lang('User is not in any group') + '.'); |
---|
117 | return; |
---|
118 | } |
---|
119 | |
---|
120 | //SAMBA |
---|
121 | if (document.getElementById('tabcontent6').style.display != 'none'){ |
---|
122 | if ((document.forms[0].sambalogonscript.value == '') && (!document.forms[0].sambalogonscript.disabled)){ |
---|
123 | alert(get_lang('Logon script is empty') + '.'); |
---|
124 | return; |
---|
125 | } |
---|
126 | if ((document.forms[0].sambahomedirectory.value == '') && (!document.forms[0].sambahomedirectory.disabled)){ |
---|
127 | alert(get_lang('Users home directory is empty') + '.'); |
---|
128 | return; |
---|
129 | } |
---|
130 | } |
---|
131 | |
---|
132 | // Uid, Mail and CPF exist? |
---|
133 | var attrs_array = new Array(); |
---|
134 | attrs_array['type'] = type; |
---|
135 | attrs_array['uid'] = document.forms[0].uid.value; |
---|
136 | attrs_array['mail'] = document.forms[0].mail.value; |
---|
137 | attrs_array['cpf'] = document.forms[0].corporative_information_cpf.value; |
---|
138 | |
---|
139 | if (document.forms[0].mailalternateaddress.value != '') |
---|
140 | attrs_array['mailalternateaddress'] = document.forms[0].mailalternateaddress.value; |
---|
141 | var attributes = connector.serialize(attrs_array); |
---|
142 | |
---|
143 | var handler_validate_fields = function(data) |
---|
144 | { |
---|
145 | if (!data.status) |
---|
146 | { |
---|
147 | alert(data.msg); |
---|
148 | } |
---|
149 | else |
---|
150 | { |
---|
151 | if ( (data.question) && (!confirm(data.question)) ) |
---|
152 | { |
---|
153 | return false; |
---|
154 | } |
---|
155 | |
---|
156 | if (type == 'create_user') |
---|
157 | { |
---|
158 | cExecuteForm ("$this.user.create", document.forms[0], handler_create); |
---|
159 | } |
---|
160 | else |
---|
161 | { |
---|
162 | //Turn enabled all checkboxes and inputs |
---|
163 | document.getElementById('changepassword').disabled = false; |
---|
164 | document.getElementById('phpgwaccountstatus').disabled = false; |
---|
165 | document.getElementById('phpgwaccountvisible').disabled = false; |
---|
166 | document.getElementById('telephonenumber').disabled = false; |
---|
167 | document.getElementById('mailforwardingaddress').disabled = false; |
---|
168 | document.getElementById('mailalternateaddress').disabled = false; |
---|
169 | document.getElementById('passwd_expired').disabled = false; |
---|
170 | document.getElementById('accountstatus').disabled = false; |
---|
171 | document.getElementById('deliverymode').disabled = false; |
---|
172 | document.getElementById('use_attrs_samba').disabled = false; |
---|
173 | |
---|
174 | table_apps = document.getElementById('ea_table_apps'); |
---|
175 | var inputs = table_apps.getElementsByTagName("input"); |
---|
176 | for (var i = 0; i < inputs.length; i++) |
---|
177 | { |
---|
178 | inputs[i].disabled = false; |
---|
179 | } |
---|
180 | cExecuteForm ("$this.user.save", document.forms[0], handler_save); |
---|
181 | } |
---|
182 | } |
---|
183 | } |
---|
184 | |
---|
185 | // Needed select all options from select |
---|
186 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
187 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
188 | for(var i=0; i<select_user_maillists.options.length; i++) |
---|
189 | select_user_maillists.options[i].selected = true; |
---|
190 | for(var i=0; i<select_user_groups.options.length; i++) |
---|
191 | select_user_groups.options[i].selected = true; |
---|
192 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
193 | document.getElementById('uid').disabled = false; //Caso o login seja gerado automático, tirar o disabled. |
---|
194 | cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields); |
---|
195 | } |
---|
196 | |
---|
197 | function generate_login(first_name,second_name) { |
---|
198 | if ((first_name=='') || (second_name=='')) { |
---|
199 | alert(get_lang("You must type the first and the second name before generate the login")); |
---|
200 | return; |
---|
201 | } |
---|
202 | var attrs_array = new Array(); |
---|
203 | attrs_array['first_name'] = first_name; |
---|
204 | attrs_array['second_name'] = second_name; |
---|
205 | var attributes = connector.serialize(attrs_array); |
---|
206 | |
---|
207 | var handler_generate_login = function(data) { |
---|
208 | if(data['status']) { |
---|
209 | document.getElementById('uid').value = data['msg']; |
---|
210 | emailSuggestion_expressoadmin('true','true'); |
---|
211 | document.getElementById("mail").value=document.getElementById("mail1").value; |
---|
212 | } |
---|
213 | else |
---|
214 | alert(data['msg']); |
---|
215 | } |
---|
216 | |
---|
217 | cExecute ('$this.ldap_functions.generate_login&attributes='+attributes, handler_generate_login); |
---|
218 | } |
---|
219 | |
---|
220 | // HANDLER CREATE |
---|
221 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
222 | function handler_create(data) |
---|
223 | { |
---|
224 | return_handler_create(data); |
---|
225 | } |
---|
226 | function return_handler_create(data) |
---|
227 | { |
---|
228 | if (!data.status) |
---|
229 | alert(data.msg); |
---|
230 | else |
---|
231 | alert(get_lang('User successful created') + '.'); |
---|
232 | |
---|
233 | location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users"; |
---|
234 | return; |
---|
235 | } |
---|
236 | |
---|
237 | |
---|
238 | // HANDLER SAVE |
---|
239 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
240 | function handler_save(data) |
---|
241 | { |
---|
242 | return_handler_save(data); |
---|
243 | } |
---|
244 | function return_handler_save(data) |
---|
245 | { |
---|
246 | if (!data.status){ |
---|
247 | alert(data.msg); |
---|
248 | } |
---|
249 | else{ |
---|
250 | alert(get_lang('User successful saved') + '.'); |
---|
251 | } |
---|
252 | location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users"; |
---|
253 | return; |
---|
254 | } |
---|
255 | |
---|
256 | function get_available_groups(context) |
---|
257 | { |
---|
258 | var handler_get_available_groups = function(data) |
---|
259 | { |
---|
260 | select_available_groups = document.getElementById('ea_select_available_groups'); |
---|
261 | |
---|
262 | if ((data) && (data.length > 0)) |
---|
263 | { |
---|
264 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
265 | select_available_groups.innerHTML = '#' + data; |
---|
266 | select_available_groups.outerHTML = select_available_groups.outerHTML; |
---|
267 | select_available_groups_clone = select_available_groups.cloneNode(true); |
---|
268 | document.getElementById('ea_input_searchGroup').value = ''; |
---|
269 | } |
---|
270 | else |
---|
271 | { |
---|
272 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
273 | select_available_groups.innerHTML = '#'; |
---|
274 | select_available_groups.outerHTML = select_available_groups.outerHTML; |
---|
275 | } |
---|
276 | } |
---|
277 | |
---|
278 | cExecute ('$this.ldap_functions.get_available_groups&context='+context, handler_get_available_groups); |
---|
279 | } |
---|
280 | |
---|
281 | function add_user2group() |
---|
282 | { |
---|
283 | select_available_groups = document.getElementById('ea_select_available_groups'); |
---|
284 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
285 | combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); |
---|
286 | |
---|
287 | for (i = 0 ; i < select_available_groups.length ; i++) |
---|
288 | { |
---|
289 | if (select_available_groups.options[i].selected) |
---|
290 | { |
---|
291 | isSelected = false; |
---|
292 | for(var j = 0;j < select_user_groups.options.length; j++) |
---|
293 | { |
---|
294 | if(select_user_groups.options[j].value == select_available_groups.options[i].value) |
---|
295 | { |
---|
296 | isSelected = true; |
---|
297 | break; |
---|
298 | } |
---|
299 | } |
---|
300 | |
---|
301 | if(!isSelected) |
---|
302 | { |
---|
303 | new_option1 = document.createElement('option'); |
---|
304 | new_option1.value =select_available_groups.options[i].value; |
---|
305 | new_option1.text = select_available_groups.options[i].text; |
---|
306 | new_option1.selected = true; |
---|
307 | select_user_groups.options[select_user_groups.options.length] = new_option1; |
---|
308 | |
---|
309 | new_option2 = document.createElement('option'); |
---|
310 | new_option2.value =select_available_groups.options[i].value; |
---|
311 | new_option2.text = select_available_groups.options[i].text; |
---|
312 | combo_primary_user_group.options[combo_primary_user_group.options.length] = new_option2; |
---|
313 | } |
---|
314 | } |
---|
315 | } |
---|
316 | |
---|
317 | for (j =0; j < select_available_groups.options.length; j++) |
---|
318 | select_available_groups.options[j].selected = false; |
---|
319 | } |
---|
320 | |
---|
321 | function remove_user2group() |
---|
322 | { |
---|
323 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
324 | combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); |
---|
325 | |
---|
326 | var x; |
---|
327 | var j=0; |
---|
328 | var to_remove = new Array(); |
---|
329 | |
---|
330 | for(var i = 0;i < select_user_groups.options.length; i++) |
---|
331 | { |
---|
332 | if(select_user_groups.options[i].selected) |
---|
333 | { |
---|
334 | to_remove[j] = select_user_groups.options[i].value; |
---|
335 | j++; |
---|
336 | select_user_groups.options[i--] = null; |
---|
337 | } |
---|
338 | } |
---|
339 | |
---|
340 | for (x in to_remove) |
---|
341 | { |
---|
342 | for(var i=0; i<combo_primary_user_group.options.length; i++) |
---|
343 | { |
---|
344 | if (combo_primary_user_group.options[i].value == to_remove[x]) |
---|
345 | { |
---|
346 | combo_primary_user_group.options[i] = null; |
---|
347 | } |
---|
348 | } |
---|
349 | } |
---|
350 | } |
---|
351 | |
---|
352 | function get_available_maillists(context) |
---|
353 | { |
---|
354 | var handler_get_available_maillists = function(data) |
---|
355 | { |
---|
356 | select_available_maillists = document.getElementById('ea_select_available_maillists'); |
---|
357 | |
---|
358 | if ((data) && (data.length > 0)) |
---|
359 | { |
---|
360 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
361 | select_available_maillists.innerHTML = '#' + data; |
---|
362 | select_available_maillists.outerHTML = select_available_maillists.outerHTML; |
---|
363 | select_available_maillists_clone = select_available_maillists.cloneNode(true); |
---|
364 | document.getElementById('ea_input_searchMailList').value = ''; |
---|
365 | } |
---|
366 | else |
---|
367 | { |
---|
368 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
369 | select_available_maillists.innerHTML = '#'; |
---|
370 | select_available_maillists.outerHTML = select_available_maillists.outerHTML; |
---|
371 | } |
---|
372 | } |
---|
373 | cExecute ('$this.ldap_functions.get_available_maillists&context='+context, handler_get_available_maillists); |
---|
374 | } |
---|
375 | |
---|
376 | function add_user2maillist() |
---|
377 | { |
---|
378 | select_available_maillists = document.getElementById('ea_select_available_maillists'); |
---|
379 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
380 | |
---|
381 | for (i = 0 ; i < select_available_maillists.length ; i++) |
---|
382 | { |
---|
383 | |
---|
384 | if (select_available_maillists.options[i].selected) |
---|
385 | { |
---|
386 | isSelected = false; |
---|
387 | for(var j = 0;j < select_user_maillists.options.length; j++) |
---|
388 | { |
---|
389 | if(select_user_maillists.options[j].value == select_available_maillists.options[i].value) |
---|
390 | { |
---|
391 | isSelected = true; |
---|
392 | break; |
---|
393 | } |
---|
394 | } |
---|
395 | |
---|
396 | if(!isSelected) |
---|
397 | { |
---|
398 | new_option = document.createElement('option'); |
---|
399 | new_option.value =select_available_maillists.options[i].value; |
---|
400 | new_option.text = select_available_maillists.options[i].text; |
---|
401 | new_option.selected = true; |
---|
402 | |
---|
403 | select_user_maillists.options[select_user_maillists.options.length] = new_option; |
---|
404 | } |
---|
405 | } |
---|
406 | } |
---|
407 | |
---|
408 | for (j =0; j < select_available_maillists.options.length; j++) |
---|
409 | select_available_maillists.options[j].selected = false; |
---|
410 | } |
---|
411 | |
---|
412 | function remove_user2maillist() |
---|
413 | { |
---|
414 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
415 | |
---|
416 | for(var i = 0;i < select_user_maillists.options.length; i++) |
---|
417 | if(select_user_maillists.options[i].selected) |
---|
418 | select_user_maillists.options[i--] = null; |
---|
419 | } |
---|
420 | |
---|
421 | function sinc_combos_org(context) |
---|
422 | { |
---|
423 | combo_org_groups = document.getElementById('ea_combo_org_groups'); |
---|
424 | combo_org_maillists = document.getElementById('ea_combo_org_maillists'); |
---|
425 | |
---|
426 | for (i=0; i<combo_org_groups.length; i++) |
---|
427 | { |
---|
428 | if (combo_org_groups.options[i].value == context) |
---|
429 | { |
---|
430 | combo_org_groups.options[i].selected = true; |
---|
431 | combo_org_maillists.options[i].selected = true; |
---|
432 | } |
---|
433 | } |
---|
434 | } |
---|
435 | |
---|
436 | function use_samba_attrs(value) |
---|
437 | { |
---|
438 | if (value) |
---|
439 | { |
---|
440 | if (document.forms[0].sambalogonscript.value == '') |
---|
441 | { |
---|
442 | if (document.forms[0].defaultLogonScript.value == '') |
---|
443 | { |
---|
444 | document.forms[0].sambalogonscript.value = document.forms[0].uid.value + '.bat'; |
---|
445 | } |
---|
446 | else |
---|
447 | { |
---|
448 | document.forms[0].sambalogonscript.value = document.forms[0].defaultLogonScript.value; |
---|
449 | } |
---|
450 | } |
---|
451 | if (document.forms[0].sambahomedirectory.value == '') |
---|
452 | { |
---|
453 | document.forms[0].sambahomedirectory.value = '/home/'+document.forms[0].uid.value+'/'; |
---|
454 | } |
---|
455 | } |
---|
456 | |
---|
457 | if (!document.forms[0].use_attrs_samba.disabled) |
---|
458 | { |
---|
459 | document.forms[0].sambaacctflags.disabled = !value; |
---|
460 | document.forms[0].sambadomain.disabled = !value; |
---|
461 | document.forms[0].sambalogonscript.disabled = !value; |
---|
462 | document.forms[0].sambahomedirectory.disabled = !value; |
---|
463 | } |
---|
464 | } |
---|
465 | |
---|
466 | function set_user_default_password() |
---|
467 | { |
---|
468 | var handler_set_user_default_password = function(data) |
---|
469 | { |
---|
470 | if (!data.status) |
---|
471 | alert(data.msg); |
---|
472 | else |
---|
473 | alert(get_lang('Default password successful saved') + '.'); |
---|
474 | return; |
---|
475 | } |
---|
476 | cExecute ('$this.user.set_user_default_password&uid='+document.forms[0].uid.value, handler_set_user_default_password); |
---|
477 | } |
---|
478 | |
---|
479 | function return_user_password() |
---|
480 | { |
---|
481 | var handler_return_user_password = function(data) |
---|
482 | { |
---|
483 | if (!data.status) |
---|
484 | alert(data.msg); |
---|
485 | else |
---|
486 | alert(get_lang('Users password successful returned') + '.'); |
---|
487 | return; |
---|
488 | } |
---|
489 | cExecute ('$this.user.return_user_password&uid='+document.forms[0].uid.value, handler_return_user_password); |
---|
490 | } |
---|
491 | |
---|
492 | function delete_user(uid, uidnumber) |
---|
493 | { |
---|
494 | if (confirm(get_lang("Do you really want delete the user") + " " + uid + "?")) |
---|
495 | { |
---|
496 | var handler_delete_user = function(data) |
---|
497 | { |
---|
498 | if (!data.status) |
---|
499 | alert(data.msg); |
---|
500 | else |
---|
501 | alert(get_lang('User successful deleted') + '.'); |
---|
502 | |
---|
503 | location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users"; |
---|
504 | return; |
---|
505 | } |
---|
506 | cExecute ('$this.user.delete&uidnumber='+uidnumber+'&uid='+uid, handler_delete_user); |
---|
507 | } |
---|
508 | } |
---|
509 | |
---|
510 | function rename_user(uid, uidnumber) |
---|
511 | { |
---|
512 | if (document.getElementById('accounts_form_imapDelimiter').value == '/') |
---|
513 | var reUid = /^([a-zA-Z0-9_\.\-])+$/; |
---|
514 | else |
---|
515 | var reUid = /^([a-zA-Z0-9_\-])+$/; |
---|
516 | |
---|
517 | new_uid = prompt(get_lang('Rename users login from') + ': ' + uid + " " + get_lang("to") + ': ', uid); |
---|
518 | |
---|
519 | if(!reUid.test(new_uid)){ |
---|
520 | alert(get_lang('LOGIN field contains characters not allowed') + '.'); |
---|
521 | document.forms[0].account_lid.focus(); |
---|
522 | return; |
---|
523 | } |
---|
524 | |
---|
525 | if ((new_uid) && (new_uid != uid)) |
---|
526 | { |
---|
527 | var handler_validate_fields = function(data) |
---|
528 | { |
---|
529 | if (!data.status) |
---|
530 | alert(data.msg); |
---|
531 | else |
---|
532 | cExecute ('$this.user.rename&uid='+uid+'&new_uid='+new_uid, handler_rename); |
---|
533 | |
---|
534 | return; |
---|
535 | } |
---|
536 | |
---|
537 | // New uid exist? |
---|
538 | attrs_array = new Array(); |
---|
539 | attrs_array['type'] = 'rename_user'; |
---|
540 | attrs_array['uid'] = new_uid; |
---|
541 | attributes = connector.serialize(attrs_array); |
---|
542 | |
---|
543 | cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields); |
---|
544 | } |
---|
545 | } |
---|
546 | |
---|
547 | // HANDLER RENAME |
---|
548 | function handler_rename(data) |
---|
549 | { |
---|
550 | if (!data.status) |
---|
551 | alert(data.msg); |
---|
552 | else{ |
---|
553 | alert(get_lang('User login successful renamed') + "\n" + data.exec_return); |
---|
554 | location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users"; |
---|
555 | } |
---|
556 | return; |
---|
557 | |
---|
558 | } |
---|
559 | |
---|
560 | |
---|
561 | // Variaveis Locais |
---|
562 | var finderTimeout_maillist = ''; |
---|
563 | |
---|
564 | // Funcoes Find MailList |
---|
565 | function optionFinderTimeout_maillist(obj) |
---|
566 | { |
---|
567 | clearTimeout(finderTimeout_maillist); |
---|
568 | var oWait = document.getElementById("ea_span_searching_maillist"); |
---|
569 | oWait.innerHTML = get_lang('Searching') + '...'; |
---|
570 | finderTimeout_maillist = setTimeout("optionFinder_maillist('"+obj.id+"')",500); |
---|
571 | } |
---|
572 | function optionFinder_maillist(id) { |
---|
573 | var oWait = document.getElementById("ea_span_searching_maillist"); |
---|
574 | var oText = document.getElementById(id); |
---|
575 | |
---|
576 | //Limpa todo o select |
---|
577 | for(var i = 0;i < select_available_maillists.options.length; i++) |
---|
578 | select_available_maillists.options[i--] = null; |
---|
579 | |
---|
580 | var RegExp_name = new RegExp(oText.value, "i"); |
---|
581 | |
---|
582 | //Inclui as listas começando com a pesquisa |
---|
583 | for(i = 0; i < select_available_maillists_clone.length; i++){ |
---|
584 | if (RegExp_name.test(select_available_maillists_clone[i].text)) |
---|
585 | { |
---|
586 | sel = select_available_maillists.options; |
---|
587 | option = new Option(select_available_maillists_clone[i].text,select_available_maillists_clone[i].value); |
---|
588 | sel[sel.length] = option; |
---|
589 | } |
---|
590 | } |
---|
591 | oWait.innerHTML = ' '; |
---|
592 | } |
---|
593 | |
---|
594 | // Variaveis Locais |
---|
595 | var finderTimeout_group = ''; |
---|
596 | |
---|
597 | |
---|
598 | // Funcoes Find Group |
---|
599 | function optionFinderTimeout_group(obj) |
---|
600 | { |
---|
601 | clearTimeout(finderTimeout_group); |
---|
602 | var oWait = document.getElementById("ea_span_searching_group"); |
---|
603 | oWait.innerHTML = get_lang('Searching') + '...'; |
---|
604 | finderTimeout_group = setTimeout("optionFinder_group('"+obj.id+"')",500); |
---|
605 | } |
---|
606 | function optionFinder_group(id) { |
---|
607 | var oWait = document.getElementById("ea_span_searching_group"); |
---|
608 | var oText = document.getElementById(id); |
---|
609 | |
---|
610 | //Limpa todo o select |
---|
611 | for(var i = 0;i < select_available_groups.options.length; i++) |
---|
612 | select_available_groups.options[i--] = null; |
---|
613 | |
---|
614 | var RegExp_name = new RegExp(oText.value, "i"); |
---|
615 | |
---|
616 | //Inclui as listas começando com a pesquisa |
---|
617 | for(i = 0; i < select_available_groups_clone.length; i++){ |
---|
618 | if (RegExp_name.test(select_available_groups_clone[i].text)) |
---|
619 | { |
---|
620 | sel = select_available_groups.options; |
---|
621 | option = new Option(select_available_groups_clone[i].text,select_available_groups_clone[i].value); |
---|
622 | sel[sel.length] = option; |
---|
623 | } |
---|
624 | } |
---|
625 | oWait.innerHTML = ' '; |
---|
626 | } |
---|
627 | |
---|
628 | function get_available_sambadomains(context, type) |
---|
629 | { |
---|
630 | if ((type == 'create_user') && (document.getElementById('tabcontent7').style.display != 'none')) |
---|
631 | { |
---|
632 | var handler_get_available_sambadomains = function(data) |
---|
633 | { |
---|
634 | document.forms[0].use_attrs_samba.checked = data.status; |
---|
635 | use_samba_attrs(data.status); |
---|
636 | |
---|
637 | if (data.status) |
---|
638 | { |
---|
639 | combo_sambadomains = document.getElementById('ea_combo_sambadomains'); |
---|
640 | for (i=0; i<data.sambaDomains.length; i++) |
---|
641 | { |
---|
642 | for (j=0; j<combo_sambadomains.length; j++) |
---|
643 | { |
---|
644 | if (combo_sambadomains.options[j].text == data.sambaDomains[i]) |
---|
645 | { |
---|
646 | combo_sambadomains.options[j].selected = true; |
---|
647 | break; |
---|
648 | } |
---|
649 | } |
---|
650 | } |
---|
651 | |
---|
652 | } |
---|
653 | } |
---|
654 | |
---|
655 | cExecute ('$this.ldap_functions.exist_sambadomains_in_context&context='+context, handler_get_available_sambadomains); |
---|
656 | } |
---|
657 | } |
---|
658 | |
---|
659 | function empty_inbox(uid) |
---|
660 | { |
---|
661 | var action = get_lang('Cleanned user mailbox'); |
---|
662 | var handler_write_log = function(){} |
---|
663 | var handler_empty_inbox = function(data) |
---|
664 | { |
---|
665 | if (!data.status) |
---|
666 | alert(data.msg); |
---|
667 | else{ |
---|
668 | cExecute ('$this.user.write_log_from_ajax&_action='+action+'&userinfo='+uid, handler_write_log); |
---|
669 | alert(get_lang('Emptied ') + data.inbox_size + ' ' + get_lang('MB from user inbox')); |
---|
670 | document.getElementById('mailquota_used').value = data.mailquota_used; |
---|
671 | } |
---|
672 | } |
---|
673 | cExecute ('$this.imap_functions.empty_inbox&uid='+uid, handler_empty_inbox); |
---|
674 | } |
---|
675 | |
---|
676 | function validarCPF(cpf) |
---|
677 | { |
---|
678 | if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || |
---|
679 | cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || |
---|
680 | cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || |
---|
681 | cpf == "88888888888" || cpf == "99999999999"){ |
---|
682 | return false; |
---|
683 | } |
---|
684 | |
---|
685 | soma = 0; |
---|
686 | for(i = 0; i < 9; i++) |
---|
687 | soma += parseInt(cpf.charAt(i)) * (10 - i); |
---|
688 | resto = 11 - (soma % 11); |
---|
689 | if(resto == 10 || resto == 11) |
---|
690 | resto = 0; |
---|
691 | if(resto != parseInt(cpf.charAt(9))) |
---|
692 | { |
---|
693 | return false; |
---|
694 | } |
---|
695 | |
---|
696 | soma = 0; |
---|
697 | for(i = 0; i < 10; i ++) |
---|
698 | soma += parseInt(cpf.charAt(i)) * (11 - i); |
---|
699 | resto = 11 - (soma % 11); |
---|
700 | if(resto == 10 || resto == 11) |
---|
701 | resto = 0; |
---|
702 | if(resto != parseInt(cpf.charAt(10))){ |
---|
703 | return false; |
---|
704 | } |
---|
705 | return true; |
---|
706 | } |
---|
707 | |
---|
708 | function search_organization(key, element) |
---|
709 | { |
---|
710 | var organizations = document.getElementById(element); |
---|
711 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
712 | |
---|
713 | for(i = 0; i < organizations.length; i++) |
---|
714 | { |
---|
715 | if (RegExp_org.test(organizations[i].text)) |
---|
716 | { |
---|
717 | organizations[i].selected = true; |
---|
718 | return; |
---|
719 | } |
---|
720 | } |
---|
721 | } |
---|
722 | |
---|
723 | function add_input_mailalternateaddress() |
---|
724 | { |
---|
725 | var input = document.createElement("INPUT"); |
---|
726 | input.size = 30; |
---|
727 | input.name = "mailalternateaddress[]"; |
---|
728 | input.setAttribute("autocomplete","off"); |
---|
729 | document.getElementById("td_input_mailalternateaddress").appendChild(document.createElement("br")); |
---|
730 | document.getElementById("td_input_mailalternateaddress").appendChild(input); |
---|
731 | } |
---|
732 | |
---|
733 | function add_input_mailforwardingaddress() |
---|
734 | { |
---|
735 | var input = document.createElement("INPUT"); |
---|
736 | input.size = 30; |
---|
737 | input.name = "mailforwardingaddress[]"; |
---|
738 | input.setAttribute("autocomplete","off"); |
---|
739 | document.getElementById("td_input_mailforwardingaddress").appendChild(document.createElement("br")); |
---|
740 | document.getElementById("td_input_mailforwardingaddress").appendChild(input); |
---|
741 | } |
---|