countFiles = 1; function Element( id ) { return document.getElementById( id ); } function validate_fields(type) { if (type == 'create_user') { //UID document.forms[0].uid.value = document.forms[0].uid.value.toLowerCase(); if (document.forms[0].uid.value == ''){ alert(get_lang('LOGIN field is empty') + '.'); return; } else if (document.forms[0].uid.value.length < document.forms[0].minimumSizeLogin.value){ alert(get_lang('LOGIN field must be bigger than') + ' ' + document.forms[0].minimumSizeLogin.value + ' ' + get_lang('characters') + '.'); return; } // Verifica se o delimitador do Cyrus permite ponto (dot.) nas mailboxes; if (document.forms[0].imapDelimiter.value == '/') var reUid = /^([a-zA-Z0-9_\.\-])+$/; else var reUid = /^([a-zA-Z0-9_\-])+$/; if(!reUid.test(document.forms[0].uid.value)){ alert(get_lang('LOGIN field contains characters not allowed') + '.'); return; } //PASSWORD's if (document.forms[0].password1.value == ''){ alert(get_lang('Password field is empty') + '.'); return; } if (document.forms[0].password2.value == ''){ alert(get_lang('re-password field is empty') + '.'); return; } } if (document.forms[0].password1.value != document.forms[0].password2.value){ alert(get_lang('password and re-password are different') + '.'); return; } // Corporative Information if (document.forms[0].corporative_information_employeenumber.value != "") { var re_employeenumber = /^([0-9])+$/; if(!re_employeenumber.test(document.forms[0].corporative_information_employeenumber.value)) { alert(get_lang('EmployeeNumber contains characters not allowed') + '. ' + get_lang('Only numbers are allowed') + '.'); document.forms[0].corporative_information_employeenumber.focus(); return; } } //MAIL document.forms[0].mail.value = document.forms[0].mail.value.toLowerCase(); if (document.forms[0].mail.value == ''){ alert(get_lang('Email field is empty') + '.'); return; } var reEmail = /^([a-zA-Z0-9_\-])+(\.[a-zA-Z0-9_\-]+)*\@([a-zA-Z0-9_\-])+(\.[a-zA-Z0-9_\-]+)*$/; if(!reEmail.test(document.forms[0].mail.value)){ alert(get_lang('Email field is not valid') + '.'); return false; } //FIRSTNAME var reGivenname = /^[a-zA-Z0-9 \-\.]+$/; if(!reGivenname.test(document.forms[0].givenname.value)){ alert(get_lang('First name field contains characters not allowed') + '.'); return false; } else if (document.forms[0].givenname.value == ''){ alert(get_lang('First name field is empty') + '.'); return; } //LASTNAME var reSn = /^[a-zA-Z0-9 \-\.]+$/; if(!reSn.test(document.forms[0].sn.value)){ alert(get_lang('Last name field contains characters not allowed') + '.'); return false; } else if (document.forms[0].sn.value == ''){ alert(get_lang('Last name field is empty') + '.'); return; } //TELEPHONENUMBER if (document.forms[0].telephonenumber.value != '') { reg_tel = /\(\d{2}\)\d{4}-\d{4}$/; if (!reg_tel.exec(document.forms[0].telephonenumber.value)) { alert(get_lang('Phone field is incorrect') + '.'); return; } } //FORWAR ONLY if ((document.forms[0].deliverymode.checked) && (document.forms[0].mailforwardingaddress.value == '')){ alert(get_lang('Forward email is empty') + '.'); return; } // Email Quota if (document.forms[0].mailquota.value == ''){ alert(get_lang('User without email quota') + '.'); return; } //GROUPS if (document.getElementById('ea_select_user_groups').length < 1){ alert(get_lang('User is not in any group') + '.'); return; } //SAMBA if (document.getElementById('tabcontent6').style.display != 'none'){ if ((document.forms[0].sambalogonscript.value == '') && (!document.forms[0].sambalogonscript.disabled)){ alert(get_lang('Logon script is empty') + '.'); return; } if ((document.forms[0].sambahomedirectory.value == '') && (!document.forms[0].sambahomedirectory.disabled)){ alert(get_lang('Users home directory is empty') + '.'); return; } } // Uid, Mail and CPF exist? var attrs_array = new Array(); attrs_array['type'] = type; attrs_array['uid'] = document.forms[0].uid.value; attrs_array['mail'] = document.forms[0].mail.value; attrs_array['cpf'] = document.forms[0].corporative_information_cpf.value; if (document.forms[0].mailalternateaddress.value != '') attrs_array['mailalternateaddress'] = document.forms[0].mailalternateaddress.value; var attributes = admin_connector.serialize(attrs_array); var handler_validate_fields = function(data) { if (!data.status) { alert(data.msg); } else { if ( (data.question) && (!confirm(data.question)) ) { return false; } if (type == 'create_user') { // Turn enabled checkbox on create user. document.getElementById('changepassword').disabled = false; cExecuteForm ("$this.user.create", document.forms[0], handler_create); } else { //Turn enabled all checkboxes and inputs document.getElementById('changepassword').disabled = false; document.getElementById('phpgwaccountstatus').disabled = false; document.getElementById('phpgwaccountvisible').disabled = false; document.getElementById('telephonenumber').disabled = false; document.getElementById('mailforwardingaddress').disabled = false; document.getElementById('mailalternateaddress').disabled = false; document.getElementById('passwd_expired').disabled = false; document.getElementById('accountstatus').disabled = false; document.getElementById('deliverymode').disabled = false; document.getElementById('use_attrs_samba').disabled = false; table_apps = document.getElementById('ea_table_apps'); var inputs = table_apps.getElementsByTagName("input"); for (var i = 0; i < inputs.length; i++) { inputs[i].disabled = false; } cExecuteForm ("$this.user.save", document.forms[0], handler_save); } } } // Needed select all options from select select_user_maillists = document.getElementById('ea_select_user_maillists'); select_user_groups = document.getElementById('ea_select_user_groups'); for(var i=0; i