window.rcmail&&rcmail.addEventListener("init",function(){if(rcmail.gui_objects.acltable&&(rcmail.acl_list_init(),rcmail.env.acl_users_source)){var a=rcmail.is_framed()?parent.rcmail:rcmail;a.init_address_input_events($("#acluser"),{action:"settings/plugin.acl-autocomplete"});a.set_env({autocomplete_max:rcmail.env.autocomplete_max,autocomplete_min_length:rcmail.env.autocomplete_min_length});a.add_label("autocompletechars",rcmail.labels.autocompletechars);a.add_label("autocompletemore",rcmail.labels.autocompletemore); a.addEventListener("autocomplete_insert",function(a){"acluser"==a.field.id&&(a.field.value=a.insert.replace(/[ ,;]+$/,""))})}rcmail.enable_command("acl-create","acl-save","acl-cancel","acl-mode-switch",!0);rcmail.enable_command("acl-delete","acl-edit",!1);rcmail.env.acl_advanced&&$("#acl-switch").addClass("selected")});rcube_webmail.prototype.acl_create=function(){this.acl_init_form()};rcube_webmail.prototype.acl_edit=function(){var a=this.acl_list.get_single_selection();a&&this.acl_init_form(a)}; rcube_webmail.prototype.acl_delete=function(){var a=this.acl_get_usernames();a&&a.length&&confirm(this.get_label("acl.deleteconfirm"))&&this.http_post("settings/plugin.acl",{_act:"delete",_user:a.join(","),_mbox:this.env.mailbox},this.set_busy(!0,"acl.deleting"))}; rcube_webmail.prototype.acl_save=function(){var a,b="",c=$("#acluser",this.acl_form).val();$(this.env.acl_advanced?"#advancedrights :checkbox":"#simplerights :checkbox",this.acl_form).map(function(){this.checked&&(b+=this.value)});(a=$("input:checked[name=usertype]",this.acl_form).val())&&"user"!=a&&(c=a);c?b?(a={_act:"save",_user:c,_acl:b,_mbox:this.env.mailbox},this.acl_id&&(a._old=this.acl_id),this.http_post("settings/plugin.acl",a,this.set_busy(!0,"acl.saving"))):alert(this.get_label("acl.norights")): alert(this.get_label("acl.nouser"))};rcube_webmail.prototype.acl_cancel=function(){this.ksearch_blur();this.acl_popup.dialog("close")};rcube_webmail.prototype.acl_update=function(a){a.old?this.acl_remove_row(a.old):this.env.acl[a.id]&&this.acl_remove_row(a.id);this.acl_add_row(a,!0);this.ksearch_blur();this.acl_popup.dialog("close")}; rcube_webmail.prototype.acl_mode_switch=function(a){this.env.acl_advanced=!this.env.acl_advanced;this.enable_command("acl-delete","acl-edit",!1);this.http_request("settings/plugin.acl","_act=list&_mode="+(this.env.acl_advanced?"advanced":"simple")+"&_mbox="+urlencode(this.env.mailbox),this.set_busy(!0,"loading"))}; rcube_webmail.prototype.acl_list_init=function(){var a=this.env.acl_advanced?"addClass":"removeClass";$("#acl-switch")[a]("selected");$(this.gui_objects.acltable)[a]("advanced");this.acl_list=new rcube_list_widget(this.gui_objects.acltable,{multiselect:!0,draggable:!1,keyboard:!0});this.acl_list.addEventListener("select",function(a){rcmail.acl_list_select(a)}).addEventListener("dblclick",function(a){rcmail.acl_list_dblclick(a)}).addEventListener("keypress",function(a){rcmail.acl_list_keypress(a)}).init()}; rcube_webmail.prototype.acl_list_select=function(a){rcmail.enable_command("acl-delete",0 tr",this.gui_objects.acltable).clone();$("th",g).map(function(){var b=$(""),c=$(this).attr("title"),d=this.className.replace(/^acl/,"");c&&b.attr("title",c);k&&k[d]&&(d=k[d]);"user"==d?b.addClass(d).append($("").text(a.username)):b.addClass(this.className+" "+rcmail.acl_class(a.acl,d)).text("");$(this).replaceWith(b)});g.attr("id","rcmrow"+ f);g=g.get(0);this.env.acl[f]=a.acl;for(c in this.env.acl)this.env.acl[c]&&(this.env.acl_specials.length&&0<=$.inArray(c,this.env.acl_specials)?e.push(c):d.push(c));d.sort();d=e.concat(d);c=0;for(e=d.length;c$.inArray(a,this.env.acl_specials)?d=$("td.user",c).text():f=a):b.filter(function(){return this.id.match(/^acl([lrs]|read)$/)}).prop("checked",!0);g.val(d);$("input[value="+f+"]").prop("checked",!0);this.acl_id=a;var d={},l=this,h=document.body;d[this.get_label("save")]=function(a){l.command("acl-save")};d[this.get_label("cancel")]=function(a){l.command("acl-cancel")};this.acl_popup=this.show_popup_dialog(this.acl_form.show(),a?this.get_label("acl.editperms"): this.get_label("acl.newuser"),d,{button_classes:["mainaction"],modal:!0,closeOnEscape:!0,close:function(a,b){(l.is_framed()?parent.rcmail:l).ksearch_hide();l.acl_form.appendTo(h).hide();$(this).remove();window.focus()}});"user"==f?g.focus():$("input:checked",n).focus()};rcube_webmail.prototype.acl_class=function(a,b){var c,e,d=0;a=String(a);b=String(b);c=0;for(e=b.length;c