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