MODx.grid.AccessContext=function(A){A=A||{};Ext.applyIf(A,{id:"modx-grid-access-context",url:MODx.config.connectors_url+"security/access/index.php",baseParams:{action:"getList",type:A.type||"modAccessContext",target:A.context_key},fields:["id","target","target_name","principal_class","principal","principal_name","authority","policy","policy_name","cls"],type:"modAccessContext",paging:true,columns:[{header:_("context"),dataIndex:"target_name",width:100},{header:_("user_group"),dataIndex:"principal_name",width:120},{header:_("authority"),dataIndex:"authority",width:50},{header:_("policy"),dataIndex:"policy_name",width:175}],tbar:[{text:_("acl_add"),scope:this,handler:this.createAcl}]});MODx.grid.AccessContext.superclass.constructor.call(this,A);};Ext.extend(MODx.grid.AccessContext,MODx.grid.Grid,{combos:{},windows:{},getMenu:function(){var B=this.getSelectionModel().getSelected();var C=B.data.cls;var A=[];if(this.getSelectionModel().getCount()>1){}else{if(C.indexOf("pedit")!=-1){A.push({text:_("edit"),handler:this.editAcl});}if(C.indexOf("premove")!=-1){if(A.length>0){A.push("-");}A.push({text:_("remove"),handler:this.removeAcl});}}if(A.length>0){this.addContextMenuItem(A);}},createAcl:function(C,B){var A={target:this.config.context_key,principal_class:"modUserGroup"};if(!this.windows.create_acl){this.windows.create_acl=MODx.load({xtype:"modx-window-access-context-create",record:A,listeners:{success:{fn:function(D){this.refresh();},scope:this}}});}this.windows.create_acl.fp.getForm().reset();this.windows.create_acl.setValues(A);this.windows.create_acl.show(B.target);},editAcl:function(C,B){var A=this.menu.record;Ext.applyIf(A,{context:A.target,user_group:A.principal});if(!this.windows.update_acl){this.windows.update_acl=MODx.load({xtype:"modx-window-access-context-update",acl:A.id,record:A,listeners:{success:{fn:this.refresh,scope:this}}});}this.windows.update_acl.setValues(A);this.windows.update_acl.show(B.target);},removeAcl:function(B,A){MODx.msg.confirm({title:_("ugc_remove"),text:_("access_confirm_remove"),url:this.config.url,params:{action:"removeAcl",id:this.menu.record.id,type:this.config.type||"modAccessContext"},listeners:{success:{fn:this.refresh,scope:this}}});}});Ext.reg("modx-grid-access-context",MODx.grid.AccessContext);MODx.window.UpdateAccessContext=function(A){A=A||{};var B=A.record;this.ident=A.ident||"uactx"+Ext.id();Ext.applyIf(A,{title:_("ugc_mutate"),url:MODx.config.connectors_url+"security/access/index.php",baseParams:{action:"updateAcl",type:A.type||"modAccessContext"},height:250,width:350,type:"modAccessContext",acl:0,fields:[{xtype:"hidden",name:"target",id:"modx-"+this.ident+"-target",value:B.context},{xtype:"modx-combo-usergroup",fieldLabel:_("user_group"),name:"principal",hiddenName:"principal",id:"modx-"+this.ident+"-principal",value:B.principal||"",baseParams:{action:"getList",combo:"1"},anchor:"90%"},{xtype:"textfield",fieldLabel:_("authority"),name:"authority",id:"modx-"+this.ident+"-authority",width:40,value:B.authority},{xtype:"modx-combo-policy",fieldLabel:_("policy"),name:"policy",hiddenName:"policy",id:"modx-"+this.ident+"-policy",value:B.policy||"",baseParams:{action:"getList",combo:"1"},anchor:"90%"},{xtype:"hidden",name:"principal_class",id:"modx-"+this.ident+"-principal-class",value:"modUserGroup"},{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id",value:B.id}]});MODx.window.UpdateAccessContext.superclass.constructor.call(this,A);};Ext.extend(MODx.window.UpdateAccessContext,MODx.Window);Ext.reg("modx-window-access-context-update",MODx.window.UpdateAccessContext);MODx.window.CreateAccessContext=function(A){A=A||{};var B=A.record;this.ident=A.ident||"cactx"+Ext.id();Ext.applyIf(A,{title:_("ugc_mutate"),url:MODx.config.connectors_url+"security/access/index.php",baseParams:{action:"addAcl",type:A.type||"modAccessContext"},height:250,width:350,type:"modAccessContext",acl:0,fields:[{xtype:"hidden",name:"target",id:"modx-"+this.ident+"-target"},{xtype:"hidden",name:"principal_class",id:"modx-"+this.ident+"-principal-class",value:"modUserGroup"},{xtype:"modx-combo-usergroup",fieldLabel:_("user_group"),name:"principal",hiddenName:"principal",id:"modx-"+this.ident+"-usergroup",baseParams:{action:"getList",combo:"1"},anchor:"90%"},{xtype:"textfield",fieldLabel:_("authority"),name:"authority",id:"modx-"+this.ident+"-authority",width:40},{xtype:"modx-combo-policy",fieldLabel:_("policy"),name:"policy",hiddenName:"policy",id:"modx-"+this.ident+"-policy",baseParams:{action:"getList",combo:"1"},anchor:"90%"}]});MODx.window.CreateAccessContext.superclass.constructor.call(this,A);};Ext.extend(MODx.window.CreateAccessContext,MODx.Window);Ext.reg("modx-window-access-context-create",MODx.window.CreateAccessContext);