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