diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index c6fd72e74f..bb4e0322cb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -1114,6 +1114,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); } + + public List GetUserFriends(UUID agentID) + { + List fl; + lock (m_friendLists) + { + fl = (List)m_friendLists.Get(agentID.ToString(), + m_initialScene.GetFriendList); + } + + return fl; + } } #endregion } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index effe1f0967..c79062469b 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -144,6 +144,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions private Dictionary GrantVB = new Dictionary(); private Dictionary GrantJS = new Dictionary(); private Dictionary GrantYP = new Dictionary(); + private IFriendsModule m_friendsModule = null; + #endregion #region IRegionModule Members @@ -363,6 +365,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions public void PostInitialise() { + m_friendsModule = m_scene.RequestModuleInterface(); + + if (m_friendsModule == null) + m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work"); + else + m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled"); } public void Close() @@ -479,31 +487,18 @@ namespace OpenSim.Region.CoreModules.World.Permissions protected bool IsFriendWithPerms(UUID user,UUID objectOwner) { - if (user == UUID.Zero) return false; + if (user == UUID.Zero) + return false; + + if (m_friendsModule == null) + return false; + + List profile = m_friendsModule.GetUserFriends(user); - 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; -// } - } + if(item.Friend == objectOwner && (item.FriendPerms & (uint)FriendRights.CanModifyObjects) != 0) + return true; } return false; } diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index 7a8aba23e4..8386030a1f 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs @@ -27,6 +27,7 @@ using OpenMetaverse; using OpenSim.Framework; +using System.Collections.Generic; namespace OpenSim.Region.Framework.Interfaces { @@ -45,5 +46,6 @@ namespace OpenSim.Region.Framework.Interfaces /// /// void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage); + List GetUserFriends(UUID agentID); } }