From 94619cba58a6783efd61acae56599332d7c111ba Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Sep 2014 09:22:32 -0700 Subject: Fixed a hard-to-run-into bug in groups: at the time of creation of a group, the OwnerRoleID in the groups table was inconsistent with the roleID in the roles table. OpenSim core was not running into this bug, but 3rd party modules (like Wifi) were. --- OpenSim/Addons/Groups/Service/GroupsService.cs | 28 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'OpenSim/Addons') diff --git a/OpenSim/Addons/Groups/Service/GroupsService.cs b/OpenSim/Addons/Groups/Service/GroupsService.cs index f44c094..7cbc796 100644 --- a/OpenSim/Addons/Groups/Service/GroupsService.cs +++ b/OpenSim/Addons/Groups/Service/GroupsService.cs @@ -150,7 +150,8 @@ namespace OpenSim.Groups data.Data["ShowInList"] = showInList ? "1" : "0"; data.Data["AllowPublish"] = allowPublish ? "1" : "0"; data.Data["MaturePublish"] = maturePublish ? "1" : "0"; - data.Data["OwnerRoleID"] = UUID.Random().ToString(); + UUID roleID = UUID.Random(); + data.Data["OwnerRoleID"] = roleID.ToString(); if (!m_Database.StoreGroup(data)) return UUID.Zero; @@ -159,7 +160,6 @@ namespace OpenSim.Groups _AddOrUpdateGroupRole(RequestingAgentID, data.GroupID, UUID.Zero, "Everyone", "Everyone in the group", "Member of " + name, (ulong)DefaultEveryonePowers, true); // Create Owner role - UUID roleID = UUID.Random(); _AddOrUpdateGroupRole(RequestingAgentID, data.GroupID, roleID, "Owners", "Owners of the group", "Owner of " + name, (ulong)OwnerPowers, true); // Add founder to group @@ -247,6 +247,9 @@ namespace OpenSim.Groups if (group == null) return members; + // Unfortunately this doesn't quite work on legacy group data because of a bug + // that's also being fixed here on CreateGroup. The OwnerRoleID sent to the DB was wrong. + // See how to find the ownerRoleID a few lines below. UUID ownerRoleID = new UUID(group.Data["OwnerRoleID"]); RoleData[] roles = m_Database.RetrieveRoles(GroupID); @@ -255,6 +258,11 @@ namespace OpenSim.Groups return members; List rolesList = new List(roles); + // Let's find the "real" ownerRoleID + RoleData ownerRole = rolesList.Find(r => r.Data["Powers"] == ((long)OwnerPowers).ToString()); + if (ownerRole != null) + ownerRoleID = ownerRole.RoleID; + // Check visibility? // When we don't want to check visibility, we pass it "all" as the requestingAgentID bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString()); @@ -291,17 +299,17 @@ namespace OpenSim.Groups { m.Title = selected.Data["Title"]; m.AgentPowers = UInt64.Parse(selected.Data["Powers"]); + } - m.AgentID = d.PrincipalID; - m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false; - m.Contribution = Int32.Parse(d.Data["Contribution"]); - m.ListInProfile = d.Data["ListInProfile"] == "1" ? true : false; + m.AgentID = d.PrincipalID; + m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false; + m.Contribution = Int32.Parse(d.Data["Contribution"]); + m.ListInProfile = d.Data["ListInProfile"] == "1" ? true : false; - // Is this person an owner of the group? - m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ? true : false; + // Is this person an owner of the group? + m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ? true : false; - members.Add(m); - } + members.Add(m); } return members; -- cgit v1.1