source: trunk/expressoAdmin1_2/js/jscode/users.js @ 2892

Revision 2892, 23.1 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1058 - Corrigindo problema na criação de usuários.

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