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