From 74ac2034e00286af27d309248d4add2c2a073309 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 25 Jan 2017 16:57:46 +0000 Subject: [PATCH] make use of CanDoObjectInvToObjectInv --- .../World/Permissions/PermissionsModule.cs | 1 + .../Framework/Scenes/Scene.Inventory.cs | 22 +------------------ .../Framework/Scenes/Scene.Permissions.cs | 19 ++++++++++++++++ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 1b3fdc3b77..1973bcb53d 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -303,6 +303,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory; m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; + m_scene.Permissions.OnDoObjectInvToObjectInv += CanDoObjectInvToObjectInv; m_scene.Permissions.OnViewNotecard += CanViewNotecard; m_scene.Permissions.OnViewScript += CanViewScript; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a1eb721cd3..29666d5cdd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1461,29 +1461,9 @@ namespace OpenSim.Region.Framework.Scenes return; } - // Can't transfer this - // - if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) + if(!Permissions.CanDoObjectInvToObjectInv(srcTaskItem, part, destPart)) return; - bool overrideNoMod = false; - if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) - overrideNoMod = true; - - if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) - { - // object cannot copy items to an object owned by a different owner - // unless llAllowInventoryDrop has been called - - return; - } - - // must have both move and modify permission to put an item in an object - if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) - { - return; - } - TaskInventoryItem destTaskItem = new TaskInventoryItem(); destTaskItem.ItemID = UUID.Random(); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 754609aca3..968b298f12 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -86,6 +86,7 @@ namespace OpenSim.Region.Framework.Scenes public delegate bool DelinkObjectHandler(UUID user, UUID objectID); public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID); public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); + public delegate bool DoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart); public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); public delegate bool TransferObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); public delegate bool CreateUserInventoryHandler(int invType, UUID userID); @@ -158,6 +159,7 @@ namespace OpenSim.Region.Framework.Scenes public event DelinkObjectHandler OnDelinkObject; public event CreateObjectInventoryHandler OnCreateObjectInventory; public event CopyObjectInventoryHandler OnCopyObjectInventory; + public event DoObjectInvToObjectInv OnDoObjectInvToObjectInv; public event DeleteObjectInventoryHandler OnDeleteObjectInventory; public event TransferObjectInventoryHandler OnTransferObjectInventory; public event CreateUserInventoryHandler OnCreateUserInventory; @@ -1090,6 +1092,23 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public bool CanDoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart) + { + DoObjectInvToObjectInv handler = OnDoObjectInvToObjectInv; + if (handler != null) + { + if (sourcePart == null || destPart == null || item == null) + return false; + Delegate[] list = handler.GetInvocationList(); + foreach (DoObjectInvToObjectInv h in list) + { + if (h(item, sourcePart, destPart) == false) + return false; + } + } + return true; + } + public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID) { DeleteObjectInventoryHandler handler = OnDeleteObjectInventory;