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