[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{ |
---|
[422] | 97 | alert(get_lang('Email list sucessful 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{ |
---|
[422] | 114 | alert(get_lang('Email list sucessful 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 |
---|
[422] | 139 | alert(get_lang('SCL sucessful 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 | |
---|
| 159 | function get_available_users(context, recursive) |
---|
| 160 | { |
---|
| 161 | var handler_get_available_users = function(data) |
---|
| 162 | { |
---|
| 163 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 164 | |
---|
| 165 | //Limpa o select |
---|
| 166 | for(var i=0; i<select_available_users.options.length; i++) |
---|
| 167 | { |
---|
| 168 | select_available_users.options[i] = null; |
---|
| 169 | i--; |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | if ((data) && (data.length > 0)) |
---|
| 173 | { |
---|
| 174 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
[86] | 175 | select_available_users.innerHTML = ' ' + data; |
---|
[2] | 176 | select_available_users.outerHTML = select_available_users.outerHTML; |
---|
| 177 | |
---|
| 178 | select_available_users.disabled = false; |
---|
| 179 | select_available_users_clone = document.getElementById('ea_select_available_users').cloneNode(true); |
---|
| 180 | document.getElementById('ea_input_searchUser').value = ''; |
---|
| 181 | } |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | //Impede chamada recursiva na raiz das organizações |
---|
| 185 | if ((recursive) && (document.forms[0].ldap_context.value == document.getElementById('ea_combo_org_maillists').value)) |
---|
| 186 | { |
---|
[414] | 187 | alert(get_lang('It is not allow select all users from the root organization') + '.'); |
---|
[2] | 188 | document.getElementById('ea_check_allUsers').checked = false; |
---|
| 189 | |
---|
| 190 | // Limpa select |
---|
| 191 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
[86] | 192 | select_available_users.innerHTML = ' '; |
---|
[2] | 193 | select_available_users.outerHTML = select_available_users.outerHTML; |
---|
| 194 | return; |
---|
| 195 | } |
---|
[23] | 196 | cExecute ('$this.ldap_functions.get_available_users_and_maillist&context='+context+'&recursive='+recursive+'&denied_uidnumber='+document.forms[0].uidnumber.value, handler_get_available_users); |
---|
[2] | 197 | } |
---|
| 198 | |
---|
| 199 | function add_user2maillist() |
---|
| 200 | { |
---|
| 201 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 202 | select_usersInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 203 | |
---|
| 204 | var count_available_users = select_available_users.length; |
---|
| 205 | var count_usersInMailList = select_usersInMaillist.options.length; |
---|
| 206 | var new_options = ''; |
---|
| 207 | |
---|
| 208 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 209 | { |
---|
| 210 | if (select_available_users.options[i].selected) |
---|
| 211 | { |
---|
| 212 | if(document.all) |
---|
| 213 | { |
---|
| 214 | if ( (select_usersInMaillist.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 215 | { |
---|
| 216 | new_options += "<option value=" |
---|
| 217 | + select_available_users.options[i].value |
---|
| 218 | + ">" |
---|
| 219 | + select_available_users.options[i].text |
---|
| 220 | + "</options>"; |
---|
| 221 | } |
---|
| 222 | } |
---|
| 223 | else |
---|
| 224 | { |
---|
| 225 | if ( (select_usersInMaillist.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 226 | { |
---|
| 227 | new_options += "<option value=" |
---|
| 228 | + select_available_users.options[i].value |
---|
| 229 | + ">" |
---|
| 230 | + select_available_users.options[i].text |
---|
| 231 | + "</options>"; |
---|
| 232 | } |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | if (new_options != '') |
---|
| 238 | { |
---|
[86] | 239 | select_usersInMaillist.innerHTML = ' ' + new_options + select_usersInMaillist.innerHTML; |
---|
[2] | 240 | select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML; |
---|
[81] | 241 | document.getElementById('ea_input_searchUser').value = ""; |
---|
[2] | 242 | } |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | function remove_user2maillist() |
---|
| 246 | { |
---|
| 247 | select_usersInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 248 | |
---|
| 249 | for(var i = 0;i < select_usersInMaillist.options.length; i++) |
---|
| 250 | if(select_usersInMaillist.options[i].selected) |
---|
| 251 | select_usersInMaillist.options[i--] = null; |
---|
| 252 | } |
---|
| 253 | |
---|
[23] | 254 | function add_user2scl_maillist() |
---|
| 255 | { |
---|
| 256 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 257 | select_usersInMaillist = document.getElementById('ea_select_users_SCL_Maillist'); |
---|
| 258 | |
---|
| 259 | var count_available_users = select_available_users.length; |
---|
| 260 | var count_usersInMailList = select_usersInMaillist.options.length; |
---|
| 261 | var new_options = ''; |
---|
| 262 | |
---|
| 263 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 264 | { |
---|
| 265 | if (select_available_users.options[i].selected) |
---|
| 266 | { |
---|
| 267 | if(document.all) |
---|
| 268 | { |
---|
| 269 | if ( (select_usersInMaillist.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 270 | { |
---|
| 271 | new_options += "<option value=" |
---|
| 272 | + select_available_users.options[i].value |
---|
| 273 | + ">" |
---|
| 274 | + select_available_users.options[i].text |
---|
| 275 | + "</options>"; |
---|
| 276 | } |
---|
| 277 | } |
---|
| 278 | else |
---|
| 279 | { |
---|
| 280 | if ( (select_usersInMaillist.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 281 | { |
---|
| 282 | new_options += "<option value=" |
---|
| 283 | + select_available_users.options[i].value |
---|
| 284 | + ">" |
---|
| 285 | + select_available_users.options[i].text |
---|
| 286 | + "</options>"; |
---|
| 287 | } |
---|
| 288 | } |
---|
| 289 | } |
---|
| 290 | } |
---|
| 291 | |
---|
| 292 | if (new_options != '') |
---|
| 293 | { |
---|
| 294 | select_usersInMaillist.innerHTML = '#' + new_options + select_usersInMaillist.innerHTML; |
---|
| 295 | select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML; |
---|
| 296 | } |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | function remove_user2scl_maillist() |
---|
| 300 | { |
---|
| 301 | select_usersInMaillist = document.getElementById('ea_select_users_SCL_Maillist'); |
---|
| 302 | |
---|
| 303 | for(var i = 0;i < select_usersInMaillist.options.length; i++) |
---|
| 304 | if(select_usersInMaillist.options[i].selected) |
---|
| 305 | select_usersInMaillist.options[i--] = null; |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | |
---|
[2] | 309 | // Variaveis Locais |
---|
| 310 | if (document.getElementById('ea_select_available_users')) |
---|
| 311 | { |
---|
| 312 | var select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 313 | var select_available_users_clone = select_available_users.cloneNode(true); |
---|
| 314 | } |
---|
| 315 | else |
---|
| 316 | { |
---|
| 317 | var select_available_users = ''; |
---|
| 318 | var select_available_users_clone = ''; |
---|
| 319 | } |
---|
| 320 | var finderTimeout = ''; |
---|
| 321 | |
---|
[317] | 322 | // Funcoes |
---|
[2] | 323 | function optionFinderTimeout(obj) |
---|
| 324 | { |
---|
| 325 | clearTimeout(finderTimeout); |
---|
| 326 | var oWait = document.getElementById("ea_span_searching"); |
---|
[414] | 327 | oWait.innerHTML = get_lang('Searching') + '...'; |
---|
[2] | 328 | finderTimeout = setTimeout("optionFinder('"+obj.id+"')",500); |
---|
| 329 | } |
---|
[23] | 330 | function optionFinder(id) { |
---|
[2] | 331 | var oWait = document.getElementById("ea_span_searching"); |
---|
| 332 | var oText = document.getElementById(id); |
---|
| 333 | |
---|
| 334 | //Limpa todo o select |
---|
| 335 | var select_available_users_tmp = document.getElementById('ea_select_available_users') |
---|
[23] | 336 | |
---|
[2] | 337 | for(var i = 0;i < select_available_users_tmp.options.length; i++) |
---|
| 338 | select_available_users_tmp.options[i--] = null; |
---|
[23] | 339 | |
---|
[2] | 340 | var RegExp_name = new RegExp("\\b"+oText.value, "i"); |
---|
[23] | 341 | |
---|
[2] | 342 | //Inclui usuário começando com a pesquisa |
---|
[23] | 343 | for(i = 0; i < select_available_users_clone.length; i++){ |
---|
| 344 | if ( RegExp_name.test(select_available_users_clone[i].text) || (select_available_users_clone[i].value == -1) ) |
---|
[2] | 345 | { |
---|
| 346 | sel = select_available_users_tmp.options; |
---|
[23] | 347 | option = new Option(select_available_users_clone[i].text,select_available_users_clone[i].value); |
---|
| 348 | |
---|
| 349 | if (select_available_users_clone[i].value == -1) |
---|
| 350 | option.disabled = true; |
---|
| 351 | |
---|
[2] | 352 | sel[sel.length] = option; |
---|
| 353 | } |
---|
| 354 | } |
---|
| 355 | oWait.innerHTML = ' '; |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | function delete_maillist(uid, uidnumber) |
---|
| 359 | { |
---|
[414] | 360 | if (confirm(get_lang('Do you really want delete the email list') + ' ' + uid + " ??")) |
---|
| 361 | |
---|
[2] | 362 | { |
---|
| 363 | var handler_delete_maillist = function(data) |
---|
| 364 | { |
---|
| 365 | if (!data.status) |
---|
| 366 | alert(data.msg); |
---|
| 367 | else |
---|
[438] | 368 | alert(get_lang('Email list successful deleted') + '.'); |
---|
[2] | 369 | |
---|
| 370 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 371 | return; |
---|
| 372 | } |
---|
[309] | 373 | cExecute ('$this.maillist.delete&uidnumber='+uidnumber, handler_delete_maillist); |
---|
[2] | 374 | } |
---|
| 375 | } |
---|
[73] | 376 | |
---|
[180] | 377 | function search_organization(key, element) |
---|
[73] | 378 | { |
---|
[180] | 379 | var organizations = document.getElementById(element); |
---|
[73] | 380 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
| 381 | |
---|
| 382 | for(i = 0; i < organizations.length; i++) |
---|
| 383 | { |
---|
| 384 | if (RegExp_org.test(organizations[i].text)) |
---|
| 385 | { |
---|
| 386 | organizations[i].selected = true; |
---|
| 387 | return; |
---|
| 388 | } |
---|
| 389 | } |
---|
[180] | 390 | } |
---|
| 391 | |
---|
| 392 | function emailSuggestion_maillist() |
---|
| 393 | { |
---|
| 394 | var defaultDomain = document.forms[0].defaultDomain.value; |
---|
| 395 | var base_dn = "." + dn2ufn(document.forms[0].ldap_context.value); |
---|
| 396 | var selected_context = dn2ufn(document.forms[0].context.value.toLowerCase()); |
---|
| 397 | |
---|
| 398 | var uid = document.getElementById("ea_maillist_uid"); |
---|
| 399 | var mail= document.getElementById("ea_maillist_mail"); |
---|
| 400 | |
---|
| 401 | var raw_selected_context = selected_context.replace(base_dn, ""); |
---|
| 402 | |
---|
| 403 | var array_org_name = raw_selected_context.split('.'); |
---|
| 404 | var org_name = array_org_name[array_org_name.length-1]; |
---|
| 405 | |
---|
| 406 | if (mail.value == "") |
---|
| 407 | mail.value = uid.value + "@" + org_name + "." + defaultDomain; |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | function dn2ufn(dn) |
---|
| 411 | { |
---|
| 412 | var ufn = ''; |
---|
| 413 | var array_dn = dn.split(","); |
---|
| 414 | for (x in array_dn) |
---|
| 415 | { |
---|
| 416 | var tmp = array_dn[x].split("="); |
---|
| 417 | ufn += tmp[1] + '.'; |
---|
| 418 | } |
---|
| 419 | return ufn.substring(0,(ufn.length-1)); |
---|
[309] | 420 | } |
---|