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