From 83b4b4440b7becb405840bc69d665e260fdecea0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Nov 2009 02:09:07 +0000 Subject: Patch by revolution, thank you. Mantis #1789 . Implement friends permissions. Applied with major changes. Core functionality commented pending review for possible rights escalation. No user functionality yet. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 9 ++++-- .../World/Permissions/PermissionsModule.cs | 34 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index fc7d63a..c6fd72e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -395,6 +395,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // if it leaves, we want to know, too client.OnLogout += OnLogout; + client.OnGrantUserRights += GrantUserFriendRights; + } private void ClientClosed(UUID AgentId, Scene scene) @@ -1108,7 +1110,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // tell everyone that we are offline SendPresenceState(remoteClient, fl, false); } - } - + private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) + { + ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); + } + } #endregion } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index fe9de1b..effe1f0 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -476,6 +476,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions return false; } + protected bool IsFriendWithPerms(UUID user,UUID objectOwner) + { + + if (user == UUID.Zero) return false; + + List profile = m_scene.CommsManager.GetUserFriendList(user); + foreach (FriendListItem item in profile) + { + m_log.Warn("IsFriendWithPerms called" + item.FriendPerms.ToString()); + if(item.Friend == objectOwner) + { +// if (item.FriendPerms == 3) +// { +// return true; +// } +// if (item.FriendPerms == 4) +// { +// return true; +// } +// if (item.FriendPerms == 5) +// { +// return true; +// } +// if (item.FriendPerms == 7) +// { +// return true; +// } + } + } + return false; + } protected bool IsEstateManager(UUID user) { @@ -565,6 +596,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions // Object owners should be able to edit their own content if (user == objectOwner) return objectOwnerMask; + + if (IsFriendWithPerms(user, objectOwner)) + return objectOwnerMask; // Estate users should be able to edit anything in the sim if (IsEstateManager(user) && m_RegionOwnerIsGod && !IsAdministrator(objectOwner)) -- cgit v1.1