[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 == ''){ |
---|
[1594] | 34 | alert(get_lang('repassword field is empty') + '.'); |
---|
[2] | 35 | return; |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | if (document.forms[0].password1.value != document.forms[0].password2.value){ |
---|
[1594] | 40 | alert(get_lang('password and repassword are different') + '.'); |
---|
[2] | 41 | return; |
---|
| 42 | } |
---|
[1329] | 43 | |
---|
[63] | 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 | } |
---|
[1501] | 63 | var reEmail = /^([a-zA-Z0-9_\-])+(\.[a-zA-Z0-9_\-]+)*\@([a-zA-Z0-9_\-])+(\.[a-zA-Z0-9_\-]+)*$/; |
---|
[2] | 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; |
---|
[3018] | 141 | var attributes = admin_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 | { |
---|
[3018] | 158 | // Turn enabled checkbox on create user. |
---|
| 159 | document.getElementById('changepassword').disabled = false; |
---|
[2] | 160 | cExecuteForm ("$this.user.create", document.forms[0], handler_create); |
---|
| 161 | } |
---|
| 162 | else |
---|
| 163 | { |
---|
| 164 | //Turn enabled all checkboxes and inputs |
---|
| 165 | document.getElementById('changepassword').disabled = false; |
---|
| 166 | document.getElementById('phpgwaccountstatus').disabled = false; |
---|
| 167 | document.getElementById('phpgwaccountvisible').disabled = false; |
---|
| 168 | document.getElementById('telephonenumber').disabled = false; |
---|
| 169 | document.getElementById('mailforwardingaddress').disabled = false; |
---|
| 170 | document.getElementById('mailalternateaddress').disabled = false; |
---|
[414] | 171 | document.getElementById('passwd_expired').disabled = false; |
---|
[2] | 172 | document.getElementById('accountstatus').disabled = false; |
---|
| 173 | document.getElementById('deliverymode').disabled = false; |
---|
| 174 | document.getElementById('use_attrs_samba').disabled = false; |
---|
| 175 | |
---|
| 176 | table_apps = document.getElementById('ea_table_apps'); |
---|
| 177 | var inputs = table_apps.getElementsByTagName("input"); |
---|
| 178 | for (var i = 0; i < inputs.length; i++) |
---|
| 179 | { |
---|
| 180 | inputs[i].disabled = false; |
---|
| 181 | } |
---|
| 182 | cExecuteForm ("$this.user.save", document.forms[0], handler_save); |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | // Needed select all options from select |
---|
| 188 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
| 189 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
| 190 | for(var i=0; i<select_user_maillists.options.length; i++) |
---|
| 191 | select_user_maillists.options[i].selected = true; |
---|
| 192 | for(var i=0; i<select_user_groups.options.length; i++) |
---|
| 193 | select_user_groups.options[i].selected = true; |
---|
| 194 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
[540] | 195 | document.getElementById('uid').disabled = false; //Caso o login seja gerado automático, tirar o disabled. |
---|
[2] | 196 | cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields); |
---|
| 197 | } |
---|
| 198 | |
---|
[594] | 199 | function generate_login(first_name,second_name) { |
---|
[540] | 200 | if ((first_name=='') || (second_name=='')) { |
---|
| 201 | alert(get_lang("You must type the first and the second name before generate the login")); |
---|
| 202 | return; |
---|
| 203 | } |
---|
| 204 | var attrs_array = new Array(); |
---|
| 205 | attrs_array['first_name'] = first_name; |
---|
| 206 | attrs_array['second_name'] = second_name; |
---|
[3018] | 207 | var attributes = admin_connector.serialize(attrs_array); |
---|
[540] | 208 | |
---|
[594] | 209 | var handler_generate_login = function(data) { |
---|
[540] | 210 | if(data['status']) { |
---|
| 211 | document.getElementById('uid').value = data['msg']; |
---|
| 212 | emailSuggestion_expressoadmin('true','true'); |
---|
| 213 | document.getElementById("mail").value=document.getElementById("mail1").value; |
---|
| 214 | } |
---|
| 215 | else |
---|
| 216 | alert(data['msg']); |
---|
| 217 | } |
---|
| 218 | |
---|
[594] | 219 | cExecute ('$this.ldap_functions.generate_login&attributes='+attributes, handler_generate_login); |
---|
[540] | 220 | } |
---|
| 221 | |
---|
[2] | 222 | // HANDLER CREATE |
---|
| 223 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 224 | function handler_create(data) |
---|
| 225 | { |
---|
| 226 | return_handler_create(data); |
---|
| 227 | } |
---|
| 228 | function return_handler_create(data) |
---|
| 229 | { |
---|
| 230 | if (!data.status) |
---|
| 231 | alert(data.msg); |
---|
| 232 | else |
---|
[482] | 233 | alert(get_lang('User successful created') + '.'); |
---|
[2] | 234 | |
---|
| 235 | location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users"; |
---|
| 236 | return; |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | |
---|
| 240 | // HANDLER SAVE |
---|
| 241 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 242 | function handler_save(data) |
---|
| 243 | { |
---|
| 244 | return_handler_save(data); |
---|
| 245 | } |
---|
| 246 | function return_handler_save(data) |
---|
| 247 | { |
---|
| 248 | if (!data.status){ |
---|
| 249 | alert(data.msg); |
---|
| 250 | } |
---|
| 251 | else{ |
---|
[482] | 252 | alert(get_lang('User successful saved') + '.'); |
---|
[2] | 253 | } |
---|
[47] | 254 | location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users"; |
---|
[2] | 255 | return; |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | function get_available_groups(context) |
---|
| 259 | { |
---|
| 260 | var handler_get_available_groups = function(data) |
---|
| 261 | { |
---|
| 262 | select_available_groups = document.getElementById('ea_select_available_groups'); |
---|
| 263 | |
---|
[33] | 264 | if ((data) && (data.length > 0)) |
---|
[2] | 265 | { |
---|
[33] | 266 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 267 | select_available_groups.innerHTML = '#' + data; |
---|
| 268 | select_available_groups.outerHTML = select_available_groups.outerHTML; |
---|
[2] | 269 | select_available_groups_clone = select_available_groups.cloneNode(true); |
---|
| 270 | document.getElementById('ea_input_searchGroup').value = ''; |
---|
| 271 | } |
---|
[33] | 272 | else |
---|
| 273 | { |
---|
| 274 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 275 | select_available_groups.innerHTML = '#'; |
---|
| 276 | select_available_groups.outerHTML = select_available_groups.outerHTML; |
---|
| 277 | } |
---|
[2] | 278 | } |
---|
| 279 | |
---|
[33] | 280 | cExecute ('$this.ldap_functions.get_available_groups&context='+context, handler_get_available_groups); |
---|
[2] | 281 | } |
---|
| 282 | |
---|
| 283 | function add_user2group() |
---|
| 284 | { |
---|
| 285 | select_available_groups = document.getElementById('ea_select_available_groups'); |
---|
| 286 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
| 287 | combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); |
---|
| 288 | |
---|
| 289 | for (i = 0 ; i < select_available_groups.length ; i++) |
---|
| 290 | { |
---|
| 291 | if (select_available_groups.options[i].selected) |
---|
| 292 | { |
---|
| 293 | isSelected = false; |
---|
| 294 | for(var j = 0;j < select_user_groups.options.length; j++) |
---|
| 295 | { |
---|
| 296 | if(select_user_groups.options[j].value == select_available_groups.options[i].value) |
---|
| 297 | { |
---|
| 298 | isSelected = true; |
---|
| 299 | break; |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | if(!isSelected) |
---|
| 304 | { |
---|
| 305 | new_option1 = document.createElement('option'); |
---|
| 306 | new_option1.value =select_available_groups.options[i].value; |
---|
| 307 | new_option1.text = select_available_groups.options[i].text; |
---|
| 308 | new_option1.selected = true; |
---|
| 309 | select_user_groups.options[select_user_groups.options.length] = new_option1; |
---|
| 310 | |
---|
| 311 | new_option2 = document.createElement('option'); |
---|
| 312 | new_option2.value =select_available_groups.options[i].value; |
---|
| 313 | new_option2.text = select_available_groups.options[i].text; |
---|
| 314 | combo_primary_user_group.options[combo_primary_user_group.options.length] = new_option2; |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | for (j =0; j < select_available_groups.options.length; j++) |
---|
| 320 | select_available_groups.options[j].selected = false; |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | function remove_user2group() |
---|
| 324 | { |
---|
| 325 | select_user_groups = document.getElementById('ea_select_user_groups'); |
---|
| 326 | combo_primary_user_group = document.getElementById('ea_combo_primary_user_group'); |
---|
| 327 | |
---|
| 328 | var x; |
---|
| 329 | var j=0; |
---|
| 330 | var to_remove = new Array(); |
---|
| 331 | |
---|
| 332 | for(var i = 0;i < select_user_groups.options.length; i++) |
---|
| 333 | { |
---|
| 334 | if(select_user_groups.options[i].selected) |
---|
| 335 | { |
---|
| 336 | to_remove[j] = select_user_groups.options[i].value; |
---|
| 337 | j++; |
---|
| 338 | select_user_groups.options[i--] = null; |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | |
---|
| 342 | for (x in to_remove) |
---|
| 343 | { |
---|
| 344 | for(var i=0; i<combo_primary_user_group.options.length; i++) |
---|
| 345 | { |
---|
| 346 | if (combo_primary_user_group.options[i].value == to_remove[x]) |
---|
| 347 | { |
---|
| 348 | combo_primary_user_group.options[i] = null; |
---|
| 349 | } |
---|
| 350 | } |
---|
| 351 | } |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | function get_available_maillists(context) |
---|
| 355 | { |
---|
| 356 | var handler_get_available_maillists = function(data) |
---|
| 357 | { |
---|
| 358 | select_available_maillists = document.getElementById('ea_select_available_maillists'); |
---|
| 359 | |
---|
[33] | 360 | if ((data) && (data.length > 0)) |
---|
[2] | 361 | { |
---|
[33] | 362 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 363 | select_available_maillists.innerHTML = '#' + data; |
---|
| 364 | select_available_maillists.outerHTML = select_available_maillists.outerHTML; |
---|
[2] | 365 | select_available_maillists_clone = select_available_maillists.cloneNode(true); |
---|
| 366 | document.getElementById('ea_input_searchMailList').value = ''; |
---|
| 367 | } |
---|
[33] | 368 | else |
---|
| 369 | { |
---|
| 370 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 371 | select_available_maillists.innerHTML = '#'; |
---|
| 372 | select_available_maillists.outerHTML = select_available_maillists.outerHTML; |
---|
| 373 | } |
---|
| 374 | } |
---|
[2] | 375 | cExecute ('$this.ldap_functions.get_available_maillists&context='+context, handler_get_available_maillists); |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | function add_user2maillist() |
---|
| 379 | { |
---|
| 380 | select_available_maillists = document.getElementById('ea_select_available_maillists'); |
---|
| 381 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
| 382 | |
---|
| 383 | for (i = 0 ; i < select_available_maillists.length ; i++) |
---|
| 384 | { |
---|
| 385 | |
---|
| 386 | if (select_available_maillists.options[i].selected) |
---|
| 387 | { |
---|
| 388 | isSelected = false; |
---|
| 389 | for(var j = 0;j < select_user_maillists.options.length; j++) |
---|
| 390 | { |
---|
| 391 | if(select_user_maillists.options[j].value == select_available_maillists.options[i].value) |
---|
| 392 | { |
---|
| 393 | isSelected = true; |
---|
| 394 | break; |
---|
| 395 | } |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | if(!isSelected) |
---|
| 399 | { |
---|
| 400 | new_option = document.createElement('option'); |
---|
| 401 | new_option.value =select_available_maillists.options[i].value; |
---|
| 402 | new_option.text = select_available_maillists.options[i].text; |
---|
| 403 | new_option.selected = true; |
---|
| 404 | |
---|
| 405 | select_user_maillists.options[select_user_maillists.options.length] = new_option; |
---|
| 406 | } |
---|
| 407 | } |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | for (j =0; j < select_available_maillists.options.length; j++) |
---|
| 411 | select_available_maillists.options[j].selected = false; |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | function remove_user2maillist() |
---|
| 415 | { |
---|
| 416 | select_user_maillists = document.getElementById('ea_select_user_maillists'); |
---|
| 417 | |
---|
| 418 | for(var i = 0;i < select_user_maillists.options.length; i++) |
---|
| 419 | if(select_user_maillists.options[i].selected) |
---|
| 420 | select_user_maillists.options[i--] = null; |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | function sinc_combos_org(context) |
---|
| 424 | { |
---|
| 425 | combo_org_groups = document.getElementById('ea_combo_org_groups'); |
---|
| 426 | combo_org_maillists = document.getElementById('ea_combo_org_maillists'); |
---|
| 427 | |
---|
| 428 | for (i=0; i<combo_org_groups.length; i++) |
---|
| 429 | { |
---|
| 430 | if (combo_org_groups.options[i].value == context) |
---|
| 431 | { |
---|
| 432 | combo_org_groups.options[i].selected = true; |
---|
| 433 | combo_org_maillists.options[i].selected = true; |
---|
| 434 | } |
---|
| 435 | } |
---|
| 436 | } |
---|
| 437 | |
---|
| 438 | function use_samba_attrs(value) |
---|
| 439 | { |
---|
| 440 | if (value) |
---|
| 441 | { |
---|
| 442 | if (document.forms[0].sambalogonscript.value == '') |
---|
| 443 | { |
---|
| 444 | if (document.forms[0].defaultLogonScript.value == '') |
---|
| 445 | { |
---|
| 446 | document.forms[0].sambalogonscript.value = document.forms[0].uid.value + '.bat'; |
---|
| 447 | } |
---|
| 448 | else |
---|
| 449 | { |
---|
| 450 | document.forms[0].sambalogonscript.value = document.forms[0].defaultLogonScript.value; |
---|
| 451 | } |
---|
| 452 | } |
---|
| 453 | if (document.forms[0].sambahomedirectory.value == '') |
---|
| 454 | { |
---|
| 455 | document.forms[0].sambahomedirectory.value = '/home/'+document.forms[0].uid.value+'/'; |
---|
| 456 | } |
---|
| 457 | } |
---|
[27] | 458 | |
---|
| 459 | if (!document.forms[0].use_attrs_samba.disabled) |
---|
| 460 | { |
---|
| 461 | document.forms[0].sambaacctflags.disabled = !value; |
---|
| 462 | document.forms[0].sambadomain.disabled = !value; |
---|
| 463 | document.forms[0].sambalogonscript.disabled = !value; |
---|
| 464 | document.forms[0].sambahomedirectory.disabled = !value; |
---|
| 465 | } |
---|
[2] | 466 | } |
---|
| 467 | |
---|
| 468 | function set_user_default_password() |
---|
| 469 | { |
---|
| 470 | var handler_set_user_default_password = function(data) |
---|
| 471 | { |
---|
| 472 | if (!data.status) |
---|
| 473 | alert(data.msg); |
---|
| 474 | else |
---|
[482] | 475 | alert(get_lang('Default password successful saved') + '.'); |
---|
[2] | 476 | return; |
---|
| 477 | } |
---|
| 478 | cExecute ('$this.user.set_user_default_password&uid='+document.forms[0].uid.value, handler_set_user_default_password); |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | function return_user_password() |
---|
| 482 | { |
---|
| 483 | var handler_return_user_password = function(data) |
---|
| 484 | { |
---|
| 485 | if (!data.status) |
---|
| 486 | alert(data.msg); |
---|
| 487 | else |
---|
[482] | 488 | alert(get_lang('Users password successful returned') + '.'); |
---|
[2] | 489 | return; |
---|
| 490 | } |
---|
| 491 | cExecute ('$this.user.return_user_password&uid='+document.forms[0].uid.value, handler_return_user_password); |
---|
| 492 | } |
---|
| 493 | |
---|
[64] | 494 | function delete_user(uid, uidnumber) |
---|
[2] | 495 | { |
---|
[414] | 496 | if (confirm(get_lang("Do you really want delete the user") + " " + uid + "?")) |
---|
[2] | 497 | { |
---|
| 498 | var handler_delete_user = function(data) |
---|
| 499 | { |
---|
| 500 | if (!data.status) |
---|
| 501 | alert(data.msg); |
---|
| 502 | else |
---|
[482] | 503 | alert(get_lang('User successful deleted') + '.'); |
---|
[2] | 504 | |
---|
| 505 | location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users"; |
---|
| 506 | return; |
---|
| 507 | } |
---|
[510] | 508 | cExecute ('$this.user.delete&uidnumber='+uidnumber+'&uid='+uid, handler_delete_user); |
---|
[2] | 509 | } |
---|
| 510 | } |
---|
| 511 | |
---|
[64] | 512 | function rename_user(uid, uidnumber) |
---|
[2] | 513 | { |
---|
[13] | 514 | if (document.getElementById('accounts_form_imapDelimiter').value == '/') |
---|
| 515 | var reUid = /^([a-zA-Z0-9_\.\-])+$/; |
---|
| 516 | else |
---|
| 517 | var reUid = /^([a-zA-Z0-9_\-])+$/; |
---|
| 518 | |
---|
[414] | 519 | new_uid = prompt(get_lang('Rename users login from') + ': ' + uid + " " + get_lang("to") + ': ', uid); |
---|
[13] | 520 | |
---|
[2] | 521 | if(!reUid.test(new_uid)){ |
---|
[414] | 522 | alert(get_lang('LOGIN field contains characters not allowed') + '.'); |
---|
[2] | 523 | document.forms[0].account_lid.focus(); |
---|
| 524 | return; |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | if ((new_uid) && (new_uid != uid)) |
---|
| 528 | { |
---|
| 529 | var handler_validate_fields = function(data) |
---|
| 530 | { |
---|
| 531 | if (!data.status) |
---|
| 532 | alert(data.msg); |
---|
| 533 | else |
---|
[64] | 534 | cExecute ('$this.user.rename&uid='+uid+'&new_uid='+new_uid, handler_rename); |
---|
[2] | 535 | |
---|
| 536 | return; |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | // New uid exist? |
---|
| 540 | attrs_array = new Array(); |
---|
| 541 | attrs_array['type'] = 'rename_user'; |
---|
| 542 | attrs_array['uid'] = new_uid; |
---|
[3018] | 543 | attributes = admin_connector.serialize(attrs_array); |
---|
[2] | 544 | |
---|
| 545 | cExecute ('$this.ldap_functions.validate_fields&attributes='+attributes, handler_validate_fields); |
---|
| 546 | } |
---|
| 547 | } |
---|
| 548 | |
---|
| 549 | // HANDLER RENAME |
---|
| 550 | function handler_rename(data) |
---|
| 551 | { |
---|
| 552 | if (!data.status) |
---|
| 553 | alert(data.msg); |
---|
| 554 | else{ |
---|
[482] | 555 | alert(get_lang('User login successful renamed') + "\n" + data.exec_return); |
---|
[2] | 556 | location.href="./index.php?menuaction=expressoAdmin1_2.uiaccounts.list_users"; |
---|
| 557 | } |
---|
| 558 | return; |
---|
| 559 | |
---|
| 560 | } |
---|
| 561 | |
---|
| 562 | |
---|
| 563 | // Variaveis Locais |
---|
| 564 | var finderTimeout_maillist = ''; |
---|
| 565 | |
---|
| 566 | // Funcoes Find MailList |
---|
| 567 | function optionFinderTimeout_maillist(obj) |
---|
| 568 | { |
---|
| 569 | clearTimeout(finderTimeout_maillist); |
---|
| 570 | var oWait = document.getElementById("ea_span_searching_maillist"); |
---|
[414] | 571 | oWait.innerHTML = get_lang('Searching') + '...'; |
---|
[2] | 572 | finderTimeout_maillist = setTimeout("optionFinder_maillist('"+obj.id+"')",500); |
---|
| 573 | } |
---|
[72] | 574 | function optionFinder_maillist(id) { |
---|
[2] | 575 | var oWait = document.getElementById("ea_span_searching_maillist"); |
---|
| 576 | var oText = document.getElementById(id); |
---|
| 577 | |
---|
| 578 | //Limpa todo o select |
---|
| 579 | for(var i = 0;i < select_available_maillists.options.length; i++) |
---|
| 580 | select_available_maillists.options[i--] = null; |
---|
| 581 | |
---|
| 582 | var RegExp_name = new RegExp(oText.value, "i"); |
---|
| 583 | |
---|
| 584 | //Inclui as listas começando com a pesquisa |
---|
| 585 | for(i = 0; i < select_available_maillists_clone.length; i++){ |
---|
| 586 | if (RegExp_name.test(select_available_maillists_clone[i].text)) |
---|
| 587 | { |
---|
| 588 | sel = select_available_maillists.options; |
---|
| 589 | option = new Option(select_available_maillists_clone[i].text,select_available_maillists_clone[i].value); |
---|
| 590 | sel[sel.length] = option; |
---|
| 591 | } |
---|
| 592 | } |
---|
| 593 | oWait.innerHTML = ' '; |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | // Variaveis Locais |
---|
| 597 | var finderTimeout_group = ''; |
---|
| 598 | |
---|
| 599 | |
---|
| 600 | // Funcoes Find Group |
---|
| 601 | function optionFinderTimeout_group(obj) |
---|
| 602 | { |
---|
| 603 | clearTimeout(finderTimeout_group); |
---|
| 604 | var oWait = document.getElementById("ea_span_searching_group"); |
---|
[414] | 605 | oWait.innerHTML = get_lang('Searching') + '...'; |
---|
[2] | 606 | finderTimeout_group = setTimeout("optionFinder_group('"+obj.id+"')",500); |
---|
| 607 | } |
---|
| 608 | function optionFinder_group(id) { |
---|
| 609 | var oWait = document.getElementById("ea_span_searching_group"); |
---|
| 610 | var oText = document.getElementById(id); |
---|
| 611 | |
---|
| 612 | //Limpa todo o select |
---|
| 613 | for(var i = 0;i < select_available_groups.options.length; i++) |
---|
| 614 | select_available_groups.options[i--] = null; |
---|
| 615 | |
---|
| 616 | var RegExp_name = new RegExp(oText.value, "i"); |
---|
| 617 | |
---|
| 618 | //Inclui as listas começando com a pesquisa |
---|
| 619 | for(i = 0; i < select_available_groups_clone.length; i++){ |
---|
| 620 | if (RegExp_name.test(select_available_groups_clone[i].text)) |
---|
| 621 | { |
---|
| 622 | sel = select_available_groups.options; |
---|
| 623 | option = new Option(select_available_groups_clone[i].text,select_available_groups_clone[i].value); |
---|
| 624 | sel[sel.length] = option; |
---|
| 625 | } |
---|
| 626 | } |
---|
| 627 | oWait.innerHTML = ' '; |
---|
[33] | 628 | } |
---|
| 629 | |
---|
| 630 | function get_available_sambadomains(context, type) |
---|
| 631 | { |
---|
[64] | 632 | if ((type == 'create_user') && (document.getElementById('tabcontent7').style.display != 'none')) |
---|
[33] | 633 | { |
---|
| 634 | var handler_get_available_sambadomains = function(data) |
---|
| 635 | { |
---|
| 636 | document.forms[0].use_attrs_samba.checked = data.status; |
---|
| 637 | use_samba_attrs(data.status); |
---|
| 638 | |
---|
| 639 | if (data.status) |
---|
| 640 | { |
---|
| 641 | combo_sambadomains = document.getElementById('ea_combo_sambadomains'); |
---|
| 642 | for (i=0; i<data.sambaDomains.length; i++) |
---|
| 643 | { |
---|
| 644 | for (j=0; j<combo_sambadomains.length; j++) |
---|
| 645 | { |
---|
| 646 | if (combo_sambadomains.options[j].text == data.sambaDomains[i]) |
---|
| 647 | { |
---|
| 648 | combo_sambadomains.options[j].selected = true; |
---|
| 649 | break; |
---|
| 650 | } |
---|
| 651 | } |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | } |
---|
| 655 | } |
---|
[64] | 656 | |
---|
[33] | 657 | cExecute ('$this.ldap_functions.exist_sambadomains_in_context&context='+context, handler_get_available_sambadomains); |
---|
| 658 | } |
---|
[63] | 659 | } |
---|
| 660 | |
---|
| 661 | function empty_inbox(uid) |
---|
| 662 | { |
---|
[414] | 663 | var action = get_lang('Cleanned user mailbox'); |
---|
[63] | 664 | var handler_write_log = function(){} |
---|
| 665 | var handler_empty_inbox = function(data) |
---|
| 666 | { |
---|
| 667 | if (!data.status) |
---|
| 668 | alert(data.msg); |
---|
| 669 | else{ |
---|
| 670 | cExecute ('$this.user.write_log_from_ajax&_action='+action+'&userinfo='+uid, handler_write_log); |
---|
[1913] | 671 | alert(get_lang('Emptied')+' '+ data.inbox_size + ' ' + get_lang('MB from user inbox')); |
---|
[63] | 672 | document.getElementById('mailquota_used').value = data.mailquota_used; |
---|
| 673 | } |
---|
| 674 | } |
---|
[1913] | 675 | cExecute ('$this.imap_functions.empty_user_inbox&uid='+uid, handler_empty_inbox); |
---|
[63] | 676 | } |
---|
| 677 | |
---|
| 678 | function validarCPF(cpf) |
---|
| 679 | { |
---|
| 680 | if(cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || |
---|
| 681 | cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || |
---|
| 682 | cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || |
---|
| 683 | cpf == "88888888888" || cpf == "99999999999"){ |
---|
| 684 | return false; |
---|
| 685 | } |
---|
| 686 | |
---|
| 687 | soma = 0; |
---|
| 688 | for(i = 0; i < 9; i++) |
---|
| 689 | soma += parseInt(cpf.charAt(i)) * (10 - i); |
---|
| 690 | resto = 11 - (soma % 11); |
---|
| 691 | if(resto == 10 || resto == 11) |
---|
| 692 | resto = 0; |
---|
| 693 | if(resto != parseInt(cpf.charAt(9))) |
---|
| 694 | { |
---|
| 695 | return false; |
---|
| 696 | } |
---|
| 697 | |
---|
| 698 | soma = 0; |
---|
| 699 | for(i = 0; i < 10; i ++) |
---|
| 700 | soma += parseInt(cpf.charAt(i)) * (11 - i); |
---|
| 701 | resto = 11 - (soma % 11); |
---|
| 702 | if(resto == 10 || resto == 11) |
---|
| 703 | resto = 0; |
---|
| 704 | if(resto != parseInt(cpf.charAt(10))){ |
---|
| 705 | return false; |
---|
| 706 | } |
---|
| 707 | return true; |
---|
[72] | 708 | } |
---|
| 709 | |
---|
[208] | 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); |
---|
[540] | 743 | } |
---|
[1329] | 744 | |
---|
| 745 | function set_changepassword() |
---|
| 746 | { |
---|
| 747 | if (document.getElementById('passwd_expired').checked) |
---|
| 748 | { |
---|
| 749 | document.getElementById('changepassword').checked = true; |
---|
| 750 | document.getElementById('changepassword').disabled = true; |
---|
| 751 | } |
---|
| 752 | else |
---|
| 753 | { |
---|
| 754 | document.getElementById('changepassword').disabled =false; |
---|
| 755 | } |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | |
---|