MODx.tree.ResourceGroup=function(A){A=A||{};Ext.applyIf(A,{title:_("resource_groups"),url:MODx.config.connectors_url+"security/resourcegroup.php",root_id:"0",root_name:_("resource_groups"),enableDrag:false,enableDrop:true,ddAppendOnly:true,useDefaultToolbar:true,tbar:[{text:_("resource_group_create"),scope:this,handler:this.createResourceGroup}]});MODx.tree.ResourceGroup.superclass.constructor.call(this,A);};Ext.extend(MODx.tree.ResourceGroup,MODx.tree.Tree,{forms:{},windows:{},stores:{},getMenu:function(){var B=this.cm.activeNode;var A=[];if(B.attributes.type=="modResourceGroup"){A.push({text:_("resource_group_create"),handler:this.createResourceGroup});A.push("-");A.push({text:_("resource_group_remove"),handler:this.removeResourceGroup});}else{if(B.attributes.type=="modResource"){A.push({text:_("resource_group_access_remove"),handler:this.removeResource});}}return A;},removeResource:function(A,C){var E=this.cm.activeNode;var D=E.id.split("_");D=D[1];var B=E.parentNode.id.substr(2).split("_");B=B[1];MODx.msg.confirm({text:_("resource_group_access_remove_confirm"),url:this.config.url,params:{action:"removeResource",resource:D,resourceGroup:B},listeners:{success:{fn:this.refresh,scope:this}}});},removeResourceGroup:function(A,B){var D=this.cm.activeNode;var C=D.id.substr(2).split("_");C=C[1];MODx.msg.confirm({text:_("resource_group_remove_confirm"),url:this.config.url,params:{action:"remove",id:C},listeners:{success:{fn:this.refresh,scope:this}}});},createResourceGroup:function(B,A){if(!this.windows.create){this.windows.create=MODx.load({xtype:"modx-window-resourcegroup-create",listeners:{success:{fn:this.refresh,scope:this}}});}this.windows.create.show(A.target);},_handleDrop:function(A){var C=A.dropNode;if(this.isDocCopy(A,C)){var B=new Ext.tree.TreeNode(Ext.apply({leaf:true,allowDelete:true,expanded:true},C.attributes));B.loader=undefined;if(A.target.attributes.options){A.target=this.createDGD(A.target,B.text);}A.dropNode=B;return true;}return false;},isDocCopy:function(C,D){var A=C.target.attributes;var B=D.attributes.id.split("_");B="n_"+B[1];if(C.target.findChild("id",B)!==null){return false;}if(D.attributes.type!="modResource"){return false;}if(C.point!="append"){return false;}if(A.type!="modResourceGroup"){return false;}if(A.leaf===true){return false;}return true;},createDGD:function(D,C){var B=this.getNodeById(D.attributes.cmpId);var A=new Ext.tree.TreeNode({text:C,cmpId:B.id,leaf:true,allowDelete:true,allowEdit:true,id:this._guid("o-")});B.childNodes[2].appendChild(A);B.childNodes[2].expand(false,false);return A;},_handleDrag:function(B){Ext.Msg.show({title:_("please_wait"),msg:_("saving"),width:240,progress:true,closable:false});MODx.util.Progress.reset();for(var A=1;A<20;A++){setTimeout("MODx.util.Progress.time("+A+","+MODx.util.Progress.id+")",A*1000);}MODx.Ajax.request({url:this.config.url,scope:this,params:{resource:B.dropNode.attributes.id,resourceGroup:B.target.attributes.id,action:"updateResourcesIn"},listeners:{success:{fn:function(C,D){MODx.util.Progress.reset();Ext.Msg.hide();if(!C.success){Ext.Msg.alert(_("error"),C.message);return false;}this.refresh();return true;},scope:this}}});}});Ext.reg("modx-tree-resource-group",MODx.tree.ResourceGroup);MODx.window.CreateResourceGroup=function(A){A=A||{};this.ident=A.ident||"crgrp"+Ext.id();Ext.applyIf(A,{title:_("resource_group_create"),id:this.ident,height:150,width:350,url:MODx.config.connectors_url+"security/resourcegroup.php",action:"create",fields:[{fieldLabel:_("name"),name:"name",id:"modx-"+this.ident+"-name",xtype:"textfield",anchor:"90%"}]});MODx.window.CreateResourceGroup.superclass.constructor.call(this,A);};Ext.extend(MODx.window.CreateResourceGroup,MODx.Window);Ext.reg("modx-window-resourcegroup-create",MODx.window.CreateResourceGroup);