[5144] | 1 | countFiles = 1; |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Método que cria uma nova regra de tamanho máximo de mensagem. |
---|
| 5 | */ |
---|
| 6 | function create_messages_size() |
---|
| 7 | { |
---|
| 8 | select_owners = Element('ea_select_owners'); |
---|
| 9 | hidden_owners_acl = Element('owners_acls'); |
---|
| 10 | for(var i = 0;i < select_owners.options.length; i++){ |
---|
| 11 | var user = select_owners.options[i].value; |
---|
| 12 | select_owners.options[i].value = user; |
---|
| 13 | select_owners.options[i].selected = true; |
---|
| 14 | } |
---|
| 15 | //hidden_owners_acl.value = admin_connector.serialize(sharemailbox.ownersAcl); |
---|
| 16 | |
---|
| 17 | cExecuteForm ("$this.bomessages_size.create_rule", document.getElementById('messages_size_form_template'), handler_create_messages_size); |
---|
| 18 | hidden_owners_acl.value = ""; |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | /* |
---|
| 22 | * Handlers do método que cria uma nova regra. |
---|
| 23 | */ |
---|
| 24 | function handler_create_messages_size(data_return) |
---|
| 25 | { |
---|
| 26 | handler_create_messages_size2(data_return); |
---|
| 27 | return; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | function handler_create_messages_size2(data_return) |
---|
| 31 | { |
---|
| 32 | if (!data_return.status) |
---|
| 33 | { |
---|
| 34 | write_msg(data_return.msg, 'error'); |
---|
| 35 | } |
---|
| 36 | else |
---|
| 37 | { |
---|
| 38 | close_lightbox(); |
---|
| 39 | write_msg(get_lang('New rule successful created') + '.', 'normal'); |
---|
| 40 | history.go(); |
---|
| 41 | } |
---|
| 42 | } |
---|
| 43 | /* |
---|
| 44 | * Fim dos processamentos para criar uma nova regra. |
---|
| 45 | */ |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | function save_default_max_size(default_max_size) |
---|
| 49 | { |
---|
| 50 | /* Valida o valor do campo de tamanho padrão */ |
---|
| 51 | |
---|
| 52 | /* Verifica se não é um número*/ |
---|
| 53 | if(isNaN(default_max_size)) |
---|
| 54 | { |
---|
| 55 | alert(get_lang("Default size must be a number")); |
---|
| 56 | return; |
---|
| 57 | } |
---|
| 58 | /* Verifica se é negativo */ |
---|
| 59 | if(default_max_size < 0) |
---|
| 60 | { |
---|
| 61 | alert(get_lang("Default size can not be negative")); |
---|
| 62 | return; |
---|
| 63 | } |
---|
| 64 | cExecute ('$this.bomessages_size.save_default_rule&default_max_size='+default_max_size, handle_save_default_max_size); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | function handle_save_default_max_size(data_return) |
---|
| 68 | { |
---|
| 69 | if (!data_return.status) |
---|
| 70 | { |
---|
| 71 | write_msg(data_return.msg, 'error'); |
---|
| 72 | } |
---|
| 73 | else |
---|
| 74 | { |
---|
| 75 | //close_lightbox(); |
---|
| 76 | write_msg(get_lang('New default value successful created') + '.', 'normal'); |
---|
| 77 | history.go(); |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | /* |
---|
| 83 | * Método que deleta uma regra. |
---|
| 84 | */ |
---|
| 85 | function delete_messages_size(rule_name) |
---|
| 86 | { |
---|
| 87 | rule_name = rule_name.replace(/%/g," "); |
---|
| 88 | if (!confirm(get_lang('Are you sure that you want to delete this rule') + "?")) |
---|
| 89 | return; |
---|
| 90 | |
---|
| 91 | var handle_delete_messages_size = function(data_return) |
---|
| 92 | { |
---|
| 93 | if (!data_return.status) |
---|
| 94 | { |
---|
| 95 | write_msg(data_return.msg, 'error'); |
---|
| 96 | } |
---|
| 97 | else |
---|
| 98 | { |
---|
| 99 | write_msg(get_lang('Rule successful deleted') + '.', 'normal'); |
---|
| 100 | //get_messages_size(Element('ea_rules_search').value); |
---|
| 101 | history.go(); |
---|
| 102 | } |
---|
| 103 | return; |
---|
| 104 | } |
---|
| 105 | cExecute ('$this.bomessages_size.delete_rule&rule_name='+rule_name, handle_delete_messages_size); |
---|
| 106 | } |
---|
| 107 | /* |
---|
| 108 | * Fim dos processamentos para deletar uma regra. |
---|
| 109 | */ |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | /* |
---|
| 113 | * Método que busca os usuários no ldap de acordo com a organização. |
---|
| 114 | */ |
---|
| 115 | function get_available_users(ctx, sentence, handler) // Fazer com que retorne também grupos junto com usuários |
---|
| 116 | { |
---|
| 117 | var handler_get_users = function(data) |
---|
| 118 | { |
---|
| 119 | if ((data) && (data.length > 0)) |
---|
| 120 | { |
---|
| 121 | if( typeof data == "string" ) |
---|
| 122 | data = (new Function("return " + data))(); |
---|
| 123 | |
---|
| 124 | handler( data ); |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | cExecute ('$this.ldap_functions.get_available_users_messages_size&context=' + ctx + ( sentence ? '&sentence=' + sentence: '' ), handler_get_users); |
---|
| 129 | } |
---|
| 130 | /* |
---|
| 131 | * Fim dos processamentos para buscar os usuários do LDAP. |
---|
| 132 | */ |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | /* |
---|
| 136 | * Método que busca os usuários e grupos no ldap de acordo com a organização. |
---|
| 137 | */ |
---|
| 138 | function get_available_users_and_groups(ctx, sentence, handler) // Fazer com que retorne também grupos junto com usuários |
---|
| 139 | { |
---|
| 140 | var handler_get_users = function(data) |
---|
| 141 | { |
---|
| 142 | if ((data) && (data.length > 0)) |
---|
| 143 | { |
---|
| 144 | if( typeof data == "string" ) |
---|
| 145 | data = (new Function("return " + data))(); |
---|
| 146 | |
---|
| 147 | handler( data ); |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | cExecute ('$this.bomessages_size.get_available_users_and_groups&context=' + ctx + ( sentence ? '&sentence=' + sentence: '' ), handler_get_users); |
---|
| 152 | } |
---|
| 153 | /* |
---|
| 154 | * Fim dos processamentos para buscar os usuários e grupos do LDAP. |
---|
| 155 | */ |
---|
| 156 | |
---|
| 157 | |
---|
| 158 | /* |
---|
| 159 | * Método que edita uma regra de tamanho de mensagem. |
---|
| 160 | */ |
---|
| 161 | function edit_messages_size(name_rule) |
---|
| 162 | { |
---|
| 163 | // Retira os % do nome da regra. |
---|
| 164 | name_rule = name_rule.replace(/%/g," "); |
---|
| 165 | var handle_edit_messages_size = function(data) |
---|
| 166 | { |
---|
| 167 | if (data.status == true) |
---|
| 168 | { |
---|
| 169 | modal('messages_size_modal','save'); |
---|
| 170 | Element('original_rule_name').value = data.email_recipient; |
---|
| 171 | Element('rule_name').value = data.email_recipient; |
---|
| 172 | |
---|
| 173 | //Necessario, pois o IE6 tem um bug que não exibe as novas opções se o innerHTML estava vazio |
---|
| 174 | Element('ea_select_owners').innerHTML = ' ' + data.options; |
---|
| 175 | Element('ea_select_owners').outerHTML = Element('ea_select_owners').outerHTML; |
---|
| 176 | Element('max_messages_size').value = data.email_max_recipient; |
---|
| 177 | } |
---|
| 178 | else |
---|
| 179 | write_msg(data.msg, 'error'); |
---|
| 180 | } |
---|
| 181 | cExecute ("$this.bomessages_size.get_users_by_rule&name_rule="+name_rule, handle_edit_messages_size); |
---|
| 182 | } |
---|
| 183 | /* |
---|
| 184 | * Fim dos processamentos para editar uma regra. |
---|
| 185 | */ |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | /* |
---|
| 189 | * Método que salva uma regra. É chamado quando uma regra é aberta para edição. |
---|
| 190 | */ |
---|
| 191 | function save_messages_size() |
---|
| 192 | { |
---|
| 193 | if (is_ie){ |
---|
| 194 | var i = 0; |
---|
| 195 | while (document.forms(i).name != "messages_size_form_template"){i++} |
---|
| 196 | form = document.forms(i); |
---|
| 197 | } |
---|
| 198 | else form = document.getElementById('messages_size_form_template'); |
---|
| 199 | |
---|
| 200 | hidden_owners_acl = Element('owners_acls'); |
---|
| 201 | select_owners = Element('ea_select_owners'); |
---|
| 202 | for(var i = 0;i < select_owners.options.length; i++){ |
---|
| 203 | var user = select_owners.options[i].value; |
---|
| 204 | select_owners.options[i].value = user; |
---|
| 205 | if(select_owners.options[i] != "") |
---|
| 206 | select_owners.options[i].selected = true; |
---|
| 207 | } |
---|
| 208 | hidden_owners_acl.value = admin_connector.serialize(sharemailbox.ownersAcl); |
---|
| 209 | |
---|
| 210 | cExecuteForm ("$this.bomessages_size.save_rule", document.getElementById('messages_size_form_template'), handler_save_messages_size); |
---|
| 211 | //cExecute ("$this.bomessages_size.save_rule&owners="+owners, handler_save_messages_size); |
---|
| 212 | //hidden_owners_acl.value = ""; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | /* |
---|
| 216 | * Handlers do método que salva uma regra. |
---|
| 217 | */ |
---|
| 218 | function handler_save_messages_size(data_return) |
---|
| 219 | { |
---|
| 220 | handler_save_messages_size2(data_return); |
---|
| 221 | return; |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | function handler_save_messages_size2(data_return) |
---|
| 225 | { |
---|
| 226 | if (!data_return.status) |
---|
| 227 | { |
---|
| 228 | write_msg(data_return.msg, 'error'); |
---|
| 229 | } |
---|
| 230 | else |
---|
| 231 | { |
---|
| 232 | //get_messages_size(Element('ea_rules_search').value); |
---|
| 233 | close_lightbox(); |
---|
| 234 | write_msg(get_lang('Rule successful saved') + '.', 'normal'); |
---|
| 235 | history.go(); |
---|
| 236 | } |
---|
| 237 | return; |
---|
| 238 | } |
---|
| 239 | /* |
---|
| 240 | * Fim dos processamentos para salvar uma regra. |
---|
| 241 | */ |
---|
| 242 | |
---|
| 243 | |
---|
| 244 | /* |
---|
| 245 | * Método que busca as regras de acordo com uma entrada do usuário. |
---|
| 246 | */ |
---|
| 247 | function get_messages_size_timeOut(input, event) |
---|
| 248 | { |
---|
| 249 | |
---|
| 250 | var table = |
---|
| 251 | |
---|
| 252 | Element('messages_size_content').innerHTML = '<table border="0" width="90%"><tr bgcolor="#d3dce3"><td width="30%">'+get_lang("rule name")+'</td><td width="30%">'+get_lang("max size rule")+'</td><td width="5%" align="center">'+get_lang("remove")+'</td></tr>'+'</table>'; |
---|
| 253 | |
---|
| 254 | if (event.keyCode === 13) |
---|
| 255 | { |
---|
| 256 | get_messages_size( input ); |
---|
| 257 | //cExecute ('$this.bomessages_size.get_rules_by_user&input='+input, handler_get_messages_size); |
---|
| 258 | } |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | function get_messages_size(input, callback) |
---|
| 262 | { |
---|
| 263 | var handler_get_messages_size = function(data) |
---|
| 264 | { |
---|
| 265 | if (data.status == 'true') |
---|
| 266 | { |
---|
| 267 | // Em data.trs está armazenado todas as linhas que foram retornadas da busca pelo parametro passado pelo usuário. |
---|
| 268 | var table = '<table border="0" width="90%"><tr bgcolor="#d3dce3"><td width="30%">'+get_lang("rule name")+'</td><td width="30%">'+get_lang("max size rule")+'</td><td width="5%" align="center">'+get_lang("remove")+'</td></tr>'+data.trs+'</table>'; |
---|
| 269 | Element('messages_size_content').innerHTML = table; |
---|
| 270 | } |
---|
| 271 | else{ |
---|
| 272 | write_msg(data.msg, 'error'); |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | // Modificar para chamar o get_rules_by_user para o usuário buscar por nome de usuário e não de regra. |
---|
| 276 | cExecute ('$this.bomessages_size.get_rules&input='+input, handler_get_messages_size); |
---|
| 277 | } |
---|
| 278 | /* |
---|
| 279 | * Fim dos processamentos para buscar uma regra. |
---|
| 280 | */ |
---|
| 281 | |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | /* |
---|
| 285 | * Método que remove os usuários que foram adicionados para participar da regra no modal. |
---|
| 286 | */ |
---|
| 287 | function remove_user() |
---|
| 288 | { |
---|
| 289 | select_owners = Element('ea_select_owners'); |
---|
| 290 | for(var i = 0;i < select_owners.options.length; i++) |
---|
| 291 | if(select_owners.options[i].selected){ |
---|
| 292 | var user = select_owners.options[i].value; |
---|
| 293 | delete sharemailbox.ownersAcl[user]; |
---|
| 294 | select_owners.options[i--] = null; |
---|
| 295 | } |
---|
| 296 | //Nova chamada a "Element" é Necessária devido a um bug do ie com select |
---|
| 297 | select_owners = Element('ea_select_owners'); |
---|
| 298 | if(select_owners.options.length > 0 ){ |
---|
| 299 | select_owners.options[0].selected = true; |
---|
| 300 | var user = select_owners.options[0].value; |
---|
| 301 | sharemailbox.getaclfromuser(user); |
---|
| 302 | } |
---|
| 303 | } |
---|
| 304 | |
---|
| 305 | |
---|
| 306 | |
---|
| 307 | |
---|
| 308 | function findUsersAndGroups(obj, numMin, event) |
---|
| 309 | { |
---|
| 310 | if( event && event.keyCode != 13 ) |
---|
| 311 | return; |
---|
| 312 | |
---|
| 313 | findUsersAndGroupsInLdap(obj.id,numMin); |
---|
| 314 | |
---|
| 315 | |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | function findUsersAndGroupsInLdap(id, numMin) |
---|
| 319 | { |
---|
| 320 | optionFind( id, 'ea_select_available_users', |
---|
| 321 | 'expressoAdmin1_2.bomessages_size.get_available_users_and_groups2', |
---|
| 322 | 'ea_combo_org', 'ea_span_searching' ); |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | function handlerGetAvailableUsersAndGroups(data) |
---|
| 326 | { |
---|
| 327 | |
---|
| 328 | var selectUsersAndGroups = Element('ea_select_available_users'); |
---|
| 329 | |
---|
| 330 | for(var i=0; i < selectUsersAndGroups.options.length; i++) |
---|
| 331 | { |
---|
| 332 | selectUsersAndGroups.options[i] = null; |
---|
| 333 | i--; |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | var options = '###'; |
---|
| 337 | if (data) |
---|
| 338 | { |
---|
| 339 | if(data.groups && data.groups.length > 0) { |
---|
| 340 | data.groups = '<option value="-1" disabled>-------------'+Element("txt_groups").value+' --------- </option>' + data.groups; |
---|
| 341 | } |
---|
| 342 | if(data.users && data.users.length > 0) { |
---|
| 343 | data.users = '<option value="-1" disabled>-------------'+Element("txt_users").value+' ---------</option>' + data.users; |
---|
| 344 | } |
---|
| 345 | options += data.groups && data.groups.length > 0 ? data.groups : ''; |
---|
| 346 | options += data.users && data.users.length > 0 ? data.users : ''; |
---|
| 347 | |
---|
| 348 | //if(is_firefox_0) |
---|
| 349 | //fixBugInnerSelect(selectUsersAndGroups,options); |
---|
| 350 | //else |
---|
| 351 | selectUsersAndGroups.innerHTML = options; |
---|
| 352 | |
---|
| 353 | selectUsersAndGroups.outerHTML = selectUsersAndGroups.outerHTML; |
---|
| 354 | selectUsersAndGroups.disabled = false; |
---|
| 355 | //selectUsersClone = Element('selectUsers').cloneNode(true); |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | function optionFinder(obj) { |
---|
| 361 | |
---|
| 362 | var id = obj.id; |
---|
| 363 | finder2( Element(id).value, 'ea_select_available_users', function( sentence, refillHandler ){ |
---|
| 364 | |
---|
| 365 | Element("ea_span_searching").innerHTML = get_lang('searching') + '...'; |
---|
| 366 | |
---|
| 367 | get_available_users( Element('ea_combo_org').value, sentence, function( data ){ |
---|
| 368 | |
---|
| 369 | Element("ea_span_searching").innerHTML = ' '; |
---|
| 370 | |
---|
| 371 | refillHandler( data ); |
---|
| 372 | }); |
---|
| 373 | } ); |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | |
---|
| 377 | function finder2( sentences, fillHandler, searchHandler ) |
---|
| 378 | { |
---|
| 379 | //caso fillHandler nao seja uma funcao, usar a default |
---|
| 380 | if( typeof fillHandler === "string" ) |
---|
| 381 | { |
---|
| 382 | var selectId = fillHandler; |
---|
| 383 | |
---|
| 384 | fillHandler = function( fill ){ |
---|
| 385 | |
---|
| 386 | //recupera as options do respectivo select |
---|
| 387 | var select = Element( selectId ).options; |
---|
| 388 | |
---|
| 389 | //Limpa todo o select |
---|
| 390 | select.length = 0; |
---|
| 391 | |
---|
| 392 | //Inclui usuario comecando com a pesquisa |
---|
| 393 | for( var value in fill ) |
---|
| 394 | select[select.length] = new Option( fill[value]["name"], value ); |
---|
| 395 | |
---|
| 396 | //chama o server side caso nao encontre resultado nenhum com essa sentenca |
---|
| 397 | return( select.length === 0 ); |
---|
| 398 | } |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | var original = sentences, fill = false; |
---|
| 402 | |
---|
| 403 | //checa se a variavel eh uma string ou regexp. Caso seja, a converte em um mapa |
---|
| 404 | if( typeof sentences === "string" || ( sentences.test && sentences.match ) ) |
---|
| 405 | sentences = { "name": sentences }; |
---|
| 406 | |
---|
| 407 | //varrer todas as sentencas e secoes especificas |
---|
| 408 | for( var section in sentences ) |
---|
| 409 | { |
---|
| 410 | //sentenca para a secao especifica. |
---|
| 411 | var sentence = sentences[section]; |
---|
| 412 | |
---|
| 413 | //checa se eh uma string. Se for, converte-la para uma regexp. |
---|
| 414 | if( typeof sentence === "string" ) |
---|
| 415 | { |
---|
| 416 | //TODO: tornar esse limite configuravel de acordo com a configuracao do expresso |
---|
| 417 | if( sentence.length < 3 ) continue; |
---|
| 418 | sentence = sentences[section] = new RegExp("\\b"+sentence, "i"); |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | if( !fill ) |
---|
| 422 | fill = {}; |
---|
| 423 | |
---|
| 424 | //populando o mapa filtrando pela determinada sentenca |
---|
| 425 | for( var key in userData ) |
---|
| 426 | { |
---|
| 427 | if( !userData[key] ) |
---|
| 428 | userData[key] = {}; |
---|
| 429 | |
---|
| 430 | if ( sentence.test( userData[key][section] ) ) |
---|
| 431 | { |
---|
| 432 | if( !fill[key] ) |
---|
| 433 | fill[key] = {}; |
---|
| 434 | |
---|
| 435 | fill[ key ][ section ] = userData[ key ][ section ]; |
---|
| 436 | } |
---|
| 437 | } |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | //tenta chamar o handler para popular, caso nao consiga chama o server side |
---|
| 441 | if( fill && fillHandler( fill ) && searchHandler ) |
---|
| 442 | { |
---|
| 443 | //handler chamado pelo callback do servidor para repopular. |
---|
| 444 | var refillHandler = function( data, sections ){ |
---|
| 445 | |
---|
| 446 | if( !sections ) |
---|
| 447 | sections = "name"; |
---|
| 448 | |
---|
| 449 | if( typeof sections === "string" ) |
---|
| 450 | { |
---|
| 451 | if( !data[sections] ) |
---|
| 452 | var dt = data, data = {}; |
---|
| 453 | data[sections] = dt; |
---|
| 454 | |
---|
| 455 | sections = [ sections ]; |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | for( var i = 0; sections[i]; section = sections[i++] ) |
---|
| 459 | { |
---|
| 460 | for ( var key in data[section] ) |
---|
| 461 | { |
---|
| 462 | if( !userData[key] ) |
---|
| 463 | userData[key] = {}; |
---|
| 464 | |
---|
| 465 | userData[key][section] = data[section][key]; |
---|
| 466 | } |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | finder( sentences, fillHandler ); |
---|
| 470 | }; |
---|
| 471 | |
---|
| 472 | searchHandler( original, refillHandler ); |
---|
| 473 | } |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | |
---|
| 477 | function set_onload() |
---|
| 478 | { |
---|
| 479 | get_associated_domain(Element('ea_combo_org').value); |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | |
---|
| 483 | |
---|
| 484 | function search_organization(key, element) |
---|
| 485 | { |
---|
| 486 | var organizations = Element(element); |
---|
| 487 | var RegExp_org = new RegExp("\\b"+key, "i"); |
---|
| 488 | |
---|
| 489 | for(i = 0; i < organizations.length; i++) |
---|
| 490 | { |
---|
| 491 | if (RegExp_org.test(organizations[i].text)) |
---|
| 492 | { |
---|
| 493 | organizations[i].selected = true; |
---|
| 494 | return; |
---|
| 495 | } |
---|
| 496 | } |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | |
---|
| 500 | var userData = {}; |
---|
| 501 | |
---|
| 502 | function add_user() |
---|
| 503 | { |
---|
| 504 | select_available_users = Element('ea_select_available_users'); |
---|
| 505 | select_owners = Element('ea_select_owners'); |
---|
| 506 | |
---|
| 507 | var count_available_users = select_available_users.length; |
---|
| 508 | var new_options = ''; |
---|
| 509 | |
---|
| 510 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 511 | { |
---|
| 512 | if (select_available_users.options[i].selected) |
---|
| 513 | { |
---|
| 514 | if(document.all) |
---|
| 515 | { |
---|
| 516 | if ( (select_owners.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 517 | { |
---|
| 518 | new_options += "<option value=" |
---|
| 519 | + select_available_users.options[i].value |
---|
| 520 | + ">" |
---|
| 521 | + select_available_users.options[i].text |
---|
| 522 | + "</options>"; |
---|
| 523 | } |
---|
| 524 | } |
---|
| 525 | else |
---|
| 526 | { |
---|
| 527 | if ( (select_owners.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 528 | { |
---|
| 529 | new_options += "<option value=" |
---|
| 530 | + select_available_users.options[i].value |
---|
| 531 | + ">" |
---|
| 532 | + select_available_users.options[i].text |
---|
| 533 | + "</options>"; |
---|
| 534 | } |
---|
| 535 | } |
---|
| 536 | } |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | if (new_options != '') |
---|
| 540 | { |
---|
| 541 | select_owners.innerHTML = " " + new_options + select_owners.innerHTML; |
---|
| 542 | select_owners.outerHTML = select_owners.outerHTML; |
---|
| 543 | select_owners = Element('ea_select_owners'); |
---|
| 544 | select_owners.options[0].selected = true; |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | |
---|
| 549 | |
---|
| 550 | function cShareMailbox() |
---|
| 551 | { |
---|
| 552 | this.arrayWin = new Array(); |
---|
| 553 | this.el; |
---|
| 554 | this.alert = false; |
---|
| 555 | this.ownersAcl = new Array(); |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | cShareMailbox.prototype.get_available_users = function(context) |
---|
| 559 | { |
---|
| 560 | var handler_get_available_users = function(data) |
---|
| 561 | { |
---|
| 562 | select_available_users = document.getElementById('em_select_available_users'); |
---|
| 563 | |
---|
| 564 | //Limpa o select |
---|
| 565 | for(var i=0; i<select_available_users.options.length; i++) |
---|
| 566 | { |
---|
| 567 | select_available_users.options[i] = null; |
---|
| 568 | i--; |
---|
| 569 | } |
---|
| 570 | |
---|
| 571 | if ((data) && (data.length > 0)) |
---|
| 572 | { |
---|
| 573 | // Necessario, pois o IE6 tem um bug que retira o primeiro options se o innerHTML estiver vazio. |
---|
| 574 | select_available_users.innerHTML = '#' + data; |
---|
| 575 | select_available_users.outerHTML = select_available_users.outerHTML; |
---|
| 576 | |
---|
| 577 | select_available_users.disabled = false; |
---|
| 578 | select_available_users_clone = document.getElementById('em_select_available_users').cloneNode(true); |
---|
| 579 | document.getElementById('em_input_searchUser').value = ''; |
---|
| 580 | } |
---|
| 581 | } |
---|
| 582 | cExecute ("$this.ldap_functions.get_available_users2&context="+context, handler_get_available_users); |
---|
| 583 | } |
---|
| 584 | |
---|
| 585 | cShareMailbox.prototype.getaclfromuser = function(user) |
---|
| 586 | { |
---|
| 587 | |
---|
| 588 | |
---|
[6884] | 589 | if ( (this.ownersAcl[user].indexOf('l',0) >= 0) && |
---|
| 590 | (this.ownersAcl[user].indexOf('r',0) >= 0) && |
---|
| 591 | (this.ownersAcl[user].indexOf('s',0) >= 0) |
---|
| 592 | ) |
---|
| 593 | { |
---|
| 594 | Element('em_input_sendAcl').disabled = false; |
---|
| 595 | Element('em_input_readAcl').checked = true; |
---|
[5144] | 596 | } |
---|
| 597 | else |
---|
[6884] | 598 | Element('em_input_sendAcl').disabled = true; |
---|
| 599 | |
---|
| 600 | if ( (this.ownersAcl[user].indexOf('t',0) >= 0) && |
---|
| 601 | (this.ownersAcl[user].indexOf('e',0) >= 0) |
---|
| 602 | ) |
---|
| 603 | { |
---|
| 604 | Element('em_input_deleteAcl').checked = true; |
---|
| 605 | } |
---|
| 606 | if ( (this.ownersAcl[user].indexOf('w',0) >= 0) && |
---|
| 607 | (this.ownersAcl[user].indexOf('i',0) >= 0) |
---|
| 608 | ) |
---|
| 609 | { |
---|
| 610 | Element('em_input_writeAcl').checked = true; |
---|
| 611 | } |
---|
| 612 | if ((this.ownersAcl[user].indexOf('p',0) >= 0) && |
---|
| 613 | (this.ownersAcl[user].indexOf('a',0) >= 0) ) |
---|
| 614 | { |
---|
| 615 | Element('em_input_sendAcl').disabled = false; |
---|
| 616 | Element('em_input_sendAcl').checked = true; |
---|
| 617 | } |
---|
[5144] | 618 | |
---|
[6884] | 619 | if ( (this.ownersAcl[user].indexOf('k',0) >= 0) && |
---|
| 620 | (this.ownersAcl[user].indexOf('x',0) >= 0) |
---|
| 621 | ) |
---|
| 622 | { |
---|
| 623 | Element('em_input_folderAcl').checked = true; |
---|
| 624 | } |
---|
| 625 | |
---|
| 626 | } |
---|
| 627 | |
---|
| 628 | cShareMailbox.prototype.setaclfromuser = function() |
---|
| 629 | { |
---|
| 630 | var acl = ''; |
---|
| 631 | var select = Element('ea_select_owners'); |
---|
| 632 | |
---|
| 633 | if(select.selectedIndex == "-1"){ |
---|
| 634 | alert("Selecione antes um usuario!"); |
---|
| 635 | return false; |
---|
| 636 | } |
---|
| 637 | |
---|
| 638 | for(var k = 0; k < select.options.length; k ++ ) |
---|
| 639 | { |
---|
| 640 | if(select.options[k].selected !== true ) continue; |
---|
| 641 | |
---|
| 642 | |
---|
| 643 | acl = ''; |
---|
| 644 | var user = select.options[k].value; |
---|
| 645 | |
---|
[5144] | 646 | if (Element('em_input_readAcl').checked) { |
---|
[6884] | 647 | Element('em_input_sendAcl').disabled = false; |
---|
| 648 | acl = 'lrsa'; |
---|
[5144] | 649 | } |
---|
| 650 | else{ |
---|
[6884] | 651 | Element('em_input_sendAcl').disabled = true; |
---|
| 652 | Element('em_input_sendAcl').checked = false; |
---|
| 653 | } |
---|
[5144] | 654 | |
---|
| 655 | if (Element('em_input_deleteAcl').checked) |
---|
[6884] | 656 | acl += 'te'; |
---|
[5144] | 657 | |
---|
| 658 | if (Element('em_input_writeAcl').checked) |
---|
| 659 | acl += 'wi'; |
---|
| 660 | |
---|
| 661 | if (Element('em_input_sendAcl').checked) |
---|
[6884] | 662 | acl += 'p'; |
---|
[5144] | 663 | |
---|
| 664 | if (Element('em_input_folderAcl').checked) |
---|
[6884] | 665 | acl += 'kx'; |
---|
| 666 | |
---|
| 667 | |
---|
[5144] | 668 | this.ownersAcl[user] = acl; |
---|
[6884] | 669 | } |
---|
[5144] | 670 | } |
---|
| 671 | |
---|
| 672 | cShareMailbox.prototype.add_user = function() |
---|
| 673 | { |
---|
| 674 | var select_available_users = document.getElementById('em_select_available_users'); |
---|
| 675 | var select_users = document.getElementById('ea_select_owners'); |
---|
| 676 | |
---|
| 677 | var count_available_users = select_available_users.length; |
---|
| 678 | var count_users = select_users.options.length; |
---|
| 679 | var new_options = ''; |
---|
| 680 | |
---|
| 681 | for (i = 0 ; i < count_available_users ; i++) |
---|
| 682 | { |
---|
| 683 | if (select_available_users.options[i].selected) |
---|
| 684 | { |
---|
| 685 | if(document.all) |
---|
| 686 | { |
---|
| 687 | if ( (select_users.innerHTML.indexOf('value='+select_available_users.options[i].value)) == '-1' ) |
---|
| 688 | { |
---|
| 689 | new_options += '<option value=' |
---|
| 690 | + select_available_users.options[i].value |
---|
| 691 | + '>' |
---|
| 692 | + select_available_users.options[i].text |
---|
| 693 | + '</option>'; |
---|
| 694 | } |
---|
| 695 | } |
---|
| 696 | else |
---|
| 697 | { |
---|
| 698 | if ( (select_users.innerHTML.indexOf('value="'+select_available_users.options[i].value+'"')) == '-1' ) |
---|
| 699 | { |
---|
| 700 | new_options += '<option value=' |
---|
| 701 | + select_available_users.options[i].value |
---|
| 702 | + '>' |
---|
| 703 | + select_available_users.options[i].text |
---|
| 704 | + '</option>'; |
---|
| 705 | } |
---|
| 706 | } |
---|
| 707 | } |
---|
| 708 | } |
---|
| 709 | |
---|
| 710 | if (new_options != '') |
---|
| 711 | { |
---|
| 712 | select_users.innerHTML = '#' + new_options + select_users.innerHTML; |
---|
| 713 | select_users.outerHTML = select_users.outerHTML; |
---|
| 714 | |
---|
| 715 | } |
---|
| 716 | } |
---|
| 717 | |
---|
| 718 | cShareMailbox.prototype.remove_user = function() |
---|
| 719 | { |
---|
| 720 | select_users = document.getElementById('ea_select_owners'); |
---|
| 721 | |
---|
| 722 | for(var i = 0;i < select_users.options.length; i++) |
---|
| 723 | if(select_users.options[i].selected) |
---|
| 724 | select_users.options[i--] = null; |
---|
| 725 | |
---|
| 726 | Element('em_input_readAcl').checked = false; |
---|
| 727 | Element('em_input_deleteAcl').checked = false; |
---|
| 728 | Element('em_input_writeAcl').checked = false; |
---|
| 729 | Element('em_input_sendAcl').checked = false; |
---|
| 730 | Element('em_input_folderAcl').checked = false; |
---|
| 731 | } |
---|
| 732 | |
---|
| 733 | |
---|
| 734 | /* Build the Object */ |
---|
| 735 | var sharemailbox; |
---|
| 736 | sharemailbox = new cShareMailbox(); |
---|