[2] | 1 | countFiles = 0; |
---|
| 2 | function validate_fields(type) |
---|
| 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(); |
---|
| 6 | |
---|
| 7 | if (document.forms[0].uid.value == ''){ |
---|
| 8 | alert('Campo LOGIN da lista está vazio.'); |
---|
| 9 | return; |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | if (document.forms[0].cn.value == ''){ |
---|
| 13 | alert('Campo NOME da lista está vazio.'); |
---|
| 14 | return; |
---|
| 15 | } |
---|
[23] | 16 | |
---|
| 17 | if (document.forms[0].restrictionsOnEmailLists.value == 'true') |
---|
| 18 | { |
---|
| 19 | uid_tmp = document.forms[0].uid.value.split("-"); |
---|
| 20 | if ((uid_tmp.length < 3) || (uid_tmp[0] != 'lista')){ |
---|
| 21 | alert( |
---|
| 22 | 'O campo LOGIN da lista está incompleto.\n' + |
---|
| 23 | 'O nome da lista deve ser formado assim:\n' + |
---|
| 24 | 'lista-ORGANIZACAO-NOME_DA_LISTA.\n' + |
---|
| 25 | 'Ex: lista-celepar-rh.'); |
---|
| 26 | return; |
---|
| 27 | } |
---|
[2] | 28 | } |
---|
| 29 | |
---|
| 30 | if (document.forms[0].uid.value.split(" ").length > 1){ |
---|
| 31 | alert('Campo LOGIN comtém espaços.'); |
---|
| 32 | document.forms[0].uid.focus(); |
---|
| 33 | return; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | if (document.forms[0].mail.value == ''){ |
---|
| 37 | alert('Campo E-MAIL da lista está vazio.'); |
---|
| 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)){ |
---|
| 43 | alert("Campo E-mail não é válido."); |
---|
| 44 | return false; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | select_userInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 48 | if (select_userInMaillist.options.length == 0){ |
---|
| 49 | alert('Nenhum usuário faz parte da lista.'); |
---|
| 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++) |
---|
| 68 | select_userInMaillist.options[i].selected = true; |
---|
| 69 | |
---|
| 70 | // O UID da lista foi alterado ou é uma nova lista. |
---|
| 71 | if ((document.forms[0].old_uid.value != document.forms[0].uid.value) || (type == 'create_maillist')){ |
---|
| 72 | cExecute ('$this.maillist.validate_fields&uid='+document.forms[0].uid.value, handler_validate_fields); |
---|
| 73 | } |
---|
| 74 | else if (type == 'edit_maillist') |
---|
| 75 | { |
---|
| 76 | cExecuteForm ("$this.maillist.save", document.forms[0], handler_save); |
---|
| 77 | } |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | // HANDLER CREATE |
---|
| 81 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 82 | function handler_create(data) |
---|
| 83 | { |
---|
| 84 | return_handler_create(data); |
---|
| 85 | } |
---|
| 86 | function return_handler_create(data) |
---|
| 87 | { |
---|
| 88 | if (!data.status) |
---|
| 89 | alert(data.msg); |
---|
| 90 | else{ |
---|
| 91 | alert('Lista de emails criada com êxito!'); |
---|
| 92 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 93 | } |
---|
| 94 | return; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | // HANDLER SAVE |
---|
| 98 | // É necessário 2 funcões de retorno por causa do cExecuteForm. |
---|
| 99 | function handler_save(data) |
---|
| 100 | { |
---|
| 101 | return_handler_save(data); |
---|
| 102 | } |
---|
| 103 | function return_handler_save(data) |
---|
| 104 | { |
---|
| 105 | if (!data.status) |
---|
| 106 | alert(data.msg); |
---|
| 107 | else{ |
---|
| 108 | alert('Lista de emails salva com êxito!!'); |
---|
| 109 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 110 | } |
---|
| 111 | return; |
---|
| 112 | } |
---|
| 113 | |
---|
[23] | 114 | function save_scl() |
---|
| 115 | { |
---|
| 116 | select_users_SCL_Maillist = document.getElementById('ea_select_users_SCL_Maillist'); |
---|
| 117 | // Needed select all options from select |
---|
| 118 | for(var i=0; i<select_users_SCL_Maillist.options.length; i++) |
---|
| 119 | select_users_SCL_Maillist.options[i].selected = true; |
---|
[2] | 120 | |
---|
[23] | 121 | cExecuteForm ("$this.maillist.save_scl", document.forms[0], handler_save_scl); |
---|
| 122 | } |
---|
| 123 | function handler_save_scl(data) |
---|
| 124 | { |
---|
| 125 | return_handler_save_scl(data); |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | function return_handler_save_scl(data) |
---|
| 129 | { |
---|
| 130 | if (!data.status) |
---|
| 131 | alert(data.msg); |
---|
| 132 | else |
---|
| 133 | alert('Sending Control List salva com êxito!!'); |
---|
| 134 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 135 | return; |
---|
| 136 | } |
---|
| 137 | |
---|
[2] | 138 | function sinc_combos_org(context, recursive) |
---|
| 139 | { |
---|
| 140 | combo_org_maillists = document.getElementById('ea_combo_org_maillists'); |
---|
| 141 | |
---|
| 142 | for (i=0; i<combo_org_maillists.length; i++) |
---|
| 143 | { |
---|
| 144 | if (combo_org_maillists.options[i].value == context) |
---|
| 145 | { |
---|
| 146 | combo_org_maillists.options[i].selected = true; |
---|
| 147 | get_available_users(context, recursive); |
---|
| 148 | break; |
---|
| 149 | } |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | function get_available_users(context, recursive) |
---|
| 154 | { |
---|
| 155 | var handler_get_available_users = function(data) |
---|
| 156 | { |
---|
| 157 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 158 | |
---|
| 159 | //Limpa o select |
---|
| 160 | for(var i=0; i<select_available_users.options.length; i++) |
---|
| 161 | { |
---|
| 162 | select_available_users.options[i] = null; |
---|
| 163 | i--; |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | if ((data) && (data.length > 0)) |
---|
| 167 | { |
---|
| 168 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
[86] | 169 | select_available_users.innerHTML = ' ' + data; |
---|
[2] | 170 | select_available_users.outerHTML = select_available_users.outerHTML; |
---|
| 171 | |
---|
| 172 | select_available_users.disabled = false; |
---|
| 173 | select_available_users_clone = document.getElementById('ea_select_available_users').cloneNode(true); |
---|
| 174 | document.getElementById('ea_input_searchUser').value = ''; |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | //Impede chamada recursiva na raiz das organizações |
---|
| 179 | if ((recursive) && (document.forms[0].ldap_context.value == document.getElementById('ea_combo_org_maillists').value)) |
---|
| 180 | { |
---|
| 181 | alert('Nao é possível selecionar todos os usuários da organização raiz.') |
---|
| 182 | document.getElementById('ea_check_allUsers').checked = false; |
---|
| 183 | |
---|
| 184 | // Limpa select |
---|
| 185 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
[86] | 186 | select_available_users.innerHTML = ' '; |
---|
[2] | 187 | select_available_users.outerHTML = select_available_users.outerHTML; |
---|
| 188 | return; |
---|
| 189 | } |
---|
[23] | 190 | 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] | 191 | } |
---|
| 192 | |
---|
| 193 | function add_user2maillist() |
---|
| 194 | { |
---|
| 195 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 196 | select_usersInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 197 | |
---|
| 198 | var count_available_users = select_available_users.length; |
---|
| 199 | var count_usersInMailList = select_usersInMaillist.options.length; |
---|
| 200 | var new_options = ''; |
---|
| 201 | |
---|
| 202 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 203 | { |
---|
| 204 | if (select_available_users.options[i].selected) |
---|
| 205 | { |
---|
| 206 | if(document.all) |
---|
| 207 | { |
---|
| 208 | if ( (select_usersInMaillist.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 209 | { |
---|
| 210 | new_options += "<option value=" |
---|
| 211 | + select_available_users.options[i].value |
---|
| 212 | + ">" |
---|
| 213 | + select_available_users.options[i].text |
---|
| 214 | + "</options>"; |
---|
| 215 | } |
---|
| 216 | } |
---|
| 217 | else |
---|
| 218 | { |
---|
| 219 | if ( (select_usersInMaillist.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 220 | { |
---|
| 221 | new_options += "<option value=" |
---|
| 222 | + select_available_users.options[i].value |
---|
| 223 | + ">" |
---|
| 224 | + select_available_users.options[i].text |
---|
| 225 | + "</options>"; |
---|
| 226 | } |
---|
| 227 | } |
---|
| 228 | } |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | if (new_options != '') |
---|
| 232 | { |
---|
[86] | 233 | select_usersInMaillist.innerHTML = ' ' + new_options + select_usersInMaillist.innerHTML; |
---|
[2] | 234 | select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML; |
---|
[81] | 235 | document.getElementById('ea_input_searchUser').value = ""; |
---|
[2] | 236 | } |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | function remove_user2maillist() |
---|
| 240 | { |
---|
| 241 | select_usersInMaillist = document.getElementById('ea_select_usersInMaillist'); |
---|
| 242 | |
---|
| 243 | for(var i = 0;i < select_usersInMaillist.options.length; i++) |
---|
| 244 | if(select_usersInMaillist.options[i].selected) |
---|
| 245 | select_usersInMaillist.options[i--] = null; |
---|
| 246 | } |
---|
| 247 | |
---|
[23] | 248 | function add_user2scl_maillist() |
---|
| 249 | { |
---|
| 250 | select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 251 | select_usersInMaillist = document.getElementById('ea_select_users_SCL_Maillist'); |
---|
| 252 | |
---|
| 253 | var count_available_users = select_available_users.length; |
---|
| 254 | var count_usersInMailList = select_usersInMaillist.options.length; |
---|
| 255 | var new_options = ''; |
---|
| 256 | |
---|
| 257 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 258 | { |
---|
| 259 | if (select_available_users.options[i].selected) |
---|
| 260 | { |
---|
| 261 | if(document.all) |
---|
| 262 | { |
---|
| 263 | if ( (select_usersInMaillist.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 264 | { |
---|
| 265 | new_options += "<option value=" |
---|
| 266 | + select_available_users.options[i].value |
---|
| 267 | + ">" |
---|
| 268 | + select_available_users.options[i].text |
---|
| 269 | + "</options>"; |
---|
| 270 | } |
---|
| 271 | } |
---|
| 272 | else |
---|
| 273 | { |
---|
| 274 | if ( (select_usersInMaillist.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 275 | { |
---|
| 276 | new_options += "<option value=" |
---|
| 277 | + select_available_users.options[i].value |
---|
| 278 | + ">" |
---|
| 279 | + select_available_users.options[i].text |
---|
| 280 | + "</options>"; |
---|
| 281 | } |
---|
| 282 | } |
---|
| 283 | } |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | if (new_options != '') |
---|
| 287 | { |
---|
| 288 | select_usersInMaillist.innerHTML = '#' + new_options + select_usersInMaillist.innerHTML; |
---|
| 289 | select_usersInMaillist.outerHTML = select_usersInMaillist.outerHTML; |
---|
| 290 | } |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | function remove_user2scl_maillist() |
---|
| 294 | { |
---|
| 295 | select_usersInMaillist = document.getElementById('ea_select_users_SCL_Maillist'); |
---|
| 296 | |
---|
| 297 | for(var i = 0;i < select_usersInMaillist.options.length; i++) |
---|
| 298 | if(select_usersInMaillist.options[i].selected) |
---|
| 299 | select_usersInMaillist.options[i--] = null; |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | |
---|
[2] | 303 | // Variaveis Locais |
---|
| 304 | if (document.getElementById('ea_select_available_users')) |
---|
| 305 | { |
---|
| 306 | var select_available_users = document.getElementById('ea_select_available_users'); |
---|
| 307 | var select_available_users_clone = select_available_users.cloneNode(true); |
---|
| 308 | } |
---|
| 309 | else |
---|
| 310 | { |
---|
| 311 | var select_available_users = ''; |
---|
| 312 | var select_available_users_clone = ''; |
---|
| 313 | } |
---|
| 314 | var finderTimeout = ''; |
---|
| 315 | |
---|
| 316 | // Funcoes |
---|
| 317 | function optionFinderTimeout(obj) |
---|
| 318 | { |
---|
| 319 | clearTimeout(finderTimeout); |
---|
| 320 | var oWait = document.getElementById("ea_span_searching"); |
---|
| 321 | oWait.innerHTML = 'Buscando...'; |
---|
| 322 | finderTimeout = setTimeout("optionFinder('"+obj.id+"')",500); |
---|
| 323 | } |
---|
[23] | 324 | function optionFinder(id) { |
---|
[2] | 325 | var oWait = document.getElementById("ea_span_searching"); |
---|
| 326 | var oText = document.getElementById(id); |
---|
| 327 | |
---|
| 328 | //Limpa todo o select |
---|
| 329 | var select_available_users_tmp = document.getElementById('ea_select_available_users') |
---|
[23] | 330 | |
---|
[2] | 331 | for(var i = 0;i < select_available_users_tmp.options.length; i++) |
---|
| 332 | select_available_users_tmp.options[i--] = null; |
---|
[23] | 333 | |
---|
[2] | 334 | var RegExp_name = new RegExp("\\b"+oText.value, "i"); |
---|
[23] | 335 | |
---|
[2] | 336 | //Inclui usuário começando com a pesquisa |
---|
[23] | 337 | for(i = 0; i < select_available_users_clone.length; i++){ |
---|
| 338 | if ( RegExp_name.test(select_available_users_clone[i].text) || (select_available_users_clone[i].value == -1) ) |
---|
[2] | 339 | { |
---|
| 340 | sel = select_available_users_tmp.options; |
---|
[23] | 341 | option = new Option(select_available_users_clone[i].text,select_available_users_clone[i].value); |
---|
| 342 | |
---|
| 343 | if (select_available_users_clone[i].value == -1) |
---|
| 344 | option.disabled = true; |
---|
| 345 | |
---|
[2] | 346 | sel[sel.length] = option; |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | oWait.innerHTML = ' '; |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | function delete_maillist(uid, uidnumber) |
---|
| 353 | { |
---|
| 354 | if (confirm("Realmente deletar Lista " + uid + " ??")) |
---|
| 355 | { |
---|
| 356 | var handler_delete_maillist = function(data) |
---|
| 357 | { |
---|
| 358 | if (!data.status) |
---|
| 359 | alert(data.msg); |
---|
| 360 | else |
---|
| 361 | alert('Lista de email deletada com êxito!!'); |
---|
| 362 | |
---|
| 363 | location.href="./index.php?menuaction=expressoAdmin1_2.uimaillists.list_maillists"; |
---|
| 364 | return; |
---|
| 365 | } |
---|
| 366 | cExecute ('$this.maillist.delete&uidnumber='+uidnumber, handler_delete_maillist); |
---|
| 367 | } |
---|
| 368 | } |
---|
[73] | 369 | |
---|
| 370 | function search_organization(key) |
---|
| 371 | { |
---|
| 372 | var organizations = document.getElementById('ea_combo_org_info'); |
---|
| 373 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
| 374 | |
---|
| 375 | for(i = 0; i < organizations.length; i++) |
---|
| 376 | { |
---|
| 377 | if (RegExp_org.test(organizations[i].text)) |
---|
| 378 | { |
---|
| 379 | organizations[i].selected = true; |
---|
| 380 | return; |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | } |
---|