MODx.grid.UserGroups=function(A){A=A||{};Ext.applyIf(A,{title:"",id:"modx-grid-user-groups",url:MODx.config.connectors_url+"security/group.php",fields:["usergroup","name","member","role","rolename"],columns:[{header:_("user_group"),dataIndex:"name",width:175},{header:_("role"),dataIndex:"rolename",width:175}],tbar:[{text:_("user_group_user_add"),handler:this.addGroup}]});MODx.grid.UserGroups.superclass.constructor.call(this,A);this.userRecord=new Ext.data.Record.create([{name:"usergroup"},{name:"name"},{name:"member"},{name:"role"},{name:"rolename"}]);this.addEvents("beforeUpdateRole","afterUpdateRole","beforeAddGroup","afterAddGroup");};Ext.extend(MODx.grid.UserGroups,MODx.grid.LocalGrid,{updateRole:function(A,C){var B=this.menu.record;B.user=this.config.user;this.fireEvent("beforeUpdateRole",B);this.loadWindow(A,C,{xtype:"modx-window-user-groups-role-update",record:B,listeners:{success:{fn:function(E){var D=this.getStore();var F=D.getAt(this.menu.recordIndex);F.set("role",E.role);F.set("rolename",E.rolename);this.fireEvent("afterUpdateRole",E);},scope:this}}});},addGroup:function(A,C){var B={member:this.config.user};this.fireEvent("beforeUpdateRole",B);this.loadWindow(A,C,{xtype:"modx-window-user-addgroup",record:B,listeners:{success:{fn:function(E){var D=this.getStore();var F=new this.userRecord(E);D.add(F);this.fireEvent("afterAddGroup",E);},scope:this}}});},_showMenu:function(C,B,D){D.stopEvent();D.preventDefault();var A=this.menu;A.recordIndex=B;A.record=this.getStore().getAt(B).data;if(!this.getSelectionModel().isSelected(B)){this.getSelectionModel().selectRow(B);}A.removeAll();A.add({text:_("user_role_update"),handler:this.updateRole,scope:this},"-",{text:_("user_group_user_remove"),handler:this.remove.createDelegate(this,[{text:_("user_group_remove_confirm")}]),scope:this});A.show(D.target);}});Ext.reg("modx-grid-user-groups",MODx.grid.UserGroups);MODx.window.AddGroupToUser=function(A){A=A||{};Ext.applyIf(A,{title:_("user_group_user_add"),height:150,width:375,url:MODx.config.connectors_url+"security/user/group.php",action:"create",fields:[{fieldLabel:_("user_group"),name:"usergroup",hiddenName:"usergroup",id:"modx-agu-usergroup",xtype:"modx-combo-usergroup",editable:false,allowBlank:false,anchor:"90%"},{fieldLabel:_("role"),name:"role",hiddenName:"role",id:"modx-agu-role",xtype:"modx-combo-role",allowBlank:false,anchor:"90%"},{name:"member",xtype:"hidden"}]});MODx.window.AddGroupToUser.superclass.constructor.call(this,A);};Ext.extend(MODx.window.AddGroupToUser,MODx.Window,{submit:function(){var D=this.fp.getForm().getValues();var C=Ext.getCmp("modx-grid-user-groups");var B=C.getStore();var A=B.query("usergroup",D.usergroup).items;if(A.length>0){MODx.msg.alert(_("error"),_("user_err_ae_group"));return false;}D.rolename=Ext.getCmp("modx-agu-role").getRawValue();D.name=Ext.getCmp("modx-agu-usergroup").getRawValue();this.fireEvent("success",D);this.hide();return false;}});Ext.reg("modx-window-user-addgroup",MODx.window.AddGroupToUser);MODx.window.UpdateUserGroupsRole=function(A){A=A||{};Ext.applyIf(A,{id:"modx-window-user-groups-role-update",title:_("user_group_user_update_role"),url:MODx.config.connectors_url+"security/user.php",action:"updateRole",fields:[{xtype:"hidden",name:"user",value:A.user},{xtype:"modx-combo-role",id:"modx-uugrs-role",name:"role",fieldLabel:_("role"),anchor:"90%"}]});MODx.window.UpdateUserGroupsRole.superclass.constructor.call(this,A);};Ext.extend(MODx.window.UpdateUserGroupsRole,MODx.Window,{submit:function(){var A=this.fp.getForm().getValues();A.rolename=Ext.getCmp("modx-uugrs-role").getRawValue();this.fireEvent("success",A);this.hide();return false;}});Ext.reg("modx-window-user-groups-role-update",MODx.window.UpdateUserGroupsRole);