[903] | 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 | |
---|
| 9 | if (document.forms[0].uid.value == ''){ |
---|
| 10 | alert('Campo Login está vazio.'); |
---|
| 11 | return; |
---|
| 12 | } |
---|
| 13 | else |
---|
| 14 | { |
---|
| 15 | if (document.forms[0].uid.value.length < document.forms[0].minimumSizeLogin.value) |
---|
| 16 | { |
---|
| 17 | alert('Campo Login deve ter mais que '+document.forms[0].minimumSizeLogin.value+' caracteres.'); |
---|
| 18 | return; |
---|
| 19 | } |
---|
| 20 | else |
---|
| 21 | { |
---|
| 22 | var re_cpf = /^([0-9])+$/; |
---|
| 23 | if ((document.forms[0].uid.value.length == 11)&&(re_cpf.test(document.forms[0].uid.value))&&(!validarCPF(document.forms[0].uid.value))) |
---|
| 24 | { |
---|
| 25 | alert('O CPF do login está errado.'); |
---|
| 26 | return; |
---|
| 27 | } |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | // Verifica se o delimitador do Cyrus permite ponto (dot.) nas mailboxes; |
---|
| 31 | if (document.forms[0].imapDelimiter.value == '/') |
---|
| 32 | var reUid = /^([a-zA-Z0-9_\.\-])+$/; |
---|
| 33 | else |
---|
| 34 | var reUid = /^([a-zA-Z0-9_\-])+$/; |
---|
| 35 | if(!reUid.test(document.forms[0].uid.value)){ |
---|
| 36 | alert('Campo Login contém caracteres não permitidos.'); |
---|
| 37 | document.forms[0].account_lid.focus(); |
---|
| 38 | return; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | //PASSWORD's |
---|
| 42 | if (document.forms[0].password1.value == ''){ |
---|
| 43 | alert('Campo Senha está vazio.'); |
---|
| 44 | return; |
---|
| 45 | } |
---|
| 46 | if (document.forms[0].password2.value == ''){ |
---|
| 47 | alert('Campo Re-Senha está vazio.'); |
---|
| 48 | return; |
---|
| 49 | } |
---|
| 50 | } |
---|
| 51 | if (document.forms[0].password1.value != document.forms[0].password2.value){ |
---|
| 52 | alert('Campo Senha e Re-Senha são diferentes.'); |
---|
| 53 | return; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | // Corporative Information |
---|
| 57 | if (document.forms[0].corporative_information_employeenumber.value != "") |
---|
| 58 | { |
---|
| 59 | var re_employeenumber = /^([0-9])+$/; |
---|
| 60 | |
---|
| 61 | if(!re_employeenumber.test(document.forms[0].corporative_information_employeenumber.value)) |
---|
| 62 | { |
---|
| 63 | alert('Somente números são permitidos no campo Matrícula.'); |
---|
| 64 | document.forms[0].corporative_information_employeenumber.focus(); |
---|
| 65 | return; |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | if (document.forms[0].corporative_information_cpf.value != "") |
---|
| 70 | { |
---|
| 71 | var re_cpf = /^([0-9])+$/; |
---|
| 72 | |
---|
| 73 | if(!re_cpf.test(document.forms[0].corporative_information_cpf.value)) |
---|
| 74 | { |
---|
| 75 | alert('Somente números são permitidos no campo CPF.'); |
---|
| 76 | document.forms[0].corporative_information_employeenumber.focus(); |
---|
| 77 | return; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | if (! validarCPF(document.forms[0].corporative_information_cpf.value) ) |
---|
| 81 | { |
---|
| 82 | alert("Campo CPF inválido."); |
---|
| 83 | document.forms[0].corporative_information_cpf.focus(); |
---|
| 84 | return; |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | //MAIL |
---|
| 90 | document.forms[0].mail.value = document.forms[0].mail.value.toLowerCase(); |
---|
| 91 | if (document.forms[0].mail.value == ''){ |
---|
| 92 | alert('Campo E-mail está vazio.'); |
---|
| 93 | return; |
---|
| 94 | } |
---|
| 95 | var reEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; |
---|
| 96 | if(!reEmail.test(document.forms[0].mail.value)){ |
---|
| 97 | alert("Campo E-mail não é válido."); |
---|
| 98 | return false; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | //FIRSTNAME |
---|
| 102 | var reGivenname = /^[a-zA-Z0-9 \-\.]+$/; |
---|
| 103 | if(!reGivenname.test(document.forms[0].givenname.value)){ |
---|
| 104 | alert('Primeiro Nome contém caracteres inválidos.'); |
---|
| 105 | return false; |
---|
| 106 | } |
---|
| 107 | else if (document.forms[0].givenname.value == ''){ |
---|
| 108 | alert('Campo Primeiro Nome está vazio.'); |
---|
| 109 | return; |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | //LASTNAME |
---|
| 113 | var reSn = /^[a-zA-Z0-9 \-\.]+$/; |
---|
| 114 | if(!reSn.test(document.forms[0].sn.value)){ |
---|
| 115 | alert('Último Nome contém caracteres inválidos.'); |
---|
| 116 | return false; |
---|
| 117 | } |
---|
| 118 | else if (document.forms[0].sn.value == ''){ |
---|
| 119 | alert('Campo Último Nome está vazio.'); |
---|
| 120 | return; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | //TELEPHONENUMBER |
---|
| 124 | if (document.forms[0].corporative_information_telephonenumber.value != '') |
---|
| 125 | { |
---|
| 126 | reg_tel = /\(\d{2}\)\d{4}-\d{4}$/; |
---|
| 127 | if (!reg_tel.exec(document.forms[0].corporative_information_telephonenumber.value)) |
---|
| 128 | { |
---|
| 129 | alert('Campo Telefone incorreto.'); |
---|
| 130 | return; |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | //FORWAR ONLY |
---|
| 135 | if ((document.forms[0].deliverymode.checked) && (document.forms[0].mailforwardingaddress.value == '')){ |
---|
| 136 | alert('Campo E-mail de Encaminhamento está vazio.'); |
---|
| 137 | return; |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | // Email Quota |
---|
| 141 | if (document.forms[0].mailquota.value == ''){ |
---|
| 142 | alert('Usuário sem Cota.'); |
---|
| 143 | return; |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | //GROUPS |
---|
| 147 | if (document.getElementById('ea_select_user_groups').length < 1){ |
---|
| 148 | add_defaultGroup(); |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | //SAMBA |
---|
| 152 | if (document.getElementById('tabcontent6').style.display != 'none'){ |
---|
| 153 | if ((document.forms[0].sambalogonscript.value == '') && (!document.forms[0].sambalogonscript.disabled)){ |
---|
| 154 | alert('Script de logon do usuário está vazio.'); |
---|
| 155 | return; |
---|
| 156 | } |
---|
| 157 | if ((document.forms[0].sambahomedirectory.value == '') && (!document.forms[0].sambahomedirectory.disabled)){ |
---|
| 158 | alert('Diretório Home do usuário está vazio.'); |
---|
| 159 | return; |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | // Uid & Mail exist? |
---|
| 164 | var attrs_array = new Array(); |
---|
| 165 | attrs_array['type'] = type; |
---|
| 166 | attrs_array['uid'] = document.forms[0].uid.value; |
---|
| 167 | attrs_array['mail'] = document.forms[0].mail.value; |
---|
| 168 | if (document.forms[0].mailalternateaddress.value != '') |
---|
| 169 | attrs_array['mailalternateaddress'] = document.forms[0].mailalternateaddress.value; |
---|
| 170 | var attributes = connector.serialize(attrs_array); |
---|
| 171 | |
---|
| 172 | var handler_validate_fields = function(data) |
---|
| 173 | { |
---|
| 174 | if (!data.status) |
---|
| 175 | alert(data.msg); |
---|
| 176 | else |
---|
| 177 | { |
---|
| 178 | if (type == 'create_user') |
---|
| 179 | { |
---|
| 180 | cExecuteForm ("$this.user.create", document.forms[0], handler_create); |
---|
| 181 | } |
---|
| 182 | else |
---|
| 183 | { |
---|
| 184 | //Turn enabled all checkboxes and inputs |
---|
| 185 | document.getElementById('changepassword').disabled = false; |
---|
| 186 | document.getElementById('phpgwaccountstatus').disabled = false; |
---|
| 187 | document.getElementById('phpgwaccountvisible').disabled = false; |
---|
| 188 | document.getElementById('corporative_information_telephonenumber').disabled = false; |
---|
| 189 | document.getElementById('mailforwardingaddress').disabled = false; |
---|
| 190 | document.getElementById('mailalternateaddress').disabled = false; |
---|
| 191 | document.getElementById('accountstatus').disabled = false; |
---|
| 192 | document.getElementById('deliverymode').disabled = false; |
---|
| 193 | document.getElementById('use_attrs_samba').disabled = false; |
---|
| 194 | |
---|
| 195 | table_apps = document.getElementById('ea_table_apps'); |
---|
| 196 | var inputs = table_apps.getElementsByTagName("input"); |
---|
| 197 | for (var i = 0; i < inputs.length; i++) |
---|
| 198 | { |
---|
| 199 | inputs[i].disabled = false; |
---|
| 200 | } |
---|
| 201 | cExecuteForm ("$this.user.save", document.forms[0], handler_save); |
---|
| 202 | } |
---|
| 203 | } |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | // Needed select all options from select |
---|
| 207 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
| 208 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
| 209 | for(var i=0; i<select_user_maillists.options.length; i++) |
---|
| 210 | select_user_maillists.options[i].selected = true; |
---|
| 211 | for(var i=0; i<select_user_groups.options.length; i++) |
---|
| 212 | select_user_groups.options[i].selected = true; |
---|
| 213 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
| 214 | |
---|
| 215 | cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | // HANDLER CREATE |
---|
| 219 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 220 | function handler_create(data) |
---|
| 221 | { |
---|
| 222 | return_handler_create(data); |
---|
| 223 | } |
---|
| 224 | function return_handler_create(data) |
---|
| 225 | { |
---|
| 226 | if (!data.status) |
---|
| 227 | alert(data.msg); |
---|
| 228 | else |
---|
| 229 | alert('Usuário criado com êxito.'); |
---|
| 230 | |
---|
| 231 | location.href="./index.php?menuaction=expressoAdminSerpro.uiaccounts.list_users"; |
---|
| 232 | return; |
---|
| 233 | } |
---|
| 234 | |
---|
| 235 | |
---|
| 236 | // HANDLER SAVE |
---|
| 237 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 238 | function handler_save(data) |
---|
| 239 | { |
---|
| 240 | return_handler_save(data); |
---|
| 241 | } |
---|
| 242 | function return_handler_save(data) |
---|
| 243 | { |
---|
| 244 | if (!data.status){ |
---|
| 245 | alert(data.msg); |
---|
| 246 | } |
---|
| 247 | else{ |
---|
| 248 | alert('Usuário salvo com êxito.'); |
---|
| 249 | } |
---|
| 250 | location.href="./index.php?menuaction=expressoAdminSerpro.uiaccounts.list_users"; |
---|
| 251 | return; |
---|
| 252 | } |
---|
| 253 | |
---|
| 254 | function get_available_groups(context) |
---|
| 255 | { |
---|
| 256 | var handler_get_available_groups = function(data) |
---|
| 257 | { |
---|
| 258 | select_available_groups = document.getElementById('ea_select_available_groups'); |
---|
| 259 | |
---|
| 260 | if ((data) && (data.length > 0)) |
---|
| 261 | { |
---|
| 262 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 263 | select_available_groups.innerHTML = '#' + data; |
---|
| 264 | select_available_groups.outerHTML = select_available_groups.outerHTML; |
---|
| 265 | select_available_groups_clone = select_available_groups.cloneNode(true); |
---|
| 266 | document.getElementById('ea_input_searchGroup').value = ''; |
---|
| 267 | } |
---|
| 268 | else |
---|
| 269 | { |
---|
| 270 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 271 | select_available_groups.innerHTML = '#'; |
---|
| 272 | select_available_groups.outerHTML = select_available_groups.outerHTML; |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | cExecute ('$this.ldap_functions.get_available_groups&context='+context, handler_get_available_groups); |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | function add_user2group() |
---|
| 280 | { |
---|
| 281 | select_available_groups = document.getElementById('ea_select_available_groups'); |
---|
| 282 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
| 283 | combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); |
---|
| 284 | |
---|
| 285 | for (i = 0 ; i < select_available_groups.length ; i++) |
---|
| 286 | { |
---|
| 287 | if (select_available_groups.options[i].selected) |
---|
| 288 | { |
---|
| 289 | isSelected = false; |
---|
| 290 | for(var j = 0;j < select_user_groups.options.length; j++) |
---|
| 291 | { |
---|
| 292 | if(select_user_groups.options[j].value == select_available_groups.options[i].value) |
---|
| 293 | { |
---|
| 294 | isSelected = true; |
---|
| 295 | break; |
---|
| 296 | } |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | if(!isSelected) |
---|
| 300 | { |
---|
| 301 | new_option1 = document.createElement('option'); |
---|
| 302 | new_option1.value =select_available_groups.options[i].value; |
---|
| 303 | new_option1.text = select_available_groups.options[i].text; |
---|
| 304 | new_option1.selected = true; |
---|
| 305 | select_user_groups.options[select_user_groups.options.length] = new_option1; |
---|
| 306 | |
---|
| 307 | new_option2 = document.createElement('option'); |
---|
| 308 | new_option2.value =select_available_groups.options[i].value; |
---|
| 309 | new_option2.text = select_available_groups.options[i].text; |
---|
| 310 | combo_primary_user_group.options[combo_primary_user_group.options.length] = new_option2; |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | for (j =0; j < select_available_groups.options.length; j++) |
---|
| 316 | select_available_groups.options[j].selected = false; |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | function add_defaultGroup() |
---|
| 320 | { |
---|
| 321 | select_available_groups = document.getElementById('ea_select_available_groups'); |
---|
| 322 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
| 323 | combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); |
---|
| 324 | for (i = 0 ; i < select_available_groups.length ; i++) |
---|
| 325 | { |
---|
| 326 | if (select_available_groups.options[i].text=="Default") |
---|
| 327 | { |
---|
| 328 | new_option1 = document.createElement('option'); |
---|
| 329 | new_option1.value =select_available_groups.options[i].value; |
---|
| 330 | new_option1.text = select_available_groups.options[i].text; |
---|
| 331 | new_option1.selected = true; |
---|
| 332 | select_user_groups.options[select_user_groups.options.length] = new_option1; |
---|
| 333 | |
---|
| 334 | new_option2 = document.createElement('option'); |
---|
| 335 | new_option2.value =select_available_groups.options[i].value; |
---|
| 336 | new_option2.text = select_available_groups.options[i].text; |
---|
| 337 | combo_primary_user_group.options[combo_primary_user_group.options.length] = new_option2; |
---|
| 338 | } |
---|
| 339 | } |
---|
| 340 | |
---|
| 341 | for (j =0; j < select_available_groups.options.length; j++) |
---|
| 342 | select_available_groups.options[j].selected = false; |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | function remove_user2group() |
---|
| 346 | { |
---|
| 347 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
| 348 | combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); |
---|
| 349 | |
---|
| 350 | var x; |
---|
| 351 | var j=0; |
---|
| 352 | var to_remove = new Array(); |
---|
| 353 | |
---|
| 354 | for(var i = 0;i < select_user_groups.options.length; i++) |
---|
| 355 | { |
---|
| 356 | if(select_user_groups.options[i].selected) |
---|
| 357 | { |
---|
| 358 | to_remove[j] = select_user_groups.options[i].value; |
---|
| 359 | j++; |
---|
| 360 | select_user_groups.options[i--] = null; |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | |
---|
| 364 | for (x in to_remove) |
---|
| 365 | { |
---|
| 366 | for(var i=0; i<combo_primary_user_group.options.length; i++) |
---|
| 367 | { |
---|
| 368 | if (combo_primary_user_group.options[i].value == to_remove[x]) |
---|
| 369 | { |
---|
| 370 | combo_primary_user_group.options[i] = null; |
---|
| 371 | } |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | function get_available_maillists(context) |
---|
| 377 | { |
---|
| 378 | var handler_get_available_maillists = function(data) |
---|
| 379 | { |
---|
| 380 | select_available_maillists = document.getElementById('ea_select_available_maillists'); |
---|
| 381 | |
---|
| 382 | if ((data) && (data.length > 0)) |
---|
| 383 | { |
---|
| 384 | // Necessário, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 385 | select_available_maillists.innerHTML = '#' + data; |
---|
| 386 | select_available_maillists.outerHTML = select_available_maillists.outerHTML; |
---|
| 387 | select_available_maillists_clone = select_available_maillists.cloneNode(true); |
---|
| 388 | document.getElementById('ea_input_searchMailList').value = ''; |
---|
| 389 | } |
---|
| 390 | else |
---|
| 391 | { |
---|
| 392 | // Necessário, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 393 | select_available_maillists.innerHTML = '#'; |
---|
| 394 | select_available_maillists.outerHTML = select_available_maillists.outerHTML; |
---|
| 395 | } |
---|
| 396 | } |
---|
| 397 | cExecute ('$this.ldap_functions.get_available_maillists&context='+context, handler_get_available_maillists); |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | function add_user2maillist() |
---|
| 401 | { |
---|
| 402 | select_available_maillists = document.getElementById('ea_select_available_maillists'); |
---|
| 403 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
| 404 | |
---|
| 405 | for (i = 0 ; i < select_available_maillists.length ; i++) |
---|
| 406 | { |
---|
| 407 | |
---|
| 408 | if (select_available_maillists.options[i].selected) |
---|
| 409 | { |
---|
| 410 | isSelected = false; |
---|
| 411 | for(var j = 0;j < select_user_maillists.options.length; j++) |
---|
| 412 | { |
---|
| 413 | if(select_user_maillists.options[j].value == select_available_maillists.options[i].value) |
---|
| 414 | { |
---|
| 415 | isSelected = true; |
---|
| 416 | break; |
---|
| 417 | } |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | if(!isSelected) |
---|
| 421 | { |
---|
| 422 | new_option = document.createElement('option'); |
---|
| 423 | new_option.value =select_available_maillists.options[i].value; |
---|
| 424 | new_option.text = select_available_maillists.options[i].text; |
---|
| 425 | new_option.selected = true; |
---|
| 426 | |
---|
| 427 | select_user_maillists.options[select_user_maillists.options.length] = new_option; |
---|
| 428 | } |
---|
| 429 | } |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | for (j =0; j < select_available_maillists.options.length; j++) |
---|
| 433 | select_available_maillists.options[j].selected = false; |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | function remove_user2maillist() |
---|
| 437 | { |
---|
| 438 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
| 439 | |
---|
| 440 | for(var i = 0;i < select_user_maillists.options.length; i++) |
---|
| 441 | if(select_user_maillists.options[i].selected) |
---|
| 442 | select_user_maillists.options[i--] = null; |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | function sinc_combos_org(context) |
---|
| 446 | { |
---|
| 447 | combo_org_groups = document.getElementById('ea_combo_org_groups'); |
---|
| 448 | combo_org_maillists = document.getElementById('ea_combo_org_maillists'); |
---|
| 449 | |
---|
| 450 | for (i=0; i<combo_org_groups.length; i++) |
---|
| 451 | { |
---|
| 452 | if (combo_org_groups.options[i].value == context) |
---|
| 453 | { |
---|
| 454 | combo_org_groups.options[i].selected = true; |
---|
| 455 | combo_org_maillists.options[i].selected = true; |
---|
| 456 | } |
---|
| 457 | } |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | function use_samba_attrs(value) |
---|
| 461 | { |
---|
| 462 | if (value) |
---|
| 463 | { |
---|
| 464 | if (document.forms[0].sambalogonscript.value == '') |
---|
| 465 | { |
---|
| 466 | if (document.forms[0].defaultLogonScript.value == '') |
---|
| 467 | { |
---|
| 468 | document.forms[0].sambalogonscript.value = document.forms[0].uid.value + '.bat'; |
---|
| 469 | } |
---|
| 470 | else |
---|
| 471 | { |
---|
| 472 | document.forms[0].sambalogonscript.value = document.forms[0].defaultLogonScript.value; |
---|
| 473 | } |
---|
| 474 | } |
---|
| 475 | if (document.forms[0].sambahomedirectory.value == '') |
---|
| 476 | { |
---|
| 477 | document.forms[0].sambahomedirectory.value = '/home/'+document.forms[0].uid.value+'/'; |
---|
| 478 | } |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | if (!document.forms[0].use_attrs_samba.disabled) |
---|
| 482 | { |
---|
| 483 | document.forms[0].sambaacctflags.disabled = !value; |
---|
| 484 | document.forms[0].sambadomain.disabled = !value; |
---|
| 485 | document.forms[0].sambalogonscript.disabled = !value; |
---|
| 486 | document.forms[0].sambahomedirectory.disabled = !value; |
---|
| 487 | } |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | function set_user_default_password() |
---|
| 491 | { |
---|
| 492 | var handler_set_user_default_password = function(data) |
---|
| 493 | { |
---|
| 494 | if (!data.status) |
---|
| 495 | alert(data.msg); |
---|
| 496 | else |
---|
| 497 | alert('Senha padrão cadastrada com êxito.'); |
---|
| 498 | return; |
---|
| 499 | } |
---|
| 500 | document.getElementById('passwd_expired').checked = true; |
---|
| 501 | document.getElementById('passwd_expired').disabled = true; |
---|
| 502 | cExecute ('$this.user.set_user_default_password&uid='+document.forms[0].uid.value, handler_set_user_default_password); |
---|
| 503 | } |
---|
| 504 | |
---|
| 505 | function return_user_password() |
---|
| 506 | { |
---|
| 507 | var handler_return_user_password = function(data) |
---|
| 508 | { |
---|
| 509 | if (!data.status) |
---|
| 510 | alert(data.msg); |
---|
| 511 | else |
---|
| 512 | alert('Senha do usuário retornado com êxito.'); |
---|
| 513 | return; |
---|
| 514 | } |
---|
| 515 | document.getElementById('passwd_expired').checked = false; |
---|
| 516 | document.getElementById('passwd_expired').disabled = false; |
---|
| 517 | cExecute ('$this.user.return_user_password&uid='+document.forms[0].uid.value, handler_return_user_password); |
---|
| 518 | } |
---|
| 519 | |
---|
| 520 | function set_pass_expired() |
---|
| 521 | { |
---|
| 522 | if (document.getElementById('password1').value != '') |
---|
| 523 | { |
---|
| 524 | document.getElementById('passwd_expired').checked = true; |
---|
| 525 | document.getElementById('passwd_expired').disabled = true; |
---|
| 526 | } |
---|
| 527 | else |
---|
| 528 | { |
---|
| 529 | document.getElementById('passwd_expired').checked = false; |
---|
| 530 | document.getElementById('passwd_expired').disabled = false; |
---|
| 531 | } |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | function delete_user(uid, uidnumber) |
---|
| 535 | { |
---|
| 536 | if (confirm("Realmente deseja excluir o usuário " + uid + "?")) |
---|
| 537 | { |
---|
| 538 | var handler_delete_user = function(data) |
---|
| 539 | { |
---|
| 540 | if (!data.status) |
---|
| 541 | alert(data.msg); |
---|
| 542 | else |
---|
| 543 | alert('Usuário excluído com êxito.'); |
---|
| 544 | |
---|
| 545 | location.href="./index.php?menuaction=expressoAdminSerpro.uiaccounts.list_users"; |
---|
| 546 | return; |
---|
| 547 | } |
---|
| 548 | cExecute ('$this.user.delete&uidnumber='+uidnumber, handler_delete_user); |
---|
| 549 | } |
---|
| 550 | } |
---|
| 551 | |
---|
| 552 | function rename_user(uid, uidnumber) |
---|
| 553 | { |
---|
| 554 | if (document.getElementById('accounts_form_imapDelimiter').value == '/') |
---|
| 555 | var reUid = /^([a-zA-Z0-9_\.\-])+$/; |
---|
| 556 | else |
---|
| 557 | var reUid = /^([a-zA-Z0-9_\-])+$/; |
---|
| 558 | |
---|
| 559 | new_uid = prompt("Alterar login do usuário " + uid + " para: ", uid); |
---|
| 560 | |
---|
| 561 | if(!reUid.test(new_uid)){ |
---|
| 562 | alert('Campo Login contém caracteres não permitidos.'); |
---|
| 563 | document.forms[0].account_lid.focus(); |
---|
| 564 | return; |
---|
| 565 | } |
---|
| 566 | |
---|
| 567 | if ((new_uid) && (new_uid != uid)) |
---|
| 568 | { |
---|
| 569 | var handler_validate_fields = function(data) |
---|
| 570 | { |
---|
| 571 | if (!data.status) |
---|
| 572 | alert(data.msg); |
---|
| 573 | else |
---|
| 574 | cExecute ('$this.user.rename&uid='+uid+'&new_uid='+new_uid, handler_rename); |
---|
| 575 | |
---|
| 576 | return; |
---|
| 577 | } |
---|
| 578 | |
---|
| 579 | // New uid exist? |
---|
| 580 | attrs_array = new Array(); |
---|
| 581 | attrs_array['type'] = 'rename_user'; |
---|
| 582 | attrs_array['uid'] = new_uid; |
---|
| 583 | attributes = connector.serialize(attrs_array); |
---|
| 584 | |
---|
| 585 | cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields); |
---|
| 586 | } |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | // HANDLER RENAME |
---|
| 590 | function handler_rename(data) |
---|
| 591 | { |
---|
| 592 | if (!data.status) |
---|
| 593 | alert(data.msg); |
---|
| 594 | else{ |
---|
| 595 | alert("Usuário renomeado com êxito.\n" + data.exec_return); |
---|
| 596 | location.href="./index.php?menuaction=expressoAdminSerpro.uiaccounts.list_users"; |
---|
| 597 | } |
---|
| 598 | return; |
---|
| 599 | |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | |
---|
| 603 | // Variaveis Locais |
---|
| 604 | var finderTimeout_maillist = ''; |
---|
| 605 | |
---|
| 606 | // Funcoes Find MailList |
---|
| 607 | function optionFinderTimeout_maillist(obj) |
---|
| 608 | { |
---|
| 609 | clearTimeout(finderTimeout_maillist); |
---|
| 610 | var oWait = document.getElementById("ea_span_searching_maillist"); |
---|
| 611 | oWait.innerHTML = 'Buscando...'; |
---|
| 612 | finderTimeout_maillist = setTimeout("optionFinder_maillist('"+obj.id+"')",500); |
---|
| 613 | } |
---|
| 614 | function optionFinder_maillist(id) { |
---|
| 615 | var oWait = document.getElementById("ea_span_searching_maillist"); |
---|
| 616 | var oText = document.getElementById(id); |
---|
| 617 | |
---|
| 618 | //Limpa todo o select |
---|
| 619 | for(var i = 0;i < select_available_maillists.options.length; i++) |
---|
| 620 | select_available_maillists.options[i--] = null; |
---|
| 621 | |
---|
| 622 | var RegExp_name = new RegExp(oText.value, "i"); |
---|
| 623 | |
---|
| 624 | //Inclui as listas começando com a pesquisa |
---|
| 625 | for(i = 0; i < select_available_maillists_clone.length; i++){ |
---|
| 626 | if (RegExp_name.test(select_available_maillists_clone[i].text)) |
---|
| 627 | { |
---|
| 628 | sel = select_available_maillists.options; |
---|
| 629 | option = new Option(select_available_maillists_clone[i].text,select_available_maillists_clone[i].value); |
---|
| 630 | sel[sel.length] = option; |
---|
| 631 | } |
---|
| 632 | } |
---|
| 633 | oWait.innerHTML = ' '; |
---|
| 634 | } |
---|
| 635 | |
---|
| 636 | // Variaveis Locais |
---|
| 637 | var finderTimeout_group = ''; |
---|
| 638 | |
---|
| 639 | |
---|
| 640 | // Funcoes Find Group |
---|
| 641 | function optionFinderTimeout_group(obj) |
---|
| 642 | { |
---|
| 643 | clearTimeout(finderTimeout_group); |
---|
| 644 | var oWait = document.getElementById("ea_span_searching_group"); |
---|
| 645 | oWait.innerHTML = 'Buscando...'; |
---|
| 646 | finderTimeout_group = setTimeout("optionFinder_group('"+obj.id+"')",500); |
---|
| 647 | } |
---|
| 648 | function optionFinder_group(id) { |
---|
| 649 | var oWait = document.getElementById("ea_span_searching_group"); |
---|
| 650 | var oText = document.getElementById(id); |
---|
| 651 | |
---|
| 652 | //Limpa todo o select |
---|
| 653 | for(var i = 0;i < select_available_groups.options.length; i++) |
---|
| 654 | select_available_groups.options[i--] = null; |
---|
| 655 | |
---|
| 656 | var RegExp_name = new RegExp(oText.value, "i"); |
---|
| 657 | |
---|
| 658 | //Inclui as listas começando com a pesquisa |
---|
| 659 | for(i = 0; i < select_available_groups_clone.length; i++){ |
---|
| 660 | if (RegExp_name.test(select_available_groups_clone[i].text)) |
---|
| 661 | { |
---|
| 662 | sel = select_available_groups.options; |
---|
| 663 | option = new Option(select_available_groups_clone[i].text,select_available_groups_clone[i].value); |
---|
| 664 | sel[sel.length] = option; |
---|
| 665 | } |
---|
| 666 | } |
---|
| 667 | oWait.innerHTML = ' '; |
---|
| 668 | } |
---|
| 669 | |
---|
| 670 | function get_available_sambadomains(context, type) |
---|
| 671 | { |
---|
| 672 | if ((type == 'create_user') && (document.getElementById('tabcontent7').style.display != 'none')) |
---|
| 673 | { |
---|
| 674 | var handler_get_available_sambadomains = function(data) |
---|
| 675 | { |
---|
| 676 | document.forms[0].use_attrs_samba.checked = data.status; |
---|
| 677 | use_samba_attrs(data.status); |
---|
| 678 | |
---|
| 679 | if (data.status) |
---|
| 680 | { |
---|
| 681 | combo_sambadomains = document.getElementById('ea_combo_sambadomains'); |
---|
| 682 | for (i=0; i<data.sambaDomains.length; i++) |
---|
| 683 | { |
---|
| 684 | for (j=0; j<combo_sambadomains.length; j++) |
---|
| 685 | { |
---|
| 686 | if (combo_sambadomains.options[j].text == data.sambaDomains[i]) |
---|
| 687 | { |
---|
| 688 | combo_sambadomains.options[j].selected = true; |
---|
| 689 | break; |
---|
| 690 | } |
---|
| 691 | } |
---|
| 692 | } |
---|
| 693 | |
---|
| 694 | } |
---|
| 695 | } |
---|
| 696 | |
---|
| 697 | cExecute ('$this.ldap_functions.exist_sambadomains_in_context&context='+context, handler_get_available_sambadomains); |
---|
| 698 | } |
---|
| 699 | } |
---|
| 700 | |
---|
| 701 | function empty_inbox(uid) |
---|
| 702 | { |
---|
| 703 | var action = "Excluindo todas as mensagem da Caixa do usuário"; |
---|
| 704 | var handler_write_log = function(){} |
---|
| 705 | var handler_empty_inbox = function(data) |
---|
| 706 | { |
---|
| 707 | if (!data.status) |
---|
| 708 | alert(data.msg); |
---|
| 709 | else{ |
---|
| 710 | cExecute ('$this.user.write_log_from_ajax&_action='+action+'&userinfo='+uid, handler_write_log); |
---|
| 711 | alert("Esvaziados '" + data.inbox_size + "' MB da caixa postal do usuário."); |
---|
| 712 | document.getElementById('mailquota_used').value = data.mailquota_used; |
---|
| 713 | } |
---|
| 714 | } |
---|
| 715 | cExecute ('$this.imap_functions.empty_inbox&uid='+uid, handler_empty_inbox); |
---|
| 716 | } |
---|
| 717 | |
---|
| 718 | function validarCPF(cpf) |
---|
| 719 | { |
---|
| 720 | if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || |
---|
| 721 | cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || |
---|
| 722 | cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || |
---|
| 723 | cpf == "88888888888" || cpf == "99999999999"){ |
---|
| 724 | return false; |
---|
| 725 | } |
---|
| 726 | |
---|
| 727 | soma = 0; |
---|
| 728 | for(i = 0; i < 9; i++) |
---|
| 729 | soma += parseInt(cpf.charAt(i)) * (10 - i); |
---|
| 730 | resto = 11 - (soma % 11); |
---|
| 731 | if(resto == 10 || resto == 11) |
---|
| 732 | resto = 0; |
---|
| 733 | if(resto != parseInt(cpf.charAt(9))) |
---|
| 734 | { |
---|
| 735 | return false; |
---|
| 736 | } |
---|
| 737 | |
---|
| 738 | soma = 0; |
---|
| 739 | for(i = 0; i < 10; i ++) |
---|
| 740 | soma += parseInt(cpf.charAt(i)) * (11 - i); |
---|
| 741 | resto = 11 - (soma % 11); |
---|
| 742 | if(resto == 10 || resto == 11) |
---|
| 743 | resto = 0; |
---|
| 744 | if(resto != parseInt(cpf.charAt(10))){ |
---|
| 745 | return false; |
---|
| 746 | } |
---|
| 747 | return true; |
---|
| 748 | } |
---|
| 749 | |
---|
| 750 | /* |
---|
| 751 | function search_organization(key) |
---|
| 752 | { |
---|
| 753 | var organizations = document.getElementById('ea_combo_org_info'); |
---|
| 754 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
| 755 | |
---|
| 756 | for(i = 0; i < organizations.length; i++) |
---|
| 757 | { |
---|
| 758 | if (RegExp_org.test(organizations[i].text)) |
---|
| 759 | { |
---|
| 760 | organizations[i].selected = true; |
---|
| 761 | return; |
---|
| 762 | } |
---|
| 763 | } |
---|
| 764 | }*/ |
---|
| 765 | |
---|
| 766 | function search_organization(key, element) |
---|
| 767 | { |
---|
| 768 | var organizations = document.getElementById(element); |
---|
| 769 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
| 770 | |
---|
| 771 | for(i = 0; i < organizations.length; i++) |
---|
| 772 | { |
---|
| 773 | if (RegExp_org.test(organizations[i].text)) |
---|
| 774 | { |
---|
| 775 | organizations[i].selected = true; |
---|
| 776 | return; |
---|
| 777 | } |
---|
| 778 | } |
---|
| 779 | } |
---|
| 780 | |
---|
| 781 | function add_input_mailalternateaddress() |
---|
| 782 | { |
---|
| 783 | var input = document.createElement("INPUT"); |
---|
| 784 | input.size = 30; |
---|
| 785 | input.name = "mailalternateaddress[]"; |
---|
| 786 | input.setAttribute("autocomplete","off"); |
---|
| 787 | document.getElementById("td_input_mailalternateaddress").appendChild(document.createElement("br")); |
---|
| 788 | document.getElementById("td_input_mailalternateaddress").appendChild(input); |
---|
| 789 | } |
---|
| 790 | |
---|
| 791 | function add_input_mailforwardingaddress() |
---|
| 792 | { |
---|
| 793 | var input = document.createElement("INPUT"); |
---|
| 794 | input.size = 30; |
---|
| 795 | input.name = "mailforwardingaddress[]"; |
---|
| 796 | input.setAttribute("autocomplete","off"); |
---|
| 797 | document.getElementById("td_input_mailforwardingaddress").appendChild(document.createElement("br")); |
---|
| 798 | document.getElementById("td_input_mailforwardingaddress").appendChild(input); |
---|
| 799 | } |
---|
| 800 | |
---|
| 801 | function add_input_accountOwners() |
---|
| 802 | { |
---|
| 803 | if (document.getElementById('corporation_account').checked) |
---|
| 804 | { |
---|
| 805 | var input = document.createElement("INPUT"); |
---|
| 806 | input.size = 30; |
---|
| 807 | input.name = "accountOwners[]"; |
---|
| 808 | input.setAttribute("autocomplete","off"); |
---|
| 809 | document.getElementById("accountOwners").appendChild(document.createElement("br")); |
---|
| 810 | document.getElementById("accountOwners").appendChild(input); |
---|
| 811 | } |
---|
| 812 | } |
---|
| 813 | function revert_ldapPath() |
---|
| 814 | { |
---|
| 815 | document.getElementById('dn').value=document.getElementById('ldap_original_path').value; |
---|
| 816 | if (document.getElementById("ldapPathBuildD").hasChildNodes()) |
---|
| 817 | { |
---|
| 818 | var child = document.getElementById("ldapPathBuildD").childNodes[0]; |
---|
| 819 | document.getElementById("ldapPathBuildD").removeChild(child); |
---|
| 820 | } |
---|
| 821 | } |
---|
| 822 | function set_default_ldapPath() |
---|
| 823 | { |
---|
| 824 | if (document.getElementById('corporation_account').checked) |
---|
| 825 | { |
---|
| 826 | document.getElementById('dn').value=document.getElementById('corporationAccount_ldapPath').value; |
---|
| 827 | document.getElementById('ldap_relative_path').value=document.getElementById("corporationAccount_ldapPath").value; |
---|
| 828 | } |
---|
| 829 | else |
---|
| 830 | { |
---|
| 831 | document.getElementById('dn').value=document.getElementById('ldap_default_path').value; |
---|
| 832 | document.getElementById('ldap_relative_path').value=document.getElementById("ldap_default_path").value; |
---|
| 833 | } |
---|
| 834 | if (document.getElementById("ldapPathBuildD").hasChildNodes()) |
---|
| 835 | { |
---|
| 836 | var child = document.getElementById("ldapPathBuildD").childNodes[0]; |
---|
| 837 | document.getElementById("ldapPathBuildD").removeChild(child); |
---|
| 838 | } |
---|
| 839 | } |
---|
| 840 | |
---|
| 841 | function add_select_ldapPath() |
---|
| 842 | { |
---|
| 843 | if (!document.getElementById("ldapPathBuildD").hasChildNodes()) |
---|
| 844 | { |
---|
| 845 | var select = document.createElement("SELECT"); |
---|
| 846 | select.value = "teste"; |
---|
| 847 | select.id = "select_ldap_path"; |
---|
| 848 | select.onchange = function() |
---|
| 849 | { |
---|
| 850 | var select=document.getElementById("ldapPathBuildD").childNodes[0]; |
---|
| 851 | var optIndex = select.selectedIndex; |
---|
| 852 | if (optIndex!=0) |
---|
| 853 | { |
---|
| 854 | document.getElementById('dn').value=document.getElementById("ldapPathBuildD").childNodes[0].options[optIndex].value; |
---|
| 855 | document.getElementById('ldap_relative_path').value=document.getElementById("ldapPathBuildD").childNodes[0].options[optIndex].value; |
---|
| 856 | } |
---|
| 857 | else |
---|
| 858 | { |
---|
| 859 | document.getElementById('dn').value=document.getElementById("ldap_default_path").value; |
---|
| 860 | document.getElementById('ldap_relative_path').value=document.getElementById("ldap_default_path").value; |
---|
| 861 | } |
---|
| 862 | } |
---|
| 863 | document.getElementById("ldapPathBuildD").appendChild(select); |
---|
| 864 | var option = document.createElement("OPTION"); |
---|
| 865 | option.value = ""; |
---|
| 866 | option.innerHTML = " "; |
---|
| 867 | document.getElementById("ldapPathBuildD").childNodes[0].add(option,null); |
---|
| 868 | } |
---|
| 869 | else |
---|
| 870 | { |
---|
| 871 | var child = document.getElementById("ldapPathBuildD").childNodes[0]; |
---|
| 872 | document.getElementById("ldapPathBuildD").removeChild(child); |
---|
| 873 | add_select_ldapPath(); |
---|
| 874 | } |
---|
| 875 | cExecuteForm ("$this.functions.getNextLayer", document.forms[0], handler_nextLayer_functions); |
---|
| 876 | } |
---|
| 877 | |
---|
| 878 | function handler_nextLayer_functions(data){ |
---|
| 879 | return_handler_nextLayer_functions(data); |
---|
| 880 | } |
---|
| 881 | |
---|
| 882 | function return_handler_nextLayer_functions(data) |
---|
| 883 | { |
---|
| 884 | if (data.status == 'false') |
---|
| 885 | { |
---|
| 886 | var child = document.getElementById("ldapPathBuildD").childNodes[0]; |
---|
| 887 | document.getElementById("ldapPathBuildD").removeChild(child); |
---|
| 888 | alert(data.msg); |
---|
| 889 | } |
---|
| 890 | else |
---|
| 891 | { |
---|
| 892 | for(var entry in data.result) |
---|
| 893 | { |
---|
| 894 | var path=data.result[entry].split(';'); |
---|
| 895 | var option = document.createElement("OPTION"); |
---|
| 896 | option.value = path[1]; |
---|
| 897 | option.innerHTML = path[0]; |
---|
| 898 | document.getElementById("ldapPathBuildD").childNodes[0].add(option,null); |
---|
| 899 | } |
---|
| 900 | } |
---|
| 901 | return; |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | function change_corporationAccount() |
---|
| 905 | { |
---|
| 906 | if (document.getElementById('corporation_account').checked) |
---|
| 907 | { |
---|
| 908 | document.getElementById('dn').value=document.getElementById('corporationAccount_ldapPath').value; |
---|
| 909 | document.getElementById('ldap_relative_path').value=document.getElementById('corporationAccount_ldapPath').value; |
---|
| 910 | elem = document.getElementsByName('accountOwners[]'); |
---|
| 911 | for(var i=0;i < elem.length;i++) |
---|
| 912 | elem[i].disabled = false; |
---|
| 913 | } |
---|
| 914 | else |
---|
| 915 | { |
---|
| 916 | document.getElementById('dn').value=document.getElementById('ea_combo_org_groups').value; |
---|
| 917 | document.getElementById('ldap_relative_path').value=document.getElementById('ea_combo_org_groups').value; |
---|
| 918 | elem = document.getElementsByName('accountOwners[]'); |
---|
| 919 | for(var i=0;i < elem.length;i++) |
---|
| 920 | elem[i].disabled = true; |
---|
| 921 | } |
---|
| 922 | } |
---|
| 923 | |
---|
| 924 | //Envia o codigo do Estado paraget_cities() e recebe os nomes das Cidades daquele Estado, |
---|
| 925 | //depois monta a option box |
---|
| 926 | function updateCities() |
---|
| 927 | { |
---|
| 928 | |
---|
| 929 | var st = document.getElementById('corporative_information_st').value; |
---|
| 930 | |
---|
| 931 | |
---|
| 932 | var handler_update_cities = function(data) |
---|
| 933 | { |
---|
| 934 | |
---|
| 935 | var opt = ""; |
---|
| 936 | opt = '<option value="_NONE_">Escolha a cidade...</option>'; |
---|
| 937 | |
---|
| 938 | document.getElementById('corporative_information_l').innerHTML = ''; |
---|
| 939 | for(var i=0; i < data.length; i++) |
---|
| 940 | { |
---|
| 941 | opt += '<option value="'+data[i].id_city+'">'+data[i].city_name+'</option>'; |
---|
| 942 | } |
---|
| 943 | |
---|
| 944 | document.getElementById('corporative_information_l').innerHTML = opt; |
---|
| 945 | |
---|
| 946 | } |
---|
| 947 | |
---|
| 948 | params = '&st='+st; |
---|
| 949 | cExecute('$this.functions.get_cities', handler_update_cities, params); |
---|
| 950 | |
---|
| 951 | } |
---|