diff --git a/OpenSim/Addons/Groups/Service/GroupsService.cs b/OpenSim/Addons/Groups/Service/GroupsService.cs index f44c094b2b..7cbc7968e6 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; - - // Is this person an owner of the group? - m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ? true : false; - - members.Add(m); } + + 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; + + members.Add(m); } return members;