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