public List <GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID) { if (!CheckGroupPermissions(requestingAgentID, GroupID, (ulong)GroupPowers.None)) { return(new List <GroupRolesData>()); } List <GroupRolesData> GroupRoles = new List <GroupRolesData>(); List <string> Roles = data.Query("GroupID", GroupID, "osrole", "Name,Description,Title,Powers,RoleID"); for (int i = 0; i < Roles.Count; i += 5) { List <string> Count = data.Query(new string[] { "GroupID", "RoleID" }, new object[] { GroupID, UUID.Parse(Roles[i + 4]) }, "osgrouprolemembership", "count(AgentID)"); GroupRolesData roledata = new GroupRolesData(); roledata.Members = int.Parse(Count[0]); roledata.RoleID = UUID.Parse(Roles[i + 4]); roledata.Name = Roles[i + 0]; roledata.Description = Roles[i + 1]; roledata.Powers = ulong.Parse(Roles[i + 3]); roledata.Title = Roles[i + 2]; GroupRoles.Add(roledata); } return(GroupRoles); }
protected List <GroupRolesData> _GetGroupRoles(UUID groupID) { List <GroupRolesData> roles = new List <GroupRolesData>(); RoleData[] data = m_Database.RetrieveRoles(groupID); if (data == null || (data != null && data.Length == 0)) { return(roles); } foreach (RoleData d in data) { GroupRolesData r = new GroupRolesData(); r.Description = d.Data["Description"]; r.Members = m_Database.RoleMemberCount(groupID, d.RoleID); r.Name = d.Data["Name"]; r.Powers = UInt64.Parse(d.Data["Powers"]); r.RoleID = d.RoleID; r.Title = d.Data["Title"]; roles.Add(r); } return(roles); }
public List <GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID) { if (!CheckGroupPermissions(requestingAgentID, GroupID, (ulong)GroupPowers.None)) { return(new List <GroupRolesData>()); } List <GroupRolesData> AgentRoles = new List <GroupRolesData>(); List <string> RoleIDs = data.Query(new string[] { "AgentID", "GroupID" }, new object[] { AgentID, GroupID }, "osgrouprolemembership", "RoleID"); foreach (string RoleID in RoleIDs) { List <string> Role = data.Query("RoleID", RoleID, "osrole", "Name,Description,Title,Powers"); GroupRolesData roledata = new GroupRolesData(); roledata.RoleID = UUID.Parse(RoleID); roledata.Name = Role[0]; roledata.Description = Role[1]; roledata.Powers = ulong.Parse(Role[3]); roledata.Title = Role[2]; AgentRoles.Add(roledata); } return(AgentRoles); }
public List <GroupRolesData> GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID) { List <GroupRolesData> roles = new List <GroupRolesData>(); // TODO: check permissions RoleMembershipData[] data = m_Database.RetrieveMemberRoles(GroupID, AgentID); if (data == null || (data != null && data.Length == 0)) { return(roles); } foreach (RoleMembershipData d in data) { RoleData rdata = m_Database.RetrieveRole(GroupID, d.RoleID); if (rdata == null) // hippos { continue; } GroupRolesData r = new GroupRolesData(); r.Name = rdata.Data["Name"]; r.Powers = UInt64.Parse(rdata.Data["Powers"]); r.RoleID = rdata.RoleID; r.Title = rdata.Data["Title"]; roles.Add(r); } return(roles); }
public List <GroupRolesData> GetGroupRoles(string RequestingAgentID, UUID GroupID, string token) { List <GroupRolesData> roles = new List <GroupRolesData>(); Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["GroupID"] = GroupID.ToString(); sendData["RequestingAgentID"] = RequestingAgentID; sendData["AccessToken"] = GroupsDataUtils.Sanitize(token); Dictionary <string, object> ret = MakeRequest("GETGROUPROLES", sendData); if (ret == null) { return(roles); } if (!ret.ContainsKey("RESULT")) { return(roles); } if (ret["RESULT"].ToString() == "NULL") { return(roles); } foreach (object v in ((Dictionary <string, object>)ret["RESULT"]).Values) { GroupRolesData m = GroupsDataUtils.GroupRolesData((Dictionary <string, object>)v); roles.Add(m); } return(roles); }
public List <GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID) { m_log.InfoFormat("[Groups] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); List <GroupRolesData> rolesData = new List <GroupRolesData>(); osGroup group; if (m_Groups.TryGetValue(groupID, out group)) { foreach (osgRole role in group.Roles.Values) { GroupRolesData data = new GroupRolesData(); data.Description = role.Description; data.Members = role.Members; data.Name = role.Name; data.Powers = (ulong)role.Powers; data.RoleID = role.RoleID; data.Title = role.Title; m_log.DebugFormat("[Groups] Role {0} :: Powers {1}", role.Name, data.Powers); rolesData.Add(data); } } return(rolesData); }
public void RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, BooleanDelegate d) { if (d()) { lock (m_Cache) { // update the cached role string cacheKey = "role-" + RoleID.ToString(); object obj; if (m_Cache.TryGetValue(cacheKey, out obj)) { GroupRolesData r = (GroupRolesData)obj; r.Members--; } cacheKey = "roles-" + GroupID.ToString() + "-" + AgentID.ToString(); if (m_Cache.Contains(cacheKey)) { m_Cache.Remove(cacheKey); } cacheKey = "rolemembers-" + RequestingAgentID.ToString() + "-" + GroupID.ToString(); if (m_Cache.Contains(cacheKey)) { m_Cache.Remove(cacheKey); } } } }
public List <GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID) { Hashtable param = new Hashtable(); param["AgentID"] = AgentID.ToString(); param["GroupID"] = GroupID.ToString(); Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param); List <GroupRolesData> Roles = new List <GroupRolesData>(); if (respData.Contains("error")) { return(Roles); } foreach (Hashtable role in respData.Values) { GroupRolesData data = new GroupRolesData(); data.RoleID = new UUID((string)role["RoleID"]); data.Name = (string)role["Name"]; data.Description = (string)role["Description"]; data.Powers = ulong.Parse((string)role["Powers"]); data.Title = (string)role["Title"]; Roles.Add(data); } return(Roles); }
public bool AddGroupRole(UUID groupID, UUID roleID, string description, string name, ulong powers, string title, BooleanDelegate d) { if (d()) { GroupRolesData role = new GroupRolesData(); role.Description = description; role.Members = 0; role.Name = name; role.Powers = powers; role.RoleID = roleID; role.Title = title; lock (m_Cache) { m_Cache.AddOrUpdate("role-" + roleID.ToString(), role, GROUPS_CACHE_TIMEOUT); // also remove this list if (m_Cache.Contains("roles-" + groupID.ToString())) { m_Cache.Remove("roles-" + groupID.ToString()); } } return(true); } return(false); }
public static GroupRolesData GroupRolesData(Dictionary <string, object> dict) { GroupRolesData role = new GroupRolesData(); if (dict == null) { return(role); } if (dict.ContainsKey("Description") && dict["Description"] != null) { role.Description = Sanitize(dict["Description"].ToString()); } else { role.Description = string.Empty; } if (dict.ContainsKey("Members") && dict["Members"] != null) { role.Members = Int32.Parse(dict["Members"].ToString()); } if (dict.ContainsKey("Name") && dict["Name"] != null) { role.Name = Sanitize(dict["Name"].ToString()); } else { role.Name = string.Empty; } if (dict.ContainsKey("Powers") && dict["Powers"] != null) { role.Powers = UInt64.Parse(dict["Powers"].ToString()); } if (dict.ContainsKey("Title") && dict["Title"] != null) { role.Title = Sanitize(dict["Title"].ToString()); } else { role.Title = string.Empty; } if (dict.ContainsKey("RoleID") && dict["RoleID"] != null) { role.RoleID = UUID.Parse(dict["RoleID"].ToString()); } return(role); }
public static Dictionary <string, object> GroupRolesData(GroupRolesData role) { Dictionary <string, object> dict = new Dictionary <string, object>(); dict["Description"] = Sanitize(role.Description); dict["Members"] = role.Members.ToString(); dict["Name"] = Sanitize(role.Name); dict["Powers"] = role.Powers.ToString(); dict["RoleID"] = role.RoleID.ToString(); dict["Title"] = Sanitize(role.Title); return(dict); }
public void AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, BooleanDelegate d) { if (d()) { lock (m_Cache) { // update the cached role string cacheKey = "role-" + RoleID.ToString(); object obj; if (m_Cache.TryGetValue(cacheKey, out obj)) { GroupRolesData r = (GroupRolesData)obj; r.Members++; } // add this agent to the list of role members cacheKey = "rolemembers-" + RequestingAgentID.ToString() + "-" + GroupID.ToString(); if (m_Cache.TryGetValue(cacheKey, out obj)) { try { // This may throw an exception, in which case the agentID is not a UUID but a full ID // In that case, let's just remove the whoe things from the cache UUID id = new UUID(AgentID); List <ExtendedGroupRoleMembersData> xx = (List <ExtendedGroupRoleMembersData>)obj; List <GroupRoleMembersData> rmlist = xx.ConvertAll <GroupRoleMembersData>(m_ForeignImporter.ConvertGroupRoleMembersData); GroupRoleMembersData rm = new GroupRoleMembersData(); rm.MemberID = id; rm.RoleID = RoleID; rmlist.Add(rm); } catch { m_Cache.Remove(cacheKey); } } // Remove the cached info about this agent's roles // because we don't have enough local info about the new role cacheKey = "roles-" + GroupID.ToString() + "-" + AgentID.ToString(); if (m_Cache.Contains(cacheKey)) { m_Cache.Remove(cacheKey); } } } }
public bool UpdateGroupRole(UUID groupID, UUID roleID, string name, string description, string title, ulong powers, BooleanDelegate d) { if (d()) { object role; lock (m_Cache) if (m_Cache.TryGetValue("role-" + roleID.ToString(), out role)) { GroupRolesData r = (GroupRolesData)role; r.Description = description; r.Name = name; r.Powers = powers; r.Title = title; m_Cache.Update("role-" + roleID.ToString(), r, GROUPS_CACHE_TIMEOUT); } return(true); } else { lock (m_Cache) { if (m_Cache.Contains("role-" + roleID.ToString())) { m_Cache.Remove("role-" + roleID.ToString()); } // also remove these lists, because they will have an outdated role if (m_Cache.Contains("roles-" + groupID.ToString())) { m_Cache.Remove("roles-" + groupID.ToString()); } } return(false); } }
public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID) { if (!CheckGroupPermissions(requestingAgentID, GroupID, (ulong) GroupPowers.None)) return new List<GroupRolesData>(); List<GroupRolesData> GroupRoles = new List<GroupRolesData>(); List<string> Roles = data.Query("GroupID", GroupID, "osrole", "Name,Description,Title,Powers,RoleID"); for (int i = 0; i < Roles.Count; i += 5) { List<string> Count = data.Query(new[] { "GroupID", "RoleID" }, new object[] { GroupID, UUID.Parse(Roles[i + 4]) }, "osgrouprolemembership", "count(AgentID)"); GroupRolesData roledata = new GroupRolesData { Members = int.Parse(Count[0]), RoleID = UUID.Parse(Roles[i + 4]), Name = Roles[i + 0], Description = Roles[i + 1], Powers = ulong.Parse(Roles[i + 3]), Title = Roles[i + 2] }; GroupRoles.Add(roledata); } return GroupRoles; }
protected OSDMap OnMessageReceived(OSDMap message) { //We need to check and see if this is an GroupSessionAgentUpdate if (message.ContainsKey("Method") && message ["Method"] == "GroupSessionAgentUpdate") { //COMES IN ON WhiteCore.SERVER SIDE //Send it on to whomever it concerns OSDMap innerMessage = (OSDMap)message ["Message"]; if (innerMessage ["message"] == "ChatterBoxSessionAgentListUpdates") // ONLY forward on this type of message { UUID agentID = message ["AgentID"]; IEventQueueService eqs = m_registry.RequestModuleInterface <IEventQueueService> (); IAgentInfoService agentInfo = m_registry.RequestModuleInterface <IAgentInfoService> (); if (agentInfo != null) { UserInfo user = agentInfo.GetUserInfo(agentID.ToString()); if (user != null && user.IsOnline) { eqs.Enqueue(innerMessage, agentID, user.CurrentRegionID); } } } } else if (message.ContainsKey("Method") && message ["Method"] == "FixGroupRoleTitles") { // This message comes in on WhiteCore.Server side from the region UUID groupID = message ["GroupID"].AsUUID(); UUID agentID = message ["AgentID"].AsUUID(); UUID roleID = message ["RoleID"].AsUUID(); byte type = (byte)message ["Type"].AsInteger(); IGroupsServiceConnector con = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> (); List <GroupRoleMembersData> members = con.GetGroupRoleMembers(agentID, groupID); List <GroupRolesData> roles = con.GetGroupRoles(agentID, groupID); GroupRolesData everyone = null; foreach (GroupRolesData role in roles.Where(role => role.Name == "Everyone")) { everyone = role; } List <UserInfo> regionsToBeUpdated = new List <UserInfo> (); foreach (GroupRoleMembersData data in members) { if (data.RoleID == roleID) { // They were affected by the change switch ((GroupRoleUpdate)type) { case GroupRoleUpdate.Create: case GroupRoleUpdate.NoUpdate: // No changes... break; case GroupRoleUpdate.UpdatePowers: // Possible we don't need to send this? case GroupRoleUpdate.UpdateAll: case GroupRoleUpdate.UpdateData: case GroupRoleUpdate.Delete: if (type == (byte)GroupRoleUpdate.Delete) { // Set them to the most limited role since their role is gone con.SetAgentGroupSelectedRole(data.MemberID, groupID, everyone.RoleID); } // Need to update their title inworld IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> (); UserInfo info; if (agentInfoService != null && (info = agentInfoService.GetUserInfo(agentID.ToString())) != null && info.IsOnline) { // Forward the message regionsToBeUpdated.Add(info); } break; } } } if (regionsToBeUpdated.Count != 0) { ISyncMessagePosterService messagePost = m_registry.RequestModuleInterface <ISyncMessagePosterService> (); if (messagePost != null) { foreach (UserInfo userInfo in regionsToBeUpdated) { OSDMap outgoingMessage = new OSDMap(); outgoingMessage ["Method"] = "ForceUpdateGroupTitles"; outgoingMessage ["GroupID"] = groupID; outgoingMessage ["RoleID"] = roleID; outgoingMessage ["RegionID"] = userInfo.CurrentRegionID; messagePost.Post(userInfo.CurrentRegionURI, outgoingMessage); } } } } else if (message.ContainsKey("Method") && message ["Method"] == "ForceUpdateGroupTitles") { // This message comes in on the region side from WhiteCore.Server UUID groupID = message ["GroupID"].AsUUID(); UUID roleID = message ["RoleID"].AsUUID(); UUID regionID = message ["RegionID"].AsUUID(); IGroupsModule gm = m_registry.RequestModuleInterface <IGroupsModule> (); if (gm != null) { gm.UpdateUsersForExternalRoleUpdate(groupID, roleID, regionID); } } return(null); }
protected OSDMap OnMessageReceived(OSDMap message) { //We need to check and see if this is an GroupSessionAgentUpdate if (message.ContainsKey("Method") && message["Method"] == "GroupSessionAgentUpdate") { //COMES IN ON AURORA.SERVER SIDE //Send it on to whomever it concerns OSDMap innerMessage = (OSDMap)message["Message"]; if (innerMessage["message"] == "ChatterBoxSessionAgentListUpdates") //ONLY forward on this type of message { UUID agentID = message["AgentID"]; IEventQueueService eqs = m_registry.RequestModuleInterface <IEventQueueService>(); ICapsService caps = m_registry.RequestModuleInterface <ICapsService>(); if (caps != null) { IClientCapsService clientCaps = caps.GetClientCapsService(agentID); if (clientCaps != null && clientCaps.GetRootCapsService() != null) { eqs.Enqueue(innerMessage, agentID, clientCaps.GetRootCapsService().RegionHandle); } } } } else if (message.ContainsKey("Method") && message["Method"] == "FixGroupRoleTitles") { //COMES IN ON AURORA.SERVER SIDE FROM REGION UUID groupID = message["GroupID"].AsUUID(); UUID agentID = message["AgentID"].AsUUID(); UUID roleID = message["RoleID"].AsUUID(); byte type = (byte)message["Type"].AsInteger(); IGroupsServiceConnector con = DataManager.RequestPlugin <IGroupsServiceConnector>(); List <GroupRoleMembersData> members = con.GetGroupRoleMembers(agentID, groupID); List <GroupRolesData> roles = con.GetGroupRoles(agentID, groupID); GroupRolesData everyone = null; #if (!ISWIN) foreach (GroupRolesData role in roles) { if (role.Name == "Everyone") { everyone = role; } } #else foreach (GroupRolesData role in roles.Where(role => role.Name == "Everyone")) { everyone = role; } #endif List <ulong> regionsToBeUpdated = new List <ulong>(); foreach (GroupRoleMembersData data in members) { if (data.RoleID == roleID) { //They were affected by the change switch ((GroupRoleUpdate)type) { case GroupRoleUpdate.Create: case GroupRoleUpdate.NoUpdate: //No changes... break; case GroupRoleUpdate.UpdatePowers: //Possible we don't need to send this? case GroupRoleUpdate.UpdateAll: case GroupRoleUpdate.UpdateData: case GroupRoleUpdate.Delete: if (type == (byte)GroupRoleUpdate.Delete) { //Set them to the most limited role since their role is gone con.SetAgentGroupSelectedRole(data.MemberID, groupID, everyone.RoleID); } //Need to update their title inworld ICapsService caps = m_registry.RequestModuleInterface <ICapsService>(); if (caps != null) { IClientCapsService clientCaps = caps.GetClientCapsService(agentID); if (clientCaps != null && clientCaps.GetRootCapsService() != null) { regionsToBeUpdated.Add(clientCaps.GetRootCapsService().RegionHandle); } } break; } } } if (regionsToBeUpdated.Count != 0) { IAsyncMessagePostService messagePost = m_registry.RequestModuleInterface <IAsyncMessagePostService>(); if (messagePost != null) { foreach (ulong regionhandle in regionsToBeUpdated) { OSDMap outgoingMessage = new OSDMap(); outgoingMessage["Method"] = "ForceUpdateGroupTitles"; outgoingMessage["GroupID"] = groupID; outgoingMessage["RoleID"] = roleID; outgoingMessage["RegionID"] = regionhandle; messagePost.Post(regionhandle, outgoingMessage); } } } } else if (message.ContainsKey("Method") && message["Method"] == "ForceUpdateGroupTitles") { //COMES IN ON REGION SIDE FROM AURORA.SERVER UUID groupID = message["GroupID"].AsUUID(); UUID roleID = message["RoleID"].AsUUID(); ulong regionID = message["RegionID"].AsULong(); IGroupsModule gm = m_registry.RequestModuleInterface <IGroupsModule>(); if (gm != null) { gm.UpdateUsersForExternalRoleUpdate(groupID, roleID, regionID); } } else if (message.ContainsKey("Method") && message["Method"] == "SendGroupNoticeToUsers") { //COMES IN ON REGION SIDE FROM AURORA.SERVER GroupNoticeInfo notice = new GroupNoticeInfo(); notice.FromOSD((OSDMap)message["Notice"]); IGroupsModule gm = m_registry.RequestModuleInterface <IGroupsModule>(); if (gm != null) { gm.SendGroupNoticeToUsers(null, notice, true); } } return(null); }
public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID) { if (!CheckGroupPermissions(requestingAgentID, GroupID, (ulong)GroupPowers.None)) return new List<GroupRolesData>(); List<GroupRolesData> AgentRoles = new List<GroupRolesData>(); List<string> RoleIDs = data.Query(new string[] { "AgentID", "GroupID" }, new object[] { AgentID, GroupID }, "osgrouprolemembership", "RoleID"); foreach (string RoleID in RoleIDs) { List<string> Role = data.Query("RoleID", RoleID, "osrole", "Name,Description,Title,Powers"); GroupRolesData roledata = new GroupRolesData(); roledata.RoleID = UUID.Parse(RoleID); roledata.Name = Role[0]; roledata.Description = Role[1]; roledata.Powers = ulong.Parse(Role[3]); roledata.Title = Role[2]; AgentRoles.Add(roledata); } return AgentRoles; }