countFiles = 1; 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('repassword field is empty') + '.'); return; } } if (document.forms[0].password1.value != document.forms[0].password2.value){ alert(get_lang('password and repassword 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 0)) { // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. select_available_groups.innerHTML = '#' + data; select_available_groups.outerHTML = select_available_groups.outerHTML; select_available_groups_clone = select_available_groups.cloneNode(true); document.getElementById('ea_input_searchGroup').value = ''; } else { // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. select_available_groups.innerHTML = '#'; select_available_groups.outerHTML = select_available_groups.outerHTML; } } cExecute ('$this.ldap_functions.get_available_groups&context='+context, handler_get_available_groups); } function add_user2group() { select_available_groups = document.getElementById('ea_select_available_groups'); select_user_groups = document.getElementById('ea_select_user_groups'); combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); for (i = 0 ; i < select_available_groups.length ; i++) { if (select_available_groups.options[i].selected) { isSelected = false; for(var j = 0;j < select_user_groups.options.length; j++) { if(select_user_groups.options[j].value == select_available_groups.options[i].value) { isSelected = true; break; } } if(!isSelected) { new_option1 = document.createElement('option'); new_option1.value =select_available_groups.options[i].value; new_option1.text = select_available_groups.options[i].text; new_option1.selected = true; select_user_groups.options[select_user_groups.options.length] = new_option1; new_option2 = document.createElement('option'); new_option2.value =select_available_groups.options[i].value; new_option2.text = select_available_groups.options[i].text; combo_primary_user_group.options[combo_primary_user_group.options.length] = new_option2; } } } for (j =0; j < select_available_groups.options.length; j++) select_available_groups.options[j].selected = false; } function remove_user2group() { select_user_groups = document.getElementById('ea_select_user_groups'); combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); var x; var j=0; var to_remove = new Array(); for(var i = 0;i < select_user_groups.options.length; i++) { if(select_user_groups.options[i].selected) { to_remove[j] = select_user_groups.options[i].value; j++; select_user_groups.options[i--] = null; } } for (x in to_remove) { for(var i=0; i 0)) { // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. select_available_maillists.innerHTML = '#' + data; select_available_maillists.outerHTML = select_available_maillists.outerHTML; select_available_maillists_clone = select_available_maillists.cloneNode(true); document.getElementById('ea_input_searchMailList').value = ''; } else { // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. select_available_maillists.innerHTML = '#'; select_available_maillists.outerHTML = select_available_maillists.outerHTML; } } cExecute ('$this.ldap_functions.get_available_maillists&context='+context, handler_get_available_maillists); } function add_user2maillist() { select_available_maillists = document.getElementById('ea_select_available_maillists'); select_user_maillists = document.getElementById('ea_select_user_maillists'); for (i = 0 ; i < select_available_maillists.length ; i++) { if (select_available_maillists.options[i].selected) { isSelected = false; for(var j = 0;j < select_user_maillists.options.length; j++) { if(select_user_maillists.options[j].value == select_available_maillists.options[i].value) { isSelected = true; break; } } if(!isSelected) { new_option = document.createElement('option'); new_option.value =select_available_maillists.options[i].value; new_option.text = select_available_maillists.options[i].text; new_option.selected = true; select_user_maillists.options[select_user_maillists.options.length] = new_option; } } } for (j =0; j < select_available_maillists.options.length; j++) select_available_maillists.options[j].selected = false; } function remove_user2maillist() { select_user_maillists = document.getElementById('ea_select_user_maillists'); for(var i = 0;i < select_user_maillists.options.length; i++) if(select_user_maillists.options[i].selected) select_user_maillists.options[i--] = null; } function sinc_combos_org(context) { combo_org_groups = document.getElementById('ea_combo_org_groups'); combo_org_maillists = document.getElementById('ea_combo_org_maillists'); for (i=0; i