Current File : //root/panel/etc/apps/webmail/plugins/acl/acl.min.js |
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){if("acluser"==a.field.id){var b=a.insert;b.match(/\s*\(([^)]+)\)[, ]*$/)&&(b=RegExp.$1);a.field.value=b}})}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,c="",b=$("#acluser",this.acl_form).val();$(this.env.acl_advanced?"#advancedrights :checkbox":"#simplerights :checkbox",this.acl_form).map(function(){this.checked&&(c+=this.value)});(a=$("input:checked[name=usertype]",this.acl_form).val())&&"user"!=a&&(b=a);b?c?(a={_act:"save",_user:b,_acl:c,_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,toggleselect:!0});this.acl_list.addEventListener("select",function(a){rcmail.acl_list_select(a)});this.acl_list.addEventListener("dblclick",function(a){rcmail.acl_list_dblclick(a)});this.acl_list.addEventListener("keypress",
function(a){rcmail.acl_list_keypress(a)});this.acl_list.init()};rcube_webmail.prototype.acl_list_select=function(a){rcmail.enable_command("acl-delete",0<a.selection.length);rcmail.enable_command("acl-edit",1==a.selection.length);a.focus()};rcube_webmail.prototype.acl_list_dblclick=function(a){this.acl_edit()};
rcube_webmail.prototype.acl_list_keypress=function(a){if(a.key_pressed==a.ENTER_KEY)this.command("acl-edit");else if(a.key_pressed==a.DELETE_KEY||a.key_pressed==a.BACKSPACE_KEY)this.acl_form&&this.acl_form.is(":visible")||this.command("acl-delete")};rcube_webmail.prototype.acl_list_update=function(a){$(this.gui_objects.acltable).html(a);this.acl_list_init()};
rcube_webmail.prototype.acl_get_usernames=function(){var a=[],c,b,e,d=this.acl_list,f=d.get_selection();c=0;for(b=f.length;c<b;c++)if(this.env.acl_specials.length&&0<=$.inArray(f[c],this.env.acl_specials))a.push(f[c]);else if(e=d.rows[f[c]])e=$("td.user",e.obj),1==e.length&&a.push(e.text());return a};
rcube_webmail.prototype.acl_remove_row=function(a){var c=this.acl_list;c.remove_row(a);c.clear_selection();$("#rcmrow"+a).remove();this.env.acl[a]=null;this.enable_command("acl-delete",0<c.selection.length);this.enable_command("acl-edit",1==c.selection.length)};
rcube_webmail.prototype.acl_add_row=function(a,c){var b,e,d=[];e=[];var f=a.id,h=this.acl_list,k=this.env.acl_advanced?[]:this.env.acl_items,g=$("thead > tr",this.gui_objects.acltable).clone();$("td",g).map(function(){var b=this.className.replace(/^acl/,"");k&&k[b]&&(b=k[b]);"user"==b?$(this).text(a.username):$(this).addClass(rcmail.acl_class(a.acl,b)).text("")});g.attr("id","rcmrow"+f);g=g.get(0);this.env.acl[f]=a.acl;for(b in this.env.acl)this.env.acl[b]&&(this.env.acl_specials.length&&0<=$.inArray(b,
this.env.acl_specials)?e.push(b):d.push(b));d.sort();d=e.concat(d);b=0;for(e=d.length;b<e&&d[b]!=f;b++);b&&b<e?($("#rcmrow"+d[b-1]).after(g),h.init_row(g),h.rowcount++):h.insert_row(g);c&&h.select_row(a.id)};
rcube_webmail.prototype.acl_init_form=function(a){var c,b,e,d="",f="user",h=$("body");c=$("#advancedrights");var k=$("#simplerights"),g=$("#acluser");if(!this.acl_form){var l=function(){$("input[value=user]").prop("checked",!0)};g.click(l).keypress(l)}this.acl_form=$("#aclform");this.env.acl_advanced?(c.show(),k.hide()):(k.show(),c.hide(),c=k);c=$(":checkbox",c);c.attr("checked",!1);a&&(b=this.acl_list.rows[a])?(b=b.obj,c.map(function(){e=$("td."+this.id,b);e.length&&e.hasClass("enabled")&&(this.checked=
!0)}),!this.env.acl_specials.length||0>$.inArray(a,this.env.acl_specials)?d=$("td.user",b).text():f=a):c.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 n=this,m=window.rcmail,h=document.body,d={};d[rcmail.gettext("save")]=function(a){m.command("acl-save")};d[rcmail.gettext("cancel")]=function(a){m.command("acl-cancel")};this.acl_popup=rcmail.show_popup_dialog('<div style="width:480px;height:280px"> </div>',
a?rcmail.gettext("acl.editperms"):rcmail.gettext("acl.newuser"),d,{modal:!0,closeOnEscape:!1,close:function(a,b){(rcmail.is_framed()?parent.rcmail:rcmail).ksearch_hide();n.acl_form.appendTo(h).hide();$(this).remove()}});this.acl_form.appendTo(this.acl_popup).show();"user"==f&&g.focus();this.acl_list.blur()};rcube_webmail.prototype.acl_class=function(a,c){var b,e,d=0;a=String(a);c=String(c);b=0;for(e=c.length;b<e;b++)-1<a.indexOf(c[b])&&d++;return d==e?"enabled":d?"partial":"disabled"};