From d7a98925ce5693f28ef48e4228680f3a7aba12af Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 22 Sep 2008 12:52:56 +0000 Subject: Create CanEditObjectInventory to preserve the ability to have different permissions on inventory and object edits. This may be needed by the viewer on public grids --- .../Modules/World/Permissions/PermissionsModule.cs | 20 ++++++++++++++++ .../Region/Environment/Scenes/Scene.Inventory.cs | 28 ++-------------------- .../Environment/Scenes/SceneExternalChecks.cs | 27 +++++++++++++++++++++ 3 files changed, 49 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs index 3b4819b..1a36315 100644 --- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs @@ -163,6 +163,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions m_scene.ExternalChecks.addCheckDuplicateObject(CanDuplicateObject); //FULLY IMPLEMENTED m_scene.ExternalChecks.addCheckDeleteObject(CanDeleteObject); //MAYBE FULLY IMPLEMENTED m_scene.ExternalChecks.addCheckEditObject(CanEditObject);//MAYBE FULLY IMPLEMENTED + m_scene.ExternalChecks.addCheckEditObject(CanEditObjectInventory);//MAYBE FULLY IMPLEMENTED m_scene.ExternalChecks.addCheckEditParcel(CanEditParcel); //FULLY IMPLEMENTED m_scene.ExternalChecks.addCheckEditScript(CanEditScript); //NOT YET IMPLEMENTED m_scene.ExternalChecks.addCheckEditNotecard(CanEditNotecard); //NOT YET IMPLEMENTED @@ -602,6 +603,25 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions return GenericObjectPermission(editorID, objectID, false); } + private bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene) + { + DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); + if (m_bypassPermissions) return m_bypassPermissionsValue; + + SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); + + // Commented because this behavior causes issues for IBM + // With this commented, strange viewer issues can be observed + // when trying to edit scripts and/or notecards in + // "Hacked god mode" + // TODO: add group support! + // +// if(part.OwnerID != editorID) +// return false; + + return GenericObjectPermission(editorID, objectID, false); + } + private bool CanEditParcel(UUID user, ILandObject parcel, Scene scene) { DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index a188701..a1c5fe7 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1186,18 +1186,7 @@ namespace OpenSim.Region.Environment.Scenes if (part != null) { - - // replacing the following two checks with the - // ExternalChecks.ExternalChecksCanEditObject(...) - // call - - // if (part.OwnerID != remoteClient.AgentId) - // return; - - // if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) - // return; - - if (!ExternalChecks.ExternalChecksCanEditObject(part.UUID, remoteClient.AgentId)) + if (!ExternalChecks.ExternalChecksCanEditObjectInventory(part.UUID, remoteClient.AgentId)) { return; } @@ -1293,20 +1282,7 @@ System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.T SceneObjectPart part = GetSceneObjectPart(localID); if (part != null) { - - /* - if (part.OwnerID != remoteClient.AgentId) - { - return; - } - - if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) - { - return; - } - */ - - if (!ExternalChecks.ExternalChecksCanEditObject(part.UUID, remoteClient.AgentId)) + if (!ExternalChecks.ExternalChecksCanEditObjectInventory(part.UUID, remoteClient.AgentId)) { return; } diff --git a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs index 678d707..f8d041a 100644 --- a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs +++ b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs @@ -343,6 +343,33 @@ namespace OpenSim.Region.Environment.Scenes return true; } + public delegate bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene); + private List CanEditObjectInventoryCheckFunctions = new List(); + + public void addCheckEditObjectInventory(CanEditObjectInventory delegateFunc) + { + if (!CanEditObjectInventoryCheckFunctions.Contains(delegateFunc)) + CanEditObjectInventoryCheckFunctions.Add(delegateFunc); + } + + public void removeCheckEditObjectInventory(CanEditObjectInventory delegateFunc) + { + if (CanEditObjectInventoryCheckFunctions.Contains(delegateFunc)) + CanEditObjectInventoryCheckFunctions.Remove(delegateFunc); + } + + public bool ExternalChecksCanEditObjectInventory(UUID objectID, UUID editorID) + { + foreach (CanEditObjectInventory check in CanEditObjectInventoryCheckFunctions) + { + if (check(objectID, editorID, m_scene) == false) + { + return false; + } + } + return true; + } + #endregion #region MOVE OBJECT -- cgit v1.1