MODx.tree.UserGroup=function(A){A=A||{};Ext.applyIf(A,{title:_("user_groups"),id:"modx-tree-usergroup",url:MODx.config.connectors_url+"security/group.php",root_id:"n_ug_0",root_name:_("user_groups"),enableDrag:true,enableDrop:true,rootVisible:true,ddAppendOnly:true,useDefaultToolbar:true,tbar:[{text:_("user_group_new"),scope:this,handler:this.createUserGroup.createDelegate(this,[true],true)}]});MODx.tree.UserGroup.superclass.constructor.call(this,A);};Ext.extend(MODx.tree.UserGroup,MODx.tree.Tree,{windows:{},addUser:function(B,C){var E=this.cm.activeNode;var D=E.id.substr(2).split("_");D=D[1];if(D===undefined){D=0;}var A={usergroup:D};if(!this.windows.adduser){this.windows.adduser=MODx.load({xtype:"modx-window-usergroup-adduser",record:A,listeners:{success:{fn:this.refresh,scope:this}}});}this.windows.adduser.setValues(A);this.windows.adduser.show(C.target);},createUserGroup:function(B,D,F){F=F||false;var C;if(F===false){var E=this.cm.activeNode;C=E.id.substr(2).split("_");C=C[1];if(C===undefined){C=0;}}else{C=0;}var A={parent:C};if(!this.windows.createUsergroup){this.windows.createUsergroup=MODx.load({xtype:"modx-window-usergroup-create",record:A,listeners:{success:{fn:this.refresh,scope:this}}});}else{this.windows.createUsergroup.setValues(A);}this.windows.createUsergroup.show(D.target);},updateUserGroup:function(A,B){var D=this.cm.activeNode;var C=D.id.substr(2).split("_");C=C[1];location.href="index.php?a="+MODx.action["security/usergroup/update"]+"&id="+C;},getMenu:function(){var A=[];var C=this.cm.activeNode;var B=C.getUI();switch(C.attributes.type){case"usergroup":if(B.hasClass("padduser")){A.push({text:_("user_group_user_add"),handler:this.addUser});A.push("-");}if(B.hasClass("pcreate")){A.push({text:_("user_group_create"),handler:this.createUserGroup});}if(B.hasClass("pupdate")){A.push({text:_("user_group_update"),handler:this.updateUserGroup});}if(B.hasClass("premove")){A.push("-");A.push({text:_("user_group_remove"),handler:this.removeUserGroup});}break;case"user":A.push({text:_("user_group_user_remove"),handler:this.removeUser});break;}return A;},removeUserGroup:function(A,B){var D=this.cm.activeNode;var C=D.id.substr(2).split("_");C=C[1];MODx.msg.confirm({title:_("warning"),text:_("user_group_remove_confirm"),url:this.config.url,params:{action:"remove",id:C},listeners:{success:{fn:this.refresh,scope:this}}});},removeUser:function(C,D){var E=this.cm.activeNode;var A=E.id.substr(2).split("_");A=A[1];var B=E.parentNode.id.substr(2).split("_");B=B[1];MODx.msg.confirm({title:_("warning"),text:_("user_group_user_remove_confirm"),url:this.config.url,params:{action:"removeUser",user_id:A,group_id:B},listeners:{success:{fn:this.refresh,scope:this}}});},_handleDrop:function(A){s=false;switch(A.dropNode.attributes.type){case"user":s=!(A.point=="above"||A.point=="below");s=s&&A.target.attributes.type=="usergroup"&&A.point=="append";break;case"usergroup":s=true;break;}return s;}});Ext.reg("modx-tree-usergroup",MODx.tree.UserGroup);MODx.window.CreateUserGroup=function(A){A=A||{};this.ident=A.ident||"cugrp"+Ext.id();Ext.applyIf(A,{title:_("create_user_group"),id:this.ident,height:150,width:375,url:MODx.config.connectors_url+"security/group.php",action:"create",fields:[{xtype:"textfield",fieldLabel:_("name"),name:"name",id:"modx-"+this.ident+"-name",anchor:"90%"},{xtype:"textarea",fieldLabel:_("description"),name:"description",id:"modx-"+this.ident+"-description",anchor:"90%"},{name:"parent",id:"modx-"+this.ident+"-parent",xtype:"hidden"}]});MODx.window.CreateUserGroup.superclass.constructor.call(this,A);};Ext.extend(MODx.window.CreateUserGroup,MODx.Window);Ext.reg("modx-window-usergroup-create",MODx.window.CreateUserGroup);MODx.window.AddUserToUserGroup=function(A){A=A||{};this.ident=A.ident||"adtug"+Ext.id();Ext.applyIf(A,{title:_("user_group_user_add"),id:this.ident,height:150,width:375,url:MODx.config.connectors_url+"security/usergroup/user.php",action:"create",fields:[{fieldLabel:_("name"),name:"user",hiddenName:"user",xtype:"modx-combo-user",editable:true,typeAhead:true,allowBlank:false,id:"modx-"+this.ident+"-user",anchor:"90%"},{fieldLabel:_("role"),name:"role",hiddenName:"role",xtype:"modx-combo-role",id:"modx-"+this.ident+"-role",allowBlank:false,anchor:"90%"},{name:"usergroup",xtype:"hidden",id:"modx-"+this.ident+"-user-group"}]});MODx.window.AddUserToUserGroup.superclass.constructor.call(this,A);};Ext.extend(MODx.window.AddUserToUserGroup,MODx.Window);Ext.reg("modx-window-usergroup-adduser",MODx.window.AddUserToUserGroup);