/** * ACL plugin script * * @licstart The following is the entire license notice for the * JavaScript code in this file. * * Copyright (c) The Roundcube Dev Team * * The JavaScript code in this page is free software: you can redistribute it * and/or modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * @licend The above is the entire license notice * for the JavaScript code in this file. */ 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(b){"acluser"==b.field.id&&(b.field.value=b.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").find("input").prop("checked",!0)});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&&this.confirm_dialog(this.get_label("acl.deleteconfirm"),"delete",function(b,c){c.http_post("settings/plugin.acl",{_act:"delete",_user:a.join(","),_mbox:rcmail.env.mailbox},c.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"))):this.alert_dialog(this.get_label("acl.norights")): this.alert_dialog(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(b){rcmail.acl_list_select(b)}).addEventListener("dblclick",function(b){rcmail.acl_list_dblclick(b)}).addEventListener("keypress",function(b){rcmail.acl_list_keypress(b)}).init()}; rcube_webmail.prototype.acl_list_select=function(a){rcmail.enable_command("acl-delete",0 tr",this.gui_objects.acltable).clone();$("th",l).map(function(){var m=$(""),n=$(this).attr("title"),k=this.className.replace(/^acl/,"");n&&m.attr("title",n);e&&e[k]&&(k=e[k]);"user"==k?m.addClass(k).attr("title",a.title).append($("").text(a.display)):m.addClass(this.className+" "+rcmail.acl_class(a.acl,k)).html("");$(this).replaceWith(m)}); l=l.attr({id:"rcmrow"+g,"data-userid":a.username}).get(0);this.env.acl[g]=a.acl;for(f in this.env.acl)this.env.acl[f]&&(this.env.acl_specials.length&&0<=$.inArray(f,this.env.acl_specials)?d.push(f):c.push(f));c.sort();c=d.concat(c);var f=0;for(d=c.length;f$.inArray(a,this.env.acl_specials)?d=$(b).data("userid"):g=a):e.filter(function(){return this.id.match(/^acl([lrs]|read)$/)}).prop("checked",!0);f.val(d);$("input[value="+g+"]").prop("checked",!0);this.acl_id=a;d={};var k=this;h=document.body;d[this.get_label("save")]=function(p){k.command("acl-save")};d[this.get_label("cancel")]=function(p){k.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 submit","cancel"],modal:!0,closeOnEscape:!0,close:function(p,q){(k.is_framed()?parent.rcmail:k).ksearch_hide();k.acl_form.appendTo(h).hide();$(this).remove();window.focus()}});"user"==g?f.focus():$("input:checked",m).focus()};rcube_webmail.prototype.acl_class=function(a,b){var c,d=0;a=String(a);b=String(b);var g=0;for(c=b.length;g