From 5e20e32b6993a79f8f31cb12882b9c4499140275 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 14 Nov 2008 10:55:14 +0000 Subject: From: Christopher Yeoh This patch makes llAllowInventoryDrop work with the permissions module enabled. Changes include: - Enabled PropagatePermissions when permissions module serverside perms is on - change ownership of item when item is dropped into an object. Ownership changes to the owner of the object the item is dropped into - propagation of permissions if the permissions module enabled (eg next-owner mask applied) - CHANGED_ALLOWED_DROP is now passed to the change script event if an item was allowed to be dropped into the object only because llAllowInventoryDrop is enabled (instead of CHANGED_INVENTORY being passed). - Sets object flags correctly when llAllowInventoryDrop is called so clients are notified immediately of the change in state. Am not sure that calling aggregateScriptEvents is the right way to do it, but it works and seems to be the only way without making further changes to update LocalFlags --- .../Modules/World/Permissions/PermissionsModule.cs | 2 +- .../Region/Environment/Scenes/Scene.Inventory.cs | 18 +++++++---- .../Scenes/SceneObjectGroup.Inventory.cs | 35 +++++++++++++++++----- .../Scenes/SceneObjectPart.Inventory.cs | 18 +++++++---- .../Shared/Api/Implementation/LSL_Api.cs | 3 ++ .../Shared/Api/Implementation/OSSL_Api.cs | 2 +- 6 files changed, 56 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index 87348fc..c5a9066 100644 --- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs @@ -277,7 +277,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions public bool PropagatePermissions() { - return false; + return !m_bypassPermissions; } public bool BypassPermissions() diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 12095e5..590bea0 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1179,7 +1179,8 @@ namespace OpenSim.Region.Environment.Scenes destTaskItem.InvType = srcTaskItem.InvType; destTaskItem.Type = srcTaskItem.Type; - destPart.AddInventoryItem(destTaskItem); + destPart.AddInventoryItem(destTaskItem, part.OwnerID!=destPart.OwnerID + && ExternalChecks.ExternalChecksPropagatePermissions()); if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) part.RemoveInventoryItem(itemId); @@ -1249,10 +1250,15 @@ namespace OpenSim.Region.Environment.Scenes if (part != null) { - if (!ExternalChecks.ExternalChecksCanEditObjectInventory(part.UUID, remoteClient.AgentId)) - return; - TaskInventoryItem currentItem = part.GetInventoryItem(itemID); + bool allowInventoryDrop = (part.GetEffectiveObjectFlags() + & (uint)PrimFlags.AllowInventoryDrop) != 0; + // Explicity allow anyone to add to the inventory if the AllowInventoryDrop + // flag has been set. Don't however let them update an item unless + // they pass the external checks + if (!ExternalChecks.ExternalChecksCanEditObjectInventory(part.UUID, remoteClient.AgentId) + && (currentItem != null || !allowInventoryDrop )) + return; if (currentItem == null) { @@ -1417,7 +1423,7 @@ namespace OpenSim.Region.Environment.Scenes taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; - part.AddInventoryItem(taskItem); + part.AddInventoryItem(taskItem, false); part.GetProperties(remoteClient); part.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); @@ -1512,7 +1518,7 @@ namespace OpenSim.Region.Environment.Scenes destTaskItem.InvType = srcTaskItem.InvType; destTaskItem.Type = srcTaskItem.Type; - destPart.AddInventoryItemExclusive(destTaskItem); + destPart.AddInventoryItemExclusive(destTaskItem, false); if (running > 0) { diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs index bfa9763..8275ceb 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs @@ -151,23 +151,42 @@ namespace OpenSim.Region.Environment.Scenes taskItem.AssetID = item.AssetID; taskItem.Name = item.Name; taskItem.Description = item.Description; - taskItem.OwnerID = item.Owner; + taskItem.OwnerID = part.OwnerID; // Transfer ownership taskItem.CreatorID = item.Creator; taskItem.Type = item.AssetType; taskItem.InvType = item.InvType; - taskItem.BasePermissions = item.BasePermissions; - taskItem.CurrentPermissions = item.CurrentPermissions; - // FIXME: ignoring group permissions for now as they aren't stored in item - taskItem.EveryonePermissions = item.EveryOnePermissions; - taskItem.NextPermissions = item.NextPermissions; + if (remoteClient!=null && remoteClient.AgentId!=part.OwnerID && + m_scene.ExternalChecks.ExternalChecksPropagatePermissions()) { + taskItem.BasePermissions = item.BasePermissions & item.NextPermissions; + taskItem.CurrentPermissions = item.CurrentPermissions & item.NextPermissions; + taskItem.EveryonePermissions = item.EveryOnePermissions & item.NextPermissions; + taskItem.NextPermissions = item.NextPermissions; + taskItem.CurrentPermissions |= 8; + } else { + taskItem.BasePermissions = item.BasePermissions; + taskItem.CurrentPermissions = item.CurrentPermissions; + taskItem.CurrentPermissions |= 8; + taskItem.EveryonePermissions = item.EveryOnePermissions; + taskItem.NextPermissions = item.NextPermissions; + } + + + taskItem.Flags = item.Flags; // TODO: These are pending addition of those fields to TaskInventoryItem // taskItem.SalePrice = item.SalePrice; // taskItem.SaleType = item.SaleType; taskItem.CreationDate = (uint)item.CreationDate; - - part.AddInventoryItem(taskItem); + + bool addFromAllowedDrop = false; + if (remoteClient!=null) + { + addFromAllowedDrop = remoteClient.AgentId!=part.OwnerID && + m_scene.ExternalChecks.ExternalChecksPropagatePermissions(); + } + + part.AddInventoryItem(taskItem, addFromAllowedDrop); return true; } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index 501f199..fa66515 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs @@ -289,16 +289,16 @@ namespace OpenSim.Region.Environment.Scenes /// name is chosen. /// /// - public void AddInventoryItem(TaskInventoryItem item) + public void AddInventoryItem(TaskInventoryItem item, bool allowedDrop) { - AddInventoryItem(item.Name, item); + AddInventoryItem(item.Name, item, allowedDrop); } /// /// Add an item to this prim's inventory. If an item with the same name already exists, it is replaced. /// /// - public void AddInventoryItemExclusive(TaskInventoryItem item) + public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) { List il = new List(m_taskInventory.Values); foreach (TaskInventoryItem i in il) @@ -313,7 +313,7 @@ namespace OpenSim.Region.Environment.Scenes } } - AddInventoryItem(item.Name, item); + AddInventoryItem(item.Name, item, allowedDrop); } /// @@ -324,7 +324,10 @@ namespace OpenSim.Region.Environment.Scenes /// The item itself. The name within this structure is ignored in favour of the name /// given in this method's arguments /// - protected void AddInventoryItem(string name, TaskInventoryItem item) + /// + // Item was only added to inventory because AllowedDrop is set + /// + protected void AddInventoryItem(string name, TaskInventoryItem item, bool allowedDrop) { name = FindAvailableInventoryName(name); if (name == String.Empty) @@ -337,7 +340,10 @@ namespace OpenSim.Region.Environment.Scenes lock (m_taskInventory) { m_taskInventory.Add(item.ItemID, item); - TriggerScriptChangedEvent(Changed.INVENTORY); + if (allowedDrop) + TriggerScriptChangedEvent(Changed.ALLOWED_DROP); + else + TriggerScriptChangedEvent(Changed.INVENTORY); } m_inventorySerial++; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ab7b710..c1d718e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4006,6 +4006,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.ParentGroup.RootPart.AllowedDrop = true; else m_host.ParentGroup.RootPart.AllowedDrop = false; + + // Update the object flags + m_host.ParentGroup.RootPart.aggregateScriptEvents(); } public LSL_Vector llGetSunDirection() diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f9302e9..8cac070 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -1014,7 +1014,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api taskItem.PermsMask = 0; taskItem.AssetID = asset.FullID; - m_host.AddInventoryItem(taskItem); + m_host.AddInventoryItem(taskItem, false); } } } -- cgit v1.1