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