source: branches/2.0/expressoAdmin1_2/js/jscode/users.js @ 2861

Revision 2861, 22.1 KB checked in by niltonneto, 14 years ago (diff)

Ticket #1090 - Correção de falha não validada no ticket #1052.

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