MODx.panel.AccessPolicy=function(A){A=A||{};Ext.applyIf(A,{url:MODx.config.connectors_url+"security/access/policy.php",baseParams:{action:"update",id:MODx.request.id},id:"modx-panel-access-policy",class_key:"modAccessPolicy",plugin:"",bodyStyle:"",defaults:{collapsible:false,autoHeight:true},items:[{html:"<h2>"+_("policy")+(A.record?": "+A.record.name:"")+"</h2>",border:false,cls:"modx-page-header",id:"modx-policy-header"},{xtype:"modx-tabs",defaults:{bodyStyle:"padding: 15px",autoHeight:true,border:true},forceLayout:true,deferredRender:false,items:[{title:_("policy"),layout:"form",items:[{html:"<p>"+_("policy_desc")+"</p>",border:false},{xtype:"hidden",name:"id",value:A.plugin},{xtype:"textfield",fieldLabel:_("name"),name:"name",width:300,maxLength:255,enableKeyEvents:true,allowBlank:false,listeners:{keyup:{scope:this,fn:function(B,C){Ext.getCmp("modx-policy-header").getEl().update("<h2>"+_("policy")+": "+B.getValue()+"</h2>");}}}},{xtype:"textarea",fieldLabel:_("description"),name:"description",width:300,grow:true},{xtype:"textfield",fieldLabel:_("lexicon"),name:"lexicon",width:300,allowBlank:true,value:"permissions"},{html:"<hr /><p>"+_("permissions_desc")+"</p>",border:false},{xtype:"modx-grid-policy-permissions",policy:MODx.request.id,autoHeight:true,preventRender:true}]}]}],listeners:{setup:{fn:this.setup,scope:this},success:{fn:this.success,scope:this},beforeSubmit:{fn:this.beforeSubmit,scope:this}}});MODx.panel.AccessPolicy.superclass.constructor.call(this,A);};Ext.extend(MODx.panel.AccessPolicy,MODx.FormPanel,{initialized:false,setup:function(){if(this.config.policy===""||this.config.policy===0){this.fireEvent("ready");return false;}if(!this.initialized){var B=this.config.record;this.getForm().setValues(B);var A=Ext.getCmp("modx-grid-policy-permissions");if(A){A.getStore().loadData(B.permissions);}this.fireEvent("ready");MODx.fireEvent("ready");this.initialized=true;}},beforeSubmit:function(B){var A=Ext.getCmp("modx-grid-policy-permissions");Ext.apply(B.form.baseParams,{permissions:A?A.encode():{}});},success:function(A){Ext.getCmp("modx-grid-policy-permissions").getStore().commitChanges();}});Ext.reg("modx-panel-access-policy",MODx.panel.AccessPolicy);MODx.grid.PolicyPermissions=function(A){A=A||{};var B=new Ext.ux.grid.CheckColumn({header:_("enabled"),dataIndex:"enabled",width:40,sortable:false});Ext.applyIf(A,{id:"modx-grid-policy-permissions",url:MODx.config.connectors_url+"security/access/policy/index.php",baseParams:{action:"getAttributes"},cls:"modx-grid modx-policy-permissions-grid",fields:["name","description","description_trans","value","enabled"],plugins:B,columns:[{header:_("name"),dataIndex:"name",width:100,editor:{xtype:"textfield",renderer:true}},{header:_("description"),dataIndex:"description_trans",width:250,editable:false},B],data:[],width:"90%",height:300,maxHeight:300,autosave:false,autoExpandColumn:"name"});MODx.grid.PolicyPermissions.superclass.constructor.call(this,A);this.propRecord=new Ext.data.Record.create(["name","description","access","value"]);this.on("rowclick",this.onPermRowClick,this);};Ext.extend(MODx.grid.PolicyPermissions,MODx.grid.LocalGrid,{onPermRowClick:function(D,A,E){var B=this.getStore();if(!B){return ;}var C=B.getAt(A);C.set("enabled",C.get("enabled")?false:true);C.commit();}});Ext.reg("modx-grid-policy-permissions",MODx.grid.PolicyPermissions);MODx.combo.AccessPolicyTemplate=function(A){A=A||{};Ext.applyIf(A,{name:"template",hiddenName:"template",fields:["id","name","description"],forceSelection:true,typeAhead:false,editable:false,allowBlank:false,listWidth:300,url:MODx.config.connectors_url+"security/access/policy/template.php",tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{name}</span>','<p style="margin: 0; font-size: 11px; color: gray;">{description}</p></div></tpl>')});MODx.combo.AccessPolicyTemplate.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.AccessPolicyTemplate,MODx.combo.ComboBox);Ext.reg("modx-combo-access-policy-template",MODx.combo.AccessPolicyTemplate);