[2] | 1 | countFiles = 0; |
---|
[309] | 2 | function validate_fields(type) |
---|
[2] | 3 | { |
---|
| 4 | document.forms[0].uid.value = document.forms[0].uid.value.toLowerCase(); |
---|
| 5 | document.forms[0].old_uid.value = document.forms[0].old_uid.value.toLowerCase(); |
---|
[414] | 6 | |
---|
[2] | 7 | if (document.forms[0].uid.value == ''){ |
---|
[422] | 8 | alert(get_lang('login field is empty') + '.'); |
---|
[2] | 9 | return; |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | if (document.forms[0].cn.value == ''){ |
---|
[422] | 13 | alert(get_lang('name field is empty') + '.'); |
---|
[2] | 14 | return; |
---|
| 15 | } |
---|
[23] | 16 | |
---|
[309] | 17 | if (document.forms[0].restrictionsOnEmailLists.value == 'true') |
---|
[23] | 18 | { |
---|
| 19 | uid_tmp = document.forms[0].uid.value.split("-"); |
---|
| 20 | if ((uid_tmp.length < 3) || (uid_tmp[0] != 'lista')){ |
---|
[309] | 21 | alert( |
---|
[422] | 22 | get_lang('login field is incomplete') + '.\n' + |
---|
[414] | 23 | get_lang('the login field must be formed like') + ':\n' + |
---|
| 24 | get_lang('list') + '-' + get_lang('organization') + '-' + get_lang('listname') + '.\n' + |
---|
| 25 | get_lang('eg') + ': ' + 'lista-celepar-rh.'); |
---|
[23] | 26 | return; |
---|
| 27 | } |
---|
[2] | 28 | } |
---|
| 29 | |
---|
| 30 | if (document.forms[0].uid.value.split(" ").length > 1){ |
---|
[414] | 31 | alert(get_lang('LOGIN field contains characters not allowed') + '.'); |
---|
[2] | 32 | document.forms[0].uid.focus(); |
---|
| 33 | return; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | if (document.forms[0].mail.value == ''){ |
---|
[414] | 37 | alert(get_lang('EMAIL field is empty') + '.'); |
---|
[2] | 38 | document.forms[0].mail.focus(); |
---|
| 39 | return; |
---|
| 40 | } |
---|
| 41 | var reEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; |
---|
| 42 | if(!reEmail.test(document.forms[0].mail.value)){ |
---|
[414] | 43 | alert(get_lang('Email field is not valid') + '.'); |
---|
[2] | 44 | return false; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | select_userInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 48 | if (select_userInMaillist.options.length == 0){ |
---|
[414] | 49 | alert(get_lang('Any user is in the list') + '.'); |
---|
[2] | 50 | return; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | var handler_validate_fields = function(data) |
---|
| 54 | { |
---|
| 55 | if (!data.status) |
---|
| 56 | alert(data.msg); |
---|
| 57 | else |
---|
| 58 | { |
---|
| 59 | if (type == 'create_maillist') |
---|
| 60 | cExecuteForm ("$this.maillist.create", document.forms[0], handler_create); |
---|
| 61 | else if (type == 'edit_maillist') |
---|
| 62 | cExecuteForm ("$this.maillist.save", document.forms[0], handler_save); |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | // Needed select all options from select |
---|
| 67 | for(var i=0; i<select_userInMaillist.options.length; i++) |
---|
[208] | 68 | { |
---|
| 69 | // No IE, não seleciona o separador do select |
---|
| 70 | if (select_userInMaillist.options[i].value != -1) |
---|
| 71 | select_userInMaillist.options[i].selected = true; |
---|
| 72 | else |
---|
| 73 | select_userInMaillist.options[i].selected = false; |
---|
| 74 | } |
---|
| 75 | |
---|
[2] | 76 | // O UID da lista foi alterado ou é uma nova lista. |
---|
| 77 | if ((document.forms[0].old_uid.value != document.forms[0].uid.value) || (type == 'create_maillist')){ |
---|
[208] | 78 | cExecute ('$this.maillist.validate_fields&uid='+document.forms[0].uid.value+'&mail='+document.forms[0].mail.value, handler_validate_fields); |
---|
[2] | 79 | } |
---|
| 80 | else if (type == 'edit_maillist') |
---|
| 81 | { |
---|
| 82 | cExecuteForm ("$this.maillist.save", document.forms[0], handler_save); |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | // HANDLER CREATE |
---|
| 87 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 88 | function handler_create(data) |
---|
| 89 | { |
---|
| 90 | return_handler_create(data); |
---|
| 91 | } |
---|
| 92 | function return_handler_create(data) |
---|
| 93 | { |
---|
| 94 | if (!data.status) |
---|
| 95 | alert(data.msg); |
---|
| 96 | else{ |
---|
[482] | 97 | alert(get_lang('Email list successful created') + '.'); |
---|
[2] | 98 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 99 | } |
---|
| 100 | return; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | // HANDLER SAVE |
---|
| 104 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 105 | function handler_save(data) |
---|
| 106 | { |
---|
| 107 | return_handler_save(data); |
---|
| 108 | } |
---|
| 109 | function return_handler_save(data) |
---|
| 110 | { |
---|
| 111 | if (!data.status) |
---|
| 112 | alert(data.msg); |
---|
| 113 | else{ |
---|
[482] | 114 | alert(get_lang('Email list successful saved') + '.'); |
---|
[2] | 115 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 116 | } |
---|
| 117 | return; |
---|
| 118 | } |
---|
| 119 | |
---|
[23] | 120 | function save_scl() |
---|
| 121 | { |
---|
| 122 | select_users_SCL_Maillist = document.getElementById('ea_select_users_SCL_Maillist'); |
---|
| 123 | // Needed select all options from select |
---|
| 124 | for(var i=0; i<select_users_SCL_Maillist.options.length; i++) |
---|
| 125 | select_users_SCL_Maillist.options[i].selected = true; |
---|
[2] | 126 | |
---|
[23] | 127 | cExecuteForm ("$this.maillist.save_scl", document.forms[0], handler_save_scl); |
---|
| 128 | } |
---|
| 129 | function handler_save_scl(data) |
---|
| 130 | { |
---|
| 131 | return_handler_save_scl(data); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | function return_handler_save_scl(data) |
---|
| 135 | { |
---|
| 136 | if (!data.status) |
---|
| 137 | alert(data.msg); |
---|
| 138 | else |
---|
[482] | 139 | alert(get_lang('SCL successful saved') + '.'); |
---|
[23] | 140 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 141 | return; |
---|
| 142 | } |
---|
| 143 | |
---|
[2] | 144 | function sinc_combos_org(context, recursive) |
---|
| 145 | { |
---|
| 146 | combo_org_maillists = document.getElementById('ea_combo_org_maillists'); |
---|
| 147 | |
---|
| 148 | for (i=0; i<combo_org_maillists.length; i++) |
---|
| 149 | { |
---|
| 150 | if (combo_org_maillists.options[i].value == context) |
---|
| 151 | { |
---|
| 152 | combo_org_maillists.options[i].selected = true; |
---|
| 153 | get_available_users(context, recursive); |
---|
| 154 | break; |
---|
| 155 | } |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | |
---|
[3351] | 159 | function get_available_users(context, recursive,listSearch) |
---|
[2] | 160 | { |
---|
[3351] | 161 | //Impede chamada recursiva na raiz das organizações |
---|
| 162 | if(document.getElementById("autosearch").value == "true"){ |
---|
| 163 | if ((recursive) && (document.forms[0].ldap_context.value == document.getElementById('ea_combo_org_maillists').value)) |
---|
[2] | 164 | { |
---|
[3351] | 165 | alert(get_lang('It is not allow select all users from the root organization') + '.'); |
---|
| 166 | document.getElementById('ea_check_allUsers').checked = false; |
---|
| 167 | |
---|
| 168 | // Limpa select |
---|
| 169 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 170 | select_available_users.innerHTML = ' '; |
---|
[2] | 171 | select_available_users.outerHTML = select_available_users.outerHTML; |
---|
[3351] | 172 | return; |
---|
[2] | 173 | } |
---|
[3351] | 174 | cExecute ('$this.ldap_functions.get_available_users_and_maillist&context='+context+'&recursive='+recursive+'&denied_uidnumber='+document.forms[0].uidnumber.value+'&listSearch='+listSearch, handler_get_available_users); |
---|
| 175 | }else |
---|
| 176 | document.getElementById('ea_input_searchUser').value = ''; |
---|
[2] | 177 | } |
---|
| 178 | |
---|
| 179 | function add_user2maillist() |
---|
| 180 | { |
---|
| 181 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 182 | select_usersInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 183 | |
---|
| 184 | var count_available_users = select_available_users.length; |
---|
| 185 | var count_usersInMailList = select_usersInMaillist.options.length; |
---|
| 186 | var new_options = ''; |
---|
| 187 | |
---|
| 188 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 189 | { |
---|
| 190 | if (select_available_users.options[i].selected) |
---|
| 191 | { |
---|
| 192 | if(document.all) |
---|
| 193 | { |
---|
| 194 | if ( (select_usersInMaillist.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 195 | { |
---|
| 196 | new_options += "<option value=" |
---|
| 197 | + select_available_users.options[i].value |
---|
| 198 | + ">" |
---|
| 199 | + select_available_users.options[i].text |
---|
| 200 | + "</options>"; |
---|
| 201 | } |
---|
| 202 | } |
---|
| 203 | else |
---|
| 204 | { |
---|
| 205 | if ( (select_usersInMaillist.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 206 | { |
---|
| 207 | new_options += "<option value=" |
---|
| 208 | + select_available_users.options[i].value |
---|
| 209 | + ">" |
---|
| 210 | + select_available_users.options[i].text |
---|
| 211 | + "</options>"; |
---|
| 212 | } |
---|
| 213 | } |
---|
| 214 | } |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | if (new_options != '') |
---|
| 218 | { |
---|
[86] | 219 | select_usersInMaillist.innerHTML = ' ' + new_options + select_usersInMaillist.innerHTML; |
---|
[2] | 220 | select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML; |
---|
[81] | 221 | document.getElementById('ea_input_searchUser').value = ""; |
---|
[2] | 222 | } |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | function remove_user2maillist() |
---|
| 226 | { |
---|
| 227 | select_usersInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 228 | |
---|
| 229 | for(var i = 0;i < select_usersInMaillist.options.length; i++) |
---|
| 230 | if(select_usersInMaillist.options[i].selected) |
---|
| 231 | select_usersInMaillist.options[i--] = null; |
---|
| 232 | } |
---|
| 233 | |
---|
[23] | 234 | function add_user2scl_maillist() |
---|
| 235 | { |
---|
| 236 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 237 | select_usersInMaillist = document.getElementById('ea_select_users_SCL_Maillist'); |
---|
| 238 | |
---|
| 239 | var count_available_users = select_available_users.length; |
---|
| 240 | var count_usersInMailList = select_usersInMaillist.options.length; |
---|
| 241 | var new_options = ''; |
---|
| 242 | |
---|
| 243 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 244 | { |
---|
| 245 | if (select_available_users.options[i].selected) |
---|
| 246 | { |
---|
| 247 | if(document.all) |
---|
| 248 | { |
---|
| 249 | if ( (select_usersInMaillist.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 250 | { |
---|
| 251 | new_options += "<option value=" |
---|
| 252 | + select_available_users.options[i].value |
---|
| 253 | + ">" |
---|
| 254 | + select_available_users.options[i].text |
---|
| 255 | + "</options>"; |
---|
| 256 | } |
---|
| 257 | } |
---|
| 258 | else |
---|
| 259 | { |
---|
| 260 | if ( (select_usersInMaillist.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 261 | { |
---|
| 262 | new_options += "<option value=" |
---|
| 263 | + select_available_users.options[i].value |
---|
| 264 | + ">" |
---|
| 265 | + select_available_users.options[i].text |
---|
| 266 | + "</options>"; |
---|
| 267 | } |
---|
| 268 | } |
---|
| 269 | } |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | if (new_options != '') |
---|
| 273 | { |
---|
| 274 | select_usersInMaillist.innerHTML = '#' + new_options + select_usersInMaillist.innerHTML; |
---|
| 275 | select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML; |
---|
| 276 | } |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | function remove_user2scl_maillist() |
---|
| 280 | { |
---|
| 281 | select_usersInMaillist = document.getElementById('ea_select_users_SCL_Maillist'); |
---|
| 282 | |
---|
| 283 | for(var i = 0;i < select_usersInMaillist.options.length; i++) |
---|
| 284 | if(select_usersInMaillist.options[i].selected) |
---|
| 285 | select_usersInMaillist.options[i--] = null; |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | |
---|
[2] | 289 | // Variaveis Locais |
---|
| 290 | if (document.getElementById('ea_select_available_users')) |
---|
| 291 | { |
---|
| 292 | var select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 293 | var select_available_users_clone = select_available_users.cloneNode(true); |
---|
| 294 | } |
---|
| 295 | else |
---|
| 296 | { |
---|
| 297 | var select_available_users = ''; |
---|
| 298 | var select_available_users_clone = ''; |
---|
| 299 | } |
---|
| 300 | var finderTimeout = ''; |
---|
| 301 | |
---|
[317] | 302 | // Funcoes |
---|
[3351] | 303 | /*function optionFinderTimeout(obj) |
---|
[2] | 304 | { |
---|
| 305 | clearTimeout(finderTimeout); |
---|
| 306 | var oWait = document.getElementById("ea_span_searching"); |
---|
[414] | 307 | oWait.innerHTML = get_lang('Searching') + '...'; |
---|
[2] | 308 | finderTimeout = setTimeout("optionFinder('"+obj.id+"')",500); |
---|
[3351] | 309 | }*/ |
---|
| 310 | |
---|
| 311 | function optionFinderTimeout(obj, numMin, type, autoSearch,listSearch){ |
---|
| 312 | var oWait = document.getElementById("ea_span_searching"); |
---|
| 313 | oWait.innerHTML = 'Buscando...'; |
---|
| 314 | clearTimeout(finderTimeout); |
---|
| 315 | |
---|
| 316 | if(autoSearch == "True"){ |
---|
| 317 | finderTimeout = setTimeout("optionFinderLocal('"+obj.id+"')",600); |
---|
| 318 | } |
---|
| 319 | else if (obj.value.length >= numMin){ |
---|
| 320 | finderTimeout = setTimeout("optionFinderLdap('"+obj.id+"','"+numMin+"','"+type+"','"+listSearch+"')",600); |
---|
| 321 | }else { |
---|
| 322 | oWait.innerHTML = 'Mínimo de '+numMin+' letras para pesquisa'; |
---|
| 323 | var select_available_users_tmp = document.getElementById('ea_select_available_users'); |
---|
| 324 | for(var i = 0;i < select_available_users_tmp.options.length; i++) |
---|
| 325 | select_available_users_tmp.options[i--] = null; |
---|
| 326 | } |
---|
[2] | 327 | } |
---|
[3351] | 328 | var handler_get_available_users = function(data) |
---|
| 329 | { |
---|
| 330 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 331 | |
---|
| 332 | //Limpa o select |
---|
| 333 | for(var i=0; i<select_available_users.options.length; i++) |
---|
| 334 | { |
---|
| 335 | select_available_users.options[i] = null; |
---|
| 336 | i--; |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | if ((data) && (data.length > 0)) |
---|
| 340 | { |
---|
| 341 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 342 | select_available_users.innerHTML = ' ' + data; |
---|
| 343 | select_available_users.outerHTML = select_available_users.outerHTML; |
---|
| 344 | |
---|
| 345 | select_available_users.disabled = false; |
---|
| 346 | select_available_users_clone = document.getElementById('ea_select_available_users').cloneNode(true); |
---|
| 347 | //document.getElementById('ea_input_searchUser').value = ''; |
---|
| 348 | } |
---|
| 349 | |
---|
| 350 | } |
---|
| 351 | // Pesquisa LDAP |
---|
| 352 | function optionFinderLdap(id,numMin, type,listSearch){ |
---|
[2] | 353 | var oWait = document.getElementById("ea_span_searching"); |
---|
| 354 | var oText = document.getElementById(id); |
---|
[3351] | 355 | |
---|
| 356 | if (oText.value.length < numMin) { |
---|
| 357 | oWait.innerHTML = ''; |
---|
| 358 | var select_available_users_tmp = document.getElementById('ea_select_available_users'); |
---|
| 359 | for(var i = 0;i < select_available_users_tmp.options.length; i++) |
---|
| 360 | select_available_users_tmp.options[i--] = null; |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | if (oText.value.length >= numMin){ |
---|
| 364 | var context = document.getElementById('ea_combo_org_maillists').value; |
---|
| 365 | recursive = document.getElementById("ea_check_allUsers").checked; |
---|
| 366 | cExecute ('$this.ldap_functions.search_available_users_and_maillist&context='+(context)+'&recursive='+(recursive)+'&type='+(type == '' ? 'list' : 'search')+'&filter='+oText.value+'&listSearch='+listSearch, handler_get_available_users); |
---|
| 367 | oWait.innerHTML = ' '; |
---|
| 368 | } |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | function optionFinderLocal(id) { |
---|
| 372 | var oWait = document.getElementById("ea_span_searching"); |
---|
| 373 | var oText = document.getElementById(id); |
---|
[2] | 374 | |
---|
| 375 | //Limpa todo o select |
---|
| 376 | var select_available_users_tmp = document.getElementById('ea_select_available_users') |
---|
[23] | 377 | |
---|
[2] | 378 | for(var i = 0;i < select_available_users_tmp.options.length; i++) |
---|
| 379 | select_available_users_tmp.options[i--] = null; |
---|
[23] | 380 | |
---|
[2] | 381 | var RegExp_name = new RegExp("\\b"+oText.value, "i"); |
---|
[23] | 382 | |
---|
[2] | 383 | //Inclui usuário começando com a pesquisa |
---|
[23] | 384 | for(i = 0; i < select_available_users_clone.length; i++){ |
---|
| 385 | if ( RegExp_name.test(select_available_users_clone[i].text) || (select_available_users_clone[i].value == -1) ) |
---|
[2] | 386 | { |
---|
| 387 | sel = select_available_users_tmp.options; |
---|
[23] | 388 | option = new Option(select_available_users_clone[i].text,select_available_users_clone[i].value); |
---|
| 389 | |
---|
| 390 | if (select_available_users_clone[i].value == -1) |
---|
| 391 | option.disabled = true; |
---|
| 392 | |
---|
[2] | 393 | sel[sel.length] = option; |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | oWait.innerHTML = ' '; |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | function delete_maillist(uid, uidnumber) |
---|
| 400 | { |
---|
[414] | 401 | if (confirm(get_lang('Do you really want delete the email list') + ' ' + uid + " ??")) |
---|
| 402 | |
---|
[2] | 403 | { |
---|
| 404 | var handler_delete_maillist = function(data) |
---|
| 405 | { |
---|
| 406 | if (!data.status) |
---|
| 407 | alert(data.msg); |
---|
| 408 | else |
---|
[438] | 409 | alert(get_lang('Email list successful deleted') + '.'); |
---|
[2] | 410 | |
---|
| 411 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 412 | return; |
---|
| 413 | } |
---|
[309] | 414 | cExecute ('$this.maillist.delete&uidnumber='+uidnumber, handler_delete_maillist); |
---|
[2] | 415 | } |
---|
| 416 | } |
---|
[73] | 417 | |
---|
[180] | 418 | function search_organization(key, element) |
---|
[73] | 419 | { |
---|
[180] | 420 | var organizations = document.getElementById(element); |
---|
[73] | 421 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
| 422 | |
---|
| 423 | for(i = 0; i < organizations.length; i++) |
---|
| 424 | { |
---|
| 425 | if (RegExp_org.test(organizations[i].text)) |
---|
| 426 | { |
---|
| 427 | organizations[i].selected = true; |
---|
| 428 | return; |
---|
| 429 | } |
---|
| 430 | } |
---|
[180] | 431 | } |
---|
| 432 | |
---|
| 433 | function emailSuggestion_maillist() |
---|
| 434 | { |
---|
| 435 | var defaultDomain = document.forms[0].defaultDomain.value; |
---|
| 436 | var base_dn = "." + dn2ufn(document.forms[0].ldap_context.value); |
---|
| 437 | var selected_context = dn2ufn(document.forms[0].context.value.toLowerCase()); |
---|
| 438 | |
---|
| 439 | var uid = document.getElementById("ea_maillist_uid"); |
---|
| 440 | var mail= document.getElementById("ea_maillist_mail"); |
---|
| 441 | |
---|
| 442 | var raw_selected_context = selected_context.replace(base_dn, ""); |
---|
| 443 | |
---|
| 444 | var array_org_name = raw_selected_context.split('.'); |
---|
| 445 | var org_name = array_org_name[array_org_name.length-1]; |
---|
| 446 | |
---|
| 447 | if (mail.value == "") |
---|
| 448 | mail.value = uid.value + "@" + org_name + "." + defaultDomain; |
---|
| 449 | } |
---|
| 450 | |
---|
| 451 | function dn2ufn(dn) |
---|
| 452 | { |
---|
| 453 | var ufn = ''; |
---|
| 454 | var array_dn = dn.split(","); |
---|
| 455 | for (x in array_dn) |
---|
| 456 | { |
---|
| 457 | var tmp = array_dn[x].split("="); |
---|
| 458 | ufn += tmp[1] + '.'; |
---|
| 459 | } |
---|
| 460 | return ufn.substring(0,(ufn.length-1)); |
---|
[4685] | 461 | } |
---|
| 462 | function LTrim(value) |
---|
| 463 | { |
---|
| 464 | var w_space = String.fromCharCode(32); |
---|
| 465 | var strTemp = ""; |
---|
| 466 | var iTemp = 0; |
---|
| 467 | |
---|
| 468 | var v_length = value ? value.length : 0; |
---|
| 469 | if(v_length < 1) |
---|
| 470 | return ""; |
---|
| 471 | |
---|
| 472 | while(iTemp < v_length){ |
---|
| 473 | if(value && value.charAt(iTemp) != w_space){ |
---|
| 474 | strTemp = value.substring(iTemp,v_length); |
---|
| 475 | break; |
---|
| 476 | } |
---|
| 477 | iTemp++; |
---|
| 478 | } |
---|
| 479 | return strTemp; |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | function validateEmail() |
---|
| 483 | { |
---|
| 484 | |
---|
| 485 | externalEmail = document.getElementById('ea_input_externalUser'); |
---|
| 486 | |
---|
| 487 | if( externalEmail.value ) |
---|
| 488 | { |
---|
| 489 | //var element = arguments[0]; |
---|
| 490 | var validate = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; |
---|
| 491 | |
---|
| 492 | if(this.LTrim(externalEmail.value) != "" && externalEmail.value != "") |
---|
| 493 | { |
---|
| 494 | if(!validate.test(externalEmail.value)) |
---|
| 495 | { |
---|
| 496 | alert(get_lang('Email address is not valid') + '.'); |
---|
| 497 | externalEmail.focus(); |
---|
| 498 | return false; |
---|
| 499 | }else { |
---|
| 500 | this.add_externalUser2maillist(externalEmail.value); |
---|
| 501 | } |
---|
| 502 | } |
---|
| 503 | |
---|
| 504 | } |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | function add_externalUser2maillist(mailAddress) |
---|
| 508 | { |
---|
| 509 | input_externalUsers = mailAddress.toLowerCase(); //document.getElementById('ea_input_externalUser').value; |
---|
| 510 | select_usersInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 511 | |
---|
| 512 | var count_externalUsers = input_externalUsers.length; |
---|
| 513 | var count_usersInMaillist = select_usersInMaillist.options.length; |
---|
| 514 | var new_options = ''; |
---|
| 515 | |
---|
| 516 | var teste = ''; //Variavel que ira receber mensagem de alerta ao usuario; |
---|
| 517 | var alerta = new Boolean(0); //Variavel que sera usada para verificar se o alerta ao usuario sera exibido ou nao; |
---|
| 518 | |
---|
| 519 | //Laco abaixo compara se o valor escolhido em select_available_users ja existe em select_usersInMaillist |
---|
| 520 | //se existir, adiciona o valor em teste e muda a variavel alerta para true; teste sera exibido em tela |
---|
| 521 | //apenas de alerta true; ver if no fim da funcao; |
---|
| 522 | for(j = 0; j < count_usersInMaillist; j++) |
---|
| 523 | { |
---|
| 524 | var tmp = select_usersInMaillist.options[j].text |
---|
| 525 | |
---|
| 526 | if(tmp.match(input_externalUsers)) |
---|
| 527 | { |
---|
| 528 | teste = get_lang("User already belongs to the list") + "\n" + input_externalUsers + "\n"; |
---|
| 529 | alerta = new Boolean(1); |
---|
| 530 | } |
---|
| 531 | } |
---|
| 532 | |
---|
| 533 | if(alerta != true) |
---|
| 534 | { |
---|
| 535 | if(document.all) |
---|
| 536 | { |
---|
| 537 | if ( (select_usersInMaillist.innerHTML.indexOf('value='+input_externalUsers)) == '-1' ) |
---|
| 538 | { |
---|
| 539 | new_options += "<option value=" |
---|
| 540 | + input_externalUsers |
---|
| 541 | + ">" |
---|
| 542 | + input_extenalUsers |
---|
| 543 | + "</options>"; |
---|
| 544 | } |
---|
| 545 | } |
---|
| 546 | else |
---|
| 547 | { |
---|
| 548 | if ( (select_usersInMaillist.innerHTML.indexOf('value="'+input_externalUsers+'"')) == '-1' ) |
---|
| 549 | { |
---|
| 550 | new_options += "<option value=" |
---|
| 551 | + input_externalUsers |
---|
| 552 | + ">" |
---|
| 553 | + input_externalUsers |
---|
| 554 | + "</options>"; |
---|
| 555 | } |
---|
| 556 | } |
---|
| 557 | } |
---|
| 558 | |
---|
| 559 | if(alerta == true) |
---|
| 560 | { |
---|
| 561 | alert(teste); |
---|
| 562 | } |
---|
| 563 | |
---|
| 564 | |
---|
| 565 | if (new_options != '') |
---|
| 566 | { |
---|
| 567 | select_usersInMaillist.innerHTML = new_options + select_usersInMaillist.innerHTML; |
---|
| 568 | select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML; |
---|
| 569 | } |
---|
| 570 | |
---|
| 571 | document.getElementById('ea_input_externalUser').value = ''; |
---|
[309] | 572 | } |
---|