aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/IClientAPI.cs2
-rw-r--r--OpenSim/Framework/RegionInfo.cs4
-rw-r--r--OpenSim/Framework/Util.cs16
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs5
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs10
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs1
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs116
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs47
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs87
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs11
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs20
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs22
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs17
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs35
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs1699
-rw-r--r--OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs313
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Permissions.cs411
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs106
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SceneGraph.cs127
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs297
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs113
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs65
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs27
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs63
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs37
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs25
-rw-r--r--OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs81
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs4
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs13
42 files changed, 2300 insertions, 1557 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index eedba9d..ab6d58f 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -107,7 +107,7 @@ namespace OpenSim.Framework
107 public delegate void GenericCall4(Packet packet, IClientAPI remoteClient); 107 public delegate void GenericCall4(Packet packet, IClientAPI remoteClient);
108 108
109 public delegate void DeRezObject( 109 public delegate void DeRezObject(
110 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID); 110 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID, bool AddToReturns = true);
111 111
112 public delegate void GenericCall5(IClientAPI remoteClient, bool status); 112 public delegate void GenericCall5(IClientAPI remoteClient, bool status);
113 113
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 99e97e8..7de8c52 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -130,7 +130,7 @@ namespace OpenSim.Framework
130 private float m_physPrimMin = 0; 130 private float m_physPrimMin = 0;
131 private int m_physPrimMax = 0; 131 private int m_physPrimMax = 0;
132 private bool m_clampPrimSize = false; 132 private bool m_clampPrimSize = false;
133 private int m_objectCapacity = 0; 133 private int m_objectCapacity = 15000;
134 private int m_maxPrimsPerUser = -1; 134 private int m_maxPrimsPerUser = -1;
135 private int m_linksetCapacity = 0; 135 private int m_linksetCapacity = 0;
136 private string m_regionType = String.Empty; 136 private string m_regionType = String.Empty;
@@ -753,7 +753,7 @@ namespace OpenSim.Framework
753 m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); 753 m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);
754 allKeys.Remove("ClampPrimSize"); 754 allKeys.Remove("ClampPrimSize");
755 755
756 m_objectCapacity = config.GetInt("MaxPrims", 15000); 756 m_objectCapacity = config.GetInt("MaxPrims", m_objectCapacity);
757 allKeys.Remove("MaxPrims"); 757 allKeys.Remove("MaxPrims");
758 758
759 m_maxPrimsPerUser = config.GetInt("MaxPrimsPerUser", -1); 759 m_maxPrimsPerUser = config.GetInt("MaxPrimsPerUser", -1);
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index dcb660a..0ec24e6 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -80,15 +80,17 @@ namespace OpenSim.Framework
80 FoldedMask = 0x0f, 80 FoldedMask = 0x0f,
81 81
82 // 82 //
83 Transfer = 1 << 13, 83 Transfer = 1 << 13, // 0x02000
84 Modify = 1 << 14, 84 Modify = 1 << 14, // 0x04000
85 Copy = 1 << 15, 85 Copy = 1 << 15, // 0x08000
86 Export = 1 << 16, 86 Export = 1 << 16, // 0x10000
87 Move = 1 << 19, 87 Move = 1 << 19, // 0x80000
88 Damage = 1 << 20, 88 Damage = 1 << 20, // 0x100000 does not seem to be in use
89 // All does not contain Export, which is special and must be 89 // All does not contain Export, which is special and must be
90 // explicitly given 90 // explicitly given
91 All = (1 << 13) | (1 << 14) | (1 << 15) | (1 << 19) 91 All = 0x8e000,
92 AllAndExport = 0x9e000,
93 AllEffective = 0x9e000
92 } 94 }
93 95
94 /// <summary> 96 /// <summary>
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 34a9246..168836c 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -461,15 +461,14 @@ namespace OpenSim
461 while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) 461 while (regionInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null)
462 SetUpEstateOwner(scene); 462 SetUpEstateOwner(scene);
463 463
464 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
465
464 // Prims have to be loaded after module configuration since some modules may be invoked during the load 466 // Prims have to be loaded after module configuration since some modules may be invoked during the load
465 scene.LoadPrimsFromStorage(regionInfo.originRegionID); 467 scene.LoadPrimsFromStorage(regionInfo.originRegionID);
466 468
467 // TODO : Try setting resource for region xstats here on scene 469 // TODO : Try setting resource for region xstats here on scene
468 MainServer.Instance.AddStreamHandler(new RegionStatsHandler(regionInfo)); 470 MainServer.Instance.AddStreamHandler(new RegionStatsHandler(regionInfo));
469 471
470 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
471 scene.EventManager.TriggerParcelPrimCountUpdate();
472
473 if (scene.SnmpService != null) 472 if (scene.SnmpService != null)
474 { 473 {
475 scene.SnmpService.BootInfo("Grid Registration in progress", scene); 474 scene.SnmpService.BootInfo("Grid Registration in progress", scene);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
index 189fa36..69fcb7d 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs
@@ -121,6 +121,9 @@ namespace OpenSim.Region.ClientStack.Linden
121 121
122 122
123 OSD r = OSDParser.DeserializeLLSDXml((string)request["requestbody"]); 123 OSD r = OSDParser.DeserializeLLSDXml((string)request["requestbody"]);
124 if (r.Type != OSDType.Map) // not a proper req
125 return responsedata;
126
124 //UUID session_id = UUID.Zero; 127 //UUID session_id = UUID.Zero;
125 bool bypass_raycast = false; 128 bool bypass_raycast = false;
126 uint everyone_mask = 0; 129 uint everyone_mask = 0;
@@ -157,9 +160,6 @@ namespace OpenSim.Region.ClientStack.Linden
157 int state = 0; 160 int state = 0;
158 int lastattach = 0; 161 int lastattach = 0;
159 162
160 if (r.Type != OSDType.Map) // not a proper req
161 return responsedata;
162
163 OSDMap rm = (OSDMap)r; 163 OSDMap rm = (OSDMap)r;
164 164
165 if (rm.ContainsKey("ObjectData")) //v2 165 if (rm.ContainsKey("ObjectData")) //v2
@@ -307,8 +307,6 @@ namespace OpenSim.Region.ClientStack.Linden
307 } 307 }
308 } 308 }
309 309
310
311
312 Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false); 310 Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false);
313 311
314 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); 312 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
@@ -359,6 +357,8 @@ namespace OpenSim.Region.ClientStack.Linden
359 rootpart.NextOwnerMask = next_owner_mask; 357 rootpart.NextOwnerMask = next_owner_mask;
360 rootpart.Material = (byte)material; 358 rootpart.Material = (byte)material;
361 359
360 obj.AggregatePerms();
361
362 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); 362 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
363 363
364 responsedata["int_response_code"] = 200; //501; //410; //404; 364 responsedata["int_response_code"] = 200; //501; //410; //404;
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
index 6874662..116c51f 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs
@@ -335,6 +335,7 @@ namespace OpenSim.Region.ClientStack.Linden
335 grp.AbsolutePosition = obj.Position; 335 grp.AbsolutePosition = obj.Position;
336 prim.RotationOffset = obj.Rotation; 336 prim.RotationOffset = obj.Rotation;
337 337
338
338 // Required for linking 339 // Required for linking
339 grp.RootPart.ClearUpdateSchedule(); 340 grp.RootPart.ClearUpdateSchedule();
340 341
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 8ba1ba3..410ac00 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5731,28 +5731,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5731 } 5731 }
5732 5732
5733// protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID) 5733// protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
5734 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, ScenePresence sp) 5734 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart part, ScenePresence sp)
5735 { 5735 {
5736 byte[] objectData = new byte[60]; 5736 byte[] objectData = new byte[60];
5737 data.RelativePosition.ToBytes(objectData, 0); 5737 part.RelativePosition.ToBytes(objectData, 0);
5738 data.Velocity.ToBytes(objectData, 12); 5738 part.Velocity.ToBytes(objectData, 12);
5739 data.Acceleration.ToBytes(objectData, 24); 5739 part.Acceleration.ToBytes(objectData, 24);
5740 5740
5741 Quaternion rotation = data.RotationOffset; 5741 Quaternion rotation = part.RotationOffset;
5742 rotation.Normalize(); 5742 rotation.Normalize();
5743 rotation.ToBytes(objectData, 36); 5743 rotation.ToBytes(objectData, 36);
5744 data.AngularVelocity.ToBytes(objectData, 48); 5744 part.AngularVelocity.ToBytes(objectData, 48);
5745 5745
5746 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); 5746 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
5747 update.ClickAction = (byte)data.ClickAction; 5747 update.ClickAction = (byte)part.ClickAction;
5748 update.CRC = 0; 5748 update.CRC = 0;
5749 update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes; 5749 update.ExtraParams = part.Shape.ExtraParams ?? Utils.EmptyBytes;
5750 update.FullID = data.UUID; 5750 update.FullID = part.UUID;
5751 update.ID = data.LocalId; 5751 update.ID = part.LocalId;
5752 //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated 5752 //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
5753 //update.JointPivot = Vector3.Zero; 5753 //update.JointPivot = Vector3.Zero;
5754 //update.JointType = 0; 5754 //update.JointType = 0;
5755 update.Material = data.Material; 5755 update.Material = part.Material;
5756 update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim 5756 update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
5757/* 5757/*
5758 if (data.ParentGroup.IsAttachment) 5758 if (data.ParentGroup.IsAttachment)
@@ -5781,68 +5781,68 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5781 } 5781 }
5782*/ 5782*/
5783 5783
5784 if (data.ParentGroup.IsAttachment) 5784 if (part.ParentGroup.IsAttachment)
5785 { 5785 {
5786 if (data.IsRoot) 5786 if (part.IsRoot)
5787 { 5787 {
5788 update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID); 5788 update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + part.ParentGroup.FromItemID);
5789 } 5789 }
5790 else 5790 else
5791 update.NameValue = Utils.EmptyBytes; 5791 update.NameValue = Utils.EmptyBytes;
5792 5792
5793 int st = (int)data.ParentGroup.AttachmentPoint; 5793 int st = (int)part.ParentGroup.AttachmentPoint;
5794 update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ; 5794 update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ;
5795 } 5795 }
5796 else 5796 else
5797 { 5797 {
5798 update.NameValue = Utils.EmptyBytes; 5798 update.NameValue = Utils.EmptyBytes;
5799 update.State = data.Shape.State; // not sure about this 5799 update.State = part.Shape.State; // not sure about this
5800 } 5800 }
5801 5801
5802 5802
5803 update.ObjectData = objectData; 5803 update.ObjectData = objectData;
5804 update.ParentID = data.ParentID; 5804 update.ParentID = part.ParentID;
5805 update.PathBegin = data.Shape.PathBegin; 5805 update.PathBegin = part.Shape.PathBegin;
5806 update.PathCurve = data.Shape.PathCurve; 5806 update.PathCurve = part.Shape.PathCurve;
5807 update.PathEnd = data.Shape.PathEnd; 5807 update.PathEnd = part.Shape.PathEnd;
5808 update.PathRadiusOffset = data.Shape.PathRadiusOffset; 5808 update.PathRadiusOffset = part.Shape.PathRadiusOffset;
5809 update.PathRevolutions = data.Shape.PathRevolutions; 5809 update.PathRevolutions = part.Shape.PathRevolutions;
5810 update.PathScaleX = data.Shape.PathScaleX; 5810 update.PathScaleX = part.Shape.PathScaleX;
5811 update.PathScaleY = data.Shape.PathScaleY; 5811 update.PathScaleY = part.Shape.PathScaleY;
5812 update.PathShearX = data.Shape.PathShearX; 5812 update.PathShearX = part.Shape.PathShearX;
5813 update.PathShearY = data.Shape.PathShearY; 5813 update.PathShearY = part.Shape.PathShearY;
5814 update.PathSkew = data.Shape.PathSkew; 5814 update.PathSkew = part.Shape.PathSkew;
5815 update.PathTaperX = data.Shape.PathTaperX; 5815 update.PathTaperX = part.Shape.PathTaperX;
5816 update.PathTaperY = data.Shape.PathTaperY; 5816 update.PathTaperY = part.Shape.PathTaperY;
5817 update.PathTwist = data.Shape.PathTwist; 5817 update.PathTwist = part.Shape.PathTwist;
5818 update.PathTwistBegin = data.Shape.PathTwistBegin; 5818 update.PathTwistBegin = part.Shape.PathTwistBegin;
5819 update.PCode = data.Shape.PCode; 5819 update.PCode = part.Shape.PCode;
5820 update.ProfileBegin = data.Shape.ProfileBegin; 5820 update.ProfileBegin = part.Shape.ProfileBegin;
5821 update.ProfileCurve = data.Shape.ProfileCurve; 5821 update.ProfileCurve = part.Shape.ProfileCurve;
5822 update.ProfileEnd = data.Shape.ProfileEnd; 5822 update.ProfileEnd = part.Shape.ProfileEnd;
5823 update.ProfileHollow = data.Shape.ProfileHollow; 5823 update.ProfileHollow = part.Shape.ProfileHollow;
5824 update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes; 5824 update.PSBlock = part.ParticleSystem ?? Utils.EmptyBytes;
5825 update.TextColor = data.GetTextColor().GetBytes(false); 5825 update.TextColor = part.GetTextColor().GetBytes(false);
5826 update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes; 5826 update.TextureAnim = part.TextureAnimation ?? Utils.EmptyBytes;
5827 update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes; 5827 update.TextureEntry = part.Shape.TextureEntry ?? Utils.EmptyBytes;
5828 update.Scale = data.Shape.Scale; 5828 update.Scale = part.Shape.Scale;
5829 update.Text = Util.StringToBytes256(data.Text); 5829 update.Text = Util.StringToBytes256(part.Text);
5830 update.MediaURL = Util.StringToBytes256(data.MediaUrl); 5830 update.MediaURL = Util.StringToBytes256(part.MediaUrl);
5831 5831
5832 #region PrimFlags 5832 #region PrimFlags
5833 5833
5834 PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(sp, data.UUID); 5834 PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(part, sp);
5835 5835
5836 // Don't send the CreateSelected flag to everyone 5836 // Don't send the CreateSelected flag to everyone
5837 flags &= ~PrimFlags.CreateSelected; 5837 flags &= ~PrimFlags.CreateSelected;
5838 5838
5839 if (sp.UUID == data.OwnerID) 5839 if (sp.UUID == part.OwnerID)
5840 { 5840 {
5841 if (data.CreateSelected) 5841 if (part.CreateSelected)
5842 { 5842 {
5843 // Only send this flag once, then unset it 5843 // Only send this flag once, then unset it
5844 flags |= PrimFlags.CreateSelected; 5844 flags |= PrimFlags.CreateSelected;
5845 data.CreateSelected = false; 5845 part.CreateSelected = false;
5846 } 5846 }
5847 } 5847 }
5848 5848
@@ -5854,21 +5854,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5854 5854
5855 #endregion PrimFlags 5855 #endregion PrimFlags
5856 5856
5857 if (data.Sound != UUID.Zero) 5857 if (part.Sound != UUID.Zero)
5858 { 5858 {
5859 update.Sound = data.Sound; 5859 update.Sound = part.Sound;
5860 update.OwnerID = data.OwnerID; 5860 update.OwnerID = part.OwnerID;
5861 update.Gain = (float)data.SoundGain; 5861 update.Gain = (float)part.SoundGain;
5862 update.Radius = (float)data.SoundRadius; 5862 update.Radius = (float)part.SoundRadius;
5863 update.Flags = data.SoundFlags; 5863 update.Flags = part.SoundFlags;
5864 } 5864 }
5865 5865
5866 switch ((PCode)data.Shape.PCode) 5866 switch ((PCode)part.Shape.PCode)
5867 { 5867 {
5868 case PCode.Grass: 5868 case PCode.Grass:
5869 case PCode.Tree: 5869 case PCode.Tree:
5870 case PCode.NewTree: 5870 case PCode.NewTree:
5871 update.Data = new byte[] { data.Shape.State }; 5871 update.Data = new byte[] { part.Shape.State };
5872 break; 5872 break;
5873 default: 5873 default:
5874 update.Data = Utils.EmptyBytes; 5874 update.Data = Utils.EmptyBytes;
@@ -7758,10 +7758,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7758 7758
7759 ObjectDuplicate handlerObjectDuplicate = null; 7759 ObjectDuplicate handlerObjectDuplicate = null;
7760 7760
7761 for (int i = 0; i < dupe.ObjectData.Length; i++) 7761 handlerObjectDuplicate = OnObjectDuplicate;
7762 if (handlerObjectDuplicate != null)
7762 { 7763 {
7763 handlerObjectDuplicate = OnObjectDuplicate; 7764 for (int i = 0; i < dupe.ObjectData.Length; i++)
7764 if (handlerObjectDuplicate != null)
7765 { 7765 {
7766 UUID rezGroupID = dupe.AgentData.GroupID; 7766 UUID rezGroupID = dupe.AgentData.GroupID;
7767 if(!IsGroupMember(rezGroupID)) 7767 if(!IsGroupMember(rezGroupID))
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 8b8ac20..cf188aa 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -481,14 +481,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
481// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", 481// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
482// group.Name, group.LocalId, sp.Name, attachmentPt, silent); 482// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
483 483
484 if (sp.GetAttachments().Contains(group))
485 {
486// m_log.WarnFormat(
487// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
488// group.Name, group.LocalId, sp.Name, AttachmentPt);
489
490 return false;
491 }
492 484
493 if (group.GetSittingAvatarsCount() != 0) 485 if (group.GetSittingAvatarsCount() != 0)
494 { 486 {
@@ -500,6 +492,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
500 return false; 492 return false;
501 } 493 }
502 494
495 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
496 if (attachments.Contains(group))
497 {
498// if (DebugLevel > 0)
499// m_log.WarnFormat(
500// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
501// group.Name, group.LocalId, sp.Name, attachmentPt);
502
503 return false;
504 }
505
503 Vector3 attachPos = group.AbsolutePosition; 506 Vector3 attachPos = group.AbsolutePosition;
504 507
505 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 508 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
@@ -533,7 +536,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
533 { 536 {
534 attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint; 537 attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint;
535 attachPos = group.RootPart.AttachedPos; 538 attachPos = group.RootPart.AttachedPos;
536 group.HasGroupChanged = true;
537 } 539 }
538 540
539 // if we still didn't find a suitable attachment point....... 541 // if we still didn't find a suitable attachment point.......
@@ -544,18 +546,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
544 attachPos = Vector3.Zero; 546 attachPos = Vector3.Zero;
545 } 547 }
546 548
547 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
548
549 if (attachments.Contains(group))
550 {
551 if (DebugLevel > 0)
552 m_log.WarnFormat(
553 "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
554 group.Name, group.LocalId, sp.Name, attachmentPt);
555
556 return false;
557 }
558
559 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones 549 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones
560 while (attachments.Count >= 5) 550 while (attachments.Count >= 5)
561 { 551 {
@@ -579,7 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
579 lock (sp.AttachmentsSyncLock) 569 lock (sp.AttachmentsSyncLock)
580 { 570 {
581 group.AttachmentPoint = attachmentPt; 571 group.AttachmentPoint = attachmentPt;
582 group.AbsolutePosition = attachPos; 572 group.RootPart.AttachedPos = attachPos;
583 573
584 if (addToInventory && sp.PresenceType != PresenceType.Npc) 574 if (addToInventory && sp.PresenceType != PresenceType.Npc)
585 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); 575 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
@@ -956,7 +946,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
956 m_scene.DeleteFromStorage(so.UUID); 946 m_scene.DeleteFromStorage(so.UUID);
957 m_scene.EventManager.TriggerParcelPrimCountTainted(); 947 m_scene.EventManager.TriggerParcelPrimCountTainted();
958 948
959 so.AttachedAvatar = sp.UUID;
960 949
961 foreach (SceneObjectPart part in so.Parts) 950 foreach (SceneObjectPart part in so.Parts)
962 { 951 {
@@ -969,11 +958,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
969 } 958 }
970 } 959 }
971 960
972 so.AbsolutePosition = attachOffset;
973 so.RootPart.AttachedPos = attachOffset;
974 so.IsAttachment = true;
975 so.RootPart.SetParentLocalId(sp.LocalId); 961 so.RootPart.SetParentLocalId(sp.LocalId);
962 so.AttachedAvatar = sp.UUID;
976 so.AttachmentPoint = attachmentpoint; 963 so.AttachmentPoint = attachmentpoint;
964 so.RootPart.AttachedPos = attachOffset;
965 so.AbsolutePosition = attachOffset;
966 so.IsAttachment = true;
977 967
978 sp.AddAttachment(so); 968 sp.AddAttachment(so);
979 969
@@ -1322,7 +1312,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1322 if (part == null) 1312 if (part == null)
1323 return; 1313 return;
1324 1314
1325 if (!m_scene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) 1315 SceneObjectGroup group = part.ParentGroup;
1316
1317 if (!m_scene.Permissions.CanTakeObject(group, sp))
1326 { 1318 {
1327 remoteClient.SendAgentAlertMessage( 1319 remoteClient.SendAgentAlertMessage(
1328 "You don't have sufficient permissions to attach this object", false); 1320 "You don't have sufficient permissions to attach this object", false);
@@ -1334,7 +1326,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1334 AttachmentPt &= 0x7f; 1326 AttachmentPt &= 0x7f;
1335 1327
1336 // Calls attach with a Zero position 1328 // Calls attach with a Zero position
1337 SceneObjectGroup group = part.ParentGroup;
1338 if (AttachObject(sp, group , AttachmentPt, false, true, append)) 1329 if (AttachObject(sp, group , AttachmentPt, false, true, append))
1339 { 1330 {
1340 if (DebugLevel > 0) 1331 if (DebugLevel > 0)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index 297346a..315ce1b 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 private bool enabled = true; 54 private bool enabled = true;
55 private bool m_UseNewAvnCode = false;
55 private List<Scene> m_SceneList = new List<Scene>(); 56 private List<Scene> m_SceneList = new List<Scene>();
56 private string m_RestURL = String.Empty; 57 private string m_RestURL = String.Empty;
57 IMessageTransferModule m_TransferModule = null; 58 IMessageTransferModule m_TransferModule = null;
@@ -82,6 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
82 } 83 }
83 84
84 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages); 85 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages);
86 m_UseNewAvnCode = cnf.GetBoolean("UseNewAvnCode", m_UseNewAvnCode);
85 } 87 }
86 88
87 public void AddRegion(Scene scene) 89 public void AddRegion(Scene scene)
@@ -244,51 +246,72 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
244 return; 246 return;
245 } 247 }
246 248
247 Scene scene = FindScene(new UUID(im.fromAgentID)); 249 if(m_UseNewAvnCode)
248 if (scene == null) 250 {
249 scene = m_SceneList[0]; 251 Scene scene = FindScene(new UUID(im.fromAgentID));
252 if (scene == null)
253 scene = m_SceneList[0];
250 254
251 SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>( 255 UUID scopeID = scene.RegionInfo.ScopeID;
252 "POST", m_RestURL+"/SaveMessage/?scope=" + 256 SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>(
253 scene.RegionInfo.ScopeID.ToString(), im); 257 "POST", m_RestURL+"/SaveMessage/?scope=" + scopeID.ToString(), im, 20000);
254 258
255 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 259 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
256 { 260 {
257 IClientAPI client = FindClient(new UUID(im.fromAgentID)); 261 IClientAPI client = FindClient(new UUID(im.fromAgentID));
258 if (client == null) 262 if (client == null)
259 return; 263 return;
260 264
261 if (reply.Message == String.Empty) 265 if (string.IsNullOrEmpty(reply.Message))
262 reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved"); 266 reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
263 267
264 bool sendReply = true; 268 bool sendReply = true;
265 269
266 switch (reply.Disposition) 270 switch (reply.Disposition)
267 {
268 case 0: // Normal
269 break;
270 case 1: // Only once per user
271 if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
272 { 271 {
273 sendReply = false; 272 case 0: // Normal
273 break;
274 case 1: // Only once per user
275 if (m_repliesSent.ContainsKey(client) && m_repliesSent[client].Contains(new UUID(im.toAgentID)))
276 sendReply = false;
277 else
278 {
279 if (!m_repliesSent.ContainsKey(client))
280 m_repliesSent[client] = new List<UUID>();
281 m_repliesSent[client].Add(new UUID(im.toAgentID));
282 }
283 break;
274 } 284 }
275 else 285
286 if (sendReply)
276 { 287 {
277 if (!m_repliesSent.ContainsKey(client)) 288 client.SendInstantMessage(new GridInstantMessage(
278 m_repliesSent[client] = new List<UUID>(); 289 null, new UUID(im.toAgentID),
279 m_repliesSent[client].Add(new UUID(im.toAgentID)); 290 "System", new UUID(im.fromAgentID),
291 (byte)InstantMessageDialog.MessageFromAgent,
292 reply.Message,
293 false, new Vector3()));
280 } 294 }
281 break;
282 } 295 }
296 }
297 else
298 {
299 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
300 "POST", m_RestURL+"/SaveMessage/", im, 20000);
283 301
284 if (sendReply) 302 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
285 { 303 {
304 IClientAPI client = FindClient(new UUID(im.fromAgentID));
305 if (client == null)
306 return;
307
286 client.SendInstantMessage(new GridInstantMessage( 308 client.SendInstantMessage(new GridInstantMessage(
287 null, new UUID(im.toAgentID), 309 null, new UUID(im.toAgentID),
288 "System", new UUID(im.fromAgentID), 310 "System", new UUID(im.fromAgentID),
289 (byte)InstantMessageDialog.MessageFromAgent, 311 (byte)InstantMessageDialog.MessageFromAgent,
290 reply.Message, 312 "User is not logged in. "+
291 false, new Vector3())); 313 (success ? "Message saved." : "Message not saved"),
314 false, new Vector3()));
292 } 315 }
293 } 316 }
294 } 317 }
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 6dc982b..92485a1 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -2620,7 +2620,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
2620 { 2620 {
2621 // FIXME: It would be better to never add the scene object at all rather than add it and then delete 2621 // FIXME: It would be better to never add the scene object at all rather than add it and then delete
2622 // it 2622 // it
2623 if (!Scene.Permissions.CanObjectEntry(so.UUID, true, so.AbsolutePosition)) 2623 if (!Scene.Permissions.CanObjectEntry(so, true, so.AbsolutePosition))
2624 { 2624 {
2625 // Deny non attachments based on parcel settings 2625 // Deny non attachments based on parcel settings
2626 // 2626 //
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 95e7456..ba3a7c9 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -541,16 +541,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
541 541
542 #region Permissions 542 #region Permissions
543 543
544 private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) 544 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
545 { 545 {
546 if (m_bypassPermissions) return true; 546 if (m_bypassPermissions) return true;
547 547
548 if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(stealer)) 548 if(sp == null || sog == null)
549 return false;
550
551 if (!m_OutboundPermission && !UserManagementModule.IsLocalGridUser(sp.UUID))
549 { 552 {
550 SceneObjectGroup sog = null; 553 if (sog.OwnerID == sp.UUID)
551 if (m_Scene.TryGetSceneObjectGroup(objectID, out sog) && sog.OwnerID == stealer)
552 return true; 554 return true;
553
554 return false; 555 return false;
555 } 556 }
556 557
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index b37744d..67c847b 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -427,20 +427,14 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
427 originalRotations[objectGroup.UUID] = inventoryStoredRotation; 427 originalRotations[objectGroup.UUID] = inventoryStoredRotation;
428 428
429 // Restore attachment data after trip through the sim 429 // Restore attachment data after trip through the sim
430 if (objectGroup.RootPart.AttachPoint > 0) 430 if (objectGroup.AttachmentPoint > 0)
431 { 431 {
432 inventoryStoredPosition = objectGroup.RootPart.AttachedPos; 432 inventoryStoredPosition = objectGroup.RootPart.AttachedPos;
433 inventoryStoredRotation = objectGroup.RootPart.AttachRotation; 433 inventoryStoredRotation = objectGroup.RootPart.AttachRotation;
434 } 434 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
435 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
436 objectGroup.RootPart.Shape.LastAttachPoint = (byte)objectGroup.AttachmentPoint;
435 437
436 // Trees could be attached and it's been done, but it makes
437 // no sense. State must be preserved because it's the tree type
438 if (objectGroup.RootPart.Shape.PCode != (byte) PCode.Tree &&
439 objectGroup.RootPart.Shape.PCode != (byte) PCode.NewTree)
440 {
441 objectGroup.RootPart.Shape.State = objectGroup.RootPart.AttachPoint;
442 if (objectGroup.RootPart.AttachPoint > 0)
443 objectGroup.RootPart.Shape.LastAttachPoint = objectGroup.RootPart.AttachPoint;
444 } 438 }
445 439
446 objectGroup.AbsolutePosition = inventoryStoredPosition; 440 objectGroup.AbsolutePosition = inventoryStoredPosition;
@@ -1139,8 +1133,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1139 foreach (SceneObjectPart part in so.Parts) 1133 foreach (SceneObjectPart part in so.Parts)
1140 { 1134 {
1141 part.GroupMask = 0; // DO NOT propagate here 1135 part.GroupMask = 0; // DO NOT propagate here
1142 1136 if( part.OwnerID != part.GroupID)
1143 part.LastOwnerID = part.OwnerID; 1137 part.LastOwnerID = part.OwnerID;
1144 part.OwnerID = item.Owner; 1138 part.OwnerID = item.Owner;
1145 part.RezzerID = item.Owner; 1139 part.RezzerID = item.Owner;
1146 part.Inventory.ChangeInventoryOwner(item.Owner); 1140 part.Inventory.ChangeInventoryOwner(item.Owner);
@@ -1180,6 +1174,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1180 part.NextOwnerMask = item.NextPermissions & part.BaseMask; 1174 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
1181 } 1175 }
1182 } 1176 }
1177
1183 } 1178 }
1184 } 1179 }
1185 else 1180 else
@@ -1198,6 +1193,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1198 } 1193 }
1199 1194
1200 rootPart.TrimPermissions(); 1195 rootPart.TrimPermissions();
1196 so.AggregateDeepPerms();
1201 1197
1202 if (isAttachment) 1198 if (isAttachment)
1203 so.FromItemID = item.ID; 1199 so.FromItemID = item.ID;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 5d12f8b..53b9796 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -149,9 +149,11 @@ namespace OpenSim.Region.CoreModules.World.Land
149 parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache 149 parcelInfoCache.Size = 30; // the number of different parcel requests in this region to cache
150 parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0); 150 parcelInfoCache.DefaultTTL = new TimeSpan(0, 5, 0);
151 151
152 m_scene.EventManager.OnObjectAddedToScene += EventManagerOnParcelPrimCountAdd;
152 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd; 153 m_scene.EventManager.OnParcelPrimCountAdd += EventManagerOnParcelPrimCountAdd;
153 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate; 154
154 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene; 155 m_scene.EventManager.OnObjectBeingRemovedFromScene += EventManagerOnObjectBeingRemovedFromScene;
156 m_scene.EventManager.OnParcelPrimCountUpdate += EventManagerOnParcelPrimCountUpdate;
155 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate; 157 m_scene.EventManager.OnRequestParcelPrimCountUpdate += EventManagerOnRequestParcelPrimCountUpdate;
156 158
157 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel; 159 m_scene.EventManager.OnAvatarEnteringNewParcel += EventManagerOnAvatarEnteringNewParcel;
@@ -287,8 +289,10 @@ namespace OpenSim.Region.CoreModules.World.Land
287 289
288 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, 290 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0,
289 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY)); 291 (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY));
290 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 292 LandData ldata = fullSimParcel.LandData;
291 fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); 293 ldata.SimwideArea = ldata.Area;
294 ldata.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
295 ldata.ClaimDate = Util.UnixTimeSinceEpoch();
292 296
293 return AddLandObject(fullSimParcel); 297 return AddLandObject(fullSimParcel);
294 } 298 }
@@ -813,6 +817,9 @@ namespace OpenSim.Region.CoreModules.World.Land
813 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 817 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
814 } 818 }
815 819
820 if(m_landList.Count == 0 || m_landIDList == null)
821 return null;
822
816 lock (m_landIDList) 823 lock (m_landIDList)
817 { 824 {
818 try 825 try
@@ -824,8 +831,6 @@ namespace OpenSim.Region.CoreModules.World.Land
824 return null; 831 return null;
825 } 832 }
826 } 833 }
827
828 return m_landList[m_landIDList[x / 4, y / 4]];
829 } 834 }
830 835
831 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID 836 // Create a 'parcel is here' bitmap for the parcel identified by the passed landID
@@ -1576,6 +1581,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1576 } 1581 }
1577 } 1582 }
1578 } 1583 }
1584 FinalizeLandPrimCountUpdate(); // update simarea information
1579 } 1585 }
1580 } 1586 }
1581 1587
@@ -1640,9 +1646,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1640 foreach (HashSet<SceneObjectGroup> objs in returns.Values) 1646 foreach (HashSet<SceneObjectGroup> objs in returns.Values)
1641 { 1647 {
1642 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs); 1648 List<SceneObjectGroup> objs2 = new List<SceneObjectGroup>(objs);
1643 if (m_scene.Permissions.CanReturnObjects(null, remoteClient.AgentId, objs2)) 1649 if (m_scene.Permissions.CanReturnObjects(null, remoteClient, objs2))
1644 { 1650 {
1645 m_scene.returnObjects(objs2.ToArray(), remoteClient.AgentId); 1651 m_scene.returnObjects(objs2.ToArray(), remoteClient);
1646 } 1652 }
1647 else 1653 else
1648 { 1654 {
@@ -2035,7 +2041,7 @@ namespace OpenSim.Region.CoreModules.World.Land
2035 { 2041 {
2036 SceneObjectGroup[] objs = new SceneObjectGroup[1]; 2042 SceneObjectGroup[] objs = new SceneObjectGroup[1];
2037 objs[0] = obj; 2043 objs[0] = obj;
2038 ((Scene)client.Scene).returnObjects(objs, client.AgentId); 2044 ((Scene)client.Scene).returnObjects(objs, client);
2039 } 2045 }
2040 2046
2041 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); 2047 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 73b4cb5..2b5cb31 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -356,6 +356,7 @@ namespace OpenSim.Region.CoreModules.World.Land
356 } 356 }
357 } 357 }
358 358
359 // the total prims a parcel owner can have on a region
359 public int GetSimulatorMaxPrimCount() 360 public int GetSimulatorMaxPrimCount()
360 { 361 {
361 if (overrideSimulatorMaxPrimCount != null) 362 if (overrideSimulatorMaxPrimCount != null)
@@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.World.Land
370 * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus 371 * (double)m_scene.RegionInfo.RegionSettings.ObjectBonus
371 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY) 372 / (long)(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY)
372 +0.5 ); 373 +0.5 );
373 374 // sanity check
374 if(simMax > m_scene.RegionInfo.ObjectCapacity) 375 if(simMax > m_scene.RegionInfo.ObjectCapacity)
375 simMax = m_scene.RegionInfo.ObjectCapacity; 376 simMax = m_scene.RegionInfo.ObjectCapacity;
376 //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}", 377 //m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}, SimWidePrims {3}",
@@ -1043,7 +1044,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1043 else 1044 else
1044 LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]); 1045 LandData.AABBMax = new Vector3(tx, ty, (float)m_scene.Heightmap[tx - 1, ty - 1]);
1045 1046
1046 LandData.Area = tempArea * landUnit * landUnit; 1047 tempArea *= landUnit * landUnit;
1048 LandData.Area = tempArea;
1047 } 1049 }
1048 1050
1049 #endregion 1051 #endregion
@@ -1647,8 +1649,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1647 { 1649 {
1648 foreach (SceneObjectGroup obj in primsOverMe) 1650 foreach (SceneObjectGroup obj in primsOverMe)
1649 { 1651 {
1650 if (obj.OwnerID == previousOwner && obj.GroupID == UUID.Zero && 1652 if(m_scene.Permissions.CanSellObject(previousOwner,obj, (byte)SaleType.Original))
1651 (obj.GetEffectivePermissions() & (uint)(OpenSim.Framework.PermissionMask.Transfer)) != 0)
1652 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0); 1653 m_BuySellModule.BuyObject(sp.ControllingClient, UUID.Zero, obj.LocalId, 1, 0);
1653 } 1654 }
1654 } 1655 }
@@ -1662,7 +1663,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1662 { 1663 {
1663 SceneObjectGroup[] objs = new SceneObjectGroup[1]; 1664 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1664 objs[0] = obj; 1665 objs[0] = obj;
1665 m_scene.returnObjects(objs, obj.OwnerID); 1666 m_scene.returnObjects(objs, null);
1666 } 1667 }
1667 1668
1668 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client) 1669 public void ReturnLandObjects(uint type, UUID[] owners, UUID[] tasks, IClientAPI remote_client)
@@ -1693,6 +1694,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1693 { 1694 {
1694 if (obj.GroupID == LandData.GroupID) 1695 if (obj.GroupID == LandData.GroupID)
1695 { 1696 {
1697 if (obj.OwnerID == LandData.OwnerID)
1698 continue;
1696 if (!returns.ContainsKey(obj.OwnerID)) 1699 if (!returns.ContainsKey(obj.OwnerID))
1697 returns[obj.OwnerID] = 1700 returns[obj.OwnerID] =
1698 new List<SceneObjectGroup>(); 1701 new List<SceneObjectGroup>();
@@ -1734,8 +1737,8 @@ namespace OpenSim.Region.CoreModules.World.Land
1734 1737
1735 foreach (List<SceneObjectGroup> ol in returns.Values) 1738 foreach (List<SceneObjectGroup> ol in returns.Values)
1736 { 1739 {
1737 if (m_scene.Permissions.CanReturnObjects(this, remote_client.AgentId, ol)) 1740 if (m_scene.Permissions.CanReturnObjects(this, remote_client, ol))
1738 m_scene.returnObjects(ol.ToArray(), remote_client.AgentId); 1741 m_scene.returnObjects(ol.ToArray(), remote_client);
1739 } 1742 }
1740 } 1743 }
1741 1744
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 857f919..2a720db 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -92,10 +92,8 @@ namespace OpenSim.Region.CoreModules.World.Land
92 m_Scene.RegisterModuleInterface<IPrimCountModule>(this); 92 m_Scene.RegisterModuleInterface<IPrimCountModule>(this);
93 93
94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; 94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
95 m_Scene.EventManager.OnObjectBeingRemovedFromScene += 95 m_Scene.EventManager.OnObjectBeingRemovedFromScene += OnObjectBeingRemovedFromScene;
96 OnObjectBeingRemovedFromScene; 96 m_Scene.EventManager.OnParcelPrimCountTainted += OnParcelPrimCountTainted;
97 m_Scene.EventManager.OnParcelPrimCountTainted +=
98 OnParcelPrimCountTainted;
99 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); }; 97 m_Scene.EventManager.OnLandObjectAdded += delegate(ILandObject lo) { OnParcelPrimCountTainted(); };
100 } 98 }
101 99
@@ -215,29 +213,15 @@ namespace OpenSim.Region.CoreModules.World.Land
215 else 213 else
216 parcelCounts.Users[obj.OwnerID] = partCount; 214 parcelCounts.Users[obj.OwnerID] = partCount;
217 215
218 if (obj.IsSelected) 216 if (obj.IsSelected || obj.GetSittingAvatarsCount() > 0)
219 {
220 parcelCounts.Selected += partCount; 217 parcelCounts.Selected += partCount;
221 } 218
219 if (obj.OwnerID == landData.OwnerID)
220 parcelCounts.Owner += partCount;
221 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
222 parcelCounts.Group += partCount;
222 else 223 else
223 { 224 parcelCounts.Others += partCount;
224 if (landData.IsGroupOwned)
225 {
226 if (obj.OwnerID == landData.GroupID)
227 parcelCounts.Owner += partCount;
228 else if (landData.GroupID != UUID.Zero && obj.GroupID == landData.GroupID)
229 parcelCounts.Group += partCount;
230 else
231 parcelCounts.Others += partCount;
232 }
233 else
234 {
235 if (obj.OwnerID == landData.OwnerID)
236 parcelCounts.Owner += partCount;
237 else
238 parcelCounts.Others += partCount;
239 }
240 }
241 } 225 }
242 } 226 }
243 227
@@ -393,7 +377,6 @@ namespace OpenSim.Region.CoreModules.World.Land
393 count = counts.Owner; 377 count = counts.Owner;
394 count += counts.Group; 378 count += counts.Group;
395 count += counts.Others; 379 count += counts.Others;
396 count += counts.Selected;
397 } 380 }
398 } 381 }
399 382
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
index 0d8ece7..a349aa1 100644
--- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -151,7 +151,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
151 151
152 SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01); 152 SceneObjectGroup sog = SceneHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
153 m_scene.AddNewSceneObject(sog, false); 153 m_scene.AddNewSceneObject(sog, false);
154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); 154 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, m_userId, UUID.Zero, Quaternion.Identity, false);
155 155
156 Assert.That(pc.Owner, Is.EqualTo(6)); 156 Assert.That(pc.Owner, Is.EqualTo(6));
157 Assert.That(pc.Group, Is.EqualTo(0)); 157 Assert.That(pc.Group, Is.EqualTo(0));
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 2837358..90d65c7 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -89,28 +89,23 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
89 if (part == null) 89 if (part == null)
90 return; 90 return;
91 91
92 if (part.ParentGroup.IsDeleted) 92 SceneObjectGroup sog = part.ParentGroup;
93 if (sog == null || sog.IsDeleted)
93 return; 94 return;
94 95
95 if (part.OwnerID != part.GroupID && part.OwnerID != client.AgentId && (!m_scene.Permissions.IsGod(client.AgentId))) 96 // Does the user have the power to put the object on sale?
96 return; 97 if (!m_scene.Permissions.CanSellObject(client, sog, saleType))
97
98 if (part.OwnerID == part.GroupID) // Group owned
99 { 98 {
100 // Does the user have the power to put the object on sale? 99 client.SendAgentAlertMessage("You don't have permission to set object on sale", false);
101 if (!m_scene.Permissions.CanSellGroupObject(client.AgentId, part.GroupID, m_scene)) 100 return;
102 {
103 client.SendAgentAlertMessage("You don't have permission to set group-owned objects on sale", false);
104 return;
105 }
106 } 101 }
107 102
108 part = part.ParentGroup.RootPart; 103 part = sog.RootPart;
109 104
110 part.ObjectSaleType = saleType; 105 part.ObjectSaleType = saleType;
111 part.SalePrice = salePrice; 106 part.SalePrice = salePrice;
112 107
113 part.ParentGroup.HasGroupChanged = true; 108 sog.HasGroupChanged = true;
114 109
115 part.SendPropertiesToClient(client); 110 part.SendPropertiesToClient(client);
116 } 111 }
@@ -127,7 +122,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
127 switch (saleType) 122 switch (saleType)
128 { 123 {
129 case 1: // Sell as original (in-place sale) 124 case 1: // Sell as original (in-place sale)
130 uint effectivePerms = group.GetEffectivePermissions(); 125 uint effectivePerms = group.EffectiveOwnerPerms;
131 126
132 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 127 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
133 { 128 {
@@ -136,8 +131,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
136 return false; 131 return false;
137 } 132 }
138 133
139 group.SetOwnerId(remoteClient.AgentId); 134 group.SetOwner(remoteClient.AgentId, remoteClient.ActiveGroupId);
140 group.SetRootPartOwner(part, remoteClient.AgentId, remoteClient.ActiveGroupId);
141 135
142 if (m_scene.Permissions.PropagatePermissions()) 136 if (m_scene.Permissions.PropagatePermissions())
143 { 137 {
@@ -147,6 +141,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
147 child.TriggerScriptChangedEvent(Changed.OWNER); 141 child.TriggerScriptChangedEvent(Changed.OWNER);
148 child.ApplyNextOwnerPermissions(); 142 child.ApplyNextOwnerPermissions();
149 } 143 }
144 group.AggregatePerms();
150 } 145 }
151 146
152 part.ObjectSaleType = 0; 147 part.ObjectSaleType = 0;
@@ -174,7 +169,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
174 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group); 169 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
175 group.AbsolutePosition = originalPosition; 170 group.AbsolutePosition = originalPosition;
176 171
177 uint perms = group.GetEffectivePermissions(); 172 uint perms = group.EffectiveOwnerPerms;
178 173
179 if ((perms & (uint)PermissionMask.Transfer) == 0) 174 if ((perms & (uint)PermissionMask.Transfer) == 0)
180 { 175 {
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 86f0a58..bc86076 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 protected Scene m_scene; 51 protected Scene m_scene;
52 protected ScenePermissions scenePermissions;
52 protected bool m_Enabled; 53 protected bool m_Enabled;
53 54
54 private InventoryFolderImpl m_libraryRootFolder; 55 private InventoryFolderImpl m_libraryRootFolder;
@@ -69,15 +70,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
69 } 70 }
70 71
71 #region Constants 72 #region Constants
72 // These are here for testing. They will be taken out
73
74 //private uint PERM_ALL = (uint)2147483647;
75 private uint PERM_COPY = (uint)32768;
76 //private uint PERM_MODIFY = (uint)16384;
77 private uint PERM_MOVE = (uint)524288;
78 private uint PERM_TRANS = (uint)8192;
79 private uint PERM_LOCKED = (uint)540672;
80
81 /// <value> 73 /// <value>
82 /// Different user set names that come in from the configuration file. 74 /// Different user set names that come in from the configuration file.
83 /// </value> 75 /// </value>
@@ -96,14 +88,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
96 private bool m_bypassPermissionsValue = true; 88 private bool m_bypassPermissionsValue = true;
97 private bool m_propagatePermissions = false; 89 private bool m_propagatePermissions = false;
98 private bool m_debugPermissions = false; 90 private bool m_debugPermissions = false;
99 private bool m_allowGridGods = false; 91 private bool m_allowGridAdmins = false;
100 private bool m_RegionOwnerIsGod = false; 92 private bool m_RegionOwnerIsAdmin = false;
101 private bool m_RegionManagerIsGod = false; 93 private bool m_RegionManagerIsAdmin = false;
102 private bool m_forceGridGodsOnly; 94 private bool m_forceGridAdminsOnly;
103 private bool m_forceGodModeAlwaysOn; 95 private bool m_forceAdminModeAlwaysOn;
104 private bool m_allowGodActionsWithoutGodMode; 96 private bool m_allowAdminActionsWithoutGodMode;
105
106 private bool m_SimpleBuildPermissions = false;
107 97
108 /// <value> 98 /// <value>
109 /// The set of users that are allowed to create scripts. This is only active if permissions are not being 99 /// The set of users that are allowed to create scripts. This is only active if permissions are not being
@@ -172,25 +162,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
172 162
173 string[] sections = new string[] { "Startup", "Permissions" }; 163 string[] sections = new string[] { "Startup", "Permissions" };
174 164
175 m_allowGridGods = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false); 165 m_allowGridAdmins = Util.GetConfigVarFromSections<bool>(config, "allow_grid_gods", sections, false);
176 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true); 166 m_bypassPermissions = !Util.GetConfigVarFromSections<bool>(config, "serverside_object_permissions", sections, true);
177 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true); 167 m_propagatePermissions = Util.GetConfigVarFromSections<bool>(config, "propagate_permissions", sections, true);
178 168
179 m_forceGridGodsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false); 169 m_forceGridAdminsOnly = Util.GetConfigVarFromSections<bool>(config, "force_grid_gods_only", sections, false);
180 if(!m_forceGridGodsOnly) 170 if(!m_forceGridAdminsOnly)
181 { 171 {
182 m_RegionOwnerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true); 172 m_RegionOwnerIsAdmin = Util.GetConfigVarFromSections<bool>(config, "region_owner_is_god",sections, true);
183 m_RegionManagerIsGod = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false); 173 m_RegionManagerIsAdmin = Util.GetConfigVarFromSections<bool>(config, "region_manager_is_god",sections, false);
184 } 174 }
185 else 175 else
186 m_allowGridGods = true; 176 m_allowGridAdmins = true;
187 177
188 m_forceGodModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false); 178 m_forceAdminModeAlwaysOn = Util.GetConfigVarFromSections<bool>(config, "automatic_gods", sections, false);
189 m_allowGodActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false); 179 m_allowAdminActionsWithoutGodMode = Util.GetConfigVarFromSections<bool>(config, "implicit_gods", sections, false);
190 if(m_allowGodActionsWithoutGodMode) 180 if(m_allowAdminActionsWithoutGodMode)
191 m_forceGodModeAlwaysOn = false; 181 m_forceAdminModeAlwaysOn = false;
192
193 m_SimpleBuildPermissions = Util.GetConfigVarFromSections<bool>(config, "simple_build_permissions",sections, false);
194 182
195 m_allowedScriptCreators 183 m_allowedScriptCreators
196 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators); 184 = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators);
@@ -266,63 +254,77 @@ namespace OpenSim.Region.CoreModules.World.Permissions
266 m_scene = scene; 254 m_scene = scene;
267 255
268 scene.RegisterModuleInterface<IPermissionsModule>(this); 256 scene.RegisterModuleInterface<IPermissionsModule>(this);
257 scenePermissions = m_scene.Permissions;
269 258
270 //Register functions with Scene External Checks! 259 //Register functions with Scene External Checks!
271 m_scene.Permissions.OnBypassPermissions += BypassPermissions; 260 scenePermissions.OnBypassPermissions += BypassPermissions;
272 m_scene.Permissions.OnSetBypassPermissions += SetBypassPermissions; 261 scenePermissions.OnSetBypassPermissions += SetBypassPermissions;
273 m_scene.Permissions.OnPropagatePermissions += PropagatePermissions; 262 scenePermissions.OnPropagatePermissions += PropagatePermissions;
274 m_scene.Permissions.OnGenerateClientFlags += GenerateClientFlags; 263
275 m_scene.Permissions.OnAbandonParcel += CanAbandonParcel; 264 scenePermissions.OnIsGridGod += IsGridAdministrator;
276 m_scene.Permissions.OnReclaimParcel += CanReclaimParcel; 265 scenePermissions.OnIsAdministrator += IsAdministrator;
277 m_scene.Permissions.OnDeedParcel += CanDeedParcel; 266 scenePermissions.OnIsEstateManager += IsEstateManager;
278 m_scene.Permissions.OnDeedObject += CanDeedObject; 267
279 m_scene.Permissions.OnIsGod += IsGod; 268 scenePermissions.OnGenerateClientFlags += GenerateClientFlags;
280 m_scene.Permissions.OnIsGridGod += IsGridGod; 269
281 m_scene.Permissions.OnIsAdministrator += IsAdministrator; 270 scenePermissions.OnIssueEstateCommand += CanIssueEstateCommand;
282 m_scene.Permissions.OnIsEstateManager += IsEstateManager; 271 scenePermissions.OnRunConsoleCommand += CanRunConsoleCommand;
283 m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; 272
284 m_scene.Permissions.OnDeleteObject += CanDeleteObject; 273 scenePermissions.OnTeleport += CanTeleport;
285 m_scene.Permissions.OnEditObject += CanEditObject; 274
286 m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; 275 scenePermissions.OnInstantMessage += CanInstantMessage;
287 m_scene.Permissions.OnInstantMessage += CanInstantMessage; 276
288 m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; 277 scenePermissions.OnAbandonParcel += CanAbandonParcel;
289 m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; 278 scenePermissions.OnReclaimParcel += CanReclaimParcel;
290 m_scene.Permissions.OnMoveObject += CanMoveObject; 279 scenePermissions.OnDeedParcel += CanDeedParcel;
291 m_scene.Permissions.OnObjectEntry += CanObjectEntry; 280 scenePermissions.OnSellParcel += CanSellParcel;
292 m_scene.Permissions.OnReturnObjects += CanReturnObjects; 281 scenePermissions.OnEditParcelProperties += CanEditParcelProperties;
293 m_scene.Permissions.OnRezObject += CanRezObject; 282 scenePermissions.OnTerraformLand += CanTerraformLand;
294 m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; 283 scenePermissions.OnBuyLand += CanBuyLand;
295 m_scene.Permissions.OnRunScript += CanRunScript; 284
296 m_scene.Permissions.OnCompileScript += CanCompileScript; 285 scenePermissions.OnReturnObjects += CanReturnObjects;
297 m_scene.Permissions.OnSellParcel += CanSellParcel; 286
298 m_scene.Permissions.OnTakeObject += CanTakeObject; 287 scenePermissions.OnRezObject += CanRezObject;
299 m_scene.Permissions.OnSellGroupObject += CanSellGroupObject; 288 scenePermissions.OnObjectEntry += CanObjectEntry;
300 m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; 289
301 m_scene.Permissions.OnTerraformLand += CanTerraformLand; 290 scenePermissions.OnDuplicateObject += CanDuplicateObject;
302 m_scene.Permissions.OnLinkObject += CanLinkObject; 291 scenePermissions.OnDeleteObjectByIDs += CanDeleteObjectByIDs;
303 m_scene.Permissions.OnDelinkObject += CanDelinkObject; 292 scenePermissions.OnDeleteObject += CanDeleteObject;
304 m_scene.Permissions.OnBuyLand += CanBuyLand; 293 scenePermissions.OnEditObjectByIDs += CanEditObjectByIDs;
305 294 scenePermissions.OnEditObject += CanEditObject;
306 m_scene.Permissions.OnViewNotecard += CanViewNotecard; 295 scenePermissions.OnInventoryTransfer += CanInventoryTransfer;
307 m_scene.Permissions.OnViewScript += CanViewScript; 296 scenePermissions.OnMoveObject += CanMoveObject;
308 m_scene.Permissions.OnEditNotecard += CanEditNotecard; 297 scenePermissions.OnTakeObject += CanTakeObject;
309 m_scene.Permissions.OnEditScript += CanEditScript; 298 scenePermissions.OnTakeCopyObject += CanTakeCopyObject;
310 299 scenePermissions.OnLinkObject += CanLinkObject;
311 m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; 300 scenePermissions.OnDelinkObject += CanDelinkObject;
312 m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory; 301 scenePermissions.OnDeedObject += CanDeedObject;
313 m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; 302 scenePermissions.OnSellGroupObject += CanSellGroupObject;
314 m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; 303 scenePermissions.OnSellObjectByUserID += CanSellObjectByUserID;
315 m_scene.Permissions.OnResetScript += CanResetScript; 304 scenePermissions.OnSellObject += CanSellObject;
316 305
317 m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; 306 scenePermissions.OnCreateObjectInventory += CanCreateObjectInventory;
318 m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; 307 scenePermissions.OnEditObjectInventory += CanEditObjectInventory;
319 m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; 308 scenePermissions.OnCopyObjectInventory += CanCopyObjectInventory;
320 m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; 309 scenePermissions.OnDeleteObjectInventory += CanDeleteObjectInventory;
321 310 scenePermissions.OnDoObjectInvToObjectInv += CanDoObjectInvToObjectInv;
322 m_scene.Permissions.OnTeleport += CanTeleport; 311 scenePermissions.OnDropInObjectInv += CanDropInObjectInv;
323 312
324 m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; 313 scenePermissions.OnViewNotecard += CanViewNotecard;
325 m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; 314 scenePermissions.OnViewScript += CanViewScript;
315 scenePermissions.OnEditNotecard += CanEditNotecard;
316 scenePermissions.OnEditScript += CanEditScript;
317 scenePermissions.OnResetScript += CanResetScript;
318 scenePermissions.OnRunScript += CanRunScript;
319 scenePermissions.OnCompileScript += CanCompileScript;
320
321 scenePermissions.OnCreateUserInventory += CanCreateUserInventory;
322 scenePermissions.OnCopyUserInventory += CanCopyUserInventory;
323 scenePermissions.OnEditUserInventory += CanEditUserInventory;
324 scenePermissions.OnDeleteUserInventory += CanDeleteUserInventory;
325
326 scenePermissions.OnControlPrimMedia += CanControlPrimMedia;
327 scenePermissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia;
326 328
327 m_scene.AddCommand("Users", this, "bypass permissions", 329 m_scene.AddCommand("Users", this, "bypass permissions",
328 "bypass permissions <true / false>", 330 "bypass permissions <true / false>",
@@ -351,6 +353,76 @@ namespace OpenSim.Region.CoreModules.World.Permissions
351 return; 353 return;
352 354
353 m_scene.UnregisterModuleInterface<IPermissionsModule>(this); 355 m_scene.UnregisterModuleInterface<IPermissionsModule>(this);
356
357 scenePermissions.OnBypassPermissions -= BypassPermissions;
358 scenePermissions.OnSetBypassPermissions -= SetBypassPermissions;
359 scenePermissions.OnPropagatePermissions -= PropagatePermissions;
360
361 scenePermissions.OnIsGridGod -= IsGridAdministrator;
362 scenePermissions.OnIsAdministrator -= IsAdministrator;
363 scenePermissions.OnIsEstateManager -= IsEstateManager;
364
365 scenePermissions.OnGenerateClientFlags -= GenerateClientFlags;
366
367 scenePermissions.OnIssueEstateCommand -= CanIssueEstateCommand;
368 scenePermissions.OnRunConsoleCommand -= CanRunConsoleCommand;
369
370 scenePermissions.OnTeleport -= CanTeleport;
371
372 scenePermissions.OnInstantMessage -= CanInstantMessage;
373
374 scenePermissions.OnAbandonParcel -= CanAbandonParcel;
375 scenePermissions.OnReclaimParcel -= CanReclaimParcel;
376 scenePermissions.OnDeedParcel -= CanDeedParcel;
377 scenePermissions.OnSellParcel -= CanSellParcel;
378 scenePermissions.OnEditParcelProperties -= CanEditParcelProperties;
379 scenePermissions.OnTerraformLand -= CanTerraformLand;
380 scenePermissions.OnBuyLand -= CanBuyLand;
381
382 scenePermissions.OnRezObject -= CanRezObject;
383 scenePermissions.OnObjectEntry -= CanObjectEntry;
384 scenePermissions.OnReturnObjects -= CanReturnObjects;
385
386 scenePermissions.OnDuplicateObject -= CanDuplicateObject;
387 scenePermissions.OnDeleteObjectByIDs -= CanDeleteObjectByIDs;
388 scenePermissions.OnDeleteObject -= CanDeleteObject;
389 scenePermissions.OnEditObjectByIDs -= CanEditObjectByIDs;
390 scenePermissions.OnEditObject -= CanEditObject;
391 scenePermissions.OnInventoryTransfer -= CanInventoryTransfer;
392 scenePermissions.OnMoveObject -= CanMoveObject;
393 scenePermissions.OnTakeObject -= CanTakeObject;
394 scenePermissions.OnTakeCopyObject -= CanTakeCopyObject;
395 scenePermissions.OnLinkObject -= CanLinkObject;
396 scenePermissions.OnDelinkObject -= CanDelinkObject;
397 scenePermissions.OnDeedObject -= CanDeedObject;
398
399 scenePermissions.OnSellGroupObject -= CanSellGroupObject;
400 scenePermissions.OnSellObjectByUserID -= CanSellObjectByUserID;
401 scenePermissions.OnSellObject -= CanSellObject;
402
403 scenePermissions.OnCreateObjectInventory -= CanCreateObjectInventory;
404 scenePermissions.OnEditObjectInventory -= CanEditObjectInventory;
405 scenePermissions.OnCopyObjectInventory -= CanCopyObjectInventory;
406 scenePermissions.OnDeleteObjectInventory -= CanDeleteObjectInventory;
407 scenePermissions.OnDoObjectInvToObjectInv -= CanDoObjectInvToObjectInv;
408 scenePermissions.OnDropInObjectInv -= CanDropInObjectInv;
409
410 scenePermissions.OnViewNotecard -= CanViewNotecard;
411 scenePermissions.OnViewScript -= CanViewScript;
412 scenePermissions.OnEditNotecard -= CanEditNotecard;
413 scenePermissions.OnEditScript -= CanEditScript;
414 scenePermissions.OnResetScript -= CanResetScript;
415 scenePermissions.OnRunScript -= CanRunScript;
416 scenePermissions.OnCompileScript -= CanCompileScript;
417
418 scenePermissions.OnCreateUserInventory -= CanCreateUserInventory;
419 scenePermissions.OnCopyUserInventory -= CanCopyUserInventory;
420 scenePermissions.OnEditUserInventory -= CanEditUserInventory;
421 scenePermissions.OnDeleteUserInventory -= CanDeleteUserInventory;
422
423 scenePermissions.OnControlPrimMedia -= CanControlPrimMedia;
424 scenePermissions.OnInteractWithPrimMedia -= CanInteractWithPrimMedia;
425
354 } 426 }
355 427
356 public void Close() 428 public void Close()
@@ -479,32 +551,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions
479 551
480 return false; 552 return false;
481 } 553 }
482/* 554
483 private bool CheckGroupPowers(ScenePresence sp, UUID groupID, ulong powersMask) 555 protected bool GroupMemberPowers(UUID groupID, UUID userID, ref ulong powers)
484 { 556 {
485 if(sp == null || sp.ControllingClient == null) 557 powers = 0;
558 if (null == GroupsModule)
486 return false; 559 return false;
487
488 ulong grpPowers = sp.ControllingClient.GetGroupPowers(groupID);
489 560
490 return (grpPowers & powersMask) != 0; 561 GroupMembershipData gmd = GroupsModule.GetMembershipData(groupID, userID);
562
563 if (gmd != null)
564 {
565 powers = gmd.GroupPowers;
566 return true;
567 }
568 return false;
491 } 569 }
492 570
493 private bool CheckActiveGroupPowers(ScenePresence sp, UUID groupID, ulong powersMask) 571 protected bool GroupMemberPowers(UUID groupID, ScenePresence sp, ref ulong powers)
494 { 572 {
495 if(sp == null || sp.ControllingClient == null) 573 powers = 0;
496 return false; 574 IClientAPI client = sp.ControllingClient;
497 575 if (client == null)
498 if(sp.ControllingClient.ActiveGroupId != groupID)
499 return false; 576 return false;
500 // activeGroupPowers only get current selected role powers, at least with xmlgroups.
501 // lets get any role avoiding the extra burden of user also having to change role
502 // ulong grpPowers = sp.ControllingClient.ActiveGroupPowers(groupID);
503 ulong grpPowers = sp.ControllingClient.GetGroupPowers(groupID);
504 577
505 return (grpPowers & powersMask) != 0; 578 if(!client.IsGroupMember(groupID))
579 return false;
580
581 powers = client.GetGroupPowers(groupID);
582 return true;
506 } 583 }
507*/ 584
508 /// <summary> 585 /// <summary>
509 /// Parse a user set configuration setting 586 /// Parse a user set configuration setting
510 /// </summary> 587 /// </summary>
@@ -551,13 +628,13 @@ namespace OpenSim.Region.CoreModules.World.Permissions
551 if (user == UUID.Zero) 628 if (user == UUID.Zero)
552 return false; 629 return false;
553 630
554 if (m_scene.RegionInfo.EstateSettings.EstateOwner == user && m_RegionOwnerIsGod) 631 if (m_RegionOwnerIsAdmin && m_scene.RegionInfo.EstateSettings.EstateOwner == user)
555 return true; 632 return true;
556 633
557 if (IsEstateManager(user) && m_RegionManagerIsGod) 634 if (m_RegionManagerIsAdmin && IsEstateManager(user))
558 return true; 635 return true;
559 636
560 if (IsGridGod(user, null)) 637 if (IsGridAdministrator(user))
561 return true; 638 return true;
562 639
563 return false; 640 return false;
@@ -569,14 +646,15 @@ namespace OpenSim.Region.CoreModules.World.Permissions
569 /// <param name="user">The user</param> 646 /// <param name="user">The user</param>
570 /// <param name="scene">Unused, can be null</param> 647 /// <param name="scene">Unused, can be null</param>
571 /// <returns></returns> 648 /// <returns></returns>
572 protected bool IsGridGod(UUID user, Scene scene) 649 protected bool IsGridAdministrator(UUID user)
573 { 650 {
574 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 651 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
575 if (m_bypassPermissions) return m_bypassPermissionsValue; 652 if (m_bypassPermissions) return m_bypassPermissionsValue;
576 653
577 if (user == UUID.Zero) return false; 654 if (user == UUID.Zero)
655 return false;
578 656
579 if (m_allowGridGods) 657 if (m_allowGridAdmins)
580 { 658 {
581 ScenePresence sp = m_scene.GetScenePresence(user); 659 ScenePresence sp = m_scene.GetScenePresence(user);
582 if (sp != null) 660 if (sp != null)
@@ -630,8 +708,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
630 } 708 }
631 709
632 #region Object Permissions 710 #region Object Permissions
633#pragma warning disable 0612 711
634 const uint DEFAULT_FLAGS = (uint)~( 712 const uint DEFAULT_FLAGS = (uint)(
635 PrimFlags.ObjectCopy | // Tells client you can copy the object 713 PrimFlags.ObjectCopy | // Tells client you can copy the object
636 PrimFlags.ObjectModify | // tells client you can modify the object 714 PrimFlags.ObjectModify | // tells client you can modify the object
637 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod) 715 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
@@ -650,7 +728,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
650 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object 728 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
651 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object 729 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
652 ); 730 );
653#pragma warning restore 0612
654 731
655 const uint EXTRAOWNERMASK = (uint)( 732 const uint EXTRAOWNERMASK = (uint)(
656 PrimFlags.ObjectYouOwner | 733 PrimFlags.ObjectYouOwner |
@@ -665,49 +742,71 @@ namespace OpenSim.Region.CoreModules.World.Permissions
665 PrimFlags.ObjectMove 742 PrimFlags.ObjectMove
666 ); 743 );
667 744
668 public uint GenerateClientFlags(ScenePresence sp, uint curEffectivePerms, UUID objID) 745 const uint GOD_FLAGS = (uint)(
669 { 746 PrimFlags.ObjectCopy | // Tells client you can copy the object
670 if(sp == null || curEffectivePerms == 0) 747 PrimFlags.ObjectModify | // tells client you can modify the object
671 return (uint)0; 748 PrimFlags.ObjectMove | // tells client that you can move the object (only, no mod)
749 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
750 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
751 PrimFlags.ObjectAnyOwner | // Tells client that someone owns the object
752 PrimFlags.ObjectOwnerModify // Tells client that you're the owner of the object
753 );
672 754
673 SceneObjectPart task = m_scene.GetSceneObjectPart(objID); 755 const uint LOCKED_GOD_FLAGS = (uint)(
756 PrimFlags.ObjectCopy | // Tells client you can copy the object
757 PrimFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
758 PrimFlags.ObjectYouOwner | // Tells client that you're the owner of the object
759 PrimFlags.ObjectAnyOwner // Tells client that someone owns the object
760 );
761
762 const uint SHAREDMASK = (uint)(
763 PermissionMask.Move |
764 PermissionMask.Modify |
765 PermissionMask.Copy
766 );
767
768 public uint GenerateClientFlags(SceneObjectPart task, ScenePresence sp, uint curEffectivePerms)
769 {
770 if(sp == null || task == null || curEffectivePerms == 0)
771 return 0;
674 772
675 // this shouldn't ever happen.. return no permissions/objectflags.
676 if (task == null)
677 return (uint)0;
678
679 // Remove any of the objectFlags that are temporary. These will get added back if appropriate 773 // Remove any of the objectFlags that are temporary. These will get added back if appropriate
680 uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ; 774 uint objflags = curEffectivePerms & NOT_DEFAULT_FLAGS ;
681 775
682 uint returnMask; 776 uint returnMask;
683 777
684 // gods have owner rights with Modify and Move always on 778 SceneObjectGroup grp = task.ParentGroup;
779 if(grp == null)
780 return 0;
781
782 UUID taskOwnerID = task.OwnerID;
783 UUID spID = sp.UUID;
784
785 bool unlocked = (grp.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0;
786
685 if(sp.IsGod) 787 if(sp.IsGod)
686 { 788 {
687 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, true); 789 // do locked on objects owned by admin
688 returnMask |= EXTRAGODMASK; 790 if(!unlocked && spID == taskOwnerID)
689 return returnMask; 791 return objflags | LOCKED_GOD_FLAGS;
792 else
793 return objflags | GOD_FLAGS;
690 } 794 }
691 795
692 //bypass option == owner rights 796 //bypass option == owner rights
693 if (m_bypassPermissions) 797 if (m_bypassPermissions)
694 { 798 {
695 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, true); 799 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, true); //??
696 returnMask |= EXTRAOWNERMASK; 800 returnMask |= EXTRAOWNERMASK;
697 if((returnMask & (uint)PrimFlags.ObjectModify) != 0) 801 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
698 returnMask |= (uint)PrimFlags.ObjectOwnerModify; 802 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
699 return returnMask; 803 return returnMask;
700 } 804 }
701 805
702 bool unlocked = (task.ParentGroup.RootPart.OwnerMask & (uint)PermissionMask.Move) != 0;
703
704 UUID taskOwnerID = task.OwnerID;
705 UUID spID = sp.UUID;
706
707 // owner 806 // owner
708 if (spID == taskOwnerID) 807 if (spID == taskOwnerID)
709 { 808 {
710 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, unlocked); 809 returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked);
711 returnMask |= EXTRAOWNERMASK; 810 returnMask |= EXTRAOWNERMASK;
712 if((returnMask & (uint)PrimFlags.ObjectModify) != 0) 811 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
713 returnMask |= (uint)PrimFlags.ObjectOwnerModify; 812 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
@@ -717,19 +816,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
717 // if not god or owner, do attachments as everyone 816 // if not god or owner, do attachments as everyone
718 if(task.ParentGroup.IsAttachment) 817 if(task.ParentGroup.IsAttachment)
719 { 818 {
720 returnMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags, unlocked); 819 returnMask = ApplyObjectModifyMasks(grp.EffectiveEveryOnePerms, objflags, unlocked);
721 if (taskOwnerID != UUID.Zero) 820 if (taskOwnerID != UUID.Zero)
722 returnMask |= (uint)PrimFlags.ObjectAnyOwner; 821 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
723 return returnMask; 822 return returnMask;
724 } 823 }
725 824
726 UUID taskGroupID = task.GroupID; 825 UUID taskGroupID = task.GroupID;
727 bool groupdOwned = taskOwnerID == taskGroupID; 826 bool notGroupdOwned = taskOwnerID != taskGroupID;
728 827
729 // if friends with rights then owner 828 // if friends with rights then owner
730 if (!groupdOwned && IsFriendWithPerms(spID, taskOwnerID)) 829 if (notGroupdOwned && IsFriendWithPerms(spID, taskOwnerID))
731 { 830 {
732 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, unlocked); 831 returnMask = ApplyObjectModifyMasks(grp.EffectiveOwnerPerms, objflags, unlocked);
733 returnMask |= EXTRAOWNERMASK; 832 returnMask |= EXTRAOWNERMASK;
734 if((returnMask & (uint)PrimFlags.ObjectModify) != 0) 833 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
735 returnMask |= (uint)PrimFlags.ObjectOwnerModify; 834 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
@@ -738,43 +837,44 @@ namespace OpenSim.Region.CoreModules.World.Permissions
738 837
739 // group owned or shared ? 838 // group owned or shared ?
740 IClientAPI client = sp.ControllingClient; 839 IClientAPI client = sp.ControllingClient;
741 if(taskGroupID != UUID.Zero && client != null && client.IsGroupMember(taskGroupID)) 840 ulong powers = 0;
841 if(taskGroupID != UUID.Zero && GroupMemberPowers(taskGroupID, sp, ref powers))
742 { 842 {
743 if(groupdOwned) 843 if(notGroupdOwned)
744 {
745 // object is owned by group, check role powers
746 if((client.GetGroupPowers(taskGroupID) & (ulong)GroupPowers.ObjectManipulate) != 0)
747 {
748 returnMask = ApplyObjectModifyMasks(task.OwnerMask, objflags, unlocked);
749 returnMask |=
750 (uint)PrimFlags.ObjectGroupOwned |
751 (uint)PrimFlags.ObjectAnyOwner;
752 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
753 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
754 return returnMask;
755 }
756 else
757 {
758 // group sharing or everyone
759 returnMask = ApplyObjectModifyMasks(task.GroupMask | task.EveryoneMask, objflags, unlocked);
760 returnMask |=
761 (uint)PrimFlags.ObjectGroupOwned |
762 (uint)PrimFlags.ObjectAnyOwner;
763 return returnMask;
764 }
765 }
766 else
767 { 844 {
768 // group sharing or everyone 845 // group sharing or everyone
769 returnMask = ApplyObjectModifyMasks(task.GroupMask | task.EveryoneMask, objflags, unlocked); 846 returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked);
770 if (taskOwnerID != UUID.Zero) 847 if (taskOwnerID != UUID.Zero)
771 returnMask |= (uint)PrimFlags.ObjectAnyOwner; 848 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
772 return returnMask; 849 return returnMask;
773 } 850 }
851
852 // object is owned by group, check role powers
853 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
854 {
855 // group sharing or everyone
856 returnMask = ApplyObjectModifyMasks(grp.EffectiveGroupOrEveryOnePerms, objflags, unlocked);
857 returnMask |=
858 (uint)PrimFlags.ObjectGroupOwned |
859 (uint)PrimFlags.ObjectAnyOwner;
860 return returnMask;
861 }
862
863 // we may have copy without transfer
864 uint grpEffectiveOwnerPerms = grp.EffectiveOwnerPerms;
865 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
866 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
867 returnMask = ApplyObjectModifyMasks(grpEffectiveOwnerPerms, objflags, unlocked);
868 returnMask |=
869 (uint)PrimFlags.ObjectGroupOwned |
870 (uint)PrimFlags.ObjectYouOwner;
871 if((returnMask & (uint)PrimFlags.ObjectModify) != 0)
872 returnMask |= (uint)PrimFlags.ObjectOwnerModify;
873 return returnMask;
774 } 874 }
775 875
776 // fallback is everyone rights 876 // fallback is everyone rights
777 returnMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags, unlocked); 877 returnMask = ApplyObjectModifyMasks(grp.EffectiveEveryOnePerms, objflags, unlocked);
778 if (taskOwnerID != UUID.Zero) 878 if (taskOwnerID != UUID.Zero)
779 returnMask |= (uint)PrimFlags.ObjectAnyOwner; 879 returnMask |= (uint)PrimFlags.ObjectAnyOwner;
780 return returnMask; 880 return returnMask;
@@ -811,7 +911,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
811 return objectFlagsMask; 911 return objectFlagsMask;
812 } 912 }
813 913
814 // OARs need this method that handles offline users 914 // OARs still need this method that handles offline users
815 public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj) 915 public PermissionClass GetPermissionClass(UUID user, SceneObjectPart obj)
816 { 916 {
817 if (obj == null) 917 if (obj == null)
@@ -842,107 +942,182 @@ namespace OpenSim.Region.CoreModules.World.Permissions
842 return PermissionClass.Everyone; 942 return PermissionClass.Everyone;
843 } 943 }
844 944
845 /// <summary> 945 // get effective object permissions using user UUID. User rights will be fixed
846 /// General permissions checks for any operation involving an object. These supplement more specific checks 946 protected uint GetObjectPermissions(UUID currentUser, SceneObjectGroup group, bool denyOnLocked)
847 /// implemented by callers.
848 /// </summary>
849 /// <param name="currentUser"></param>
850 /// <param name="objId">This is a scene object group UUID</param>
851 /// <param name="denyOnLocked"></param>
852 /// <returns></returns>
853 protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked)
854 { 947 {
855 // Default: deny 948 if (group == null)
856 bool permission = false; 949 return 0;
857 bool locked = false;
858
859 SceneObjectPart part = m_scene.GetSceneObjectPart(objId);
860
861 if (part == null)
862 return false;
863 950
864 SceneObjectGroup group = part.ParentGroup; 951 SceneObjectPart root = group.RootPart;
952 if (root == null)
953 return 0;
865 954
866 UUID objectOwner = group.OwnerID; 955 UUID objectOwner = group.OwnerID;
867 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0); 956 bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
868 957
869 // People shouldn't be able to do anything with locked objects, except the Administrator 958 if (IsAdministrator(currentUser))
870 // The 'set permissions' runs through a different permission check, so when an object owner
871 // sets an object locked, the only thing that they can do is unlock it.
872 //
873 // Nobody but the object owner can set permissions on an object
874 //
875 if (locked && (!IsAdministrator(currentUser)) && denyOnLocked)
876 { 959 {
877 return false; 960 // do lock on admin owned objects
961 if(locked && currentUser == objectOwner)
962 return (uint)(PermissionMask.AllEffective & ~(PermissionMask.Modify | PermissionMask.Move));
963 return (uint)PermissionMask.AllEffective;
878 } 964 }
879 965
880 // Object owners should be able to edit their own content 966 uint lockmask = (uint)PermissionMask.AllEffective;
967 if(locked)
968 lockmask &= ~(uint)(PermissionMask.Modify | PermissionMask.Move);
969
881 if (currentUser == objectOwner) 970 if (currentUser == objectOwner)
882 { 971 return group.EffectiveOwnerPerms & lockmask;
883 // there is no way that later code can change this back to false 972
884 // so just return true immediately and short circuit the more 973 if (group.IsAttachment)
885 // expensive group checks 974 return 0;
886 return true;
887 975
888 //permission = true; 976 UUID sogGroupID = group.GroupID;
889 } 977 bool notgroudOwned = sogGroupID != objectOwner;
890 else if (group.IsAttachment)
891 {
892 permission = false;
893 }
894 978
895// m_log.DebugFormat( 979 if (notgroudOwned && IsFriendWithPerms(currentUser, objectOwner))
896// "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}", 980 return group.EffectiveOwnerPerms & lockmask;
897// group.GroupID,
898// m_scene.GetSceneObjectPart(objId).GroupMask,
899// IsGroupMember(group.GroupID, currentUser, 0),
900// currentUser);
901
902 // Group members should be able to edit group objects
903 if ((group.GroupID != UUID.Zero)
904 && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0)
905 && IsGroupMember(group.GroupID, currentUser, 0))
906 {
907 // Return immediately, so that the administrator can shares group objects
908 return true;
909 }
910 981
911 // Friends with benefits should be able to edit the objects too 982 ulong powers = 0;
912 if (IsFriendWithPerms(currentUser, objectOwner)) 983 if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, currentUser, ref powers))
913 { 984 {
914 // Return immediately, so that the administrator can share objects with friends 985 if(notgroudOwned)
915 return true; 986 return group.EffectiveGroupOrEveryOnePerms & lockmask;
987
988 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
989 return group.EffectiveGroupOrEveryOnePerms & lockmask;
990
991 uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask;
992 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
993 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
994 return grpEffectiveOwnerPerms;
916 } 995 }
917 996
918 // Users should be able to edit what is over their land. 997 return group.EffectiveEveryOnePerms & lockmask;
919 ILandObject parcel = m_scene.LandChannel.GetLandObject(group.AbsolutePosition.X, group.AbsolutePosition.Y); 998 }
920 if ((parcel != null) && (parcel.LandData.OwnerID == currentUser)) 999
1000 // get effective object permissions using present presence. So some may depend on requested rights (ie God)
1001 protected uint GetObjectPermissions(ScenePresence sp, SceneObjectGroup group, bool denyOnLocked)
1002 {
1003 if (sp == null || sp.IsDeleted || group == null || group.IsDeleted)
1004 return 0;
1005
1006 SceneObjectPart root = group.RootPart;
1007 if (root == null)
1008 return 0;
1009
1010 UUID spID = sp.UUID;
1011 UUID objectOwner = group.OwnerID;
1012
1013 bool locked = denyOnLocked && ((root.OwnerMask & (uint)PermissionMask.Move) == 0);
1014
1015 if (sp.IsGod)
921 { 1016 {
922 permission = true; 1017 if(locked && spID == objectOwner)
1018 return (uint)(PermissionMask.AllEffective & ~(PermissionMask.Modify | PermissionMask.Move));
1019 return (uint)PermissionMask.AllEffective;
923 } 1020 }
924 1021
925 // Estate users should be able to edit anything in the sim 1022 uint lockmask = (uint)PermissionMask.AllEffective;
926 if (IsEstateManager(currentUser)) 1023 if(locked)
1024 lockmask &= ~(uint)(PermissionMask.Modify | PermissionMask.Move);
1025
1026 if (spID == objectOwner)
1027 return group.EffectiveOwnerPerms & lockmask;
1028
1029 if (group.IsAttachment)
1030 return 0;
1031
1032 UUID sogGroupID = group.GroupID;
1033 bool notgroudOwned = sogGroupID != objectOwner;
1034
1035 if (notgroudOwned && IsFriendWithPerms(spID, objectOwner))
1036 return group.EffectiveOwnerPerms & lockmask;
1037
1038 ulong powers = 0;
1039 if (sogGroupID != UUID.Zero && GroupMemberPowers(sogGroupID, sp, ref powers))
927 { 1040 {
928 permission = true; 1041 if(notgroudOwned)
1042 return group.EffectiveGroupOrEveryOnePerms & lockmask;
1043
1044 if((powers & (ulong)GroupPowers.ObjectManipulate) == 0)
1045 return group.EffectiveGroupOrEveryOnePerms & lockmask;
1046
1047 uint grpEffectiveOwnerPerms = group.EffectiveOwnerPerms & lockmask;
1048 if((grpEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1049 grpEffectiveOwnerPerms &= ~(uint)PermissionMask.Copy;
1050 return grpEffectiveOwnerPerms;
929 } 1051 }
930 1052
931 // Admin objects should not be editable by the above 1053 return group.EffectiveEveryOnePerms & lockmask;
932 if (IsAdministrator(objectOwner)) 1054 }
1055
1056 private uint GetObjectItemPermissions(UUID userID, TaskInventoryItem ti)
1057 {
1058 UUID tiOwnerID = ti.OwnerID;
1059 if(tiOwnerID == userID)
1060 return ti.CurrentPermissions;
1061
1062 if(IsAdministrator(userID))
1063 return (uint)PermissionMask.AllEffective;
1064 // ??
1065 if (IsFriendWithPerms(userID, tiOwnerID))
1066 return ti.CurrentPermissions;
1067
1068 UUID tiGroupID = ti.GroupID;
1069 if(tiGroupID != UUID.Zero)
933 { 1070 {
934 permission = false; 1071 ulong powers = 0;
1072 if(GroupMemberPowers(tiGroupID, userID, ref powers))
1073 {
1074 if(tiGroupID == ti.OwnerID)
1075 {
1076 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1077 return ti.CurrentPermissions;
1078 }
1079 return ti.GroupPermissions;
1080 }
935 } 1081 }
936 1082
937 // Admin should be able to edit anything in the sim (including admin objects) 1083 return 0;
938 if (IsAdministrator(currentUser)) 1084 }
1085
1086 private uint GetObjectItemPermissions(ScenePresence sp, TaskInventoryItem ti, bool notEveryone)
1087 {
1088 UUID tiOwnerID = ti.OwnerID;
1089 UUID spID = sp.UUID;
1090
1091 if(tiOwnerID == spID)
1092 return ti.CurrentPermissions;
1093
1094 // ??
1095 if (IsFriendWithPerms(spID, tiOwnerID))
1096 return ti.CurrentPermissions;
1097
1098 UUID tiGroupID = ti.GroupID;
1099 if(tiGroupID != UUID.Zero)
939 { 1100 {
940 permission = true; 1101 ulong powers = 0;
1102 if(GroupMemberPowers(tiGroupID, spID, ref powers))
1103 {
1104 if(tiGroupID == ti.OwnerID)
1105 {
1106 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1107 return ti.CurrentPermissions;
1108 }
1109 uint p = ti.GroupPermissions;
1110 if(!notEveryone)
1111 p |= ti.EveryonePermissions;
1112 return p;
1113 }
941 } 1114 }
942 1115
943 return permission; 1116 if(notEveryone)
944 } 1117 return 0;
945 1118
1119 return ti.EveryonePermissions;
1120 }
946 #endregion 1121 #endregion
947 1122
948 #region Generic Permissions 1123 #region Generic Permissions
@@ -967,89 +1142,37 @@ namespace OpenSim.Region.CoreModules.World.Permissions
967 1142
968 public bool GenericEstatePermission(UUID user) 1143 public bool GenericEstatePermission(UUID user)
969 { 1144 {
970 // Default: deny
971 bool permission = false;
972
973 // Estate admins should be able to use estate tools 1145 // Estate admins should be able to use estate tools
974 if (IsEstateManager(user)) 1146 if (IsEstateManager(user))
975 permission = true; 1147 return true;
976 1148
977 // Administrators always have permission 1149 // Administrators always have permission
978 if (IsAdministrator(user)) 1150 if (IsAdministrator(user))
979 permission = true; 1151 return true;
980
981 return permission;
982 }
983
984 protected bool GenericParcelPermission(UUID user, ILandObject parcel, ulong groupPowers)
985 {
986 bool permission = false;
987
988 if (parcel.LandData.OwnerID == user)
989 {
990 permission = true;
991 }
992
993 if ((parcel.LandData.GroupID != UUID.Zero) && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
994 {
995 permission = true;
996 }
997
998 if (IsEstateManager(user))
999 {
1000 permission = true;
1001 }
1002
1003 if (IsAdministrator(user))
1004 {
1005 permission = true;
1006 }
1007
1008 if (m_SimpleBuildPermissions &&
1009 (parcel.LandData.Flags & (uint)ParcelFlags.UseAccessList) == 0 && parcel.IsInLandAccessList(user))
1010 permission = true;
1011 1152
1012 return permission; 1153 return false;
1013 } 1154 }
1014 1155
1015 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers, bool allowEstateManager) 1156 protected bool GenericParcelOwnerPermission(UUID user, ILandObject parcel, ulong groupPowers, bool allowEstateManager)
1016 { 1157 {
1017 if (parcel.LandData.OwnerID == user) 1158 if (parcel.LandData.OwnerID == user)
1018 {
1019 // Returning immediately so that group deeded objects on group deeded land don't trigger a NRE on
1020 // the subsequent redundant checks when using lParcelMediaCommandList()
1021 // See http://opensimulator.org/mantis/view.php?id=3999 for more details
1022 return true; 1159 return true;
1023 }
1024 1160
1025 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers)) 1161 if (parcel.LandData.IsGroupOwned && IsGroupMember(parcel.LandData.GroupID, user, groupPowers))
1026 {
1027 return true; 1162 return true;
1028 }
1029 1163
1030 if (allowEstateManager && IsEstateManager(user)) 1164 if (allowEstateManager && IsEstateManager(user))
1031 {
1032 return true; 1165 return true;
1033 }
1034 1166
1035 if (IsAdministrator(user)) 1167 if (IsAdministrator(user))
1036 {
1037 return true; 1168 return true;
1038 }
1039 1169
1040 return false; 1170 return false;
1041 } 1171 }
1042
1043 protected bool GenericParcelPermission(UUID user, Vector3 pos, ulong groupPowers)
1044 {
1045 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1046 if (parcel == null) return false;
1047 return GenericParcelPermission(user, parcel, groupPowers);
1048 }
1049#endregion 1172#endregion
1050 1173
1051 #region Permission Checks 1174 #region Permission Checks
1052 private bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene) 1175 private bool CanAbandonParcel(UUID user, ILandObject parcel)
1053 { 1176 {
1054 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1177 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1055 if (m_bypassPermissions) return m_bypassPermissionsValue; 1178 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1057,7 +1180,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1057 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease, false); 1180 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandRelease, false);
1058 } 1181 }
1059 1182
1060 private bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene) 1183 private bool CanReclaimParcel(UUID user, ILandObject parcel)
1061 { 1184 {
1062 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1185 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1063 if (m_bypassPermissions) return m_bypassPermissionsValue; 1186 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1065,108 +1188,223 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1065 return GenericParcelOwnerPermission(user, parcel, 0,true); 1188 return GenericParcelOwnerPermission(user, parcel, 0,true);
1066 } 1189 }
1067 1190
1068 private bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene) 1191 private bool CanDeedParcel(UUID user, ILandObject parcel)
1069 { 1192 {
1070 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1193 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1071 if (m_bypassPermissions) return m_bypassPermissionsValue; 1194 if (m_bypassPermissions) return m_bypassPermissionsValue;
1072 1195
1196 if(parcel.LandData.GroupID == UUID.Zero)
1197 return false;
1198
1199 if (IsAdministrator(user))
1200 return true;
1201
1073 if (parcel.LandData.OwnerID != user) // Only the owner can deed! 1202 if (parcel.LandData.OwnerID != user) // Only the owner can deed!
1074 return false; 1203 return false;
1075 1204
1076 ScenePresence sp = scene.GetScenePresence(user); 1205 ScenePresence sp = m_scene.GetScenePresence(user);
1077 IClientAPI client = sp.ControllingClient; 1206 if(sp == null)
1207 return false;
1078 1208
1209 IClientAPI client = sp.ControllingClient;
1079 if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0) 1210 if ((client.GetGroupPowers(parcel.LandData.GroupID) & (ulong)GroupPowers.LandDeed) == 0)
1080 return false; 1211 return false;
1081 1212
1082 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandDeed, false); 1213 return true;
1083 } 1214 }
1084 1215
1085 private bool CanDeedObject(UUID user, UUID group, Scene scene) 1216 private bool CanDeedObject(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID)
1086 { 1217 {
1087 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1218 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1088 if (m_bypassPermissions) return m_bypassPermissionsValue; 1219 if (m_bypassPermissions) return m_bypassPermissionsValue;
1089 1220
1090 ScenePresence sp = scene.GetScenePresence(user); 1221 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted || targetGroupID == UUID.Zero)
1091 IClientAPI client = sp.ControllingClient; 1222 return false;
1223
1224 // object has group already?
1225 if(sog.GroupID != targetGroupID)
1226 return false;
1227
1228 // is effectivelly shared?
1229 if(sog.EffectiveGroupPerms == 0)
1230 return false;
1092 1231
1093 if ((client.GetGroupPowers(group) & (ulong)GroupPowers.DeedObject) == 0) 1232 if(sp.IsGod)
1233 return true;
1234
1235 // owned by requester?
1236 if(sog.OwnerID != sp.UUID)
1237 return false;
1238
1239 // owner can transfer?
1240 if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1241 return false;
1242
1243 // group member ?
1244 ulong powers = 0;
1245 if(!GroupMemberPowers(targetGroupID, sp, ref powers))
1246 return false;
1247
1248 // has group rights?
1249 if ((powers & (ulong)GroupPowers.DeedObject) == 0)
1094 return false; 1250 return false;
1095 1251
1096 return true; 1252 return true;
1097 } 1253 }
1098 1254
1099 private bool IsGod(UUID user, Scene scene) 1255 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
1100 { 1256 {
1101 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1257 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1102 if (m_bypassPermissions) return m_bypassPermissionsValue; 1258 if (m_bypassPermissions) return m_bypassPermissionsValue;
1103 1259
1104 return IsAdministrator(user); 1260 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1261 return false;
1262
1263 uint perms = GetObjectPermissions(sp, sog, false);
1264 if((perms & (uint)PermissionMask.Copy) == 0)
1265 return false;
1266
1267 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
1268 return false;
1269
1270 //If they can rez, they can duplicate
1271 return CanRezObject(0, sp.UUID, sog.AbsolutePosition);
1105 } 1272 }
1106 1273
1107 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition) 1274 private bool CanDeleteObject(SceneObjectGroup sog, ScenePresence sp)
1108 { 1275 {
1276 // ignoring locked. viewers should warn and ask for confirmation
1277
1109 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1278 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1110 if (m_bypassPermissions) return m_bypassPermissionsValue; 1279 if (m_bypassPermissions) return m_bypassPermissionsValue;
1111 1280
1112 if (!GenericObjectPermission(owner, objectID, true)) 1281 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1113 {
1114 //They can't even edit the object
1115 return false; 1282 return false;
1116 }
1117 1283
1118 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1284 if(sog.IsAttachment)
1119 if (part == null)
1120 return false; 1285 return false;
1121 1286
1122 if (part.OwnerID == owner) 1287 UUID sogOwnerID = sog.OwnerID;
1288 UUID spID = sp.UUID;
1289
1290 if(sogOwnerID == spID)
1291 return true;
1292
1293 if (sp.IsGod)
1294 return true;
1295
1296 if (IsFriendWithPerms(sog.UUID, sogOwnerID))
1297 return true;
1298
1299 UUID sogGroupID = sog.GroupID;
1300 if (sogGroupID != UUID.Zero)
1123 { 1301 {
1124 if ((part.OwnerMask & PERM_COPY) == 0) 1302 ulong powers = 0;
1125 return false; 1303 if(GroupMemberPowers(sogGroupID, sp, ref powers))
1304 {
1305 if(sogGroupID == sogOwnerID)
1306 {
1307 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1308 return true;
1309 }
1310 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1311 }
1126 } 1312 }
1127 else if (part.GroupID != UUID.Zero) 1313 return false;
1128 { 1314 }
1129 if ((part.OwnerID == part.GroupID) && ((owner != part.LastOwnerID) || ((part.GroupMask & PERM_TRANS) == 0)))
1130 return false;
1131 1315
1132 if ((part.GroupMask & PERM_COPY) == 0) 1316 private bool CanDeleteObjectByIDs(UUID objectID, UUID userID)
1133 return false; 1317 {
1134 } 1318 // ignoring locked. viewers should warn and ask for confirmation
1135 1319
1136 //If they can rez, they can duplicate 1320 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1137 return CanRezObject(objectCount, owner, objectPosition, scene); 1321 if (m_bypassPermissions) return m_bypassPermissionsValue;
1322
1323 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1324 if (sog == null)
1325 return false;
1326
1327 if(sog.IsAttachment)
1328 return false;
1329
1330 UUID sogOwnerID = sog.OwnerID;
1331
1332 if(sogOwnerID == userID)
1333 return true;
1334
1335 if (IsAdministrator(userID))
1336 return true;
1337
1338 if (IsFriendWithPerms(objectID, sogOwnerID))
1339 return true;
1340
1341 UUID sogGroupID = sog.GroupID;
1342 if (sogGroupID != UUID.Zero)
1343 {
1344 ulong powers = 0;
1345 if(GroupMemberPowers(sogGroupID, userID, ref powers))
1346 {
1347 if(sogGroupID == sogOwnerID)
1348 {
1349 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1350 return true;
1351 }
1352 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1353 }
1354 }
1355 return false;
1138 } 1356 }
1139 1357
1140 private bool CanDeleteObject(UUID objectID, UUID deleter, Scene scene) 1358 private bool CanEditObjectByIDs(UUID objectID, UUID userID)
1141 { 1359 {
1142 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1360 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1143 if (m_bypassPermissions) return m_bypassPermissionsValue; 1361 if (m_bypassPermissions) return m_bypassPermissionsValue;
1144 1362
1145 return GenericObjectPermission(deleter, objectID, false); 1363 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1364 if (sog == null)
1365 return false;
1366
1367 uint perms = GetObjectPermissions(userID, sog, true);
1368 if((perms & (uint)PermissionMask.Modify) == 0)
1369 return false;
1370 return true;
1146 } 1371 }
1147 1372
1148 private bool CanEditObject(UUID objectID, UUID editorID, Scene scene) 1373 private bool CanEditObject(SceneObjectGroup sog, ScenePresence sp)
1149 { 1374 {
1150 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1375 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1151 if (m_bypassPermissions) return m_bypassPermissionsValue; 1376 if (m_bypassPermissions) return m_bypassPermissionsValue;
1152 1377
1153 return GenericObjectPermission(editorID, objectID, false); 1378 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1379 return false;
1380
1381 uint perms = GetObjectPermissions(sp, sog, true);
1382 if((perms & (uint)PermissionMask.Modify) == 0)
1383 return false;
1384 return true;
1154 } 1385 }
1155 1386
1156 private bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene) 1387 private bool CanEditObjectInventory(UUID objectID, UUID userID)
1157 { 1388 {
1158 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1389 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1159 if (m_bypassPermissions) return m_bypassPermissionsValue; 1390 if (m_bypassPermissions) return m_bypassPermissionsValue;
1160 1391
1161 return GenericObjectPermission(editorID, objectID, false); 1392 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
1393 if (sog == null)
1394 return false;
1395
1396 uint perms = GetObjectPermissions(userID, sog, true);
1397 if((perms & (uint)PermissionMask.Modify) == 0)
1398 return false;
1399 return true;
1162 } 1400 }
1163 1401
1164 private bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager) 1402 private bool CanEditParcelProperties(UUID userID, ILandObject parcel, GroupPowers p, bool allowManager)
1165 { 1403 {
1166 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1404 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1167 if (m_bypassPermissions) return m_bypassPermissionsValue; 1405 if (m_bypassPermissions) return m_bypassPermissionsValue;
1168 1406
1169 return GenericParcelOwnerPermission(user, parcel, (ulong)p, false); 1407 return GenericParcelOwnerPermission(userID, parcel, (ulong)p, false);
1170 } 1408 }
1171 1409
1172 /// <summary> 1410 /// <summary>
@@ -1177,18 +1415,18 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1177 /// <param name="user"></param> 1415 /// <param name="user"></param>
1178 /// <param name="scene"></param> 1416 /// <param name="scene"></param>
1179 /// <returns></returns> 1417 /// <returns></returns>
1180 private bool CanEditScript(UUID script, UUID objectID, UUID user, Scene scene) 1418 private bool CanEditScript(UUID script, UUID objectID, UUID userID)
1181 { 1419 {
1182 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1420 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1183 if (m_bypassPermissions) return m_bypassPermissionsValue; 1421 if (m_bypassPermissions) return m_bypassPermissionsValue;
1184 1422
1185 if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(user)) 1423 if (m_allowedScriptEditors == UserSet.Administrators && !IsAdministrator(userID))
1186 return false; 1424 return false;
1187 1425
1188 // Ordinarily, if you can view it, you can edit it 1426 // Ordinarily, if you can view it, you can edit it
1189 // There is no viewing a no mod script 1427 // There is no viewing a no mod script
1190 // 1428 //
1191 return CanViewScript(script, objectID, user, scene); 1429 return CanViewScript(script, objectID, userID);
1192 } 1430 }
1193 1431
1194 /// <summary> 1432 /// <summary>
@@ -1199,7 +1437,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1199 /// <param name="user"></param> 1437 /// <param name="user"></param>
1200 /// <param name="scene"></param> 1438 /// <param name="scene"></param>
1201 /// <returns></returns> 1439 /// <returns></returns>
1202 private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) 1440 private bool CanEditNotecard(UUID notecard, UUID objectID, UUID user)
1203 { 1441 {
1204 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1442 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1205 if (m_bypassPermissions) return m_bypassPermissionsValue; 1443 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1230,69 +1468,68 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1230 } 1468 }
1231 else // Prim inventory 1469 else // Prim inventory
1232 { 1470 {
1233 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 1471 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1234
1235 if (part == null) 1472 if (part == null)
1236 return false; 1473 return false;
1237 1474
1238 if (part.OwnerID != user) 1475 SceneObjectGroup sog = part.ParentGroup;
1239 { 1476 if (sog == null)
1240 if (part.GroupID == UUID.Zero) 1477 return false;
1241 return false;
1242
1243 if (!IsGroupMember(part.GroupID, user, 0))
1244 return false;
1245 1478
1246 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 1479 // check object mod right
1247 return false; 1480 uint perms = GetObjectPermissions(user, sog, true);
1248 } 1481 if((perms & (uint)PermissionMask.Modify) == 0)
1249 else
1250 {
1251 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1252 return false; 1482 return false;
1253 }
1254 1483
1255 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); 1484 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
1256
1257 if (ti == null) 1485 if (ti == null)
1258 return false; 1486 return false;
1259 1487
1260 if (ti.OwnerID != user) 1488 if (ti.OwnerID != user)
1261 { 1489 {
1262 if (ti.GroupID == UUID.Zero) 1490 UUID tiGroupID = ti.GroupID;
1491 if (tiGroupID == UUID.Zero)
1263 return false; 1492 return false;
1264 1493
1265 if (!IsGroupMember(ti.GroupID, user, 0)) 1494 ulong powers = 0;
1495 if(!GroupMemberPowers(tiGroupID, user, ref powers))
1266 return false; 1496 return false;
1497
1498 if(tiGroupID == ti.OwnerID && (powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1499 {
1500 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) ==
1501 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1502 return true;
1503 }
1504 if ((ti.GroupPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) ==
1505 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1506 return true;
1507 return false;
1267 } 1508 }
1268 1509
1269 // Require full perms 1510 // Require full perms
1270 if ((ti.CurrentPermissions & 1511 if ((ti.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy)) !=
1271 ((uint)PermissionMask.Modify | 1512 ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy))
1272 (uint)PermissionMask.Copy)) !=
1273 ((uint)PermissionMask.Modify |
1274 (uint)PermissionMask.Copy))
1275 return false; 1513 return false;
1276 } 1514 }
1277
1278 return true; 1515 return true;
1279 } 1516 }
1280 1517
1281 private bool CanInstantMessage(UUID user, UUID target, Scene startScene) 1518 private bool CanInstantMessage(UUID user, UUID target)
1282 { 1519 {
1283 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1520 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1284 if (m_bypassPermissions) return m_bypassPermissionsValue; 1521 if (m_bypassPermissions) return m_bypassPermissionsValue;
1285 1522
1286 // If the sender is an object, check owner instead 1523 // If the sender is an object, check owner instead
1287 // 1524 //
1288 SceneObjectPart part = startScene.GetSceneObjectPart(user); 1525 SceneObjectPart part = m_scene.GetSceneObjectPart(user);
1289 if (part != null) 1526 if (part != null)
1290 user = part.OwnerID; 1527 user = part.OwnerID;
1291 1528
1292 return GenericCommunicationPermission(user, target); 1529 return GenericCommunicationPermission(user, target);
1293 } 1530 }
1294 1531
1295 private bool CanInventoryTransfer(UUID user, UUID target, Scene startScene) 1532 private bool CanInventoryTransfer(UUID user, UUID target)
1296 { 1533 {
1297 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1534 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1298 if (m_bypassPermissions) return m_bypassPermissionsValue; 1535 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1300,7 +1537,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1300 return GenericCommunicationPermission(user, target); 1537 return GenericCommunicationPermission(user, target);
1301 } 1538 }
1302 1539
1303 private bool CanIssueEstateCommand(UUID user, Scene requestFromScene, bool ownerCommand) 1540 private bool CanIssueEstateCommand(UUID user, bool ownerCommand)
1304 { 1541 {
1305 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1542 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1306 if (m_bypassPermissions) return m_bypassPermissionsValue; 1543 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1308,178 +1545,113 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1308 if (IsAdministrator(user)) 1545 if (IsAdministrator(user))
1309 return true; 1546 return true;
1310 1547
1311 if (m_scene.RegionInfo.EstateSettings.IsEstateOwner(user))
1312 return true;
1313
1314 if (ownerCommand) 1548 if (ownerCommand)
1315 return false; 1549 return m_scene.RegionInfo.EstateSettings.IsEstateOwner(user);
1316 1550
1317 return GenericEstatePermission(user); 1551 return IsEstateManager(user);
1318 } 1552 }
1319 1553
1320 private bool CanMoveObject(UUID objectID, UUID moverID, Scene scene) 1554 private bool CanMoveObject(SceneObjectGroup sog, ScenePresence sp)
1321 { 1555 {
1322 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1556 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1323 if (m_bypassPermissions)
1324 {
1325 SceneObjectPart part = scene.GetSceneObjectPart(objectID);
1326 if (part.OwnerID != moverID)
1327 {
1328 if (!part.ParentGroup.IsDeleted)
1329 {
1330 if (part.ParentGroup.IsAttachment)
1331 return false;
1332 }
1333 }
1334 return m_bypassPermissionsValue;
1335 }
1336
1337 bool permission = GenericObjectPermission(moverID, objectID, true);
1338 if (!permission)
1339 {
1340 if (!m_scene.Entities.ContainsKey(objectID))
1341 {
1342 return false;
1343 }
1344
1345 // The client
1346 // may request to edit linked parts, and therefore, it needs
1347 // to also check for SceneObjectPart
1348
1349 // If it's not an object, we cant edit it.
1350 if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
1351 {
1352 return false;
1353 }
1354
1355
1356 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID];
1357
1358
1359 // UUID taskOwner = null;
1360 // Added this because at this point in time it wouldn't be wise for
1361 // the administrator object permissions to take effect.
1362 // UUID objectOwner = task.OwnerID;
1363 1557
1364 // Anyone can move 1558 if(sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1365 if ((task.RootPart.EveryoneMask & PERM_MOVE) != 0) 1559 return false;
1366 permission = true;
1367 1560
1368 // Locked 1561 if (m_bypassPermissions)
1369 if ((task.RootPart.OwnerMask & PERM_LOCKED) == 0)
1370 permission = false;
1371 }
1372 else
1373 { 1562 {
1374 bool locked = false; 1563 if (sog.OwnerID != sp.UUID && sog.IsAttachment)
1375 if (!m_scene.Entities.ContainsKey(objectID))
1376 {
1377 return false;
1378 }
1379
1380 // If it's not an object, we cant edit it.
1381 if ((!(m_scene.Entities[objectID] is SceneObjectGroup)))
1382 {
1383 return false;
1384 }
1385
1386 SceneObjectGroup group = (SceneObjectGroup)m_scene.Entities[objectID];
1387
1388 UUID objectOwner = group.OwnerID;
1389 locked = ((group.RootPart.OwnerMask & PERM_LOCKED) == 0);
1390
1391 // This is an exception to the generic object permission.
1392 // Administrators who lock their objects should not be able to move them,
1393 // however generic object permission should return true.
1394 // This keeps locked objects from being affected by random click + drag actions by accident
1395 // and allows the administrator to grab or delete a locked object.
1396
1397 // Administrators and estate managers are still able to click+grab locked objects not
1398 // owned by them in the scene
1399 // This is by design.
1400
1401 if (locked && (moverID == objectOwner))
1402 return false; 1564 return false;
1565 return m_bypassPermissionsValue;
1403 } 1566 }
1404 return permission; 1567
1568 uint perms = GetObjectPermissions(sp, sog, true);
1569 if((perms & (uint)PermissionMask.Move) == 0)
1570 return false;
1571 return true;
1405 } 1572 }
1406 1573
1407 private bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 1574 private bool CanObjectEntry(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
1408 { 1575 {
1409 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1576 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1410 if (m_bypassPermissions) return m_bypassPermissionsValue;
1411 1577
1578 float newX = newPoint.X;
1579 float newY = newPoint.Y;
1412 1580
1413 // allow outide region?? 1581 // allow outside region this is needed for crossings
1414 if (newPoint.X < -1f || newPoint.Y < -1f) 1582 if (newX < -1f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
1583 newY < -1f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
1415 return true; 1584 return true;
1416 if (newPoint.X > scene.RegionInfo.RegionSizeX + 1.0f || newPoint.Y > scene.RegionInfo.RegionSizeY + 1.0f)
1417 {
1418 return true;
1419 }
1420 1585
1421 SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[objectID]; 1586 if(sog == null || sog.IsDeleted)
1587 return false;
1588
1589 if (m_bypassPermissions)
1590 return m_bypassPermissionsValue;
1591
1592 ILandObject parcel = m_scene.LandChannel.GetLandObject(newX, newY);
1593 if (parcel == null)
1594 return false;
1422 1595
1423 ILandObject land = m_scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); 1596 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0)
1597 return true;
1424 1598
1425 if (!enteringRegion) 1599 if (!enteringRegion)
1426 { 1600 {
1427 ILandObject fromland = m_scene.LandChannel.GetLandObject(task.AbsolutePosition.X, task.AbsolutePosition.Y); 1601 Vector3 oldPoint = sog.AbsolutePosition;
1428 1602 ILandObject fromparcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
1429 if (fromland == land) // Not entering 1603 if (fromparcel != null && fromparcel.Equals(parcel)) // it already entered parcel ????
1430 return true; 1604 return true;
1431 } 1605 }
1432 1606
1433 if (land == null) 1607 UUID userID = sog.OwnerID;
1434 { 1608 LandData landdata = parcel.LandData;
1435 return false;
1436 }
1437 1609
1438 if ((land.LandData.Flags & ((int)ParcelFlags.AllowAPrimitiveEntry)) != 0) 1610 if (landdata.OwnerID == userID)
1439 {
1440 return true; 1611 return true;
1441 }
1442 1612
1443 if (!m_scene.Entities.ContainsKey(objectID)) 1613 if (IsAdministrator(userID))
1444 { 1614 return true;
1445 return false;
1446 }
1447 1615
1448 // If it's not an object, we cant edit it. 1616 UUID landGroupID = landdata.GroupID;
1449 if (!(m_scene.Entities[objectID] is SceneObjectGroup)) 1617 if (landGroupID != UUID.Zero)
1450 { 1618 {
1451 return false; 1619 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowGroupObjectEntry)) != 0)
1452 } 1620 return IsGroupMember(landGroupID, userID, 0);
1453
1454 1621
1455 if (GenericParcelPermission(task.OwnerID, newPoint, 0)) 1622 if (landdata.IsGroupOwned && IsGroupMember(landGroupID, userID, (ulong)GroupPowers.AllowRez))
1456 { 1623 return true;
1457 return true;
1458 } 1624 }
1459 1625
1460 //Otherwise, false! 1626 //Otherwise, false!
1461 return false; 1627 return false;
1462 } 1628 }
1463 1629
1464 private bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene) 1630 private bool CanReturnObjects(ILandObject land, ScenePresence sp, List<SceneObjectGroup> objects)
1465 { 1631 {
1466 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1632 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1467 if (m_bypassPermissions) return m_bypassPermissionsValue; 1633 if (m_bypassPermissions) return m_bypassPermissionsValue;
1468 1634
1469 GroupPowers powers; 1635 if(sp == null)
1470 ILandObject l; 1636 return true; // assuming that in this case rights are as owner
1471 1637
1472 ScenePresence sp = scene.GetScenePresence(user); 1638 UUID userID = sp.UUID;
1473 if (sp == null) 1639 bool isPrivUser = sp.IsGod || IsEstateManager(userID);
1474 return false;
1475 1640
1476 IClientAPI client = sp.ControllingClient; 1641 IClientAPI client = sp.ControllingClient;
1477 1642
1643 ulong powers = 0;
1644 ILandObject l;
1645
1478 foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects)) 1646 foreach (SceneObjectGroup g in new List<SceneObjectGroup>(objects))
1479 { 1647 {
1480 // Any user can return their own objects at any time 1648 if(g.IsAttachment)
1481 // 1649 {
1482 if (GenericObjectPermission(user, g.UUID, false)) 1650 objects.Remove(g);
1651 continue;
1652 }
1653
1654 if (isPrivUser || g.OwnerID == userID)
1483 continue; 1655 continue;
1484 1656
1485 // This is a short cut for efficiency. If land is non-null, 1657 // This is a short cut for efficiency. If land is non-null,
@@ -1493,39 +1665,40 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1493 else 1665 else
1494 { 1666 {
1495 Vector3 pos = g.AbsolutePosition; 1667 Vector3 pos = g.AbsolutePosition;
1496 1668 l = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1497 l = scene.LandChannel.GetLandObject(pos.X, pos.Y);
1498 } 1669 }
1499 1670
1500 // If it's not over any land, then we can't do a thing 1671 // If it's not over any land, then we can't do a thing
1501 if (l == null) 1672 if (l == null || l.LandData == null)
1502 { 1673 {
1503 objects.Remove(g); 1674 objects.Remove(g);
1504 continue; 1675 continue;
1505 } 1676 }
1506 1677
1678 LandData ldata = l.LandData;
1507 // If we own the land outright, then allow 1679 // If we own the land outright, then allow
1508 // 1680 //
1509 if (l.LandData.OwnerID == user) 1681 if (ldata.OwnerID == userID)
1510 continue; 1682 continue;
1511 1683
1512 // Group voodoo 1684 // Group voodoo
1513 // 1685 //
1514 if (l.LandData.IsGroupOwned) 1686 if (ldata.IsGroupOwned)
1515 { 1687 {
1516 powers = (GroupPowers)client.GetGroupPowers(l.LandData.GroupID); 1688 UUID lGroupID = ldata.GroupID;
1517 // Not a group member, or no rights at all 1689 // Not a group member, or no rights at all
1518 // 1690 //
1519 if (powers == (GroupPowers)0) 1691 powers = client.GetGroupPowers(lGroupID);
1692 if(powers == 0)
1520 { 1693 {
1521 objects.Remove(g); 1694 objects.Remove(g);
1522 continue; 1695 continue;
1523 } 1696 }
1524 1697
1525 // Group deeded object? 1698 // Group deeded object?
1526 // 1699 //
1527 if (g.OwnerID == l.LandData.GroupID && 1700 if (g.OwnerID == lGroupID &&
1528 (powers & GroupPowers.ReturnGroupOwned) == (GroupPowers)0) 1701 (powers & (ulong)GroupPowers.ReturnGroupOwned) == 0)
1529 { 1702 {
1530 objects.Remove(g); 1703 objects.Remove(g);
1531 continue; 1704 continue;
@@ -1533,14 +1706,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1533 1706
1534 // Group set object? 1707 // Group set object?
1535 // 1708 //
1536 if (g.GroupID == l.LandData.GroupID && 1709 if (g.GroupID == lGroupID &&
1537 (powers & GroupPowers.ReturnGroupSet) == (GroupPowers)0) 1710 (powers & (ulong)GroupPowers.ReturnGroupSet) == 0)
1538 { 1711 {
1539 objects.Remove(g); 1712 objects.Remove(g);
1540 continue; 1713 continue;
1541 } 1714 }
1542 1715
1543 if ((powers & GroupPowers.ReturnNonGroup) == (GroupPowers)0) 1716 if ((powers & (ulong)GroupPowers.ReturnNonGroup) == 0)
1544 { 1717 {
1545 objects.Remove(g); 1718 objects.Remove(g);
1546 continue; 1719 continue;
@@ -1563,7 +1736,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1563 return true; 1736 return true;
1564 } 1737 }
1565 1738
1566 private bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene) 1739 private bool CanRezObject(int objectCount, UUID userID, Vector3 objectPosition)
1567 { 1740 {
1568 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1741 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1569 if (m_bypassPermissions) 1742 if (m_bypassPermissions)
@@ -1576,28 +1749,28 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1576 return false; 1749 return false;
1577 1750
1578 LandData landdata = parcel.LandData; 1751 LandData landdata = parcel.LandData;
1579 if ((owner == landdata.OwnerID)) 1752 if ((userID == landdata.OwnerID))
1580 return true; 1753 return true;
1581 1754
1582 if ((landdata.Flags & (uint)ParcelFlags.CreateObjects) != 0) 1755 if ((landdata.Flags & (uint)ParcelFlags.CreateObjects) != 0)
1583 return true; 1756 return true;
1584 1757
1585 if(IsAdministrator(owner)) 1758 if(IsAdministrator(userID))
1586 return true; 1759 return true;
1587 1760
1588 if(landdata.GroupID != UUID.Zero) 1761 if(landdata.GroupID != UUID.Zero)
1589 { 1762 {
1590 if ((landdata.Flags & (uint)ParcelFlags.CreateGroupObjects) != 0) 1763 if ((landdata.Flags & (uint)ParcelFlags.CreateGroupObjects) != 0)
1591 return IsGroupMember(landdata.GroupID, owner, 0); 1764 return IsGroupMember(landdata.GroupID, userID, 0);
1592 1765
1593 if (landdata.IsGroupOwned && IsGroupMember(landdata.GroupID, owner, (ulong)GroupPowers.AllowRez)) 1766 if (landdata.IsGroupOwned && IsGroupMember(landdata.GroupID, userID, (ulong)GroupPowers.AllowRez))
1594 return true; 1767 return true;
1595 } 1768 }
1596 1769
1597 return false; 1770 return false;
1598 } 1771 }
1599 1772
1600 private bool CanRunConsoleCommand(UUID user, Scene requestFromScene) 1773 private bool CanRunConsoleCommand(UUID user)
1601 { 1774 {
1602 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1775 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1603 if (m_bypassPermissions) return m_bypassPermissionsValue; 1776 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1606,15 +1779,43 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1606 return IsAdministrator(user); 1779 return IsAdministrator(user);
1607 } 1780 }
1608 1781
1609 private bool CanRunScript(UUID script, UUID objectID, UUID user, Scene scene) 1782 private bool CanRunScript(TaskInventoryItem scriptitem, SceneObjectPart part)
1610 { 1783 {
1611 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1784 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1612 if (m_bypassPermissions) return m_bypassPermissionsValue; 1785 if (m_bypassPermissions) return m_bypassPermissionsValue;
1613 1786
1614 return true; 1787 if(scriptitem == null || part == null)
1788 return false;
1789
1790 SceneObjectGroup sog = part.ParentGroup;
1791 if(sog == null)
1792 return false;
1793
1794 Vector3 pos = sog.AbsolutePosition;
1795 ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
1796 if (parcel == null)
1797 return false;
1798
1799 LandData ldata = parcel.LandData;
1800 if(ldata == null)
1801 return false;
1802
1803 uint lflags = ldata.Flags;
1804
1805 if ((lflags & (uint)ParcelFlags.AllowOtherScripts) != 0)
1806 return true;
1807
1808 if ((part.OwnerID == ldata.OwnerID))
1809 return true;
1810
1811 if (((lflags & (uint)ParcelFlags.AllowGroupScripts) != 0)
1812 && (ldata.GroupID != UUID.Zero) && (ldata.GroupID == part.GroupID))
1813 return true;
1814
1815 return GenericEstatePermission(part.OwnerID);
1615 } 1816 }
1616 1817
1617 private bool CanSellParcel(UUID user, ILandObject parcel, Scene scene) 1818 private bool CanSellParcel(UUID user, ILandObject parcel)
1618 { 1819 {
1619 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1820 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1620 if (m_bypassPermissions) return m_bypassPermissionsValue; 1821 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1622,7 +1823,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1622 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale, true); 1823 return GenericParcelOwnerPermission(user, parcel, (ulong)GroupPowers.LandSetSale, true);
1623 } 1824 }
1624 1825
1625 private bool CanSellGroupObject(UUID userID, UUID groupID, Scene scene) 1826 private bool CanSellGroupObject(UUID userID, UUID groupID)
1626 { 1827 {
1627 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1828 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1628 if (m_bypassPermissions) return m_bypassPermissionsValue; 1829 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1630,66 +1831,159 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1630 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale); 1831 return IsGroupMember(groupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1631 } 1832 }
1632 1833
1633 private bool CanTakeObject(UUID objectID, UUID stealer, Scene scene) 1834 private bool CanSellObjectByUserID(SceneObjectGroup sog, UUID userID, byte saleType)
1634 { 1835 {
1635 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1836 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1636 if (m_bypassPermissions) return m_bypassPermissionsValue; 1837 if (m_bypassPermissions) return m_bypassPermissionsValue;
1637 1838
1638 return GenericObjectPermission(stealer,objectID, false); 1839 if (sog == null || sog.IsDeleted || userID == UUID.Zero)
1840 return false;
1841
1842 // sell is not a attachment op
1843 if(sog.IsAttachment)
1844 return false;
1845
1846 if(IsAdministrator(userID))
1847 return true;
1848
1849 uint sogEffectiveOwnerPerms = sog.EffectiveOwnerPerms;
1850 if((sogEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1851 return false;
1852
1853 if(saleType == (byte)SaleType.Copy &&
1854 (sogEffectiveOwnerPerms & (uint)PermissionMask.Copy) == 0)
1855 return false;
1856
1857 UUID sogOwnerID = sog.OwnerID;
1858
1859 if(sogOwnerID == userID)
1860 return true;
1861
1862 // else only group owned can be sold by members with powers
1863 UUID sogGroupID = sog.GroupID;
1864 if(sog.OwnerID != sogGroupID || sogGroupID == UUID.Zero)
1865 return false;
1866
1867 return IsGroupMember(sogGroupID, userID, (ulong)GroupPowers.ObjectSetForSale);
1639 } 1868 }
1640 1869
1641 private bool CanTakeCopyObject(UUID objectID, UUID userID, Scene inScene) 1870 private bool CanSellObject(SceneObjectGroup sog, ScenePresence sp, byte saleType)
1642 { 1871 {
1643 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1872 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1644 if (m_bypassPermissions) return m_bypassPermissionsValue; 1873 if (m_bypassPermissions) return m_bypassPermissionsValue;
1645 1874
1646 bool permission = GenericObjectPermission(userID, objectID, false); 1875 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1876 return false;
1647 1877
1648 SceneObjectGroup so = (SceneObjectGroup)m_scene.Entities[objectID]; 1878 // sell is not a attachment op
1879 if(sog.IsAttachment)
1880 return false;
1649 1881
1650 if (!permission) 1882 if(sp.IsGod)
1651 { 1883 return true;
1652 if (!m_scene.Entities.ContainsKey(objectID))
1653 {
1654 return false;
1655 }
1656 1884
1657 // If it's not an object, we cant edit it. 1885 uint sogEffectiveOwnerPerms = sog.EffectiveOwnerPerms;
1658 if (!(m_scene.Entities[objectID] is SceneObjectGroup)) 1886 if((sogEffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1659 { 1887 return false;
1660 return false;
1661 }
1662 1888
1663 // UUID taskOwner = null; 1889 if(saleType == (byte)SaleType.Copy &&
1664 // Added this because at this point in time it wouldn't be wise for 1890 (sogEffectiveOwnerPerms & (uint)PermissionMask.Copy) == 0)
1665 // the administrator object permissions to take effect. 1891 return false;
1666 // UUID objectOwner = task.OwnerID;
1667 1892
1668 if ((so.RootPart.EveryoneMask & PERM_COPY) != 0) 1893 UUID userID = sp.UUID;
1669 permission = true; 1894 UUID sogOwnerID = sog.OwnerID;
1670 }
1671 1895
1672 if (so.OwnerID != userID) 1896 if(sogOwnerID == userID)
1673 { 1897 return true;
1674 if ((so.GetEffectivePermissions() & (PERM_COPY | PERM_TRANS)) != (PERM_COPY | PERM_TRANS)) 1898
1675 permission = false; 1899 // else only group owned can be sold by members with powers
1676 } 1900 UUID sogGroupID = sog.GroupID;
1677 else 1901 if(sog.OwnerID != sogGroupID || sogGroupID == UUID.Zero)
1902 return false;
1903
1904 ulong powers = 0;
1905 if(!GroupMemberPowers(sogGroupID, sp, ref powers))
1906 return false;
1907
1908 if((powers & (ulong)GroupPowers.ObjectSetForSale) == 0)
1909 return false;
1910
1911 return true;
1912 }
1913
1914 private bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
1915 {
1916 // ignore locked, viewers shell ask for confirmation
1917 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1918 if (m_bypassPermissions) return m_bypassPermissionsValue;
1919
1920 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1921 return false;
1922
1923 // take is not a attachment op
1924 if(sog.IsAttachment)
1925 return false;
1926
1927 UUID sogOwnerID = sog.OwnerID;
1928 UUID spID = sp.UUID;
1929
1930 if(sogOwnerID == spID)
1931 return true;
1932
1933 if (sp.IsGod)
1934 return true;
1935
1936 if((sog.EffectiveOwnerPerms & (uint)PermissionMask.Transfer) == 0)
1937 return false;
1938
1939 if (IsFriendWithPerms(sog.UUID, sogOwnerID))
1940 return true;
1941
1942 UUID sogGroupID = sog.GroupID;
1943 if (sogGroupID != UUID.Zero)
1678 { 1944 {
1679 if ((so.GetEffectivePermissions() & PERM_COPY) != PERM_COPY) 1945 ulong powers = 0;
1680 permission = false; 1946 if(GroupMemberPowers(sogGroupID, sp, ref powers))
1947 {
1948 if(sogGroupID == sogOwnerID)
1949 {
1950 if((powers & (ulong)GroupPowers.ObjectManipulate) != 0)
1951 return true;
1952 }
1953 return (sog.EffectiveGroupPerms & (uint)PermissionMask.Modify) != 0;
1954 }
1681 } 1955 }
1956 return false;
1957 }
1682 1958
1683 return permission; 1959 private bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
1960 {
1961 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1962 if (m_bypassPermissions) return m_bypassPermissionsValue;
1963
1964 if (sog == null || sog.IsDeleted || sp == null || sp.IsDeleted)
1965 return false;
1966
1967 // refuse on attachments
1968 if(sog.IsAttachment && !sp.IsGod)
1969 return false;
1970
1971 uint perms = GetObjectPermissions(sp, sog, true);
1972 if((perms & (uint)PermissionMask.Copy) == 0)
1973 return false;
1974
1975 if(sog.OwnerID != sp.UUID && (perms & (uint)PermissionMask.Transfer) == 0)
1976 return false;
1977 return true;
1684 } 1978 }
1685 1979
1686 private bool CanTerraformLand(UUID user, Vector3 position, Scene requestFromScene) 1980 private bool CanTerraformLand(UUID userID, Vector3 position)
1687 { 1981 {
1688 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 1982 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1689 if (m_bypassPermissions) return m_bypassPermissionsValue; 1983 if (m_bypassPermissions) return m_bypassPermissionsValue;
1690 1984
1691 // Estate override 1985 // Estate override
1692 if (GenericEstatePermission(user)) 1986 if (GenericEstatePermission(userID))
1693 return true; 1987 return true;
1694 1988
1695 float X = position.X; 1989 float X = position.X;
@@ -1707,13 +2001,19 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1707 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y); 2001 ILandObject parcel = m_scene.LandChannel.GetLandObject(X, Y);
1708 if (parcel == null) 2002 if (parcel == null)
1709 return false; 2003 return false;
1710 2004
1711 // Others allowed to terraform? 2005 LandData landdata = parcel.LandData;
1712 if ((parcel.LandData.Flags & ((int)ParcelFlags.AllowTerraform)) != 0) 2006 if (landdata == null)
2007 return false;
2008
2009 if ((landdata.Flags & ((int)ParcelFlags.AllowTerraform)) != 0)
1713 return true; 2010 return true;
1714 2011
1715 // Land owner can terraform too 2012 if(landdata.OwnerID == userID)
1716 if (parcel != null && GenericParcelPermission(user, parcel, (ulong)GroupPowers.AllowEditLand)) 2013 return true;
2014
2015 if (landdata.IsGroupOwned && parcel.LandData.GroupID != UUID.Zero &&
2016 IsGroupMember(landdata.GroupID, userID, (ulong)GroupPowers.AllowEditLand))
1717 return true; 2017 return true;
1718 2018
1719 return false; 2019 return false;
@@ -1727,7 +2027,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1727 /// <param name="user"></param> 2027 /// <param name="user"></param>
1728 /// <param name="scene"></param> 2028 /// <param name="scene"></param>
1729 /// <returns></returns> 2029 /// <returns></returns>
1730 private bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene) 2030 private bool CanViewScript(UUID script, UUID objectID, UUID userID)
1731 { 2031 {
1732 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2032 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1733 if (m_bypassPermissions) return m_bypassPermissionsValue; 2033 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1739,7 +2039,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1739 if (objectID == UUID.Zero) // User inventory 2039 if (objectID == UUID.Zero) // User inventory
1740 { 2040 {
1741 IInventoryService invService = m_scene.InventoryService; 2041 IInventoryService invService = m_scene.InventoryService;
1742 InventoryItemBase assetRequestItem = invService.GetItem(user, script); 2042 InventoryItemBase assetRequestItem = invService.GetItem(userID, script);
1743 if (assetRequestItem == null && LibraryRootFolder != null) // Library item 2043 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1744 { 2044 {
1745 assetRequestItem = LibraryRootFolder.FindItem(script); 2045 assetRequestItem = LibraryRootFolder.FindItem(script);
@@ -1759,60 +2059,53 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1759 // readable only if it's really full perms 2059 // readable only if it's really full perms
1760 // 2060 //
1761 if ((assetRequestItem.CurrentPermissions & 2061 if ((assetRequestItem.CurrentPermissions &
2062/*
1762 ((uint)PermissionMask.Modify | 2063 ((uint)PermissionMask.Modify |
1763 (uint)PermissionMask.Copy | 2064 (uint)PermissionMask.Copy |
1764 (uint)PermissionMask.Transfer)) != 2065 (uint)PermissionMask.Transfer)) !=
1765 ((uint)PermissionMask.Modify | 2066 ((uint)PermissionMask.Modify |
1766 (uint)PermissionMask.Copy | 2067 (uint)PermissionMask.Copy |
1767 (uint)PermissionMask.Transfer)) 2068 (uint)PermissionMask.Transfer))
2069*/
2070 (uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
2071 (uint)(PermissionMask.Modify | PermissionMask.Copy))
1768 return false; 2072 return false;
1769 } 2073 }
1770 else // Prim inventory 2074 else // Prim inventory
1771 { 2075 {
1772 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 2076 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1773
1774 if (part == null) 2077 if (part == null)
1775 return false; 2078 return false;
1776 2079
1777 if (part.OwnerID != user) 2080 SceneObjectGroup sog = part.ParentGroup;
1778 { 2081 if (sog == null)
1779 if (part.GroupID == UUID.Zero) 2082 return false;
1780 return false;
1781
1782 if (!IsGroupMember(part.GroupID, user, 0))
1783 return false;
1784 2083
1785 if ((part.GroupMask & (uint)PermissionMask.Modify) == 0) 2084 uint perms = GetObjectPermissions(userID, sog, true);
1786 return false; 2085 if((perms & (uint)PermissionMask.Modify) == 0)
1787 } 2086 return false;
1788 else
1789 {
1790 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1791 return false;
1792 }
1793 2087
1794 TaskInventoryItem ti = part.Inventory.GetInventoryItem(script); 2088 TaskInventoryItem ti = part.Inventory.GetInventoryItem(script);
1795 2089
1796 if (ti == null) 2090// if (ti == null || ti.InvType != (int)InventoryType.LSL)
2091 if (ti == null) // legacy may not have type
1797 return false; 2092 return false;
1798 2093
1799 if (ti.OwnerID != user) 2094 uint itperms = GetObjectItemPermissions(userID, ti);
1800 {
1801 if (ti.GroupID == UUID.Zero)
1802 return false;
1803
1804 if (!IsGroupMember(ti.GroupID, user, 0))
1805 return false;
1806 }
1807 2095
1808 // Require full perms 2096 // Require full perms
1809 if ((ti.CurrentPermissions & 2097
1810 ((uint)PermissionMask.Modify | 2098 if ((itperms &
2099/*
2100 ((uint)(PermissionMask.Modify |
1811 (uint)PermissionMask.Copy | 2101 (uint)PermissionMask.Copy |
1812 (uint)PermissionMask.Transfer)) != 2102 (uint)PermissionMask.Transfer)) !=
1813 ((uint)PermissionMask.Modify | 2103 ((uint)PermissionMask.Modify |
1814 (uint)PermissionMask.Copy | 2104 (uint)PermissionMask.Copy |
1815 (uint)PermissionMask.Transfer)) 2105 (uint)PermissionMask.Transfer))
2106*/
2107 (uint)(PermissionMask.Modify | PermissionMask.Copy)) !=
2108 (uint)(PermissionMask.Modify | PermissionMask.Copy))
1816 return false; 2109 return false;
1817 } 2110 }
1818 2111
@@ -1827,7 +2120,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1827 /// <param name="user"></param> 2120 /// <param name="user"></param>
1828 /// <param name="scene"></param> 2121 /// <param name="scene"></param>
1829 /// <returns></returns> 2122 /// <returns></returns>
1830 private bool CanViewNotecard(UUID notecard, UUID objectID, UUID user, Scene scene) 2123 private bool CanViewNotecard(UUID notecard, UUID objectID, UUID userID)
1831 { 2124 {
1832 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2125 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1833 if (m_bypassPermissions) return m_bypassPermissionsValue; 2126 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1839,7 +2132,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1839 if (objectID == UUID.Zero) // User inventory 2132 if (objectID == UUID.Zero) // User inventory
1840 { 2133 {
1841 IInventoryService invService = m_scene.InventoryService; 2134 IInventoryService invService = m_scene.InventoryService;
1842 InventoryItemBase assetRequestItem = invService.GetItem(user, notecard); 2135 InventoryItemBase assetRequestItem = invService.GetItem(userID, notecard);
1843 if (assetRequestItem == null && LibraryRootFolder != null) // Library item 2136 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1844 { 2137 {
1845 assetRequestItem = LibraryRootFolder.FindItem(notecard); 2138 assetRequestItem = LibraryRootFolder.FindItem(notecard);
@@ -1857,40 +2150,29 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1857 } 2150 }
1858 else // Prim inventory 2151 else // Prim inventory
1859 { 2152 {
1860 SceneObjectPart part = scene.GetSceneObjectPart(objectID); 2153 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1861
1862 if (part == null) 2154 if (part == null)
1863 return false; 2155 return false;
1864 2156
1865 if (part.OwnerID != user) 2157 SceneObjectGroup sog = part.ParentGroup;
1866 { 2158 if (sog == null)
1867 if (part.GroupID == UUID.Zero) 2159 return false;
1868 return false;
1869
1870 if (!IsGroupMember(part.GroupID, user, 0))
1871 return false;
1872 }
1873 2160
1874 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) 2161 uint perms = GetObjectPermissions(userID, sog, true);
2162 if((perms & (uint)PermissionMask.Modify) == 0)
1875 return false; 2163 return false;
1876 2164
1877 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard); 2165 TaskInventoryItem ti = part.Inventory.GetInventoryItem(notecard);
1878 2166
2167// if (ti == null || ti.InvType != (int)InventoryType.Notecard)
1879 if (ti == null) 2168 if (ti == null)
1880 return false; 2169 return false;
1881 2170
1882 if (ti.OwnerID != user) 2171 uint itperms = GetObjectItemPermissions(userID, ti);
1883 {
1884 if (ti.GroupID == UUID.Zero)
1885 return false;
1886
1887 if (!IsGroupMember(ti.GroupID, user, 0))
1888 return false;
1889 }
1890 2172
1891 // Notecards are always readable unless no copy 2173 // Notecards are always readable unless no copy
1892 // 2174 //
1893 if ((ti.CurrentPermissions & 2175 if ((itperms &
1894 (uint)PermissionMask.Copy) != 2176 (uint)PermissionMask.Copy) !=
1895 (uint)PermissionMask.Copy) 2177 (uint)PermissionMask.Copy)
1896 return false; 2178 return false;
@@ -1906,7 +2188,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1906 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2188 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1907 if (m_bypassPermissions) return m_bypassPermissionsValue; 2189 if (m_bypassPermissions) return m_bypassPermissionsValue;
1908 2190
1909 return GenericObjectPermission(userID, objectID, false); 2191 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2192 if (sog == null)
2193 return false;
2194
2195 uint perms = GetObjectPermissions(userID, sog, true);
2196 if((perms & (uint)PermissionMask.Modify) == 0)
2197 return false;
2198 return true;
1910 } 2199 }
1911 2200
1912 private bool CanDelinkObject(UUID userID, UUID objectID) 2201 private bool CanDelinkObject(UUID userID, UUID objectID)
@@ -1914,10 +2203,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1914 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2203 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1915 if (m_bypassPermissions) return m_bypassPermissionsValue; 2204 if (m_bypassPermissions) return m_bypassPermissionsValue;
1916 2205
1917 return GenericObjectPermission(userID, objectID, false); 2206 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2207 if (sog == null)
2208 return false;
2209
2210 uint perms = GetObjectPermissions(userID, sog, true);
2211 if((perms & (uint)PermissionMask.Modify) == 0)
2212 return false;
2213 return true;
1918 } 2214 }
1919 2215
1920 private bool CanBuyLand(UUID userID, ILandObject parcel, Scene scene) 2216 private bool CanBuyLand(UUID userID, ILandObject parcel)
1921 { 2217 {
1922 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2218 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1923 if (m_bypassPermissions) return m_bypassPermissionsValue; 2219 if (m_bypassPermissions) return m_bypassPermissionsValue;
@@ -1930,6 +2226,130 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1930 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2226 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1931 if (m_bypassPermissions) return m_bypassPermissionsValue; 2227 if (m_bypassPermissions) return m_bypassPermissionsValue;
1932 2228
2229 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
2230 if (part == null)
2231 return false;
2232
2233 SceneObjectGroup sog = part.ParentGroup;
2234 if (sog == null)
2235 return false;
2236
2237 uint perms = GetObjectPermissions(userID, sog, true);
2238 if((perms & (uint)PermissionMask.Modify) == 0)
2239 return false;
2240
2241 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
2242 if(ti == null)
2243 return false;
2244
2245 uint itperms = GetObjectItemPermissions(userID, ti);
2246
2247 if((itperms & (uint)PermissionMask.Copy) == 0)
2248 return false;
2249
2250 if(sog.OwnerID != userID && (itperms & (uint)PermissionMask.Transfer) == 0)
2251 return false;
2252
2253 return true;
2254 }
2255
2256 // object inventory to object inventory item drag and drop
2257 private bool CanDoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart)
2258 {
2259 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2260
2261 if (sourcePart == null || destPart == null || item == null)
2262 return false;
2263
2264 if (m_bypassPermissions)
2265 return m_bypassPermissionsValue;
2266
2267 SceneObjectGroup srcsog = sourcePart.ParentGroup;
2268 SceneObjectGroup destsog = destPart.ParentGroup;
2269 if (srcsog == null || destsog == null)
2270 return false;
2271
2272 // dest is locked
2273 if((destsog.EffectiveOwnerPerms & (uint)PermissionMask.Move) == 0)
2274 return false;
2275
2276 uint itperms = item.CurrentPermissions;
2277
2278 // if item is no copy the source is modifed
2279 if((itperms & (uint)PermissionMask.Copy) == 0 && (srcsog.EffectiveOwnerPerms & (uint)PermissionMask.Modify) == 0)
2280 return false;
2281
2282 UUID srcOwner = srcsog.OwnerID;
2283 UUID destOwner = destsog.OwnerID;
2284 bool notSameOwner = srcOwner != destOwner;
2285
2286 if(notSameOwner)
2287 {
2288 if((itperms & (uint)PermissionMask.Transfer) == 0)
2289 return false;
2290
2291 // scripts can't be droped
2292 if(item.InvType == (int)InventoryType.LSL)
2293 return false;
2294
2295 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
2296 return false;
2297 }
2298 else
2299 {
2300 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0 &&
2301 (destsog.EffectiveOwnerPerms & (uint)PermissionMask.Modify) == 0)
2302 return false;
2303 }
2304
2305 return true;
2306 }
2307
2308 private bool CanDropInObjectInv(InventoryItemBase item, ScenePresence sp, SceneObjectPart destPart)
2309 {
2310 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2311
2312 if (sp == null || sp.IsDeleted || destPart == null || item == null)
2313 return false;
2314
2315 SceneObjectGroup destsog = destPart.ParentGroup;
2316 if (destsog == null || destsog.IsDeleted)
2317 return false;
2318
2319 if (m_bypassPermissions)
2320 return m_bypassPermissionsValue;
2321
2322 if(sp.IsGod)
2323 return true;
2324
2325 // dest is locked
2326 if((destsog.EffectiveOwnerPerms & (uint)PermissionMask.Move) == 0)
2327 return false;
2328
2329 UUID destOwner = destsog.OwnerID;
2330 UUID spID = sp.UUID;
2331 bool spNotOwner = spID != destOwner;
2332
2333 // scripts can't be droped
2334 if(spNotOwner && item.InvType == (int)InventoryType.LSL)
2335 return false;
2336
2337 if(spNotOwner || item.Owner != destOwner)
2338 {
2339 // no copy item will be moved if it has transfer
2340 uint itperms = item.CurrentPermissions;
2341 if((itperms & (uint)PermissionMask.Transfer) == 0)
2342 return false;
2343 }
2344
2345 // allowdrop is a root part thing and does bypass modify rights
2346 if((destsog.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
2347 return true;
2348
2349 uint perms = GetObjectPermissions(spID, destsog, true);
2350 if((perms & (uint)PermissionMask.Modify) == 0)
2351 return false;
2352
1933 return true; 2353 return true;
1934 } 2354 }
1935 2355
@@ -1938,6 +2358,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1938 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2358 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1939 if (m_bypassPermissions) return m_bypassPermissionsValue; 2359 if (m_bypassPermissions) return m_bypassPermissionsValue;
1940 2360
2361 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
2362 if (part == null)
2363 return false;
2364
2365 SceneObjectGroup sog = part.ParentGroup;
2366 if (sog == null)
2367 return false;
2368
2369 uint perms = GetObjectPermissions(userID, sog, true);
2370 if((perms & (uint)PermissionMask.Modify) == 0)
2371 return false;
2372
2373 TaskInventoryItem ti = part.Inventory.GetInventoryItem(itemID);
2374 if(ti == null)
2375 return false;
2376
2377 //TODO item perm ?
1941 return true; 2378 return true;
1942 } 2379 }
1943 2380
@@ -1954,26 +2391,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1954 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2391 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
1955 if (m_bypassPermissions) return m_bypassPermissionsValue; 2392 if (m_bypassPermissions) return m_bypassPermissionsValue;
1956 2393
1957 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
1958 ScenePresence p = m_scene.GetScenePresence(userID); 2394 ScenePresence p = m_scene.GetScenePresence(userID);
1959 2395
1960 if (part == null || p == null) 2396 if (p == null)
2397 return false;
2398
2399 SceneObjectGroup sog = m_scene.GetGroupByPrim(objectID);
2400 if (sog == null)
2401 return false;
2402
2403 uint perms = GetObjectPermissions(userID, sog, true);
2404 if((perms & (uint)PermissionMask.Modify) == 0)
1961 return false; 2405 return false;
1962 2406
1963 if (!IsAdministrator(userID)) 2407 if ((int)InventoryType.LSL == invType)
1964 { 2408 {
1965 if (part.OwnerID != userID) 2409 if (m_allowedScriptCreators == UserSet.Administrators)
1966 { 2410 return false;
1967 // Group permissions
1968 if ((part.GroupID == UUID.Zero) || (p.ControllingClient.GetGroupPowers(part.GroupID) == 0) || ((part.GroupMask & (uint)PermissionMask.Modify) == 0))
1969 return false;
1970 } else {
1971 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
1972 return false;
1973 }
1974 if ((int)InventoryType.LSL == invType)
1975 if (m_allowedScriptCreators == UserSet.Administrators)
1976 return false;
1977 } 2411 }
1978 2412
1979 return true; 2413 return true;
@@ -2047,22 +2481,22 @@ namespace OpenSim.Region.CoreModules.World.Permissions
2047 return true; 2481 return true;
2048 } 2482 }
2049 2483
2050 private bool CanResetScript(UUID prim, UUID script, UUID agentID, Scene scene) 2484 private bool CanResetScript(UUID primID, UUID script, UUID agentID)
2051 { 2485 {
2052 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 2486 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
2053 if (m_bypassPermissions) return m_bypassPermissionsValue; 2487 if (m_bypassPermissions) return m_bypassPermissionsValue;
2054 2488
2055 SceneObjectPart part = m_scene.GetSceneObjectPart(prim); 2489 SceneObjectGroup sog = m_scene.GetGroupByPrim(primID);
2056 2490 if (sog == null)
2057 // If we selected a sub-prim to reset, prim won't represent the object, but only a part. 2491 return false;
2058 // We have to check the permissions of the object, though.
2059 if (part.ParentID != 0) prim = part.ParentUUID;
2060 2492
2061 // You can reset the scripts in any object you can edit 2493 uint perms = GetObjectPermissions(agentID, sog, false);
2062 return GenericObjectPermission(agentID, prim, false); 2494 if((perms & (uint)PermissionMask.Modify) == 0) // ??
2495 return false;
2496 return true;
2063 } 2497 }
2064 2498
2065 private bool CanCompileScript(UUID ownerUUID, int scriptType, Scene scene) 2499 private bool CanCompileScript(UUID ownerUUID, int scriptType)
2066 { 2500 {
2067 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType); 2501 //m_log.DebugFormat("check if {0} is allowed to compile {1}", ownerUUID, scriptType);
2068 switch (scriptType) { 2502 switch (scriptType) {
@@ -2120,7 +2554,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions
2120// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", 2554// "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}",
2121// agentID, primID, face, me.ControlPermissions); 2555// agentID, primID, face, me.ControlPermissions);
2122 2556
2123 return GenericObjectPermission(agentID, part.ParentGroup.UUID, true); 2557 SceneObjectGroup sog = part.ParentGroup;
2558 if (sog == null)
2559 return false;
2560
2561 uint perms = GetObjectPermissions(agentID, sog, false);
2562 if((perms & (uint)PermissionMask.Modify) == 0)
2563 return false;
2564 return true;
2124 } 2565 }
2125 2566
2126 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) 2567 private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face)
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
index 04b6f00..167f6b5 100644
--- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
+++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs
@@ -105,8 +105,9 @@ namespace OpenSim.Region.CoreModules.World.Vegetation
105 if (rootPart.Shape.PCode != (byte)PCode.Grass) 105 if (rootPart.Shape.PCode != (byte)PCode.Grass)
106 AdaptTree(ref shape); 106 AdaptTree(ref shape);
107 107
108 m_scene.AddNewSceneObject(sceneObject, true);
109 sceneObject.SetGroup(groupID, null); 108 sceneObject.SetGroup(groupID, null);
109 m_scene.AddNewSceneObject(sceneObject, true);
110 sceneObject.AggregatePerms();
110 111
111 return sceneObject; 112 return sceneObject;
112 } 113 }
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 0c4017e..e7c2428 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -278,6 +278,8 @@ namespace OpenSim.Region.Framework.Interfaces
278 /// <param name="datastore"></param> 278 /// <param name="datastore"></param>
279 void ProcessInventoryBackup(ISimulationDataService datastore); 279 void ProcessInventoryBackup(ISimulationDataService datastore);
280 280
281 void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone);
282
281 uint MaskEffectivePermissions(); 283 uint MaskEffectivePermissions();
282 284
283 void ApplyNextOwnerPermissions(); 285 void ApplyNextOwnerPermissions();
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index c1faf21..2f016fa 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -338,6 +338,7 @@ namespace OpenSim.Region.Framework.Scenes
338 // Update item with new asset 338 // Update item with new asset
339 item.AssetID = asset.FullID; 339 item.AssetID = asset.FullID;
340 group.UpdateInventoryItem(item); 340 group.UpdateInventoryItem(item);
341 group.AggregatePerms();
341 342
342 part.SendPropertiesToClient(remoteClient); 343 part.SendPropertiesToClient(remoteClient);
343 344
@@ -1214,6 +1215,7 @@ namespace OpenSim.Region.Framework.Scenes
1214 } 1215 }
1215 1216
1216 group.RemoveInventoryItem(localID, itemID); 1217 group.RemoveInventoryItem(localID, itemID);
1218 group.AggregatePerms();
1217 } 1219 }
1218 1220
1219 part.SendPropertiesToClient(remoteClient); 1221 part.SendPropertiesToClient(remoteClient);
@@ -1378,18 +1380,10 @@ namespace OpenSim.Region.Framework.Scenes
1378 return; 1380 return;
1379 } 1381 }
1380 1382
1381 if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1383 if (!Permissions.CanCopyObjectInventory(itemId, part.UUID, remoteClient.AgentId))
1382 { 1384 {
1383 // If the item to be moved is no copy, we need to be able to 1385 // check also if we can delete the no copy item
1384 // edit the prim. 1386 if(!Permissions.CanEditObject(part.UUID, remoteClient.AgentId))
1385 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1386 return;
1387 }
1388 else
1389 {
1390 // If the item is copiable, then we just need to have perms
1391 // on it. The delete check is a pure rights check
1392 if (!Permissions.CanDeleteObject(part.UUID, remoteClient.AgentId))
1393 return; 1387 return;
1394 } 1388 }
1395 1389
@@ -1467,28 +1461,8 @@ namespace OpenSim.Region.Framework.Scenes
1467 return; 1461 return;
1468 } 1462 }
1469 1463
1470 // Can't transfer this 1464 if(!Permissions.CanDoObjectInvToObjectInv(srcTaskItem, part, destPart))
1471 //
1472 if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
1473 return;
1474
1475 bool overrideNoMod = false;
1476 if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0)
1477 overrideNoMod = true;
1478
1479 if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0)
1480 {
1481 // object cannot copy items to an object owned by a different owner
1482 // unless llAllowInventoryDrop has been called
1483
1484 return;
1485 }
1486
1487 // must have both move and modify permission to put an item in an object
1488 if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod))
1489 {
1490 return; 1465 return;
1491 }
1492 1466
1493 TaskInventoryItem destTaskItem = new TaskInventoryItem(); 1467 TaskInventoryItem destTaskItem = new TaskInventoryItem();
1494 1468
@@ -1530,9 +1504,10 @@ namespace OpenSim.Region.Framework.Scenes
1530 destTaskItem.Type = srcTaskItem.Type; 1504 destTaskItem.Type = srcTaskItem.Type;
1531 1505
1532 destPart.Inventory.AddInventoryItem(destTaskItem, part.OwnerID != destPart.OwnerID); 1506 destPart.Inventory.AddInventoryItem(destTaskItem, part.OwnerID != destPart.OwnerID);
1533
1534 if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1507 if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1508 {
1535 part.Inventory.RemoveInventoryItem(itemId); 1509 part.Inventory.RemoveInventoryItem(itemId);
1510 }
1536 1511
1537 ScenePresence avatar; 1512 ScenePresence avatar;
1538 1513
@@ -1670,76 +1645,79 @@ namespace OpenSim.Region.Framework.Scenes
1670 uint primLocalID) 1645 uint primLocalID)
1671 { 1646 {
1672 UUID itemID = itemInfo.ItemID; 1647 UUID itemID = itemInfo.ItemID;
1648 if (itemID == UUID.Zero)
1649 {
1650 m_log.ErrorFormat(
1651 "[PRIM INVENTORY]: UpdateTaskInventory called with item ID Zero on update for {1}!",
1652 remoteClient.Name);
1653 return;
1654 }
1673 1655
1674 // Find the prim we're dealing with 1656 // Find the prim we're dealing with
1675 SceneObjectPart part = GetSceneObjectPart(primLocalID); 1657 SceneObjectPart part = GetSceneObjectPart(primLocalID);
1658 if(part == null)
1659 {
1660 m_log.WarnFormat(
1661 "[PRIM INVENTORY]: " +
1662 "Update with item {0} requested of prim {1} for {2} but this prim does not exist",
1663 itemID, primLocalID, remoteClient.Name);
1664 return;
1665 }
1676 1666
1677 if (part != null) 1667 TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID);
1668
1669 if (currentItem == null)
1678 { 1670 {
1679 TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID); 1671 InventoryItemBase item = InventoryService.GetItem(remoteClient.AgentId, itemID);
1680 bool allowInventoryDrop = (part.GetEffectiveObjectFlags()
1681 & (uint)PrimFlags.AllowInventoryDrop) != 0;
1682 1672
1683 // Explicity allow anyone to add to the inventory if the 1673 // if not found Try library
1684 // AllowInventoryDrop flag has been set. Don't however let 1674 if (item == null && LibraryService != null && LibraryService.LibraryRootFolder != null)
1685 // them update an item unless they pass the external checks 1675 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1686 //
1687 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)
1688 && (currentItem != null || !allowInventoryDrop))
1689 return;
1690 1676
1691 if (currentItem == null) 1677 if(item == null)
1692 { 1678 {
1693 UUID copyID = UUID.Random(); 1679 m_log.ErrorFormat(
1694 if (itemID != UUID.Zero) 1680 "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
1695 { 1681 itemID, remoteClient.Name);
1696 InventoryItemBase item = InventoryService.GetItem(remoteClient.AgentId, itemID); 1682 return;
1683 }
1697 1684
1698 // Try library 1685 if (!Permissions.CanDropInObjectInv(item, remoteClient, part))
1699 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) 1686 return;
1700 {
1701 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1702 }
1703 1687
1704 // If we've found the item in the user's inventory or in the library 1688 UUID copyID = UUID.Random();
1705 if (item != null) 1689 bool modrights = Permissions.CanEditObject(part.ParentGroup, remoteClient);
1706 { 1690 part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID, modrights);
1707 part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID); 1691 m_log.InfoFormat(
1708 m_log.InfoFormat( 1692 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
1709 "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", 1693 item.Name, primLocalID, remoteClient.Name);
1710 item.Name, primLocalID, remoteClient.Name); 1694 part.SendPropertiesToClient(remoteClient);
1711 part.SendPropertiesToClient(remoteClient); 1695 if (!Permissions.BypassPermissions())
1712 if (!Permissions.BypassPermissions()) 1696 {
1713 { 1697 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
1714 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1698 {
1715 { 1699 List<UUID> uuids = new List<UUID>();
1716 List<UUID> uuids = new List<UUID>(); 1700 uuids.Add(itemID);
1717 uuids.Add(itemID); 1701 RemoveInventoryItem(remoteClient, uuids);
1718 RemoveInventoryItem(remoteClient, uuids);
1719 }
1720 }
1721 }
1722 else
1723 {
1724 m_log.ErrorFormat(
1725 "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
1726 itemID, remoteClient.Name);
1727 }
1728 } 1702 }
1729 } 1703 }
1730 else // Updating existing item with new perms etc 1704 }
1731 { 1705 else // Updating existing item with new perms etc
1706 {
1732// m_log.DebugFormat( 1707// m_log.DebugFormat(
1733// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", 1708// "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()",
1734// currentItem.Name, part.Name); 1709// currentItem.Name, part.Name);
1735 1710
1736 // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the 1711 if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId))
1737 // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update) 1712 return;
1738 // will not pass in a transaction ID in the update message. 1713
1739 if (transactionID != UUID.Zero && AgentTransactionsModule != null) 1714 // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the
1740 { 1715 // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update)
1741 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( 1716 // will not pass in a transaction ID in the update message.
1742 remoteClient, part, transactionID, currentItem); 1717 if (transactionID != UUID.Zero && AgentTransactionsModule != null)
1718 {
1719 AgentTransactionsModule.HandleTaskItemUpdateFromTransaction(
1720 remoteClient, part, transactionID, currentItem);
1743 1721
1744// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) 1722// if ((InventoryType)itemInfo.InvType == InventoryType.Notecard)
1745// remoteClient.SendAgentAlertMessage("Notecard saved", false); 1723// remoteClient.SendAgentAlertMessage("Notecard saved", false);
@@ -1747,49 +1725,30 @@ namespace OpenSim.Region.Framework.Scenes
1747// remoteClient.SendAgentAlertMessage("Script saved", false); 1725// remoteClient.SendAgentAlertMessage("Script saved", false);
1748// else 1726// else
1749// remoteClient.SendAgentAlertMessage("Item saved", false); 1727// remoteClient.SendAgentAlertMessage("Item saved", false);
1750 } 1728 }
1751 1729
1752 // Base ALWAYS has move 1730 // Base ALWAYS has move
1753 currentItem.BasePermissions |= (uint)PermissionMask.Move; 1731 currentItem.BasePermissions |= (uint)PermissionMask.Move;
1754 1732
1755 itemInfo.Flags = currentItem.Flags; 1733 itemInfo.Flags = currentItem.Flags;
1756 1734
1757 // Check if we're allowed to mess with permissions 1735 // Check if we're allowed to mess with permissions
1758 if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god 1736 if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god
1737 {
1738 if (remoteClient.AgentId != part.OwnerID) // Not owner
1759 { 1739 {
1760 if (remoteClient.AgentId != part.OwnerID) // Not owner 1740 // Friends and group members can't change any perms
1761 { 1741 itemInfo.BasePermissions = currentItem.BasePermissions;
1762 // Friends and group members can't change any perms 1742 itemInfo.EveryonePermissions = currentItem.EveryonePermissions;
1763 itemInfo.BasePermissions = currentItem.BasePermissions; 1743 itemInfo.GroupPermissions = currentItem.GroupPermissions;
1764 itemInfo.EveryonePermissions = currentItem.EveryonePermissions; 1744 itemInfo.NextPermissions = currentItem.NextPermissions;
1765 itemInfo.GroupPermissions = currentItem.GroupPermissions; 1745 itemInfo.CurrentPermissions = currentItem.CurrentPermissions;
1766 itemInfo.NextPermissions = currentItem.NextPermissions;
1767 itemInfo.CurrentPermissions = currentItem.CurrentPermissions;
1768 }
1769 else
1770 {
1771 // Owner can't change base, and can change other
1772 // only up to base
1773 itemInfo.BasePermissions = currentItem.BasePermissions;
1774 if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions)
1775 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone;
1776 if (itemInfo.GroupPermissions != currentItem.GroupPermissions)
1777 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup;
1778 if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions)
1779 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner;
1780 if (itemInfo.NextPermissions != currentItem.NextPermissions)
1781 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
1782 itemInfo.EveryonePermissions &= currentItem.BasePermissions;
1783 itemInfo.GroupPermissions &= currentItem.BasePermissions;
1784 itemInfo.CurrentPermissions &= currentItem.BasePermissions;
1785 itemInfo.NextPermissions &= currentItem.BasePermissions;
1786 }
1787
1788 } 1746 }
1789 else 1747 else
1790 { 1748 {
1791 if (itemInfo.BasePermissions != currentItem.BasePermissions) 1749 // Owner can't change base, and can change other
1792 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteBase; 1750 // only up to base
1751 itemInfo.BasePermissions = currentItem.BasePermissions;
1793 if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) 1752 if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions)
1794 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; 1753 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone;
1795 if (itemInfo.GroupPermissions != currentItem.GroupPermissions) 1754 if (itemInfo.GroupPermissions != currentItem.GroupPermissions)
@@ -1798,24 +1757,35 @@ namespace OpenSim.Region.Framework.Scenes
1798 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; 1757 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner;
1799 if (itemInfo.NextPermissions != currentItem.NextPermissions) 1758 if (itemInfo.NextPermissions != currentItem.NextPermissions)
1800 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; 1759 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
1760 itemInfo.EveryonePermissions &= currentItem.BasePermissions;
1761 itemInfo.GroupPermissions &= currentItem.BasePermissions;
1762 itemInfo.CurrentPermissions &= currentItem.BasePermissions;
1763 itemInfo.NextPermissions &= currentItem.BasePermissions;
1801 } 1764 }
1802 1765
1803 // Next ALWAYS has move 1766 }
1804 itemInfo.NextPermissions |= (uint)PermissionMask.Move; 1767 else
1768 {
1769 if (itemInfo.BasePermissions != currentItem.BasePermissions)
1770 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteBase;
1771 if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions)
1772 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone;
1773 if (itemInfo.GroupPermissions != currentItem.GroupPermissions)
1774 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup;
1775 if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions)
1776 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner;
1777 if (itemInfo.NextPermissions != currentItem.NextPermissions)
1778 itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
1779 }
1805 1780
1806 if (part.Inventory.UpdateInventoryItem(itemInfo)) 1781 // Next ALWAYS has move
1807 { 1782 itemInfo.NextPermissions |= (uint)PermissionMask.Move;
1808 part.SendPropertiesToClient(remoteClient); 1783
1809 } 1784 if (part.Inventory.UpdateInventoryItem(itemInfo))
1785 {
1786 part.SendPropertiesToClient(remoteClient);
1810 } 1787 }
1811 } 1788 }
1812 else
1813 {
1814 m_log.WarnFormat(
1815 "[PRIM INVENTORY]: " +
1816 "Update with item {0} requested of prim {1} for {2} but this prim does not exist",
1817 itemID, primLocalID, remoteClient.Name);
1818 }
1819 } 1789 }
1820 1790
1821 /// <summary> 1791 /// <summary>
@@ -1978,6 +1948,8 @@ namespace OpenSim.Region.Framework.Scenes
1978 part.Inventory.AddInventoryItem(taskItem, false); 1948 part.Inventory.AddInventoryItem(taskItem, false);
1979 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); 1949 part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
1980 1950
1951 part.ParentGroup.AggregatePerms();
1952
1981 // tell anyone managing scripts that a new script exists 1953 // tell anyone managing scripts that a new script exists
1982 EventManager.TriggerNewScript(agentID, part, taskItem.ItemID); 1954 EventManager.TriggerNewScript(agentID, part, taskItem.ItemID);
1983 1955
@@ -2113,13 +2085,20 @@ namespace OpenSim.Region.Framework.Scenes
2113 /// <param name='action'>DeRezAction</param> 2085 /// <param name='action'>DeRezAction</param>
2114 /// <param name='destinationID'>User folder ID to place derezzed object</param> 2086 /// <param name='destinationID'>User folder ID to place derezzed object</param>
2115 public virtual void DeRezObjects( 2087 public virtual void DeRezObjects(
2116 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID) 2088 IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID, bool AddToReturns = true)
2117 { 2089 {
2118 // First, see of we can perform the requested action and 2090 // First, see of we can perform the requested action and
2119 // build a list of eligible objects 2091 // build a list of eligible objects
2120 List<uint> deleteIDs = new List<uint>(); 2092 List<uint> deleteIDs = new List<uint>();
2121 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); 2093 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
2122 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); 2094 List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>();
2095 List<SceneObjectGroup> takeDeleteGroups = new List<SceneObjectGroup>();
2096
2097 ScenePresence sp = null;
2098 if(remoteClient != null)
2099 sp = remoteClient.SceneAgent as ScenePresence;
2100 else if(action != DeRezAction.Return)
2101 return; // only Return can be called without a client
2123 2102
2124 // Start with true for both, then remove the flags if objects 2103 // Start with true for both, then remove the flags if objects
2125 // that we can't derez are part of the selection 2104 // that we can't derez are part of the selection
@@ -2175,17 +2154,17 @@ namespace OpenSim.Region.Framework.Scenes
2175 { 2154 {
2176 if (action == DeRezAction.TakeCopy) 2155 if (action == DeRezAction.TakeCopy)
2177 { 2156 {
2178 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) 2157 if (!Permissions.CanTakeCopyObject(grp, sp))
2179 permissionToTakeCopy = false; 2158 permissionToTakeCopy = false;
2180 } 2159 }
2181 else 2160 else
2182 { 2161 {
2183 permissionToTakeCopy = false; 2162 permissionToTakeCopy = false;
2184 } 2163 }
2185 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) 2164 if (!Permissions.CanTakeObject(grp, sp))
2186 permissionToTake = false; 2165 permissionToTake = false;
2187 2166
2188 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) 2167 if (!Permissions.CanDeleteObject(grp, remoteClient))
2189 permissionToDelete = false; 2168 permissionToDelete = false;
2190 } 2169 }
2191 2170
@@ -2226,13 +2205,14 @@ namespace OpenSim.Region.Framework.Scenes
2226 { 2205 {
2227 if (Permissions.CanReturnObjects( 2206 if (Permissions.CanReturnObjects(
2228 null, 2207 null,
2229 remoteClient.AgentId, 2208 remoteClient,
2230 new List<SceneObjectGroup>() {grp})) 2209 new List<SceneObjectGroup>() {grp}))
2231 { 2210 {
2232 permissionToTake = true; 2211 permissionToTake = true;
2233 permissionToDelete = true; 2212 permissionToDelete = true;
2234 2213 if(AddToReturns)
2235 AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); 2214 AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition,
2215 "parcel owner return");
2236 } 2216 }
2237 } 2217 }
2238 else // Auto return passes through here with null agent 2218 else // Auto return passes through here with null agent
@@ -2242,26 +2222,24 @@ namespace OpenSim.Region.Framework.Scenes
2242 } 2222 }
2243 } 2223 }
2244 2224
2245 if (permissionToTake && (!permissionToDelete))
2246 takeGroups.Add(grp);
2247
2248 if (permissionToDelete) 2225 if (permissionToDelete)
2249 { 2226 {
2250 if (permissionToTake) 2227 if (permissionToTake)
2228 takeDeleteGroups.Add(grp);
2229 else
2251 deleteGroups.Add(grp); 2230 deleteGroups.Add(grp);
2252 deleteIDs.Add(grp.LocalId); 2231 deleteIDs.Add(grp.LocalId);
2253 } 2232 }
2233 else if(permissionToTake)
2234 takeGroups.Add(grp);
2254 } 2235 }
2255 2236
2256 SendKillObject(deleteIDs); 2237 SendKillObject(deleteIDs);
2257 2238
2258 if (deleteGroups.Count > 0) 2239 if (takeDeleteGroups.Count > 0)
2259 { 2240 {
2260 foreach (SceneObjectGroup g in deleteGroups)
2261 deleteIDs.Remove(g.LocalId);
2262
2263 m_asyncSceneObjectDeleter.DeleteToInventory( 2241 m_asyncSceneObjectDeleter.DeleteToInventory(
2264 action, destinationID, deleteGroups, remoteClient, 2242 action, destinationID, takeDeleteGroups, remoteClient,
2265 true); 2243 true);
2266 } 2244 }
2267 if (takeGroups.Count > 0) 2245 if (takeGroups.Count > 0)
@@ -2270,7 +2248,7 @@ namespace OpenSim.Region.Framework.Scenes
2270 action, destinationID, takeGroups, remoteClient, 2248 action, destinationID, takeGroups, remoteClient,
2271 false); 2249 false);
2272 } 2250 }
2273 if (deleteIDs.Count > 0) 2251 if (deleteGroups.Count > 0)
2274 { 2252 {
2275 foreach (SceneObjectGroup g in deleteGroups) 2253 foreach (SceneObjectGroup g in deleteGroups)
2276 DeleteSceneObject(g, true); 2254 DeleteSceneObject(g, true);
@@ -2658,6 +2636,7 @@ namespace OpenSim.Region.Framework.Scenes
2658 2636
2659 // We can only call this after adding the scene object, since the scene object references the scene 2637 // We can only call this after adding the scene object, since the scene object references the scene
2660 // to find out if scripts should be activated at all. 2638 // to find out if scripts should be activated at all.
2639 group.AggregatePerms();
2661 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); 2640 group.CreateScriptInstances(param, true, DefaultScriptEngine, 3);
2662 2641
2663 group.ScheduleGroupForFullUpdate(); 2642 group.ScheduleGroupForFullUpdate();
@@ -2667,7 +2646,7 @@ namespace OpenSim.Region.Framework.Scenes
2667 } 2646 }
2668 2647
2669 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, 2648 public virtual bool returnObjects(SceneObjectGroup[] returnobjects,
2670 UUID AgentId) 2649 IClientAPI client)
2671 { 2650 {
2672 List<uint> localIDs = new List<uint>(); 2651 List<uint> localIDs = new List<uint>();
2673 2652
@@ -2677,8 +2656,8 @@ namespace OpenSim.Region.Framework.Scenes
2677 "parcel owner return"); 2656 "parcel owner return");
2678 localIDs.Add(grp.RootPart.LocalId); 2657 localIDs.Add(grp.RootPart.LocalId);
2679 } 2658 }
2680 DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, 2659 DeRezObjects(client, localIDs, UUID.Zero, DeRezAction.Return,
2681 UUID.Zero); 2660 UUID.Zero, false);
2682 2661
2683 return true; 2662 return true;
2684 } 2663 }
@@ -2709,9 +2688,6 @@ namespace OpenSim.Region.Framework.Scenes
2709 { 2688 {
2710 if (ownerID != UUID.Zero) 2689 if (ownerID != UUID.Zero)
2711 return; 2690 return;
2712
2713 if (!Permissions.CanDeedObject(remoteClient.AgentId, groupID))
2714 return;
2715 } 2691 }
2716 2692
2717 List<SceneObjectGroup> groups = new List<SceneObjectGroup>(); 2693 List<SceneObjectGroup> groups = new List<SceneObjectGroup>();
@@ -2742,21 +2718,22 @@ namespace OpenSim.Region.Framework.Scenes
2742 child.TriggerScriptChangedEvent(Changed.OWNER); 2718 child.TriggerScriptChangedEvent(Changed.OWNER);
2743 } 2719 }
2744 } 2720 }
2745 else // The object was deeded to the group 2721 else // The object deeded to the group
2746 { 2722 {
2747 if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) 2723 if (!Permissions.CanDeedObject(remoteClient, sog, groupID))
2748 continue; 2724 continue;
2749 2725
2750 if (!Permissions.CanTransferObject(sog.UUID, groupID)) 2726 sog.SetOwnerId(groupID);
2751 continue;
2752 2727
2753 if (sog.GroupID != groupID) 2728 // this is wrong, GroupMask is used for group sharing, still possible to set
2754 continue; 2729 // this whould give owner rights to users that are member of group but don't have role powers to edit
2730// sog.RootPart.GroupMask = sog.RootPart.OwnerMask;
2755 2731
2756 sog.SetOwnerId(groupID); 2732 // we should keep all permissions on deed to group
2757 // Make the group mask be the previous owner mask 2733 // and with this comented code, if user does not set next permissions on the object
2758 sog.RootPart.GroupMask = sog.RootPart.OwnerMask; 2734 // and on ALL contents of ALL prims, he may loose rights, making the object useless
2759 sog.ApplyNextOwnerPermissions(); 2735 sog.ApplyNextOwnerPermissions();
2736 sog.AggregatePerms();
2760 2737
2761 sog.ScheduleGroupForFullUpdate(); 2738 sog.ScheduleGroupForFullUpdate();
2762 2739
@@ -2766,8 +2743,6 @@ namespace OpenSim.Region.Framework.Scenes
2766 child.Inventory.ChangeInventoryOwner(groupID); 2743 child.Inventory.ChangeInventoryOwner(groupID);
2767 child.TriggerScriptChangedEvent(Changed.OWNER); 2744 child.TriggerScriptChangedEvent(Changed.OWNER);
2768 } 2745 }
2769
2770
2771 } 2746 }
2772 } 2747 }
2773 2748
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index e611897..4fef9c3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -183,10 +183,12 @@ namespace OpenSim.Region.Framework.Scenes
183 part.SendFullUpdate(remoteClient); 183 part.SendFullUpdate(remoteClient);
184 184
185 // A prim is only tainted if it's allowed to be edited by the person clicking it. 185 // A prim is only tainted if it's allowed to be edited by the person clicking it.
186 if (Permissions.CanChangeSelectedState(sog.UUID, (ScenePresence)remoteClient.SceneAgent)) 186 if (Permissions.CanChangeSelectedState(part, (ScenePresence)remoteClient.SceneAgent))
187 { 187 {
188 bool oldsel = part.IsSelected;
188 part.IsSelected = true; 189 part.IsSelected = true;
189 EventManager.TriggerParcelPrimCountTainted(); 190 if(!oldsel)
191 EventManager.TriggerParcelPrimCountTainted();
190 } 192 }
191 193
192 part.SendPropertiesToClient(remoteClient); 194 part.SendPropertiesToClient(remoteClient);
@@ -228,6 +230,7 @@ namespace OpenSim.Region.Framework.Scenes
228 if (so.OwnerID == remoteClient.AgentId) 230 if (so.OwnerID == remoteClient.AgentId)
229 { 231 {
230 so.SetGroup(groupID, remoteClient); 232 so.SetGroup(groupID, remoteClient);
233 EventManager.TriggerParcelPrimCountTainted();
231 } 234 }
232 } 235 }
233 } 236 }
@@ -249,7 +252,7 @@ namespace OpenSim.Region.Framework.Scenes
249 // handled by group, but by prim. Legacy cruft. 252 // handled by group, but by prim. Legacy cruft.
250 // TODO: Make selection flagging per prim! 253 // TODO: Make selection flagging per prim!
251 // 254 //
252 if (Permissions.CanChangeSelectedState(part.ParentGroup.UUID, (ScenePresence)remoteClient.SceneAgent)) 255 if (Permissions.CanChangeSelectedState(part, (ScenePresence)remoteClient.SceneAgent))
253 { 256 {
254 part.IsSelected = false; 257 part.IsSelected = false;
255 if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) 258 if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected)
@@ -325,7 +328,7 @@ namespace OpenSim.Region.Framework.Scenes
325 if(group == null || group.IsDeleted) 328 if(group == null || group.IsDeleted)
326 return; 329 return;
327 330
328 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.) 331 if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
329 { 332 {
330 group.GrabMovement(objectID, offset, pos, remoteClient); 333 group.GrabMovement(objectID, offset, pos, remoteClient);
331 } 334 }
@@ -386,7 +389,7 @@ namespace OpenSim.Region.Framework.Scenes
386 SceneObjectGroup group = GetGroupByPrim(objectID); 389 SceneObjectGroup group = GetGroupByPrim(objectID);
387 if (group != null) 390 if (group != null)
388 { 391 {
389 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.) 392 if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
390 { 393 {
391 group.SpinStart(remoteClient); 394 group.SpinStart(remoteClient);
392 } 395 }
@@ -404,7 +407,7 @@ namespace OpenSim.Region.Framework.Scenes
404 SceneObjectGroup group = GetGroupByPrim(objectID); 407 SceneObjectGroup group = GetGroupByPrim(objectID);
405 if (group != null) 408 if (group != null)
406 { 409 {
407 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.) 410 if (Permissions.CanMoveObject(group, remoteClient))// && PermissionsMngr.)
408 { 411 {
409 group.SpinMovement(rotation, remoteClient); 412 group.SpinMovement(rotation, remoteClient);
410 } 413 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
index 8f32b03..7d69a9b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs
@@ -37,52 +37,59 @@ using OpenSim.Region.Framework.Interfaces;
37namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
38{ 38{
39 #region Delegates 39 #region Delegates
40 public delegate uint GenerateClientFlagsHandler(ScenePresence sp, uint curEffectivePerms, UUID objectID); 40 public delegate uint GenerateClientFlagsHandler(SceneObjectPart part, ScenePresence sp, uint curEffectivePerms);
41 public delegate void SetBypassPermissionsHandler(bool value); 41 public delegate void SetBypassPermissionsHandler(bool value);
42 public delegate bool BypassPermissionsHandler(); 42 public delegate bool BypassPermissionsHandler();
43 public delegate bool PropagatePermissionsHandler(); 43 public delegate bool PropagatePermissionsHandler();
44 public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition, Scene scene); 44 public delegate bool RezObjectHandler(int objectCount, UUID owner, Vector3 objectPosition);
45 public delegate bool DeleteObjectHandler(UUID objectID, UUID deleter, Scene scene); 45 public delegate bool DeleteObjectHandlerByIDs(UUID objectID, UUID deleter);
46 public delegate bool TransferObjectHandler(UUID objectID, UUID recipient, Scene scene); 46 public delegate bool DeleteObjectHandler(SceneObjectGroup sog, ScenePresence sp);
47 public delegate bool TakeObjectHandler(UUID objectID, UUID stealer, Scene scene); 47 public delegate bool TransferObjectHandler(UUID objectID, UUID recipient);
48 public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID, Scene scene); 48 public delegate bool TakeObjectHandler(SceneObjectGroup sog, ScenePresence sp);
49 public delegate bool TakeCopyObjectHandler(UUID objectID, UUID userID, Scene inScene); 49 public delegate bool SellGroupObjectHandler(UUID userID, UUID groupID);
50 public delegate bool DuplicateObjectHandler(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition); 50 public delegate bool SellObjectHandlerByUserID(SceneObjectGroup sog, UUID userID, byte saleType);
51 public delegate bool EditObjectHandler(UUID objectID, UUID editorID, Scene scene); 51 public delegate bool SellObjectHandler(SceneObjectGroup sog, ScenePresence sp, byte saleType);
52 public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID, Scene scene); 52 public delegate bool TakeCopyObjectHandler(SceneObjectGroup sog, ScenePresence sp);
53 public delegate bool MoveObjectHandler(UUID objectID, UUID moverID, Scene scene); 53 public delegate bool DuplicateObjectHandler(SceneObjectGroup sog, ScenePresence sp);
54 public delegate bool ObjectEntryHandler(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene); 54 public delegate bool EditObjectByIDsHandler(UUID objectID, UUID editorID);
55 public delegate bool ReturnObjectsHandler(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene); 55 public delegate bool EditObjectHandler(SceneObjectGroup sog, ScenePresence sp);
56 public delegate bool InstantMessageHandler(UUID user, UUID target, Scene startScene); 56 public delegate bool EditObjectInventoryHandler(UUID objectID, UUID editorID);
57 public delegate bool InventoryTransferHandler(UUID user, UUID target, Scene startScene); 57 public delegate bool MoveObjectHandler(SceneObjectGroup sog, ScenePresence sp);
58 public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); 58 public delegate bool ObjectEntryHandler(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint);
59 public delegate bool ViewNotecardHandler(UUID script, UUID objectID, UUID user, Scene scene); 59 public delegate bool ReturnObjectsHandler(ILandObject land, ScenePresence sp, List<SceneObjectGroup> objects);
60 public delegate bool EditScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); 60 public delegate bool InstantMessageHandler(UUID user, UUID target);
61 public delegate bool EditNotecardHandler(UUID notecard, UUID objectID, UUID user, Scene scene); 61 public delegate bool InventoryTransferHandler(UUID user, UUID target);
62 public delegate bool RunScriptHandler(UUID script, UUID objectID, UUID user, Scene scene); 62 public delegate bool ViewScriptHandler(UUID script, UUID objectID, UUID user);
63 public delegate bool CompileScriptHandler(UUID ownerUUID, int scriptType, Scene scene); 63 public delegate bool ViewNotecardHandler(UUID script, UUID objectID, UUID user);
64 public delegate bool StartScriptHandler(UUID script, UUID user, Scene scene); 64 public delegate bool EditScriptHandler(UUID script, UUID objectID, UUID user);
65 public delegate bool StopScriptHandler(UUID script, UUID user, Scene scene); 65 public delegate bool EditNotecardHandler(UUID notecard, UUID objectID, UUID user);
66 public delegate bool ResetScriptHandler(UUID prim, UUID script, UUID user, Scene scene); 66 public delegate bool RunScriptHandlerByIDs(UUID script, UUID objectID, UUID user);
67 public delegate bool TerraformLandHandler(UUID user, Vector3 position, Scene requestFromScene); 67 public delegate bool RunScriptHandler(TaskInventoryItem item, SceneObjectPart part);
68 public delegate bool RunConsoleCommandHandler(UUID user, Scene requestFromScene); 68 public delegate bool CompileScriptHandler(UUID ownerUUID, int scriptType);
69 public delegate bool IssueEstateCommandHandler(UUID user, Scene requestFromScene, bool ownerCommand); 69 public delegate bool StartScriptHandler(UUID script, UUID user);
70 public delegate bool IsGodHandler(UUID user, Scene requestFromScene); 70 public delegate bool StopScriptHandler(UUID script, UUID user);
71 public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene); 71 public delegate bool ResetScriptHandler(UUID prim, UUID script, UUID user);
72 public delegate bool TerraformLandHandler(UUID user, Vector3 position);
73 public delegate bool RunConsoleCommandHandler(UUID user);
74 public delegate bool IssueEstateCommandHandler(UUID user, bool ownerCommand);
75 public delegate bool IsGodHandler(UUID user);
76 public delegate bool IsGridGodHandler(UUID user);
72 public delegate bool IsAdministratorHandler(UUID user); 77 public delegate bool IsAdministratorHandler(UUID user);
73 public delegate bool IsEstateManagerHandler(UUID user); 78 public delegate bool IsEstateManagerHandler(UUID user);
74 public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); 79 public delegate bool EditParcelHandler(UUID user, ILandObject parcel);
75 public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager); 80 public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, bool allowManager);
76 public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); 81 public delegate bool SellParcelHandler(UUID user, ILandObject parcel);
77 public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); 82 public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel);
78 public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene); 83 public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel);
79 public delegate bool DeedParcelHandler(UUID user, ILandObject parcel, Scene scene); 84 public delegate bool DeedParcelHandler(UUID user, ILandObject parcel);
80 public delegate bool DeedObjectHandler(UUID user, UUID group, Scene scene); 85 public delegate bool DeedObjectHandler(ScenePresence sp, SceneObjectGroup sog, UUID targetGroupID);
81 public delegate bool BuyLandHandler(UUID user, ILandObject parcel, Scene scene); 86 public delegate bool BuyLandHandler(UUID user, ILandObject parcel);
82 public delegate bool LinkObjectHandler(UUID user, UUID objectID); 87 public delegate bool LinkObjectHandler(UUID user, UUID objectID);
83 public delegate bool DelinkObjectHandler(UUID user, UUID objectID); 88 public delegate bool DelinkObjectHandler(UUID user, UUID objectID);
84 public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID); 89 public delegate bool CreateObjectInventoryHandler(int invType, UUID objectID, UUID userID);
85 public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); 90 public delegate bool CopyObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
91 public delegate bool DoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart);
92 public delegate bool DoDropInObjectInv(InventoryItemBase item, ScenePresence sp, SceneObjectPart destPart);
86 public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); 93 public delegate bool DeleteObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
87 public delegate bool TransferObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID); 94 public delegate bool TransferObjectInventoryHandler(UUID itemID, UUID objectID, UUID userID);
88 public delegate bool CreateUserInventoryHandler(int invType, UUID userID); 95 public delegate bool CreateUserInventoryHandler(int invType, UUID userID);
@@ -112,12 +119,18 @@ namespace OpenSim.Region.Framework.Scenes
112 public event BypassPermissionsHandler OnBypassPermissions; 119 public event BypassPermissionsHandler OnBypassPermissions;
113 public event PropagatePermissionsHandler OnPropagatePermissions; 120 public event PropagatePermissionsHandler OnPropagatePermissions;
114 public event RezObjectHandler OnRezObject; 121 public event RezObjectHandler OnRezObject;
122 public event DeleteObjectHandlerByIDs OnDeleteObjectByIDs;
115 public event DeleteObjectHandler OnDeleteObject; 123 public event DeleteObjectHandler OnDeleteObject;
116 public event TransferObjectHandler OnTransferObject; 124 public event TransferObjectHandler OnTransferObject;
117 public event TakeObjectHandler OnTakeObject; 125 public event TakeObjectHandler OnTakeObject;
126
118 public event SellGroupObjectHandler OnSellGroupObject; 127 public event SellGroupObjectHandler OnSellGroupObject;
128 public event SellObjectHandlerByUserID OnSellObjectByUserID;
129 public event SellObjectHandler OnSellObject;
130
119 public event TakeCopyObjectHandler OnTakeCopyObject; 131 public event TakeCopyObjectHandler OnTakeCopyObject;
120 public event DuplicateObjectHandler OnDuplicateObject; 132 public event DuplicateObjectHandler OnDuplicateObject;
133 public event EditObjectByIDsHandler OnEditObjectByIDs;
121 public event EditObjectHandler OnEditObject; 134 public event EditObjectHandler OnEditObject;
122 public event EditObjectInventoryHandler OnEditObjectInventory; 135 public event EditObjectInventoryHandler OnEditObjectInventory;
123 public event MoveObjectHandler OnMoveObject; 136 public event MoveObjectHandler OnMoveObject;
@@ -129,6 +142,7 @@ namespace OpenSim.Region.Framework.Scenes
129 public event ViewNotecardHandler OnViewNotecard; 142 public event ViewNotecardHandler OnViewNotecard;
130 public event EditScriptHandler OnEditScript; 143 public event EditScriptHandler OnEditScript;
131 public event EditNotecardHandler OnEditNotecard; 144 public event EditNotecardHandler OnEditNotecard;
145 public event RunScriptHandlerByIDs OnRunScriptByIDs;
132 public event RunScriptHandler OnRunScript; 146 public event RunScriptHandler OnRunScript;
133 public event CompileScriptHandler OnCompileScript; 147 public event CompileScriptHandler OnCompileScript;
134 public event StartScriptHandler OnStartScript; 148 public event StartScriptHandler OnStartScript;
@@ -137,7 +151,6 @@ namespace OpenSim.Region.Framework.Scenes
137 public event TerraformLandHandler OnTerraformLand; 151 public event TerraformLandHandler OnTerraformLand;
138 public event RunConsoleCommandHandler OnRunConsoleCommand; 152 public event RunConsoleCommandHandler OnRunConsoleCommand;
139 public event IssueEstateCommandHandler OnIssueEstateCommand; 153 public event IssueEstateCommandHandler OnIssueEstateCommand;
140 public event IsGodHandler OnIsGod;
141 public event IsGridGodHandler OnIsGridGod; 154 public event IsGridGodHandler OnIsGridGod;
142 public event IsAdministratorHandler OnIsAdministrator; 155 public event IsAdministratorHandler OnIsAdministrator;
143 public event IsEstateManagerHandler OnIsEstateManager; 156 public event IsEstateManagerHandler OnIsEstateManager;
@@ -153,6 +166,8 @@ namespace OpenSim.Region.Framework.Scenes
153 public event DelinkObjectHandler OnDelinkObject; 166 public event DelinkObjectHandler OnDelinkObject;
154 public event CreateObjectInventoryHandler OnCreateObjectInventory; 167 public event CreateObjectInventoryHandler OnCreateObjectInventory;
155 public event CopyObjectInventoryHandler OnCopyObjectInventory; 168 public event CopyObjectInventoryHandler OnCopyObjectInventory;
169 public event DoObjectInvToObjectInv OnDoObjectInvToObjectInv;
170 public event DoDropInObjectInv OnDropInObjectInv;
156 public event DeleteObjectInventoryHandler OnDeleteObjectInventory; 171 public event DeleteObjectInventoryHandler OnDeleteObjectInventory;
157 public event TransferObjectInventoryHandler OnTransferObjectInventory; 172 public event TransferObjectInventoryHandler OnTransferObjectInventory;
158 public event CreateUserInventoryHandler OnCreateUserInventory; 173 public event CreateUserInventoryHandler OnCreateUserInventory;
@@ -167,7 +182,7 @@ namespace OpenSim.Region.Framework.Scenes
167 182
168 #region Object Permission Checks 183 #region Object Permission Checks
169 184
170 public uint GenerateClientFlags(ScenePresence sp, UUID objectID) 185 public uint GenerateClientFlags( SceneObjectPart part, ScenePresence sp)
171 { 186 {
172 // libomv will moan about PrimFlags.ObjectYouOfficer being 187 // libomv will moan about PrimFlags.ObjectYouOfficer being
173 // obsolete... 188 // obsolete...
@@ -182,8 +197,6 @@ namespace OpenSim.Region.Framework.Scenes
182 PrimFlags.ObjectOwnerModify; 197 PrimFlags.ObjectOwnerModify;
183#pragma warning restore 0612 198#pragma warning restore 0612
184 199
185 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
186
187 if (part == null) 200 if (part == null)
188 return 0; 201 return 0;
189 202
@@ -195,7 +208,7 @@ namespace OpenSim.Region.Framework.Scenes
195 Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); 208 Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
196 foreach (GenerateClientFlagsHandler check in list) 209 foreach (GenerateClientFlagsHandler check in list)
197 { 210 {
198 perms &= check(sp, perms, objectID); 211 perms &= check(part, sp, perms);
199 } 212 }
200 } 213 }
201 return perms; 214 return perms;
@@ -247,7 +260,7 @@ namespace OpenSim.Region.Framework.Scenes
247 Delegate[] list = handler.GetInvocationList(); 260 Delegate[] list = handler.GetInvocationList();
248 foreach (RezObjectHandler h in list) 261 foreach (RezObjectHandler h in list)
249 { 262 {
250 if (h(objectCount, owner,objectPosition, m_scene) == false) 263 if (h(objectCount, owner,objectPosition) == false)
251 return false; 264 return false;
252 } 265 }
253 } 266 }
@@ -261,141 +274,183 @@ namespace OpenSim.Region.Framework.Scenes
261 { 274 {
262 bool result = true; 275 bool result = true;
263 276
264 DeleteObjectHandler handler = OnDeleteObject; 277 DeleteObjectHandlerByIDs handler = OnDeleteObjectByIDs;
265 if (handler != null) 278 if (handler != null)
266 { 279 {
267 Delegate[] list = handler.GetInvocationList(); 280 Delegate[] list = handler.GetInvocationList();
268 foreach (DeleteObjectHandler h in list) 281 foreach (DeleteObjectHandlerByIDs h in list)
269 { 282 {
270 if (h(objectID, deleter, m_scene) == false) 283 if (h(objectID, deleter) == false)
271 { 284 {
272 result = false; 285 result = false;
273 break; 286 break;
274 } 287 }
275 } 288 }
276 } 289 }
277
278 return result; 290 return result;
279 } 291 }
280 292
281 public bool CanTransferObject(UUID objectID, UUID recipient) 293 public bool CanDeleteObject(SceneObjectGroup sog, IClientAPI client)
282 { 294 {
283 bool result = true; 295 DeleteObjectHandler handler = OnDeleteObject;
296 if (handler != null)
297 {
298 if(sog == null || client == null || client.SceneAgent == null)
299 return false;
300
301 ScenePresence sp = client.SceneAgent as ScenePresence;
302
303 Delegate[] list = handler.GetInvocationList();
304 foreach (DeleteObjectHandler h in list)
305 {
306 if (h(sog, sp) == false)
307 return false;
308 }
309 }
310
311 return true;
312 }
284 313
314 public bool CanTransferObject(UUID objectID, UUID recipient)
315 {
285 TransferObjectHandler handler = OnTransferObject; 316 TransferObjectHandler handler = OnTransferObject;
286 if (handler != null) 317 if (handler != null)
287 { 318 {
288 Delegate[] list = handler.GetInvocationList(); 319 Delegate[] list = handler.GetInvocationList();
289 foreach (TransferObjectHandler h in list) 320 foreach (TransferObjectHandler h in list)
290 { 321 {
291 if (h(objectID, recipient, m_scene) == false) 322 if (h(objectID, recipient) == false)
292 { 323 return false;
293 result = false;
294 break;
295 }
296 } 324 }
297 } 325 }
298 326 return true;
299 return result;
300 } 327 }
301 328
302 #endregion 329 #endregion
303 330
304 #region TAKE OBJECT 331 #region TAKE OBJECT
305 public bool CanTakeObject(UUID objectID, UUID AvatarTakingUUID) 332 public bool CanTakeObject(SceneObjectGroup sog, ScenePresence sp)
306 { 333 {
307 bool result = true;
308
309 TakeObjectHandler handler = OnTakeObject; 334 TakeObjectHandler handler = OnTakeObject;
310 if (handler != null) 335 if (handler != null)
311 { 336 {
337 if(sog == null || sp == null)
338 return false;
339
312 Delegate[] list = handler.GetInvocationList(); 340 Delegate[] list = handler.GetInvocationList();
313 foreach (TakeObjectHandler h in list) 341 foreach (TakeObjectHandler h in list)
314 { 342 {
315 if (h(objectID, AvatarTakingUUID, m_scene) == false) 343 if (h(sog, sp) == false)
316 { 344 return false;
317 result = false;
318 break;
319 }
320 } 345 }
321 } 346 }
322
323// m_log.DebugFormat( 347// m_log.DebugFormat(
324// "[SCENE PERMISSIONS]: CanTakeObject() fired for object {0}, taker {1}, result {2}", 348// "[SCENE PERMISSIONS]: CanTakeObject() fired for object {0}, taker {1}, result {2}",
325// objectID, AvatarTakingUUID, result); 349// objectID, AvatarTakingUUID, result);
326 350 return true;
327 return result;
328 } 351 }
329 352
330 #endregion 353 #endregion
331 354
332 #region SELL GROUP OBJECT 355 #region SELL GROUP OBJECT
333 public bool CanSellGroupObject(UUID userID, UUID groupID, Scene scene) 356 public bool CanSellGroupObject(UUID userID, UUID groupID)
334 { 357 {
335 bool result = true;
336
337 SellGroupObjectHandler handler = OnSellGroupObject; 358 SellGroupObjectHandler handler = OnSellGroupObject;
338 if (handler != null) 359 if (handler != null)
339 { 360 {
340 Delegate[] list = handler.GetInvocationList(); 361 Delegate[] list = handler.GetInvocationList();
341 foreach (SellGroupObjectHandler h in list) 362 foreach (SellGroupObjectHandler h in list)
342 { 363 {
343 if (h(userID, groupID, scene) == false) 364 if (h(userID, groupID) == false)
344 { 365 return false;
345 result = false;
346 break;
347 }
348 } 366 }
349 } 367 }
350
351 //m_log.DebugFormat( 368 //m_log.DebugFormat(
352 // "[SCENE PERMISSIONS]: CanSellGroupObject() fired for user {0}, group {1}, result {2}", 369 // "[SCENE PERMISSIONS]: CanSellGroupObject() fired for user {0}, group {1}, result {2}",
353 // userID, groupID, result); 370 // userID, groupID, result);
371 return true;
372 }
354 373
355 return result; 374 #endregion
375
376 #region SELL OBJECT
377 public bool CanSellObject(IClientAPI client, SceneObjectGroup sog, byte saleType)
378 {
379 SellObjectHandler handler = OnSellObject;
380 if (handler != null)
381 {
382 if(sog == null || client == null || client.SceneAgent == null)
383 return false;
384
385 ScenePresence sp = client.SceneAgent as ScenePresence;
386 Delegate[] list = handler.GetInvocationList();
387 foreach (SellObjectHandler h in list)
388 {
389 if (h(sog, sp, saleType) == false)
390 return false;
391 }
392 }
393 return true;
394 }
395
396 public bool CanSellObject(UUID userID, SceneObjectGroup sog, byte saleType)
397 {
398 SellObjectHandlerByUserID handler = OnSellObjectByUserID;
399 if (handler != null)
400 {
401 if(sog == null)
402 return false;
403 Delegate[] list = handler.GetInvocationList();
404 foreach (SellObjectHandlerByUserID h in list)
405 {
406 if (h(sog, userID, saleType) == false)
407 return false;
408 }
409 }
410 return true;
356 } 411 }
357 412
358 #endregion 413 #endregion
359 414
360 415
361 #region TAKE COPY OBJECT 416 #region TAKE COPY OBJECT
362 public bool CanTakeCopyObject(UUID objectID, UUID userID) 417 public bool CanTakeCopyObject(SceneObjectGroup sog, ScenePresence sp)
363 { 418 {
364 bool result = true;
365
366 TakeCopyObjectHandler handler = OnTakeCopyObject; 419 TakeCopyObjectHandler handler = OnTakeCopyObject;
367 if (handler != null) 420 if (handler != null)
368 { 421 {
422 if(sog == null || sp == null)
423 return false;
369 Delegate[] list = handler.GetInvocationList(); 424 Delegate[] list = handler.GetInvocationList();
370 foreach (TakeCopyObjectHandler h in list) 425 foreach (TakeCopyObjectHandler h in list)
371 { 426 {
372 if (h(objectID, userID, m_scene) == false) 427 if (h(sog, sp) == false)
373 { 428 return false;
374 result = false;
375 break;
376 }
377 } 429 }
378 } 430 }
379
380// m_log.DebugFormat( 431// m_log.DebugFormat(
381// "[SCENE PERMISSIONS]: CanTakeCopyObject() fired for object {0}, user {1}, result {2}", 432// "[SCENE PERMISSIONS]: CanTakeCopyObject() fired for object {0}, user {1}, result {2}",
382// objectID, userID, result); 433// objectID, userID, result);
383 434 return true;
384 return result;
385 } 435 }
386 436
387 #endregion 437 #endregion
388 438
389 #region DUPLICATE OBJECT 439 #region DUPLICATE OBJECT
390 public bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition) 440 public bool CanDuplicateObject(SceneObjectGroup sog, UUID agentID)
391 { 441 {
392 DuplicateObjectHandler handler = OnDuplicateObject; 442 DuplicateObjectHandler handler = OnDuplicateObject;
393 if (handler != null) 443 if (handler != null)
394 { 444 {
445 if(sog == null || sog.IsDeleted)
446 return false;
447 ScenePresence sp = m_scene.GetScenePresence(agentID);
448 if(sp == null || sp.IsDeleted)
449 return false;
395 Delegate[] list = handler.GetInvocationList(); 450 Delegate[] list = handler.GetInvocationList();
396 foreach (DuplicateObjectHandler h in list) 451 foreach (DuplicateObjectHandler h in list)
397 { 452 {
398 if (h(objectCount, objectID, owner, m_scene, objectPosition) == false) 453 if (h(sog, sp) == false)
399 return false; 454 return false;
400 } 455 }
401 } 456 }
@@ -411,9 +466,9 @@ namespace OpenSim.Region.Framework.Scenes
411 PrimFlags.ObjectOwnerModify 466 PrimFlags.ObjectOwnerModify
412 ); 467 );
413 468
414 public bool CanChangeSelectedState(UUID objectID, ScenePresence sp) 469 public bool CanChangeSelectedState(SceneObjectPart part, ScenePresence sp)
415 { 470 {
416 uint perms = GenerateClientFlags(sp , objectID); 471 uint perms = GenerateClientFlags(part, sp);
417 return (perms & CANSELECTMASK) != 0; 472 return (perms & CANSELECTMASK) != 0;
418 } 473 }
419 474
@@ -421,13 +476,33 @@ namespace OpenSim.Region.Framework.Scenes
421 #region EDIT OBJECT 476 #region EDIT OBJECT
422 public bool CanEditObject(UUID objectID, UUID editorID) 477 public bool CanEditObject(UUID objectID, UUID editorID)
423 { 478 {
479 EditObjectByIDsHandler handler = OnEditObjectByIDs;
480 if (handler != null)
481 {
482 Delegate[] list = handler.GetInvocationList();
483 foreach (EditObjectByIDsHandler h in list)
484 {
485 if (h(objectID, editorID) == false)
486 return false;
487 }
488 }
489 return true;
490 }
491
492 public bool CanEditObject(SceneObjectGroup sog, IClientAPI client)
493 {
424 EditObjectHandler handler = OnEditObject; 494 EditObjectHandler handler = OnEditObject;
425 if (handler != null) 495 if (handler != null)
426 { 496 {
497 if(sog == null || client == null || client.SceneAgent == null)
498 return false;
499
500 ScenePresence sp = client.SceneAgent as ScenePresence;
501
427 Delegate[] list = handler.GetInvocationList(); 502 Delegate[] list = handler.GetInvocationList();
428 foreach (EditObjectHandler h in list) 503 foreach (EditObjectHandler h in list)
429 { 504 {
430 if (h(objectID, editorID, m_scene) == false) 505 if (h(sog, sp) == false)
431 return false; 506 return false;
432 } 507 }
433 } 508 }
@@ -442,7 +517,7 @@ namespace OpenSim.Region.Framework.Scenes
442 Delegate[] list = handler.GetInvocationList(); 517 Delegate[] list = handler.GetInvocationList();
443 foreach (EditObjectInventoryHandler h in list) 518 foreach (EditObjectInventoryHandler h in list)
444 { 519 {
445 if (h(objectID, editorID, m_scene) == false) 520 if (h(objectID, editorID) == false)
446 return false; 521 return false;
447 } 522 }
448 } 523 }
@@ -452,15 +527,20 @@ namespace OpenSim.Region.Framework.Scenes
452 #endregion 527 #endregion
453 528
454 #region MOVE OBJECT 529 #region MOVE OBJECT
455 public bool CanMoveObject(UUID objectID, UUID moverID) 530 public bool CanMoveObject(SceneObjectGroup sog, IClientAPI client)
456 { 531 {
457 MoveObjectHandler handler = OnMoveObject; 532 MoveObjectHandler handler = OnMoveObject;
458 if (handler != null) 533 if (handler != null)
459 { 534 {
535 if(sog == null || client == null || client.SceneAgent == null)
536 return false;
537
538 ScenePresence sp = client.SceneAgent as ScenePresence;
539
460 Delegate[] list = handler.GetInvocationList(); 540 Delegate[] list = handler.GetInvocationList();
461 foreach (MoveObjectHandler h in list) 541 foreach (MoveObjectHandler h in list)
462 { 542 {
463 if (h(objectID, moverID, m_scene) == false) 543 if (h(sog, sp) == false)
464 return false; 544 return false;
465 } 545 }
466 } 546 }
@@ -470,7 +550,7 @@ namespace OpenSim.Region.Framework.Scenes
470 #endregion 550 #endregion
471 551
472 #region OBJECT ENTRY 552 #region OBJECT ENTRY
473 public bool CanObjectEntry(UUID objectID, bool enteringRegion, Vector3 newPoint) 553 public bool CanObjectEntry(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
474 { 554 {
475 ObjectEntryHandler handler = OnObjectEntry; 555 ObjectEntryHandler handler = OnObjectEntry;
476 if (handler != null) 556 if (handler != null)
@@ -478,7 +558,7 @@ namespace OpenSim.Region.Framework.Scenes
478 Delegate[] list = handler.GetInvocationList(); 558 Delegate[] list = handler.GetInvocationList();
479 foreach (ObjectEntryHandler h in list) 559 foreach (ObjectEntryHandler h in list)
480 { 560 {
481 if (h(objectID, enteringRegion, newPoint, m_scene) == false) 561 if (h(sog, enteringRegion, newPoint) == false)
482 return false; 562 return false;
483 } 563 }
484 } 564 }
@@ -488,29 +568,30 @@ namespace OpenSim.Region.Framework.Scenes
488 #endregion 568 #endregion
489 569
490 #region RETURN OBJECT 570 #region RETURN OBJECT
491 public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects) 571 public bool CanReturnObjects(ILandObject land, IClientAPI client, List<SceneObjectGroup> objects)
492 { 572 {
493 bool result = true;
494
495 ReturnObjectsHandler handler = OnReturnObjects; 573 ReturnObjectsHandler handler = OnReturnObjects;
496 if (handler != null) 574 if (handler != null)
497 { 575 {
576 if(objects == null)
577 return false;
578
579 ScenePresence sp = null;
580 if(client != null && client.SceneAgent != null)
581 sp = client.SceneAgent as ScenePresence;
582
498 Delegate[] list = handler.GetInvocationList(); 583 Delegate[] list = handler.GetInvocationList();
499 foreach (ReturnObjectsHandler h in list) 584 foreach (ReturnObjectsHandler h in list)
500 { 585 {
501 if (h(land, user, objects, m_scene) == false) 586 if (h(land, sp, objects) == false)
502 { 587 return false;
503 result = false;
504 break;
505 }
506 } 588 }
507 } 589 }
508
509// m_log.DebugFormat( 590// m_log.DebugFormat(
510// "[SCENE PERMISSIONS]: CanReturnObjects() fired for user {0} for {1} objects on {2}, result {3}", 591// "[SCENE PERMISSIONS]: CanReturnObjects() fired for user {0} for {1} objects on {2}, result {3}",
511// user, objects.Count, land.LandData.Name, result); 592// user, objects.Count, land.LandData.Name, result);
512 593
513 return result; 594 return true;
514 } 595 }
515 596
516 #endregion 597 #endregion
@@ -524,7 +605,7 @@ namespace OpenSim.Region.Framework.Scenes
524 Delegate[] list = handler.GetInvocationList(); 605 Delegate[] list = handler.GetInvocationList();
525 foreach (InstantMessageHandler h in list) 606 foreach (InstantMessageHandler h in list)
526 { 607 {
527 if (h(user, target, m_scene) == false) 608 if (h(user, target) == false)
528 return false; 609 return false;
529 } 610 }
530 } 611 }
@@ -542,7 +623,7 @@ namespace OpenSim.Region.Framework.Scenes
542 Delegate[] list = handler.GetInvocationList(); 623 Delegate[] list = handler.GetInvocationList();
543 foreach (InventoryTransferHandler h in list) 624 foreach (InventoryTransferHandler h in list)
544 { 625 {
545 if (h(user, target, m_scene) == false) 626 if (h(user, target) == false)
546 return false; 627 return false;
547 } 628 }
548 } 629 }
@@ -560,7 +641,7 @@ namespace OpenSim.Region.Framework.Scenes
560 Delegate[] list = handler.GetInvocationList(); 641 Delegate[] list = handler.GetInvocationList();
561 foreach (ViewScriptHandler h in list) 642 foreach (ViewScriptHandler h in list)
562 { 643 {
563 if (h(script, objectID, user, m_scene) == false) 644 if (h(script, objectID, user) == false)
564 return false; 645 return false;
565 } 646 }
566 } 647 }
@@ -575,7 +656,7 @@ namespace OpenSim.Region.Framework.Scenes
575 Delegate[] list = handler.GetInvocationList(); 656 Delegate[] list = handler.GetInvocationList();
576 foreach (ViewNotecardHandler h in list) 657 foreach (ViewNotecardHandler h in list)
577 { 658 {
578 if (h(script, objectID, user, m_scene) == false) 659 if (h(script, objectID, user) == false)
579 return false; 660 return false;
580 } 661 }
581 } 662 }
@@ -593,7 +674,7 @@ namespace OpenSim.Region.Framework.Scenes
593 Delegate[] list = handler.GetInvocationList(); 674 Delegate[] list = handler.GetInvocationList();
594 foreach (EditScriptHandler h in list) 675 foreach (EditScriptHandler h in list)
595 { 676 {
596 if (h(script, objectID, user, m_scene) == false) 677 if (h(script, objectID, user) == false)
597 return false; 678 return false;
598 } 679 }
599 } 680 }
@@ -608,7 +689,7 @@ namespace OpenSim.Region.Framework.Scenes
608 Delegate[] list = handler.GetInvocationList(); 689 Delegate[] list = handler.GetInvocationList();
609 foreach (EditNotecardHandler h in list) 690 foreach (EditNotecardHandler h in list)
610 { 691 {
611 if (h(script, objectID, user, m_scene) == false) 692 if (h(script, objectID, user) == false)
612 return false; 693 return false;
613 } 694 }
614 } 695 }
@@ -620,19 +701,37 @@ namespace OpenSim.Region.Framework.Scenes
620 #region RUN SCRIPT (When Script Placed in Object) 701 #region RUN SCRIPT (When Script Placed in Object)
621 public bool CanRunScript(UUID script, UUID objectID, UUID user) 702 public bool CanRunScript(UUID script, UUID objectID, UUID user)
622 { 703 {
704 RunScriptHandlerByIDs handler = OnRunScriptByIDs;
705 if (handler != null)
706 {
707 Delegate[] list = handler.GetInvocationList();
708 foreach (RunScriptHandlerByIDs h in list)
709 {
710 if (h(script, objectID, user) == false)
711 return false;
712 }
713 }
714 return true;
715 }
716
717 public bool CanRunScript(TaskInventoryItem item, SceneObjectPart part)
718 {
623 RunScriptHandler handler = OnRunScript; 719 RunScriptHandler handler = OnRunScript;
624 if (handler != null) 720 if (handler != null)
625 { 721 {
722 if(item == null || part == null)
723 return false;
626 Delegate[] list = handler.GetInvocationList(); 724 Delegate[] list = handler.GetInvocationList();
627 foreach (RunScriptHandler h in list) 725 foreach (RunScriptHandler h in list)
628 { 726 {
629 if (h(script, objectID, user, m_scene) == false) 727 if (h(item, part) == false)
630 return false; 728 return false;
631 } 729 }
632 } 730 }
633 return true; 731 return true;
634 } 732 }
635 733
734
636 #endregion 735 #endregion
637 736
638 #region COMPILE SCRIPT (When Script needs to get (re)compiled) 737 #region COMPILE SCRIPT (When Script needs to get (re)compiled)
@@ -644,7 +743,7 @@ namespace OpenSim.Region.Framework.Scenes
644 Delegate[] list = handler.GetInvocationList(); 743 Delegate[] list = handler.GetInvocationList();
645 foreach (CompileScriptHandler h in list) 744 foreach (CompileScriptHandler h in list)
646 { 745 {
647 if (h(ownerUUID, scriptType, m_scene) == false) 746 if (h(ownerUUID, scriptType) == false)
648 return false; 747 return false;
649 } 748 }
650 } 749 }
@@ -662,7 +761,7 @@ namespace OpenSim.Region.Framework.Scenes
662 Delegate[] list = handler.GetInvocationList(); 761 Delegate[] list = handler.GetInvocationList();
663 foreach (StartScriptHandler h in list) 762 foreach (StartScriptHandler h in list)
664 { 763 {
665 if (h(script, user, m_scene) == false) 764 if (h(script, user) == false)
666 return false; 765 return false;
667 } 766 }
668 } 767 }
@@ -680,7 +779,7 @@ namespace OpenSim.Region.Framework.Scenes
680 Delegate[] list = handler.GetInvocationList(); 779 Delegate[] list = handler.GetInvocationList();
681 foreach (StopScriptHandler h in list) 780 foreach (StopScriptHandler h in list)
682 { 781 {
683 if (h(script, user, m_scene) == false) 782 if (h(script, user) == false)
684 return false; 783 return false;
685 } 784 }
686 } 785 }
@@ -698,7 +797,7 @@ namespace OpenSim.Region.Framework.Scenes
698 Delegate[] list = handler.GetInvocationList(); 797 Delegate[] list = handler.GetInvocationList();
699 foreach (ResetScriptHandler h in list) 798 foreach (ResetScriptHandler h in list)
700 { 799 {
701 if (h(prim, script, user, m_scene) == false) 800 if (h(prim, script, user) == false)
702 return false; 801 return false;
703 } 802 }
704 } 803 }
@@ -716,7 +815,7 @@ namespace OpenSim.Region.Framework.Scenes
716 Delegate[] list = handler.GetInvocationList(); 815 Delegate[] list = handler.GetInvocationList();
717 foreach (TerraformLandHandler h in list) 816 foreach (TerraformLandHandler h in list)
718 { 817 {
719 if (h(user, pos, m_scene) == false) 818 if (h(user, pos) == false)
720 return false; 819 return false;
721 } 820 }
722 } 821 }
@@ -734,7 +833,7 @@ namespace OpenSim.Region.Framework.Scenes
734 Delegate[] list = handler.GetInvocationList(); 833 Delegate[] list = handler.GetInvocationList();
735 foreach (RunConsoleCommandHandler h in list) 834 foreach (RunConsoleCommandHandler h in list)
736 { 835 {
737 if (h(user, m_scene) == false) 836 if (h(user) == false)
738 return false; 837 return false;
739 } 838 }
740 } 839 }
@@ -752,7 +851,7 @@ namespace OpenSim.Region.Framework.Scenes
752 Delegate[] list = handler.GetInvocationList(); 851 Delegate[] list = handler.GetInvocationList();
753 foreach (IssueEstateCommandHandler h in list) 852 foreach (IssueEstateCommandHandler h in list)
754 { 853 {
755 if (h(user, m_scene, ownerCommand) == false) 854 if (h(user, ownerCommand) == false)
756 return false; 855 return false;
757 } 856 }
758 } 857 }
@@ -763,13 +862,13 @@ namespace OpenSim.Region.Framework.Scenes
763 #region CAN BE GODLIKE 862 #region CAN BE GODLIKE
764 public bool IsGod(UUID user) 863 public bool IsGod(UUID user)
765 { 864 {
766 IsGodHandler handler = OnIsGod; 865 IsAdministratorHandler handler = OnIsAdministrator;
767 if (handler != null) 866 if (handler != null)
768 { 867 {
769 Delegate[] list = handler.GetInvocationList(); 868 Delegate[] list = handler.GetInvocationList();
770 foreach (IsGodHandler h in list) 869 foreach (IsAdministratorHandler h in list)
771 { 870 {
772 if (h(user, m_scene) == false) 871 if (h(user) == false)
773 return false; 872 return false;
774 } 873 }
775 } 874 }
@@ -784,7 +883,7 @@ namespace OpenSim.Region.Framework.Scenes
784 Delegate[] list = handler.GetInvocationList(); 883 Delegate[] list = handler.GetInvocationList();
785 foreach (IsGridGodHandler h in list) 884 foreach (IsGridGodHandler h in list)
786 { 885 {
787 if (h(user, m_scene) == false) 886 if (h(user) == false)
788 return false; 887 return false;
789 } 888 }
790 } 889 }
@@ -832,7 +931,7 @@ namespace OpenSim.Region.Framework.Scenes
832 Delegate[] list = handler.GetInvocationList(); 931 Delegate[] list = handler.GetInvocationList();
833 foreach (EditParcelPropertiesHandler h in list) 932 foreach (EditParcelPropertiesHandler h in list)
834 { 933 {
835 if (h(user, parcel, p, m_scene, allowManager) == false) 934 if (h(user, parcel, p, allowManager) == false)
836 return false; 935 return false;
837 } 936 }
838 } 937 }
@@ -849,7 +948,7 @@ namespace OpenSim.Region.Framework.Scenes
849 Delegate[] list = handler.GetInvocationList(); 948 Delegate[] list = handler.GetInvocationList();
850 foreach (SellParcelHandler h in list) 949 foreach (SellParcelHandler h in list)
851 { 950 {
852 if (h(user, parcel, m_scene) == false) 951 if (h(user, parcel) == false)
853 return false; 952 return false;
854 } 953 }
855 } 954 }
@@ -866,7 +965,7 @@ namespace OpenSim.Region.Framework.Scenes
866 Delegate[] list = handler.GetInvocationList(); 965 Delegate[] list = handler.GetInvocationList();
867 foreach (AbandonParcelHandler h in list) 966 foreach (AbandonParcelHandler h in list)
868 { 967 {
869 if (h(user, parcel, m_scene) == false) 968 if (h(user, parcel) == false)
870 return false; 969 return false;
871 } 970 }
872 } 971 }
@@ -882,7 +981,7 @@ namespace OpenSim.Region.Framework.Scenes
882 Delegate[] list = handler.GetInvocationList(); 981 Delegate[] list = handler.GetInvocationList();
883 foreach (ReclaimParcelHandler h in list) 982 foreach (ReclaimParcelHandler h in list)
884 { 983 {
885 if (h(user, parcel, m_scene) == false) 984 if (h(user, parcel) == false)
886 return false; 985 return false;
887 } 986 }
888 } 987 }
@@ -897,22 +996,27 @@ namespace OpenSim.Region.Framework.Scenes
897 Delegate[] list = handler.GetInvocationList(); 996 Delegate[] list = handler.GetInvocationList();
898 foreach (DeedParcelHandler h in list) 997 foreach (DeedParcelHandler h in list)
899 { 998 {
900 if (h(user, parcel, m_scene) == false) 999 if (h(user, parcel) == false)
901 return false; 1000 return false;
902 } 1001 }
903 } 1002 }
904 return true; 1003 return true;
905 } 1004 }
906 1005
907 public bool CanDeedObject(UUID user, UUID group) 1006 public bool CanDeedObject(IClientAPI client, SceneObjectGroup sog, UUID targetGroupID)
908 { 1007 {
909 DeedObjectHandler handler = OnDeedObject; 1008 DeedObjectHandler handler = OnDeedObject;
910 if (handler != null) 1009 if (handler != null)
911 { 1010 {
1011 if(sog == null || client == null || client.SceneAgent == null || targetGroupID == UUID.Zero)
1012 return false;
1013
1014 ScenePresence sp = client.SceneAgent as ScenePresence;
1015
912 Delegate[] list = handler.GetInvocationList(); 1016 Delegate[] list = handler.GetInvocationList();
913 foreach (DeedObjectHandler h in list) 1017 foreach (DeedObjectHandler h in list)
914 { 1018 {
915 if (h(user, group, m_scene) == false) 1019 if (h(sp, sog, targetGroupID) == false)
916 return false; 1020 return false;
917 } 1021 }
918 } 1022 }
@@ -927,7 +1031,7 @@ namespace OpenSim.Region.Framework.Scenes
927 Delegate[] list = handler.GetInvocationList(); 1031 Delegate[] list = handler.GetInvocationList();
928 foreach (BuyLandHandler h in list) 1032 foreach (BuyLandHandler h in list)
929 { 1033 {
930 if (h(user, parcel, m_scene) == false) 1034 if (h(user, parcel) == false)
931 return false; 1035 return false;
932 } 1036 }
933 } 1037 }
@@ -1003,6 +1107,45 @@ namespace OpenSim.Region.Framework.Scenes
1003 return true; 1107 return true;
1004 } 1108 }
1005 1109
1110 public bool CanDoObjectInvToObjectInv(TaskInventoryItem item, SceneObjectPart sourcePart, SceneObjectPart destPart)
1111 {
1112 DoObjectInvToObjectInv handler = OnDoObjectInvToObjectInv;
1113 if (handler != null)
1114 {
1115 if (sourcePart == null || destPart == null || item == null)
1116 return false;
1117 Delegate[] list = handler.GetInvocationList();
1118 foreach (DoObjectInvToObjectInv h in list)
1119 {
1120 if (h(item, sourcePart, destPart) == false)
1121 return false;
1122 }
1123 }
1124 return true;
1125 }
1126
1127 public bool CanDropInObjectInv(InventoryItemBase item, IClientAPI client, SceneObjectPart destPart)
1128 {
1129 DoDropInObjectInv handler = OnDropInObjectInv;
1130 if (handler != null)
1131 {
1132 if (client == null || client.SceneAgent == null|| destPart == null || item == null)
1133 return false;
1134
1135 ScenePresence sp = client.SceneAgent as ScenePresence;
1136 if(sp == null || sp.IsDeleted)
1137 return false;
1138
1139 Delegate[] list = handler.GetInvocationList();
1140 foreach (DoDropInObjectInv h in list)
1141 {
1142 if (h(item, sp, destPart) == false)
1143 return false;
1144 }
1145 }
1146 return true;
1147 }
1148
1006 public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID) 1149 public bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
1007 { 1150 {
1008 DeleteObjectInventoryHandler handler = OnDeleteObjectInventory; 1151 DeleteObjectInventoryHandler handler = OnDeleteObjectInventory;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index fd13821..c5b082c 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2388,6 +2388,7 @@ namespace OpenSim.Region.Framework.Scenes
2388 EventManager.TriggerOnSceneObjectLoaded(group); 2388 EventManager.TriggerOnSceneObjectLoaded(group);
2389 SceneObjectPart rootPart = group.GetPart(group.UUID); 2389 SceneObjectPart rootPart = group.GetPart(group.UUID);
2390 rootPart.Flags &= ~PrimFlags.Scripted; 2390 rootPart.Flags &= ~PrimFlags.Scripted;
2391 group.AggregateDeepPerms();
2391 rootPart.TrimPermissions(); 2392 rootPart.TrimPermissions();
2392 2393
2393 // Don't do this here - it will get done later on when sculpt data is loaded. 2394 // Don't do this here - it will get done later on when sculpt data is loaded.
@@ -2640,8 +2641,8 @@ namespace OpenSim.Region.Framework.Scenes
2640 { 2641 {
2641 // Otherwise, use this default creation code; 2642 // Otherwise, use this default creation code;
2642 sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); 2643 sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
2643 AddNewSceneObject(sceneObject, true);
2644 sceneObject.SetGroup(groupID, null); 2644 sceneObject.SetGroup(groupID, null);
2645 AddNewSceneObject(sceneObject, true);
2645 2646
2646 if (AgentPreferencesService != null) // This will override the brave new full perm world! 2647 if (AgentPreferencesService != null) // This will override the brave new full perm world!
2647 { 2648 {
@@ -2659,6 +2660,7 @@ namespace OpenSim.Region.Framework.Scenes
2659 if (UserManagementModule != null) 2660 if (UserManagementModule != null)
2660 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID); 2661 sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
2661 2662
2663 sceneObject.AggregateDeepPerms();
2662 sceneObject.ScheduleGroupForFullUpdate(); 2664 sceneObject.ScheduleGroupForFullUpdate();
2663 2665
2664 return sceneObject; 2666 return sceneObject;
@@ -2805,7 +2807,7 @@ namespace OpenSim.Region.Framework.Scenes
2805 SceneObjectGroup sog = (SceneObjectGroup)e; 2807 SceneObjectGroup sog = (SceneObjectGroup)e;
2806 if (sog != null && !sog.IsAttachment) 2808 if (sog != null && !sog.IsAttachment)
2807 { 2809 {
2808 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) 2810 if (!exceptNoCopy || ((sog.EffectiveOwnerPerms & (uint)PermissionMask.Copy) != 0))
2809 { 2811 {
2810 DeleteSceneObject((SceneObjectGroup)e, false); 2812 DeleteSceneObject((SceneObjectGroup)e, false);
2811 } 2813 }
@@ -2819,7 +2821,7 @@ namespace OpenSim.Region.Framework.Scenes
2819 } 2821 }
2820 if (toReturn.Count > 0) 2822 if (toReturn.Count > 0)
2821 { 2823 {
2822 returnObjects(toReturn.ToArray(), UUID.Zero); 2824 returnObjects(toReturn.ToArray(), null);
2823 } 2825 }
2824 } 2826 }
2825 2827
@@ -3640,7 +3642,9 @@ namespace OpenSim.Region.Framework.Scenes
3640 /// <param name="GroupID">Group of new object</param> 3642 /// <param name="GroupID">Group of new object</param>
3641 public void DuplicateObject(uint originalPrim, Vector3 offset, uint flags, UUID AgentID, UUID GroupID) 3643 public void DuplicateObject(uint originalPrim, Vector3 offset, uint flags, UUID AgentID, UUID GroupID)
3642 { 3644 {
3643 SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, flags, AgentID, GroupID, Quaternion.Identity); 3645 bool createSelected = (flags & (uint)PrimFlags.CreateSelected) != 0;
3646 SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, AgentID,
3647 GroupID, Quaternion.Identity, createSelected);
3644 if (copy != null) 3648 if (copy != null)
3645 EventManager.TriggerObjectAddedToScene(copy); 3649 EventManager.TriggerObjectAddedToScene(copy);
3646 } 3650 }
@@ -3670,6 +3674,8 @@ namespace OpenSim.Region.Framework.Scenes
3670 SceneObjectPart target = GetSceneObjectPart(localID); 3674 SceneObjectPart target = GetSceneObjectPart(localID);
3671 SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj); 3675 SceneObjectPart target2 = GetSceneObjectPart(RayTargetObj);
3672 3676
3677 bool createSelected = (dupeFlags & (uint)PrimFlags.CreateSelected) != 0;
3678
3673 if (target != null && target2 != null) 3679 if (target != null && target2 != null)
3674 { 3680 {
3675 Vector3 direction = Vector3.Normalize(RayEnd - RayStart); 3681 Vector3 direction = Vector3.Normalize(RayEnd - RayStart);
@@ -3711,13 +3717,13 @@ namespace OpenSim.Region.Framework.Scenes
3711 Quaternion worldRot = target2.GetWorldRotation(); 3717 Quaternion worldRot = target2.GetWorldRotation();
3712 3718
3713 // SceneObjectGroup obj = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); 3719 // SceneObjectGroup obj = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot);
3714 copy = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, worldRot); 3720 copy = m_sceneGraph.DuplicateObject(localID, pos, AgentID, GroupID, worldRot, createSelected);
3715 //obj.Rotation = worldRot; 3721 //obj.Rotation = worldRot;
3716 //obj.UpdateGroupRotationR(worldRot); 3722 //obj.UpdateGroupRotationR(worldRot);
3717 } 3723 }
3718 else 3724 else
3719 { 3725 {
3720 copy = m_sceneGraph.DuplicateObject(localID, pos, target.GetEffectiveObjectFlags(), AgentID, GroupID, Quaternion.Identity); 3726 copy = m_sceneGraph.DuplicateObject(localID, pos, AgentID, GroupID, Quaternion.Identity, createSelected);
3721 } 3727 }
3722 3728
3723 if (copy != null) 3729 if (copy != null)
@@ -5114,65 +5120,59 @@ Label_GroupsDone:
5114 #endregion 5120 #endregion
5115 5121
5116 #region Script Engine 5122 #region Script Engine
5117 5123 public bool LSLScriptDanger(SceneObjectPart part, Vector3 pos)
5118 private bool ScriptDanger(SceneObjectPart part, Vector3 pos)
5119 { 5124 {
5125
5120 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y); 5126 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
5121 if (part != null) 5127 if (parcel == null)
5122 { 5128 return true;
5123 if (parcel != null) 5129
5124 { 5130 LandData ldata = parcel.LandData;
5125 if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0) 5131 if (ldata == null)
5126 { 5132 return true;
5127 return true; 5133
5128 } 5134 uint landflags = ldata.Flags;
5129 else if ((part.OwnerID == parcel.LandData.OwnerID) || Permissions.IsGod(part.OwnerID)) 5135
5130 { 5136 uint mask = (uint)(ParcelFlags.CreateObjects | ParcelFlags.AllowAPrimitiveEntry);
5131 return true; 5137 if((landflags & mask) != mask)
5132 } 5138 return true;
5133 else if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0) 5139
5134 && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID)) 5140 if((landflags & (uint)ParcelFlags.AllowOtherScripts) != 0)
5135 { 5141 return false;
5136 return true;
5137 }
5138 else
5139 {
5140 return false;
5141 }
5142 }
5143 else
5144 {
5145 5142
5146 if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY) 5143 if(part == null)
5147 { 5144 return true;
5148 // The only time parcel != null when an object is inside a region is when 5145 if(part.GroupID == ldata.GroupID && (landflags & (uint)ParcelFlags.AllowGroupScripts) != 0)
5149 // there is nothing behind the landchannel. IE, no land plugin loaded.
5150 return true;
5151 }
5152 else
5153 {
5154 // The object is outside of this region. Stop piping events to it.
5155 return false;
5156 }
5157 }
5158 }
5159 else
5160 {
5161 return false; 5146 return false;
5162 } 5147
5148 return true;
5163 } 5149 }
5164 5150
5165 public bool ScriptDanger(uint localID, Vector3 pos) 5151 private bool ScriptDanger(SceneObjectPart part, Vector3 pos)
5166 { 5152 {
5167 SceneObjectPart part = GetSceneObjectPart(localID); 5153 if (part == null)
5168 if (part != null) 5154 return false;
5155
5156 ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
5157 if (parcel != null)
5169 { 5158 {
5170 return ScriptDanger(part, pos); 5159 if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0)
5160 return true;
5161
5162 if ((part.OwnerID == parcel.LandData.OwnerID) || Permissions.IsGod(part.OwnerID))
5163 return true;
5164
5165 if (((parcel.LandData.Flags & (uint)ParcelFlags.AllowGroupScripts) != 0)
5166 && (parcel.LandData.GroupID != UUID.Zero) && (parcel.LandData.GroupID == part.GroupID))
5167 return true;
5171 } 5168 }
5172 else 5169 else
5173 { 5170 {
5174 return false; 5171 if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY)
5172 return true;
5175 } 5173 }
5174
5175 return false;
5176 } 5176 }
5177 5177
5178 public bool PipeEventsForScript(uint localID) 5178 public bool PipeEventsForScript(uint localID)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 2f65ce2..49e98e7 100755
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -343,7 +343,7 @@ namespace OpenSim.Region.Framework.Scenes
343 sceneObject.ForceInventoryPersistence(); 343 sceneObject.ForceInventoryPersistence();
344 sceneObject.HasGroupChanged = true; 344 sceneObject.HasGroupChanged = true;
345 } 345 }
346 346 sceneObject.AggregateDeepPerms();
347 return ret; 347 return ret;
348 } 348 }
349 349
@@ -1358,7 +1358,7 @@ namespace OpenSim.Region.Framework.Scenes
1358 SceneObjectGroup grp = part.ParentGroup; 1358 SceneObjectGroup grp = part.ParentGroup;
1359 if (grp != null) 1359 if (grp != null)
1360 { 1360 {
1361 if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) 1361 if (m_parentScene.Permissions.CanEditObject(grp, remoteClient))
1362 { 1362 {
1363 // These two are exceptions SL makes in the interpretation 1363 // These two are exceptions SL makes in the interpretation
1364 // of the change flags. Must check them here because otherwise 1364 // of the change flags. Must check them here because otherwise
@@ -1379,7 +1379,7 @@ namespace OpenSim.Region.Framework.Scenes
1379 if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0) 1379 if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0)
1380 { 1380 {
1381 // Are we allowed to move it? 1381 // Are we allowed to move it?
1382 if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId)) 1382 if (m_parentScene.Permissions.CanMoveObject(grp, remoteClient))
1383 { 1383 {
1384 // Strip all but move and rotation from request 1384 // Strip all but move and rotation from request
1385 data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); 1385 data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation);
@@ -1406,7 +1406,7 @@ namespace OpenSim.Region.Framework.Scenes
1406 1406
1407 if (part != null) 1407 if (part != null)
1408 { 1408 {
1409 if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) 1409 if (m_parentScene.Permissions.CanEditObject(part.ParentGroup, remoteClient))
1410 { 1410 {
1411 bool physbuild = false; 1411 bool physbuild = false;
1412 if (part.ParentGroup.RootPart.PhysActor != null) 1412 if (part.ParentGroup.RootPart.PhysActor != null)
@@ -1428,7 +1428,7 @@ namespace OpenSim.Region.Framework.Scenes
1428 SceneObjectGroup group = GetGroupByPrim(localID); 1428 SceneObjectGroup group = GetGroupByPrim(localID);
1429 if (group != null) 1429 if (group != null)
1430 { 1430 {
1431 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1431 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1432 { 1432 {
1433 bool physbuild = false; 1433 bool physbuild = false;
1434 if (group.RootPart.PhysActor != null) 1434 if (group.RootPart.PhysActor != null)
@@ -1474,7 +1474,7 @@ namespace OpenSim.Region.Framework.Scenes
1474 SceneObjectGroup group = GetGroupByPrim(localID); 1474 SceneObjectGroup group = GetGroupByPrim(localID);
1475 if (group != null) 1475 if (group != null)
1476 { 1476 {
1477 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1477 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
1478 { 1478 {
1479 group.UpdateSingleRotation(rot, localID); 1479 group.UpdateSingleRotation(rot, localID);
1480 } 1480 }
@@ -1492,7 +1492,7 @@ namespace OpenSim.Region.Framework.Scenes
1492 SceneObjectGroup group = GetGroupByPrim(localID); 1492 SceneObjectGroup group = GetGroupByPrim(localID);
1493 if (group != null) 1493 if (group != null)
1494 { 1494 {
1495 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1495 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
1496 { 1496 {
1497 group.UpdateSingleRotation(rot, pos, localID); 1497 group.UpdateSingleRotation(rot, pos, localID);
1498 } 1498 }
@@ -1510,7 +1510,7 @@ namespace OpenSim.Region.Framework.Scenes
1510 SceneObjectGroup group = GetGroupByPrim(localID); 1510 SceneObjectGroup group = GetGroupByPrim(localID);
1511 if (group != null) 1511 if (group != null)
1512 { 1512 {
1513 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1513 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
1514 { 1514 {
1515 group.UpdateGroupRotationR(rot); 1515 group.UpdateGroupRotationR(rot);
1516 } 1516 }
@@ -1529,7 +1529,7 @@ namespace OpenSim.Region.Framework.Scenes
1529 SceneObjectGroup group = GetGroupByPrim(localID); 1529 SceneObjectGroup group = GetGroupByPrim(localID);
1530 if (group != null) 1530 if (group != null)
1531 { 1531 {
1532 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId)) 1532 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient))
1533 { 1533 {
1534 group.UpdateGroupRotationPR(pos, rot); 1534 group.UpdateGroupRotationPR(pos, rot);
1535 } 1535 }
@@ -1547,7 +1547,7 @@ namespace OpenSim.Region.Framework.Scenes
1547 SceneObjectGroup group = GetGroupByPrim(localID); 1547 SceneObjectGroup group = GetGroupByPrim(localID);
1548 if (group != null) 1548 if (group != null)
1549 { 1549 {
1550 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId) || group.IsAttachment) 1550 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient) || group.IsAttachment)
1551 { 1551 {
1552 group.UpdateSinglePosition(pos, localID); 1552 group.UpdateSinglePosition(pos, localID);
1553 } 1553 }
@@ -1562,17 +1562,6 @@ namespace OpenSim.Region.Framework.Scenes
1562 /// <param name="remoteClient"></param> 1562 /// <param name="remoteClient"></param>
1563 public void UpdatePrimGroupPosition(uint localId, Vector3 pos, IClientAPI remoteClient) 1563 public void UpdatePrimGroupPosition(uint localId, Vector3 pos, IClientAPI remoteClient)
1564 { 1564 {
1565 UpdatePrimGroupPosition(localId, pos, remoteClient.AgentId);
1566 }
1567
1568 /// <summary>
1569 /// Update the position of the given group.
1570 /// </summary>
1571 /// <param name="localId"></param>
1572 /// <param name="pos"></param>
1573 /// <param name="updatingAgentId"></param>
1574 public void UpdatePrimGroupPosition(uint localId, Vector3 pos, UUID updatingAgentId)
1575 {
1576 SceneObjectGroup group = GetGroupByPrim(localId); 1565 SceneObjectGroup group = GetGroupByPrim(localId);
1577 1566
1578 if (group != null) 1567 if (group != null)
@@ -1580,7 +1569,7 @@ namespace OpenSim.Region.Framework.Scenes
1580 if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) 1569 if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0))
1581 { 1570 {
1582 // Set the new attachment point data in the object 1571 // Set the new attachment point data in the object
1583 byte attachmentPoint = group.GetAttachmentPoint(); 1572 byte attachmentPoint = (byte)group.AttachmentPoint;
1584 group.UpdateGroupPosition(pos); 1573 group.UpdateGroupPosition(pos);
1585 group.IsAttachment = false; 1574 group.IsAttachment = false;
1586 group.AbsolutePosition = group.RootPart.AttachedPos; 1575 group.AbsolutePosition = group.RootPart.AttachedPos;
@@ -1589,8 +1578,8 @@ namespace OpenSim.Region.Framework.Scenes
1589 } 1578 }
1590 else 1579 else
1591 { 1580 {
1592 if (m_parentScene.Permissions.CanMoveObject(group.UUID, updatingAgentId) 1581 if (m_parentScene.Permissions.CanMoveObject(group, remoteClient)
1593 && m_parentScene.Permissions.CanObjectEntry(group.UUID, false, pos)) 1582 && m_parentScene.Permissions.CanObjectEntry(group, false, pos))
1594 { 1583 {
1595 group.UpdateGroupPosition(pos); 1584 group.UpdateGroupPosition(pos);
1596 } 1585 }
@@ -1614,7 +1603,7 @@ namespace OpenSim.Region.Framework.Scenes
1614 1603
1615 if (group != null) 1604 if (group != null)
1616 { 1605 {
1617 if (m_parentScene.Permissions.CanEditObject(group.UUID,remoteClient.AgentId)) 1606 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1618 { 1607 {
1619 group.UpdateTextureEntry(localID, texture); 1608 group.UpdateTextureEntry(localID, texture);
1620 } 1609 }
@@ -1638,7 +1627,7 @@ namespace OpenSim.Region.Framework.Scenes
1638 SceneObjectGroup group = GetGroupByPrim(localID); 1627 SceneObjectGroup group = GetGroupByPrim(localID);
1639 if (group != null) 1628 if (group != null)
1640 { 1629 {
1641 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1630 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1642 { 1631 {
1643 // VolumeDetect can't be set via UI and will always be off when a change is made there 1632 // VolumeDetect can't be set via UI and will always be off when a change is made there
1644 // now only change volume dtc if phantom off 1633 // now only change volume dtc if phantom off
@@ -1685,7 +1674,7 @@ namespace OpenSim.Region.Framework.Scenes
1685 SceneObjectGroup group = GetGroupByPrim(primLocalID); 1674 SceneObjectGroup group = GetGroupByPrim(primLocalID);
1686 if (group != null) 1675 if (group != null)
1687 { 1676 {
1688 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1677 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1689 { 1678 {
1690 group.SetPartName(Util.CleanString(name), primLocalID); 1679 group.SetPartName(Util.CleanString(name), primLocalID);
1691 group.HasGroupChanged = true; 1680 group.HasGroupChanged = true;
@@ -1703,7 +1692,7 @@ namespace OpenSim.Region.Framework.Scenes
1703 SceneObjectGroup group = GetGroupByPrim(primLocalID); 1692 SceneObjectGroup group = GetGroupByPrim(primLocalID);
1704 if (group != null) 1693 if (group != null)
1705 { 1694 {
1706 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1695 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1707 { 1696 {
1708 group.SetPartDescription(Util.CleanString(description), primLocalID); 1697 group.SetPartDescription(Util.CleanString(description), primLocalID);
1709 group.HasGroupChanged = true; 1698 group.HasGroupChanged = true;
@@ -1725,7 +1714,7 @@ namespace OpenSim.Region.Framework.Scenes
1725 SceneObjectGroup group = GetGroupByPrim(primLocalID); 1714 SceneObjectGroup group = GetGroupByPrim(primLocalID);
1726 if (group != null) 1715 if (group != null)
1727 { 1716 {
1728 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1717 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1729 { 1718 {
1730 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); 1719 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID);
1731 if (part != null) 1720 if (part != null)
@@ -1742,7 +1731,7 @@ namespace OpenSim.Region.Framework.Scenes
1742 SceneObjectGroup group = GetGroupByPrim(primLocalID); 1731 SceneObjectGroup group = GetGroupByPrim(primLocalID);
1743 if (group != null) 1732 if (group != null)
1744 { 1733 {
1745 if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 1734 if (m_parentScene.Permissions.CanEditObject(group, remoteClient))
1746 { 1735 {
1747 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); 1736 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID);
1748 if (part != null) 1737 if (part != null)
@@ -2025,27 +2014,9 @@ namespace OpenSim.Region.Framework.Scenes
2025 2014
2026 protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID) 2015 protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID)
2027 { 2016 {
2028 UUID user = remoteClient.AgentId; 2017 SceneObjectGroup sog = GetGroupByPrim(localID);
2029 UUID objid = UUID.Zero; 2018 if(sog == null)
2030 SceneObjectPart obj = null; 2019 return;
2031
2032 EntityBase[] entityList = GetEntities();
2033 foreach (EntityBase ent in entityList)
2034 {
2035 if (ent is SceneObjectGroup)
2036 {
2037 SceneObjectGroup sog = ent as SceneObjectGroup;
2038
2039 foreach (SceneObjectPart part in sog.Parts)
2040 {
2041 if (part.LocalId == localID)
2042 {
2043 objid = part.UUID;
2044 obj = part;
2045 }
2046 }
2047 }
2048 }
2049 2020
2050 //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints 2021 //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints
2051 //aka ObjectFlags.JointWheel = IncludeInSearch 2022 //aka ObjectFlags.JointWheel = IncludeInSearch
@@ -2062,15 +2033,15 @@ namespace OpenSim.Region.Framework.Scenes
2062 // libomv will complain about PrimFlags.JointWheel being 2033 // libomv will complain about PrimFlags.JointWheel being
2063 // deprecated, so we 2034 // deprecated, so we
2064 #pragma warning disable 0612 2035 #pragma warning disable 0612
2065 if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(objid, user)) 2036 if (IncludeInSearch && m_parentScene.Permissions.CanEditObject(sog, remoteClient))
2066 { 2037 {
2067 obj.ParentGroup.RootPart.AddFlag(PrimFlags.JointWheel); 2038 sog.RootPart.AddFlag(PrimFlags.JointWheel);
2068 obj.ParentGroup.HasGroupChanged = true; 2039 sog.HasGroupChanged = true;
2069 } 2040 }
2070 else if (!IncludeInSearch && m_parentScene.Permissions.CanMoveObject(objid,user)) 2041 else if (!IncludeInSearch && m_parentScene.Permissions.CanMoveObject(sog, remoteClient))
2071 { 2042 {
2072 obj.ParentGroup.RootPart.RemFlag(PrimFlags.JointWheel); 2043 sog.RootPart.RemFlag(PrimFlags.JointWheel);
2073 obj.ParentGroup.HasGroupChanged = true; 2044 sog.HasGroupChanged = true;
2074 } 2045 }
2075 #pragma warning restore 0612 2046 #pragma warning restore 0612
2076 } 2047 }
@@ -2086,7 +2057,7 @@ namespace OpenSim.Region.Framework.Scenes
2086 /// <param name="rot"></param> 2057 /// <param name="rot"></param>
2087 /// <returns>null if duplication fails, otherwise the duplicated object</returns> 2058 /// <returns>null if duplication fails, otherwise the duplicated object</returns>
2088 /// <summary> 2059 /// <summary>
2089 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) 2060 public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, UUID AgentID, UUID GroupID, Quaternion rot, bool createSelected)
2090 { 2061 {
2091// m_log.DebugFormat( 2062// m_log.DebugFormat(
2092// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", 2063// "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}",
@@ -2095,27 +2066,28 @@ namespace OpenSim.Region.Framework.Scenes
2095 SceneObjectGroup original = GetGroupByPrim(originalPrimID); 2066 SceneObjectGroup original = GetGroupByPrim(originalPrimID);
2096 if (original != null) 2067 if (original != null)
2097 { 2068 {
2098 if (m_parentScene.Permissions.CanDuplicateObject( 2069 if (m_parentScene.Permissions.CanDuplicateObject(original, AgentID))
2099 original.PrimCount, original.UUID, AgentID, original.AbsolutePosition))
2100 { 2070 {
2101 SceneObjectGroup copy = original.Copy(true); 2071 SceneObjectGroup copy = original.Copy(true);
2102 copy.AbsolutePosition = copy.AbsolutePosition + offset; 2072 copy.AbsolutePosition = copy.AbsolutePosition + offset;
2103 2073
2074 SceneObjectPart[] parts = copy.Parts;
2075
2076 m_numTotalPrim += parts.Length;
2077
2104 if (original.OwnerID != AgentID) 2078 if (original.OwnerID != AgentID)
2105 { 2079 {
2106 copy.SetOwnerId(AgentID); 2080 copy.SetOwner(AgentID, GroupID);
2107 copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID);
2108
2109 SceneObjectPart[] partList = copy.Parts;
2110 2081
2111 if (m_parentScene.Permissions.PropagatePermissions()) 2082 if (m_parentScene.Permissions.PropagatePermissions())
2112 { 2083 {
2113 foreach (SceneObjectPart child in partList) 2084 foreach (SceneObjectPart child in parts)
2114 { 2085 {
2115 child.Inventory.ChangeInventoryOwner(AgentID); 2086 child.Inventory.ChangeInventoryOwner(AgentID);
2116 child.TriggerScriptChangedEvent(Changed.OWNER); 2087 child.TriggerScriptChangedEvent(Changed.OWNER);
2117 child.ApplyNextOwnerPermissions(); 2088 child.ApplyNextOwnerPermissions();
2118 } 2089 }
2090 copy.AggregatePerms();
2119 } 2091 }
2120 } 2092 }
2121 2093
@@ -2125,10 +2097,6 @@ namespace OpenSim.Region.Framework.Scenes
2125 lock (SceneObjectGroupsByFullID) 2097 lock (SceneObjectGroupsByFullID)
2126 SceneObjectGroupsByFullID[copy.UUID] = copy; 2098 SceneObjectGroupsByFullID[copy.UUID] = copy;
2127 2099
2128 SceneObjectPart[] parts = copy.Parts;
2129
2130 m_numTotalPrim += parts.Length;
2131
2132 foreach (SceneObjectPart part in parts) 2100 foreach (SceneObjectPart part in parts)
2133 { 2101 {
2134 if (part.GetPrimType() == PrimType.SCULPT) 2102 if (part.GetPrimType() == PrimType.SCULPT)
@@ -2144,28 +2112,19 @@ namespace OpenSim.Region.Framework.Scenes
2144 2112
2145 // PROBABLE END OF FIXME 2113 // PROBABLE END OF FIXME
2146 2114
2147 // Since we copy from a source group that is in selected 2115 copy.IsSelected = createSelected;
2148 // state, but the copy is shown deselected in the viewer,
2149 // We need to clear the selection flag here, else that
2150 // prim never gets persisted at all. The client doesn't
2151 // think it's selected, so it will never send a deselect...
2152 copy.IsSelected = false;
2153
2154 m_numPrim += copy.Parts.Length;
2155 2116
2156 if (rot != Quaternion.Identity) 2117 if (rot != Quaternion.Identity)
2157 {
2158 copy.UpdateGroupRotationR(rot); 2118 copy.UpdateGroupRotationR(rot);
2159 } 2119
2120 // required for physics to update it's position
2121 copy.ResetChildPrimPhysicsPositions();
2160 2122
2161 copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); 2123 copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1);
2162 copy.HasGroupChanged = true;
2163 copy.ScheduleGroupForFullUpdate();
2164 copy.ResumeScripts(); 2124 copy.ResumeScripts();
2165 2125
2166 // required for physics to update it's position 2126 copy.HasGroupChanged = true;
2167 copy.AbsolutePosition = copy.AbsolutePosition; 2127 copy.ScheduleGroupForFullUpdate();
2168
2169 return copy; 2128 return copy;
2170 } 2129 }
2171 } 2130 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 9f98554..12e53a8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -111,7 +111,7 @@ namespace OpenSim.Region.Framework.Scenes
111 /// <param name="item">The user inventory item being added.</param> 111 /// <param name="item">The user inventory item being added.</param>
112 /// <param name="copyItemID">The item UUID that should be used by the new item.</param> 112 /// <param name="copyItemID">The item UUID that should be used by the new item.</param>
113 /// <returns></returns> 113 /// <returns></returns>
114 public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID) 114 public bool AddInventoryItem(UUID agentID, uint localID, InventoryItemBase item, UUID copyItemID, bool withModRights = true)
115 { 115 {
116// m_log.DebugFormat( 116// m_log.DebugFormat(
117// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}", 117// "[PRIM INVENTORY]: Adding inventory item {0} from {1} to part with local ID {2}",
@@ -120,69 +120,72 @@ namespace OpenSim.Region.Framework.Scenes
120 UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID; 120 UUID newItemId = (copyItemID != UUID.Zero) ? copyItemID : item.ID;
121 121
122 SceneObjectPart part = GetPart(localID); 122 SceneObjectPart part = GetPart(localID);
123 if (part != null) 123 if (part == null)
124 { 124 {
125 TaskInventoryItem taskItem = new TaskInventoryItem(); 125 m_log.ErrorFormat(
126 126 "[PRIM INVENTORY]: " +
127 taskItem.ItemID = newItemId; 127 "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}",
128 taskItem.AssetID = item.AssetID; 128 localID, Name, UUID, newItemId);
129 taskItem.Name = item.Name; 129 return false;
130 taskItem.Description = item.Description; 130 }
131 taskItem.OwnerID = part.OwnerID; // Transfer ownership 131
132 taskItem.CreatorID = item.CreatorIdAsUuid; 132 TaskInventoryItem taskItem = new TaskInventoryItem();
133 taskItem.Type = item.AssetType;
134 taskItem.InvType = item.InvType;
135
136 if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
137 {
138 taskItem.BasePermissions = item.BasePermissions &
139 item.NextPermissions;
140 taskItem.CurrentPermissions = item.CurrentPermissions &
141 item.NextPermissions;
142 taskItem.EveryonePermissions = item.EveryOnePermissions &
143 item.NextPermissions;
144 taskItem.GroupPermissions = item.GroupPermissions &
145 item.NextPermissions;
146 taskItem.NextPermissions = item.NextPermissions;
147 // We're adding this to a prim we don't own. Force
148 // owner change
149 taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
150 }
151 else
152 {
153 taskItem.BasePermissions = item.BasePermissions;
154 taskItem.CurrentPermissions = item.CurrentPermissions;
155 taskItem.EveryonePermissions = item.EveryOnePermissions;
156 taskItem.GroupPermissions = item.GroupPermissions;
157 taskItem.NextPermissions = item.NextPermissions;
158 }
159 133
160 taskItem.Flags = item.Flags; 134 taskItem.ItemID = newItemId;
135 taskItem.AssetID = item.AssetID;
136 taskItem.Name = item.Name;
137 taskItem.Description = item.Description;
138 taskItem.OwnerID = part.OwnerID; // Transfer ownership
139 taskItem.CreatorID = item.CreatorIdAsUuid;
140 taskItem.Type = item.AssetType;
141 taskItem.InvType = item.InvType;
142
143 if (agentID != part.OwnerID && m_scene.Permissions.PropagatePermissions())
144 {
145 taskItem.BasePermissions = item.BasePermissions &
146 item.NextPermissions;
147 taskItem.CurrentPermissions = item.CurrentPermissions &
148 item.NextPermissions;
149 taskItem.EveryonePermissions = item.EveryOnePermissions &
150 item.NextPermissions;
151 taskItem.GroupPermissions = item.GroupPermissions &
152 item.NextPermissions;
153 taskItem.NextPermissions = item.NextPermissions;
154 // We're adding this to a prim we don't own. Force
155 // owner change
156 taskItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm;
157
158 }
159 else
160 {
161 taskItem.BasePermissions = item.BasePermissions;
162 taskItem.CurrentPermissions = item.CurrentPermissions;
163 taskItem.EveryonePermissions = item.EveryOnePermissions;
164 taskItem.GroupPermissions = item.GroupPermissions;
165 taskItem.NextPermissions = item.NextPermissions;
166 }
167
168 taskItem.Flags = item.Flags;
161 169
162// m_log.DebugFormat( 170// m_log.DebugFormat(
163// "[PRIM INVENTORY]: Flags are 0x{0:X} for item {1} added to part {2} by {3}", 171// "[PRIM INVENTORY]: Flags are 0x{0:X} for item {1} added to part {2} by {3}",
164// taskItem.Flags, taskItem.Name, localID, remoteClient.Name); 172// taskItem.Flags, taskItem.Name, localID, remoteClient.Name);
165 173
166 // TODO: These are pending addition of those fields to TaskInventoryItem 174 // TODO: These are pending addition of those fields to TaskInventoryItem
167// taskItem.SalePrice = item.SalePrice; 175// taskItem.SalePrice = item.SalePrice;
168// taskItem.SaleType = item.SaleType; 176// taskItem.SaleType = item.SaleType;
169 taskItem.CreationDate = (uint)item.CreationDate; 177 taskItem.CreationDate = (uint)item.CreationDate;
170 178
171 bool addFromAllowedDrop = agentID != part.OwnerID; 179 bool addFromAllowedDrop;
172 180 if(withModRights)
173 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop); 181 addFromAllowedDrop = false;
174
175 return true;
176 }
177 else 182 else
178 { 183 addFromAllowedDrop = (part.ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0;
179 m_log.ErrorFormat( 184
180 "[PRIM INVENTORY]: " + 185 part.Inventory.AddInventoryItem(taskItem, addFromAllowedDrop);
181 "Couldn't find prim local ID {0} in group {1}, {2} to add inventory item ID {3}", 186 part.ParentGroup.AggregatePerms();
182 localID, Name, UUID, newItemId); 187 return true;
183 }
184 188
185 return false;
186 } 189 }
187 190
188 /// <summary> 191 /// <summary>
@@ -248,6 +251,194 @@ namespace OpenSim.Region.Framework.Scenes
248 return -1; 251 return -1;
249 } 252 }
250 253
254 // new test code, to place in better place later
255 private object PermissionsLock = new object();
256
257 private uint m_EffectiveEveryOnePerms;
258 public uint EffectiveEveryOnePerms
259 {
260 get
261 {
262 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
263 // bc this is on heavy duty code paths
264 // but for now we need to test the concept
265// AggregateDeepPerms();
266 return m_EffectiveEveryOnePerms;
267 }
268 }
269
270 private uint m_EffectiveGroupPerms;
271 public uint EffectiveGroupPerms
272 {
273 get
274 {
275 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
276 // bc this is on heavy duty code paths
277 // but for now we need to test the concept
278// AggregateDeepPerms();
279 return m_EffectiveGroupPerms;
280 }
281 }
282
283 private uint m_EffectiveGroupOrEveryOnePerms;
284 public uint EffectiveGroupOrEveryOnePerms
285 {
286 get
287 {
288 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
289 // bc this is on heavy duty code paths
290 // but for now we need to test the concept
291// AggregateDeepPerms();
292 return m_EffectiveGroupOrEveryOnePerms;
293 }
294 }
295
296 private uint m_EffectiveOwnerPerms;
297 public uint EffectiveOwnerPerms
298 {
299 get
300 {
301 // this can't be done here but on every place where a change may happen (rez, (de)link, contents , perms, etc)
302 // bc this is on heavy duty code paths
303 // but for now we need to test the concept
304 // AggregateDeepPerms();
305 return m_EffectiveOwnerPerms;
306 }
307 }
308
309 // aggregates perms scanning parts and their contents
310 // AggregatePerms does same using cached parts content perms
311 public void AggregateDeepPerms()
312 {
313 lock(PermissionsLock)
314 {
315 // aux
316 const uint allmask = (uint)PermissionMask.AllEffective;
317 const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
318 const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
319
320 uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move;
321 bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0;
322
323 uint rootOwnerPerms = RootPart.OwnerMask;
324 uint owner = rootOwnerPerms;
325 uint rootGroupPerms = RootPart.GroupMask;
326 uint group = rootGroupPerms;
327 uint rootEveryonePerms = RootPart.EveryoneMask;
328 uint everyone = rootEveryonePerms;
329
330 SceneObjectPart[] parts = m_parts.GetArray();
331 for (int i = 0; i < parts.Length; i++)
332 {
333 SceneObjectPart part = parts[i];
334 part.AggregateInnerPerms();
335 owner &= part.AggregatedInnerOwnerPerms;
336 group &= part.AggregatedInnerGroupPerms;
337 everyone &= part.AggregatedInnerEveryonePerms;
338 }
339 // recover modify and move
340 rootOwnerPerms &= movemodmask;
341 owner |= rootOwnerPerms;
342 if((owner & copytransfermast) == 0)
343 owner |= (uint)PermissionMask.Transfer;
344
345 owner &= basePerms;
346 m_EffectiveOwnerPerms = owner;
347 uint ownertransfermask = owner & (uint)PermissionMask.Transfer;
348
349 // recover modify and move
350 rootGroupPerms &= movemodmask;
351 group |= rootGroupPerms;
352 if(noBaseTransfer)
353 group &=~(uint)PermissionMask.Copy;
354 else
355 group |= ownertransfermask;
356
357 uint groupOrEveryone = group;
358 m_EffectiveGroupPerms = group & owner;
359
360 // recover move
361 rootEveryonePerms &= (uint)PermissionMask.Move;
362 everyone |= rootEveryonePerms;
363 everyone &= ~(uint)PermissionMask.Modify;
364 if(noBaseTransfer)
365 everyone &=~(uint)PermissionMask.Copy;
366 else
367 everyone |= ownertransfermask;
368
369 groupOrEveryone |= everyone;
370
371 m_EffectiveEveryOnePerms = everyone & owner;
372 m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner;
373 }
374 }
375
376 // aggregates perms scanning parts, assuming their contents was already aggregated and cached
377 // ie is AggregateDeepPerms without the part.AggregateInnerPerms() call on parts loop
378 public void AggregatePerms()
379 {
380 lock(PermissionsLock)
381 {
382 // aux
383 const uint allmask = (uint)PermissionMask.AllEffective;
384 const uint movemodmask = (uint)(PermissionMask.Move | PermissionMask.Modify);
385 const uint copytransfermast = (uint)(PermissionMask.Copy | PermissionMask.Transfer);
386
387 uint basePerms = (RootPart.BaseMask & allmask) | (uint)PermissionMask.Move;
388 bool noBaseTransfer = (basePerms & (uint)PermissionMask.Transfer) == 0;
389
390 uint rootOwnerPerms = RootPart.OwnerMask;
391 uint owner = rootOwnerPerms;
392 uint rootGroupPerms = RootPart.GroupMask;
393 uint group = rootGroupPerms;
394 uint rootEveryonePerms = RootPart.EveryoneMask;
395 uint everyone = rootEveryonePerms;
396
397 SceneObjectPart[] parts = m_parts.GetArray();
398 for (int i = 0; i < parts.Length; i++)
399 {
400 SceneObjectPart part = parts[i];
401 owner &= part.AggregatedInnerOwnerPerms;
402 group &= part.AggregatedInnerGroupPerms;
403 everyone &= part.AggregatedInnerEveryonePerms;
404 }
405 // recover modify and move
406 rootOwnerPerms &= movemodmask;
407 owner |= rootOwnerPerms;
408 if((owner & copytransfermast) == 0)
409 owner |= (uint)PermissionMask.Transfer;
410
411 owner &= basePerms;
412 m_EffectiveOwnerPerms = owner;
413 uint ownertransfermask = owner & (uint)PermissionMask.Transfer;
414
415 // recover modify and move
416 rootGroupPerms &= movemodmask;
417 group |= rootGroupPerms;
418 if(noBaseTransfer)
419 group &=~(uint)PermissionMask.Copy;
420 else
421 group |= ownertransfermask;
422
423 uint groupOrEveryone = group;
424 m_EffectiveGroupPerms = group & owner;
425
426 // recover move
427 rootEveryonePerms &= (uint)PermissionMask.Move;
428 everyone |= rootEveryonePerms;
429 everyone &= ~(uint)PermissionMask.Modify;
430 if(noBaseTransfer)
431 everyone &=~(uint)PermissionMask.Copy;
432 else
433 everyone |= ownertransfermask;
434
435 groupOrEveryone |= everyone;
436
437 m_EffectiveEveryOnePerms = everyone & owner;
438 m_EffectiveGroupOrEveryOnePerms = groupOrEveryone & owner;
439 }
440 }
441
251 public uint GetEffectivePermissions() 442 public uint GetEffectivePermissions()
252 { 443 {
253 return GetEffectivePermissions(false); 444 return GetEffectivePermissions(false);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 6332beb..bf4d60c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -647,7 +647,7 @@ namespace OpenSim.Region.Framework.Scenes
647 localIDs.Add(sog.RootPart.LocalId); 647 localIDs.Add(sog.RootPart.LocalId);
648 sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition, 648 sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition,
649 "Returned at region cross"); 649 "Returned at region cross");
650 sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero); 650 sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero, false);
651 } 651 }
652 catch (Exception) 652 catch (Exception)
653 { 653 {
@@ -1785,63 +1785,6 @@ namespace OpenSim.Region.Framework.Scenes
1785 } 1785 }
1786 } 1786 }
1787 1787
1788 /// <summary>
1789 /// Attach this scene object to the given avatar.
1790 /// </summary>
1791 /// <param name="agentID"></param>
1792 /// <param name="attachmentpoint"></param>
1793 /// <param name="AttachOffset"></param>
1794 private void AttachToAgent(
1795 ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
1796 {
1797 if (avatar != null)
1798 {
1799 // don't attach attachments to child agents
1800 if (avatar.IsChildAgent) return;
1801
1802 // Remove from database and parcel prim count
1803 m_scene.DeleteFromStorage(so.UUID);
1804 m_scene.EventManager.TriggerParcelPrimCountTainted();
1805
1806 so.AttachedAvatar = avatar.UUID;
1807
1808 if (so.RootPart.PhysActor != null)
1809 {
1810 m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor);
1811 so.RootPart.PhysActor = null;
1812 }
1813
1814 so.AbsolutePosition = attachOffset;
1815 so.RootPart.AttachedPos = attachOffset;
1816 so.IsAttachment = true;
1817 so.RootPart.SetParentLocalId(avatar.LocalId);
1818 so.AttachmentPoint = attachmentpoint;
1819
1820 avatar.AddAttachment(this);
1821
1822 if (!silent)
1823 {
1824 // Killing it here will cause the client to deselect it
1825 // It then reappears on the avatar, deselected
1826 // through the full update below
1827 //
1828 if (IsSelected)
1829 {
1830 m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId });
1831 }
1832
1833 IsSelected = false; // fudge....
1834 ScheduleGroupForFullUpdate();
1835 }
1836 }
1837 else
1838 {
1839 m_log.WarnFormat(
1840 "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present",
1841 UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName);
1842 }
1843 }
1844
1845 public byte GetAttachmentPoint() 1788 public byte GetAttachmentPoint()
1846 { 1789 {
1847 return m_rootPart.Shape.State; 1790 return m_rootPart.Shape.State;
@@ -2313,7 +2256,7 @@ namespace OpenSim.Region.Framework.Scenes
2313 RootPart.UUID); 2256 RootPart.UUID);
2314 m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn"); 2257 m_scene.AddReturn(OwnerID == GroupID ? LastOwnerID : OwnerID, Name, AbsolutePosition, "parcel autoreturn");
2315 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero, 2258 m_scene.DeRezObjects(null, new List<uint>() { RootPart.LocalId }, UUID.Zero,
2316 DeRezAction.Return, UUID.Zero); 2259 DeRezAction.Return, UUID.Zero, false);
2317 2260
2318 return; 2261 return;
2319 } 2262 }
@@ -2443,17 +2386,16 @@ namespace OpenSim.Region.Framework.Scenes
2443 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); 2386 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
2444 dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; 2387 dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
2445 2388
2446
2447 if (userExposed) 2389 if (userExposed)
2448 dupe.m_rootPart.TrimPermissions(); 2390 dupe.m_rootPart.TrimPermissions();
2449 2391
2450 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); 2392 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray());
2451 2393
2452 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) 2394 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2)
2453 { 2395 {
2454 return p1.LinkNum.CompareTo(p2.LinkNum); 2396 return p1.LinkNum.CompareTo(p2.LinkNum);
2455 } 2397 }
2456 ); 2398 );
2457 2399
2458 foreach (SceneObjectPart part in partList) 2400 foreach (SceneObjectPart part in partList)
2459 { 2401 {
@@ -2505,10 +2447,12 @@ namespace OpenSim.Region.Framework.Scenes
2505 if (dupe.m_rootPart.PhysActor != null) 2447 if (dupe.m_rootPart.PhysActor != null)
2506 dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building 2448 dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building
2507 2449
2450 dupe.AggregateDeepPerms();
2451
2508 dupe.HasGroupChanged = true; 2452 dupe.HasGroupChanged = true;
2509 dupe.AttachToBackup(); 2453 dupe.AttachToBackup();
2510 2454
2511 ScheduleGroupForFullUpdate(); 2455 dupe.ScheduleGroupForFullUpdate();
2512 } 2456 }
2513 2457
2514 m_dupeInProgress = false; 2458 m_dupeInProgress = false;
@@ -2746,25 +2690,33 @@ namespace OpenSim.Region.Framework.Scenes
2746 } 2690 }
2747 2691
2748 /// <summary> 2692 /// <summary>
2749 /// Set the owner of the root part. 2693 /// Set the owner of all linkset.
2750 /// </summary> 2694 /// </summary>
2751 /// <param name="part"></param>
2752 /// <param name="cAgentID"></param> 2695 /// <param name="cAgentID"></param>
2753 /// <param name="cGroupID"></param> 2696 /// <param name="cGroupID"></param>
2754 public void SetRootPartOwner(SceneObjectPart part, UUID cAgentID, UUID cGroupID) 2697 public void SetOwner(UUID cAgentID, UUID cGroupID)
2755 { 2698 {
2756 part.LastOwnerID = part.OwnerID; 2699 SceneObjectPart rpart = RootPart;
2757 part.OwnerID = cAgentID; 2700 UUID oldowner = rpart.OwnerID;
2758 part.GroupID = cGroupID; 2701 ForEachPart(delegate(SceneObjectPart part)
2702 {
2703 if(part.GroupID != part.OwnerID)
2704 part.LastOwnerID = part.OwnerID;
2705 part.OwnerID = cAgentID;
2706 part.GroupID = cGroupID;
2707 });
2759 2708
2760 if (part.OwnerID != cAgentID) 2709 if (oldowner != cAgentID)
2761 { 2710 {
2762 // Apply Next Owner Permissions if we're not bypassing permissions 2711 // Apply Next Owner Permissions if we're not bypassing permissions
2763 if (!m_scene.Permissions.BypassPermissions()) 2712 if (!m_scene.Permissions.BypassPermissions())
2713 {
2764 ApplyNextOwnerPermissions(); 2714 ApplyNextOwnerPermissions();
2715 AggregatePerms();
2716 }
2765 } 2717 }
2766 2718
2767 part.ScheduleFullUpdate(); 2719 rpart.ScheduleFullUpdate();
2768 } 2720 }
2769 2721
2770 /// <summary> 2722 /// <summary>
@@ -3420,6 +3372,7 @@ namespace OpenSim.Region.Framework.Scenes
3420 objectGroup.HasGroupChangedDueToDelink = true; 3372 objectGroup.HasGroupChangedDueToDelink = true;
3421 3373
3422 InvalidBoundsRadius(); 3374 InvalidBoundsRadius();
3375 objectGroup.AggregatePerms();
3423 3376
3424 if (sendEvents) 3377 if (sendEvents)
3425 linkPart.TriggerScriptChangedEvent(Changed.LINK); 3378 linkPart.TriggerScriptChangedEvent(Changed.LINK);
@@ -3958,8 +3911,8 @@ namespace OpenSim.Region.Framework.Scenes
3958 3911
3959 public void AdjustChildPrimPermissions(bool forceTaskInventoryPermissive) 3912 public void AdjustChildPrimPermissions(bool forceTaskInventoryPermissive)
3960 { 3913 {
3961 uint newOwnerMask = (uint)(PermissionMask.All | PermissionMask.Export) & 0xfffffff8; // Mask folded bits 3914 uint newOwnerMask = (uint)(PermissionMask.All | PermissionMask.Export) & 0xfffffff0; // Mask folded bits
3962 uint foldedPerms = RootPart.OwnerMask & 3; 3915 uint foldedPerms = RootPart.OwnerMask & (uint)PermissionMask.FoldedMask;
3963 3916
3964 ForEachPart(part => 3917 ForEachPart(part =>
3965 { 3918 {
@@ -3970,14 +3923,14 @@ namespace OpenSim.Region.Framework.Scenes
3970 part.Inventory.ApplyGodPermissions(part.BaseMask); 3923 part.Inventory.ApplyGodPermissions(part.BaseMask);
3971 }); 3924 });
3972 3925
3973 uint lockMask = ~(uint)(PermissionMask.Move | PermissionMask.Modify); 3926 uint lockMask = ~(uint)(PermissionMask.Move);
3974 uint lockBit = RootPart.OwnerMask & (uint)(PermissionMask.Move | PermissionMask.Modify); 3927 uint lockBit = RootPart.OwnerMask & (uint)(PermissionMask.Move);
3975 RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); 3928 RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask);
3976 3929
3977// m_log.DebugFormat( 3930// m_log.DebugFormat(
3978// "[SCENE OBJECT GROUP]: RootPart.OwnerMask now {0} for {1} in {2}", 3931// "[SCENE OBJECT GROUP]: RootPart.OwnerMask now {0} for {1} in {2}",
3979// (OpenMetaverse.PermissionMask)RootPart.OwnerMask, Name, Scene.Name); 3932// (OpenMetaverse.PermissionMask)RootPart.OwnerMask, Name, Scene.Name);
3980 3933 AggregatePerms();
3981 RootPart.ScheduleFullUpdate(); 3934 RootPart.ScheduleFullUpdate();
3982 } 3935 }
3983 3936
@@ -4002,6 +3955,7 @@ namespace OpenSim.Region.Framework.Scenes
4002 { 3955 {
4003 foreach (SceneObjectPart part in Parts) 3956 foreach (SceneObjectPart part in Parts)
4004 part.Inventory.ApplyGodPermissions(RootPart.BaseMask); 3957 part.Inventory.ApplyGodPermissions(RootPart.BaseMask);
3958 AggregatePerms();
4005 } 3959 }
4006 3960
4007 HasGroupChanged = true; 3961 HasGroupChanged = true;
@@ -4647,7 +4601,7 @@ namespace OpenSim.Region.Framework.Scenes
4647 } 4601 }
4648 if ((change & ObjectChangeType.Position) != 0) 4602 if ((change & ObjectChangeType.Position) != 0)
4649 { 4603 {
4650 if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) 4604 if (IsAttachment || m_scene.Permissions.CanObjectEntry(group, false, data.position))
4651 UpdateGroupPosition(data.position); 4605 UpdateGroupPosition(data.position);
4652 updateType = updatetype.groupterse; 4606 updateType = updatetype.groupterse;
4653 } 4607 }
@@ -5217,6 +5171,7 @@ namespace OpenSim.Region.Framework.Scenes
5217 { 5171 {
5218 part.ResetOwnerChangeFlag(); 5172 part.ResetOwnerChangeFlag();
5219 }); 5173 });
5174 AggregatePerms();
5220 } 5175 }
5221 5176
5222 // clear some references to easy cg 5177 // clear some references to easy cg
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 557b55e..bf0e31b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -244,11 +244,6 @@ namespace OpenSim.Region.Framework.Scenes
244 244
245 public uint TimeStampTerse; 245 public uint TimeStampTerse;
246 246
247 // The following two are to hold the attachment data
248 // while an object is inworld
249 [XmlIgnore]
250 public byte AttachPoint = 0;
251
252 [XmlIgnore] 247 [XmlIgnore]
253 public Quaternion AttachRotation = Quaternion.Identity; 248 public Quaternion AttachRotation = Quaternion.Identity;
254 249
@@ -277,7 +272,11 @@ namespace OpenSim.Region.Framework.Scenes
277 272
278 public scriptEvents AggregateScriptEvents; 273 public scriptEvents AggregateScriptEvents;
279 274
280 public Vector3 AttachedPos; 275 public Vector3 AttachedPos
276 {
277 get;
278 set;
279 }
281 280
282 // rotation locks on local X,Y and or Z axis bit flags 281 // rotation locks on local X,Y and or Z axis bit flags
283 // bits are as in llSetStatus defined in SceneObjectGroup.axisSelect enum 282 // bits are as in llSetStatus defined in SceneObjectGroup.axisSelect enum
@@ -476,8 +475,8 @@ namespace OpenSim.Region.Framework.Scenes
476 APIDActive = false; 475 APIDActive = false;
477 Flags = 0; 476 Flags = 0;
478 CreateSelected = true; 477 CreateSelected = true;
479
480 TrimPermissions(); 478 TrimPermissions();
479 AggregateInnerPerms();
481 } 480 }
482 481
483 #endregion Constructors 482 #endregion Constructors
@@ -2228,7 +2227,11 @@ namespace OpenSim.Region.Framework.Scenes
2228 dupe.LocalId = plocalID; 2227 dupe.LocalId = plocalID;
2229 2228
2230 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 2229 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
2231 dupe.LastOwnerID = OwnerID; 2230 if(OwnerID != GroupID)
2231 dupe.LastOwnerID = OwnerID;
2232 else
2233 dupe.LastOwnerID = LastOwnerID; // redundant ?
2234
2232 dupe.RezzerID = RezzerID; 2235 dupe.RezzerID = RezzerID;
2233 2236
2234 byte[] extraP = new byte[Shape.ExtraParams.Length]; 2237 byte[] extraP = new byte[Shape.ExtraParams.Length];
@@ -2537,6 +2540,35 @@ namespace OpenSim.Region.Framework.Scenes
2537 return (uint)Flags | (uint)LocalFlags; 2540 return (uint)Flags | (uint)LocalFlags;
2538 } 2541 }
2539 2542
2543 // some of this lines need be moved to other place later
2544
2545 // effective permitions considering only this part inventory contents perms
2546 public uint AggregatedInnerOwnerPerms {get; private set; }
2547 public uint AggregatedInnerGroupPerms {get; private set; }
2548 public uint AggregatedInnerEveryonePerms {get; private set; }
2549 private object InnerPermsLock = new object();
2550
2551 public void AggregateInnerPerms()
2552 {
2553 // assuming child prims permissions masks are irrelevant on a linkset
2554 // root part is handle at SOG since its masks are the sog masks
2555 const uint mask = (uint)PermissionMask.AllEffective;
2556
2557 uint owner = mask;
2558 uint group = mask;
2559 uint everyone = mask;
2560
2561 lock(InnerPermsLock) // do we really need this?
2562 {
2563 if(Inventory != null)
2564 Inventory.AggregateInnerPerms(ref owner, ref group, ref everyone);
2565
2566 AggregatedInnerOwnerPerms = owner & mask;
2567 AggregatedInnerGroupPerms = group & mask;
2568 AggregatedInnerEveryonePerms = everyone & mask;
2569 }
2570 }
2571
2540 public Vector3 GetGeometricCenter() 2572 public Vector3 GetGeometricCenter()
2541 { 2573 {
2542 // this is not real geometric center but a average of positions relative to root prim acording to 2574 // this is not real geometric center but a average of positions relative to root prim acording to
@@ -4464,7 +4496,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
4464 4496
4465 break; 4497 break;
4466 } 4498 }
4467 4499 AggregateInnerPerms();
4468 SendFullUpdateToAllClients(); 4500 SendFullUpdateToAllClients();
4469 } 4501 }
4470 } 4502 }
@@ -4481,6 +4513,8 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
4481 EveryoneMask = source.EveryoneMask & BaseMask; 4513 EveryoneMask = source.EveryoneMask & BaseMask;
4482 NextOwnerMask = source.NextOwnerMask & BaseMask; 4514 NextOwnerMask = source.NextOwnerMask & BaseMask;
4483 4515
4516 AggregateInnerPerms();
4517
4484 if (OwnerMask != prevOwnerMask || 4518 if (OwnerMask != prevOwnerMask ||
4485 GroupMask != prevGroupMask || 4519 GroupMask != prevGroupMask ||
4486 EveryoneMask != prevEveryoneMask || 4520 EveryoneMask != prevEveryoneMask ||
@@ -5212,16 +5246,13 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5212 5246
5213 if (OwnerID != item.Owner) 5247 if (OwnerID != item.Owner)
5214 { 5248 {
5215 //LogPermissions("Before ApplyNextOwnerPermissions"); 5249 if(OwnerID != GroupID)
5250 LastOwnerID = OwnerID;
5251 OwnerID = item.Owner;
5252 Inventory.ChangeInventoryOwner(item.Owner);
5216 5253
5217 if (scene.Permissions.PropagatePermissions()) 5254 if (scene.Permissions.PropagatePermissions())
5218 ApplyNextOwnerPermissions(); 5255 ApplyNextOwnerPermissions();
5219
5220 //LogPermissions("After ApplyNextOwnerPermissions");
5221
5222 LastOwnerID = OwnerID;
5223 OwnerID = item.Owner;
5224 Inventory.ChangeInventoryOwner(item.Owner);
5225 } 5256 }
5226 } 5257 }
5227 5258
@@ -5245,6 +5276,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5245 GroupMask = 0; // Giving an object zaps group permissions 5276 GroupMask = 0; // Giving an object zaps group permissions
5246 5277
5247 Inventory.ApplyNextOwnerPermissions(); 5278 Inventory.ApplyNextOwnerPermissions();
5279 AggregateInnerPerms();
5248 } 5280 }
5249 5281
5250 public void UpdateLookAt() 5282 public void UpdateLookAt()
@@ -5306,6 +5338,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
5306 item.OwnerChanged = false; 5338 item.OwnerChanged = false;
5307 Inventory.UpdateInventoryItem(item, false, false); 5339 Inventory.UpdateInventoryItem(item, false, false);
5308 } 5340 }
5341 AggregateInnerPerms();
5309 } 5342 }
5310 5343
5311 /// <summary> 5344 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index bf56de2..b53c355 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -360,7 +360,7 @@ namespace OpenSim.Region.Framework.Scenes
360// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}", 360// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
361// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); 361// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
362 362
363 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 363 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item, m_part))
364 { 364 {
365 StoreScriptError(item.ItemID, "no permission"); 365 StoreScriptError(item.ItemID, "no permission");
366 return false; 366 return false;
@@ -807,6 +807,7 @@ namespace OpenSim.Region.Framework.Scenes
807 else 807 else
808 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 808 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
809 809
810 m_part.AggregateInnerPerms();
810 m_inventorySerial++; 811 m_inventorySerial++;
811 //m_inventorySerial += 2; 812 //m_inventorySerial += 2;
812 HasInventoryChanged = true; 813 HasInventoryChanged = true;
@@ -829,7 +830,7 @@ namespace OpenSim.Region.Framework.Scenes
829// m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 830// m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
830 } 831 }
831 m_items.LockItemsForWrite(false); 832 m_items.LockItemsForWrite(false);
832 833 m_part.AggregateInnerPerms();
833 m_inventorySerial++; 834 m_inventorySerial++;
834 } 835 }
835 836
@@ -965,7 +966,8 @@ namespace OpenSim.Region.Framework.Scenes
965 { 966 {
966 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) 967 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & (uint)PermissionMask.Slam) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
967 { 968 {
968 part.LastOwnerID = part.OwnerID; 969 if(part.GroupID != part.OwnerID)
970 part.LastOwnerID = part.OwnerID;
969 part.OwnerID = item.OwnerID; 971 part.OwnerID = item.OwnerID;
970 part.Inventory.ChangeInventoryOwner(item.OwnerID); 972 part.Inventory.ChangeInventoryOwner(item.OwnerID);
971 } 973 }
@@ -979,6 +981,7 @@ namespace OpenSim.Region.Framework.Scenes
979 } 981 }
980// old code end 982// old code end
981 rootPart.TrimPermissions(); 983 rootPart.TrimPermissions();
984 group.AggregateDeepPerms();
982 } 985 }
983 986
984 return true; 987 return true;
@@ -1020,16 +1023,20 @@ namespace OpenSim.Region.Framework.Scenes
1020 item.AssetID = m_items[item.ItemID].AssetID; 1023 item.AssetID = m_items[item.ItemID].AssetID;
1021 1024
1022 m_items[item.ItemID] = item; 1025 m_items[item.ItemID] = item;
1026
1023 m_inventorySerial++; 1027 m_inventorySerial++;
1024 if (fireScriptEvents) 1028 if (fireScriptEvents)
1025 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 1029 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
1026 1030
1027 if (considerChanged) 1031 if (considerChanged)
1028 { 1032 {
1033 m_part.AggregateInnerPerms();
1034 m_part.ParentGroup.AggregatePerms();
1029 HasInventoryChanged = true; 1035 HasInventoryChanged = true;
1030 m_part.ParentGroup.HasGroupChanged = true; 1036 m_part.ParentGroup.HasGroupChanged = true;
1031 } 1037 }
1032 m_items.LockItemsForWrite(false); 1038 m_items.LockItemsForWrite(false);
1039
1033 return true; 1040 return true;
1034 } 1041 }
1035 else 1042 else
@@ -1066,6 +1073,10 @@ namespace OpenSim.Region.Framework.Scenes
1066 m_items.LockItemsForWrite(true); 1073 m_items.LockItemsForWrite(true);
1067 m_items.Remove(itemID); 1074 m_items.Remove(itemID);
1068 m_items.LockItemsForWrite(false); 1075 m_items.LockItemsForWrite(false);
1076
1077 m_part.AggregateInnerPerms();
1078 m_part.ParentGroup.AggregatePerms();
1079
1069 m_inventorySerial++; 1080 m_inventorySerial++;
1070 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 1081 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
1071 1082
@@ -1317,6 +1328,16 @@ namespace OpenSim.Region.Framework.Scenes
1317 } 1328 }
1318 } 1329 }
1319 1330
1331 public void AggregateInnerPerms(ref uint owner, ref uint group, ref uint everyone)
1332 {
1333 foreach (TaskInventoryItem item in m_items.Values)
1334 {
1335 owner &= item.CurrentPermissions;
1336 group &= item.GroupPermissions;
1337 everyone &= item.EveryonePermissions;
1338 }
1339 }
1340
1320 public uint MaskEffectivePermissions() 1341 public uint MaskEffectivePermissions()
1321 { 1342 {
1322 uint mask=0x7fffffff; 1343 uint mask=0x7fffffff;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 9545c13..a5af7e1 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2029,11 +2029,6 @@ namespace OpenSim.Region.Framework.Scenes
2029 m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF); 2029 m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF);
2030 } 2030 }
2031 2031
2032 // Tell the client that we're totally ready
2033 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
2034
2035 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2036
2037 if (!string.IsNullOrEmpty(m_callbackURI)) 2032 if (!string.IsNullOrEmpty(m_callbackURI))
2038 { 2033 {
2039 // We cannot sleep here since this would hold up the inbound packet processing thread, as 2034 // We cannot sleep here since this would hold up the inbound packet processing thread, as
@@ -2054,6 +2049,7 @@ namespace OpenSim.Region.Framework.Scenes
2054 2049
2055 Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI); 2050 Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI);
2056 m_callbackURI = null; 2051 m_callbackURI = null;
2052 m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2057 } 2053 }
2058// else 2054// else
2059// { 2055// {
@@ -2062,19 +2058,48 @@ namespace OpenSim.Region.Framework.Scenes
2062// client.Name, client.AgentId, m_scene.RegionInfo.RegionName); 2058// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
2063// } 2059// }
2064 2060
2065 m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 2061
2062 // Tell the client that we're totally ready
2063 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
2064 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2065
2066 bool isHGTP = (m_teleportFlags & TeleportFlags.ViaHGLogin) != 0;
2067
2068 int delayctnr = Util.EnvironmentTickCount();
2069
2070 if (!IsChildAgent)
2071 {
2072 // verify baked textures and cache
2073 bool cachedbaked = false;
2074
2075 if (IsNPC)
2076 cachedbaked = true;
2077 else
2078 {
2079 if (m_scene.AvatarFactory != null && !isHGTP)
2080 cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
2081
2082 // not sure we need this
2083 if (!cachedbaked)
2084 {
2085 if (m_scene.AvatarFactory != null)
2086 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2087 }
2088 }
2089 m_log.DebugFormat("[CompleteMovement] Baked check: {0}ms", Util.EnvironmentTickCountSubtract(ts));
2090 }
2066 2091
2067 if(m_teleportFlags > 0) 2092 if(m_teleportFlags > 0)
2068 { 2093 {
2069 gotCrossUpdate = false; // sanity check 2094 gotCrossUpdate = false; // sanity check
2070 Thread.Sleep(500); // let viewers catch us 2095 if(Util.EnvironmentTickCountSubtract(delayctnr)< 500)
2096 Thread.Sleep(500); // let viewers catch us
2071 } 2097 }
2072 2098
2073 if(!gotCrossUpdate) 2099 if(!gotCrossUpdate)
2074 RotateToLookAt(look); 2100 RotateToLookAt(look);
2075 2101
2076 // HG 2102 // HG
2077 bool isHGTP = (m_teleportFlags & TeleportFlags.ViaHGLogin) != 0;
2078 if(isHGTP) 2103 if(isHGTP)
2079 { 2104 {
2080// ControllingClient.SendNameReply(m_uuid, Firstname, Lastname); 2105// ControllingClient.SendNameReply(m_uuid, Firstname, Lastname);
@@ -2101,24 +2126,6 @@ namespace OpenSim.Region.Framework.Scenes
2101 2126
2102 if (!IsChildAgent) 2127 if (!IsChildAgent)
2103 { 2128 {
2104 // verify baked textures and cache
2105 bool cachedbaked = false;
2106
2107 if (IsNPC)
2108 cachedbaked = true;
2109 else
2110 {
2111 if (m_scene.AvatarFactory != null && !isHGTP)
2112 cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
2113
2114 // not sure we need this
2115 if (!cachedbaked)
2116 {
2117 if (m_scene.AvatarFactory != null)
2118 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2119 }
2120 }
2121
2122 List<ScenePresence> allpresences = m_scene.GetScenePresences(); 2129 List<ScenePresence> allpresences = m_scene.GetScenePresences();
2123 2130
2124 // send avatar object to all presences including us, so they cross it into region 2131 // send avatar object to all presences including us, so they cross it into region
@@ -3110,6 +3117,7 @@ namespace OpenSim.Region.Framework.Scenes
3110 3117
3111 Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose; 3118 Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose;
3112 m_pos = standPos; 3119 m_pos = standPos;
3120
3113 } 3121 }
3114 3122
3115 // We need to wait until we have calculated proper stand positions before sitting up the physical 3123 // We need to wait until we have calculated proper stand positions before sitting up the physical
@@ -3124,6 +3132,7 @@ namespace OpenSim.Region.Framework.Scenes
3124 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3132 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3125 3133
3126 SendAvatarDataToAllAgents(); 3134 SendAvatarDataToAllAgents();
3135 m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
3127 } 3136 }
3128 3137
3129 // reset to default sitAnimation 3138 // reset to default sitAnimation
@@ -3256,6 +3265,7 @@ namespace OpenSim.Region.Framework.Scenes
3256 // Moved here to avoid a race with default sit anim 3265 // Moved here to avoid a race with default sit anim
3257 // The script event needs to be raised after the default sit anim is set. 3266 // The script event needs to be raised after the default sit anim is set.
3258 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3267 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3268 m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
3259 } 3269 }
3260 } 3270 }
3261 3271
@@ -3405,6 +3415,7 @@ namespace OpenSim.Region.Framework.Scenes
3405 3415
3406 Animator.SetMovementAnimations("SIT"); 3416 Animator.SetMovementAnimations("SIT");
3407 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3417 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3418 m_scene.EventManager.TriggerParcelPrimCountTainted(); // update select/ sat on
3408 } 3419 }
3409 3420
3410 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) 3421 public void HandleAgentSit(IClientAPI remoteClient, UUID agentID)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index b8d210c..a12a401 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -114,7 +114,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
114 // Script state may, or may not, exist. Not having any, is NOT 114 // Script state may, or may not, exist. Not having any, is NOT
115 // ever a problem. 115 // ever a problem.
116 sceneObject.LoadScriptState(reader); 116 sceneObject.LoadScriptState(reader);
117 117 sceneObject.AggregateDeepPerms();
118 return sceneObject; 118 return sceneObject;
119 } 119 }
120 120
@@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
278 // Script state may, or may not, exist. Not having any, is NOT 278 // Script state may, or may not, exist. Not having any, is NOT
279 // ever a problem. 279 // ever a problem.
280 sceneObject.LoadScriptState(doc); 280 sceneObject.LoadScriptState(doc);
281 281 sceneObject.AggregatePerms();
282 return sceneObject; 282 return sceneObject;
283 } 283 }
284 catch (Exception e) 284 catch (Exception e)
@@ -1739,6 +1739,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1739 1739
1740 reader.ReadEndElement(); // SceneObjectPart 1740 reader.ReadEndElement(); // SceneObjectPart
1741 1741
1742 obj.AggregateInnerPerms();
1742 // m_log.DebugFormat("[SceneObjectSerializer]: parsed SOP {0} {1}", obj.Name, obj.UUID); 1743 // m_log.DebugFormat("[SceneObjectSerializer]: parsed SOP {0} {1}", obj.Name, obj.UUID);
1743 return obj; 1744 return obj;
1744 } 1745 }
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
index 01bc491..0f022dd 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
@@ -70,6 +70,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
70 //obj.RegenerateFullIDs(); 70 //obj.RegenerateFullIDs();
71 71
72 scene.AddNewSceneObject(obj, true); 72 scene.AddNewSceneObject(obj, true);
73 obj.AggregateDeepPerms();
73 } 74 }
74 } 75 }
75 else 76 else
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
index 56723bf..4d2eb3f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
67 67
68 SceneObjectGroup dupeSo 68 SceneObjectGroup dupeSo
69 = scene.SceneGraph.DuplicateObject( 69 = scene.SceneGraph.DuplicateObject(
70 part1.LocalId, new Vector3(10, 0, 0), 0, ownerId, UUID.Zero, Quaternion.Identity); 70 part1.LocalId, new Vector3(10, 0, 0), ownerId, UUID.Zero, Quaternion.Identity, false);
71 Assert.That(dupeSo.Parts.Length, Is.EqualTo(2)); 71 Assert.That(dupeSo.Parts.Length, Is.EqualTo(2));
72 72
73 SceneObjectPart dupePart1 = dupeSo.GetLinkNumPart(1); 73 SceneObjectPart dupePart1 = dupeSo.GetLinkNumPart(1);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
index e1e973c..abf8c48 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectCrossingTests.cs
@@ -157,29 +157,28 @@ namespace OpenSim.Region.Framework.Scenes.Tests
157 157
158 // Cross 158 // Cross
159 sceneA.SceneGraph.UpdatePrimGroupPosition( 159 sceneA.SceneGraph.UpdatePrimGroupPosition(
160 so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), userId); 160 so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), sp1SceneA.ControllingClient);
161 161
162 // crossing is async 162 // crossing is async
163 Thread.Sleep(500); 163 Thread.Sleep(500);
164 164
165 SceneObjectGroup so1PostCross; 165 SceneObjectGroup so1PostCross;
166 166
167 { 167 ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId);
168 ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId); 168 Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");
169 Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");
170 169
171 ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId); 170 ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId);
172 TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient); 171 TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient);
173 sceneBTc.CompleteMovement(); 172 sceneBTc.CompleteMovement();
174 173
175 Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true"); 174 Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
176 Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject); 175 Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject);
176
177 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
178 so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
179 Assert.NotNull(so1PostCross);
180 Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
177 181
178 Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
179 so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
180 Assert.NotNull(so1PostCross);
181 Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
182 }
183 182
184 Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition; 183 Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition;
185 184
@@ -187,7 +186,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
187 186
188 // Recross 187 // Recross
189 sceneB.SceneGraph.UpdatePrimGroupPosition( 188 sceneB.SceneGraph.UpdatePrimGroupPosition(
190 so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), userId); 189 so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), sp1SceneBPostCross.ControllingClient);
191 190
192 // crossing is async 191 // crossing is async
193 Thread.Sleep(500); 192 Thread.Sleep(500);
@@ -255,13 +254,19 @@ namespace OpenSim.Region.Framework.Scenes.Tests
255 lmmA.EventManagerOnNoLandDataFromStorage(); 254 lmmA.EventManagerOnNoLandDataFromStorage();
256 lmmB.EventManagerOnNoLandDataFromStorage(); 255 lmmB.EventManagerOnNoLandDataFromStorage();
257 256
257 AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
258 TestClient tc = new TestClient(acd, sceneA);
259 List<TestClient> destinationTestClients = new List<TestClient>();
260 EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);
261 ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd);
262
258 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail); 263 SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
259 UUID so1Id = so1.UUID; 264 UUID so1Id = so1.UUID;
260 so1.AbsolutePosition = new Vector3(128, 10, 20); 265 so1.AbsolutePosition = new Vector3(128, 10, 20);
261 266
262 // Cross with a negative value. We must make this call rather than setting AbsolutePosition directly 267 // Cross with a negative value. We must make this call rather than setting AbsolutePosition directly
263 // because only this will execute permission checks in the source region. 268 // because only this will execute permission checks in the source region.
264 sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), userId); 269 sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), sp1SceneA.ControllingClient);
265 270
266 // crossing is async 271 // crossing is async
267 Thread.Sleep(500); 272 Thread.Sleep(500);
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
index ed27385..92b5831 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
@@ -134,11 +134,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
134 private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) 134 private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint)
135 { 135 {
136 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); 136 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host);
137
138 if (hostPart == null) 137 if (hostPart == null)
139 return 0; 138 return 0;
140 139
141 if (hostPart.ParentGroup.IsAttachment) 140 SceneObjectGroup hostgroup = hostPart.ParentGroup;
141
142 if (hostgroup== null || hostgroup.IsAttachment)
142 return 0; 143 return 0;
143 144
144 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>(); 145 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>();
@@ -156,32 +157,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
156 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target)) 157 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target))
157 return 0; 158 return 0;
158 159
159 if (target.UUID != hostPart.ParentGroup.OwnerID) 160 if (target.UUID != hostgroup.OwnerID)
160 { 161 {
161 uint effectivePerms = hostPart.ParentGroup.GetEffectivePermissions(); 162 uint effectivePerms = hostgroup.EffectiveOwnerPerms;
162 163
163 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 164 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
164 return 0; 165 return 0;
165 166
166 hostPart.ParentGroup.SetOwnerId(target.UUID); 167 hostgroup.SetOwner(target.UUID, target.ControllingClient.ActiveGroupId);
167 hostPart.ParentGroup.SetRootPartOwner(hostPart.ParentGroup.RootPart, target.UUID, target.ControllingClient.ActiveGroupId);
168 168
169 if (m_scene.Permissions.PropagatePermissions()) 169 if (m_scene.Permissions.PropagatePermissions())
170 { 170 {
171 foreach (SceneObjectPart child in hostPart.ParentGroup.Parts) 171 foreach (SceneObjectPart child in hostgroup.Parts)
172 { 172 {
173 child.Inventory.ChangeInventoryOwner(target.UUID); 173 child.Inventory.ChangeInventoryOwner(target.UUID);
174 child.TriggerScriptChangedEvent(Changed.OWNER); 174 child.TriggerScriptChangedEvent(Changed.OWNER);
175 child.ApplyNextOwnerPermissions(); 175 child.ApplyNextOwnerPermissions();
176 } 176 }
177 hostgroup.AggregatePerms();
177 } 178 }
178 179
179 hostPart.ParentGroup.RootPart.ObjectSaleType = 0; 180 hostgroup.RootPart.ObjectSaleType = 0;
180 hostPart.ParentGroup.RootPart.SalePrice = 10; 181 hostgroup.RootPart.SalePrice = 10;
181 182
182 hostPart.ParentGroup.HasGroupChanged = true; 183 hostgroup.HasGroupChanged = true;
183 hostPart.ParentGroup.RootPart.SendPropertiesToClient(target.ControllingClient); 184 hostgroup.RootPart.SendPropertiesToClient(target.ControllingClient);
184 hostPart.ParentGroup.RootPart.ScheduleFullUpdate(); 185 hostgroup.RootPart.ScheduleFullUpdate();
185 } 186 }
186 187
187 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0; 188 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0;
diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index 9c0fa75..af32d05 100644
--- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
+++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.OptionalModules
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private bool m_enabled; 53 private bool m_enabled;
54 54
55 private Scene m_scene;
55 public string Name { get { return "PrimLimitsModule"; } } 56 public string Name { get { return "PrimLimitsModule"; } }
56 57
57 public Type ReplaceableInterface { get { return null; } } 58 public Type ReplaceableInterface { get { return null; } }
@@ -77,9 +78,9 @@ namespace OpenSim.Region.OptionalModules
77 public void AddRegion(Scene scene) 78 public void AddRegion(Scene scene)
78 { 79 {
79 if (!m_enabled) 80 if (!m_enabled)
80 {
81 return; 81 return;
82 } 82
83 m_scene = scene;
83 scene.Permissions.OnRezObject += CanRezObject; 84 scene.Permissions.OnRezObject += CanRezObject;
84 scene.Permissions.OnObjectEntry += CanObjectEnter; 85 scene.Permissions.OnObjectEntry += CanObjectEnter;
85 scene.Permissions.OnDuplicateObject += CanDuplicateObject; 86 scene.Permissions.OnDuplicateObject += CanDuplicateObject;
@@ -89,14 +90,12 @@ namespace OpenSim.Region.OptionalModules
89 90
90 public void RemoveRegion(Scene scene) 91 public void RemoveRegion(Scene scene)
91 { 92 {
92 if (m_enabled) 93 if (!m_enabled)
93 {
94 return; 94 return;
95 }
96 95
97 scene.Permissions.OnRezObject -= CanRezObject; 96 m_scene.Permissions.OnRezObject -= CanRezObject;
98 scene.Permissions.OnObjectEntry -= CanObjectEnter; 97 m_scene.Permissions.OnObjectEntry -= CanObjectEnter;
99 scene.Permissions.OnDuplicateObject -= CanDuplicateObject; 98 m_scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
100 } 99 }
101 100
102 public void RegionLoaded(Scene scene) 101 public void RegionLoaded(Scene scene)
@@ -104,11 +103,12 @@ namespace OpenSim.Region.OptionalModules
104 m_dialogModule = scene.RequestModuleInterface<IDialogModule>(); 103 m_dialogModule = scene.RequestModuleInterface<IDialogModule>();
105 } 104 }
106 105
107 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene) 106 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition)
108 { 107 {
109 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 108
109 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
110 110
111 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 111 string response = DoCommonChecks(objectCount, ownerID, lo);
112 112
113 if (response != null) 113 if (response != null)
114 { 114 {
@@ -119,88 +119,79 @@ namespace OpenSim.Region.OptionalModules
119 } 119 }
120 120
121 //OnDuplicateObject 121 //OnDuplicateObject
122 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID ownerID, Scene scene, Vector3 objectPosition) 122 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
123 { 123 {
124 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 124 Vector3 objectPosition = sog.AbsolutePosition;
125 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
125 126
126 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 127 string response = DoCommonChecks(sog.PrimCount, sp.UUID, lo);
127 128
128 if (response != null) 129 if (response != null)
129 { 130 {
130 m_dialogModule.SendAlertToUser(ownerID, response); 131 m_dialogModule.SendAlertToUser(sp.UUID, response);
131 return false; 132 return false;
132 } 133 }
133 return true; 134 return true;
134 } 135 }
135 136
136 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 137 private bool CanObjectEnter(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
137 { 138 {
138 if (newPoint.X < -1f || newPoint.X > (scene.RegionInfo.RegionSizeX + 1) || 139 float newX = newPoint.X;
139 newPoint.Y < -1f || newPoint.Y > (scene.RegionInfo.RegionSizeY) ) 140 float newY = newPoint.Y;
141 if (newX < -1.0f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
142 newY < -1.0f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
140 return true; 143 return true;
141 144
142 SceneObjectPart obj = scene.GetSceneObjectPart(objectID); 145 if (sog == null)
143
144 if (obj == null)
145 return false; 146 return false;
146 147
147 // Prim counts are determined by the location of the root prim. if we're 148 ILandObject newParcel = m_scene.LandChannel.GetLandObject(newX, newY);
148 // moving a child prim, just let it pass
149 if (!obj.IsRoot)
150 {
151 return true;
152 }
153
154 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
155 149
156 if (newParcel == null) 150 if (newParcel == null)
157 return true; 151 return true;
158 152
159 Vector3 oldPoint = obj.GroupPosition; 153 if(!enteringRegion)
160 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
161
162 // The prim hasn't crossed a region boundry so we don't need to worry
163 // about prim counts here
164 if(oldParcel != null && oldParcel.Equals(newParcel))
165 { 154 {
166 return true; 155 Vector3 oldPoint = sog.AbsolutePosition;
156 ILandObject oldParcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
157 if(oldParcel != null && oldParcel.Equals(newParcel))
158 return true;
167 } 159 }
168 160
169 int objectCount = obj.ParentGroup.PrimCount; 161 int objectCount = sog.PrimCount;
170 int usedPrims = newParcel.PrimCounts.Total;
171 int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount();
172 162
173 // TODO: Add Special Case here for temporary prims 163 // TODO: Add Special Case here for temporary prims
174 164
175 string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene); 165 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
176 166
177 if (response != null) 167 if (response != null)
178 { 168 {
179 m_dialogModule.SendAlertToUser(obj.OwnerID, response); 169 if(m_dialogModule != null)
170 m_dialogModule.SendAlertToUser(sog.OwnerID, response);
180 return false; 171 return false;
181 } 172 }
182 return true; 173 return true;
183 } 174 }
184 175
185 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo, Scene scene) 176 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo)
186 { 177 {
187 string response = null; 178 string response = null;
188 179
189 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount(); 180 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount();
190 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity) 181 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity)
191 { 182 {
192 response = "Unable to rez object because the parcel is too full"; 183 response = "Unable to rez object because the parcel is full";
193 } 184 }
194 else 185 else
195 { 186 {
196 int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser; 187 int maxPrimsPerUser = m_scene.RegionInfo.MaxPrimsPerUser;
197 if (maxPrimsPerUser >= 0) 188 if (maxPrimsPerUser >= 0)
198 { 189 {
199 // per-user prim limit is set 190 // per-user prim limit is set
200 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned) 191 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned)
201 { 192 {
202 // caller is not the sole Parcel owner 193 // caller is not the sole Parcel owner
203 EstateSettings estateSettings = scene.RegionInfo.EstateSettings; 194 EstateSettings estateSettings = m_scene.RegionInfo.EstateSettings;
204 if (ownerID != estateSettings.EstateOwner) 195 if (ownerID != estateSettings.EstateOwner)
205 { 196 {
206 // caller is NOT the Estate owner 197 // caller is NOT the Estate owner
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index a9fdb66..6cf0092 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -665,7 +665,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
665 taskItem.AssetID = asset.FullID; 665 taskItem.AssetID = asset.FullID;
666 666
667 host.Inventory.AddInventoryItem(taskItem, false); 667 host.Inventory.AddInventoryItem(taskItem, false);
668 668 host.ParentGroup.AggregatePerms();
669 m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); 669 m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString());
670 } 670 }
671 671
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index e22c6ea..b26fa32 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -523,9 +523,9 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
523 523
524 rootPart.AddFlag(PrimFlags.Phantom); 524 rootPart.AddFlag(PrimFlags.Phantom);
525 525
526 m_scene.AddNewSceneObject(sceneObject, true);
527 sceneObject.SetGroup(groupID, null); 526 sceneObject.SetGroup(groupID, null);
528 527 m_scene.AddNewSceneObject(sceneObject, true);
528 sceneObject.AggregatePerms();
529 return sceneObject; 529 return sceneObject;
530 } 530 }
531 531
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
index a2fbf41..45ef273 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
@@ -920,8 +920,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
920 } 920 }
921 set 921 set
922 { 922 {
923 float old = m_density;
923 m_density = value / 100f; 924 m_density = value / 100f;
924 // for not prim mass is not updated since this implies full rebuild of body inertia TODO 925 if(m_density != old)
926 UpdatePrimBodyData();
925 } 927 }
926 } 928 }
927 public override float GravModifier 929 public override float GravModifier
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9c67395..62654ee 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2735,7 +2735,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2735 if (part.ParentGroup.RootPart == part) 2735 if (part.ParentGroup.RootPart == part)
2736 { 2736 {
2737 SceneObjectGroup parent = part.ParentGroup; 2737 SceneObjectGroup parent = part.ParentGroup;
2738 if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos)) 2738 if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent, false, (Vector3)toPos))
2739 return; 2739 return;
2740 parent.UpdateGroupPosition((Vector3)toPos); 2740 parent.UpdateGroupPosition((Vector3)toPos);
2741 } 2741 }
@@ -7976,7 +7976,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7976 public LSL_Integer llScriptDanger(LSL_Vector pos) 7976 public LSL_Integer llScriptDanger(LSL_Vector pos)
7977 { 7977 {
7978 m_host.AddScriptLPS(1); 7978 m_host.AddScriptLPS(1);
7979 bool result = World.ScriptDanger(m_host.LocalId, pos); 7979 bool result = World.LSLScriptDanger(m_host, pos);
7980 if (result) 7980 if (result)
7981 { 7981 {
7982 return 1; 7982 return 1;
@@ -7985,7 +7985,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7985 { 7985 {
7986 return 0; 7986 return 0;
7987 } 7987 }
7988
7989 } 7988 }
7990 7989
7991 public void llDialog(string avatar, string message, LSL_List buttons, int chat_channel) 7990 public void llDialog(string avatar, string message, LSL_List buttons, int chat_channel)
@@ -15880,7 +15879,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
15880 return; 15879 return;
15881 } 15880 }
15882 15881
15883 group.RootPart.AttachPoint = group.RootPart.Shape.State;
15884 group.RootPart.AttachedPos = group.AbsolutePosition; 15882 group.RootPart.AttachedPos = group.AbsolutePosition;
15885 15883
15886 group.ResetIDs(); 15884 group.ResetIDs();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index e769c6d..4c3f7ee 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2038,6 +2038,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2038 m_host.Inventory.AddInventoryItemExclusive(taskItem, false); 2038 m_host.Inventory.AddInventoryItemExclusive(taskItem, false);
2039 else 2039 else
2040 m_host.Inventory.AddInventoryItem(taskItem, false); 2040 m_host.Inventory.AddInventoryItem(taskItem, false);
2041 m_host.ParentGroup.AggregatePerms();
2041 2042
2042 return taskItem; 2043 return taskItem;
2043 } 2044 }
@@ -3537,7 +3538,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3537 3538
3538 LSL_Float health = new LSL_Float(-1); 3539 LSL_Float health = new LSL_Float(-1);
3539 ScenePresence presence = World.GetScenePresence(new UUID(avatar)); 3540 ScenePresence presence = World.GetScenePresence(new UUID(avatar));
3540 if (presence != null) health = presence.Health; 3541 if (presence != null)
3542 health = presence.Health;
3541 return health; 3543 return health;
3542 } 3544 }
3543 3545
@@ -3577,7 +3579,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3577 UUID avatarId = new UUID(avatar); 3579 UUID avatarId = new UUID(avatar);
3578 ScenePresence presence = World.GetScenePresence(avatarId); 3580 ScenePresence presence = World.GetScenePresence(avatarId);
3579 3581
3580 if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) 3582 if (presence != null)
3581 { 3583 {
3582 float health = presence.Health; 3584 float health = presence.Health;
3583 health += (float)healing; 3585 health += (float)healing;
@@ -3597,7 +3599,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3597 UUID avatarId = new UUID(avatar); 3599 UUID avatarId = new UUID(avatar);
3598 ScenePresence presence = World.GetScenePresence(avatarId); 3600 ScenePresence presence = World.GetScenePresence(avatarId);
3599 3601
3600 if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) 3602 if (presence != null)
3601 { 3603 {
3602 if (health > 100.0) 3604 if (health > 100.0)
3603 health = 100.0; 3605 health = 100.0;
@@ -3616,7 +3618,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3616 UUID avatarId = new UUID(avatar); 3618 UUID avatarId = new UUID(avatar);
3617 ScenePresence presence = World.GetScenePresence(avatarId); 3619 ScenePresence presence = World.GetScenePresence(avatarId);
3618 3620
3619 if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition())) 3621 if (presence != null)
3620 presence.HealRate = (float)healrate; 3622 presence.HealRate = (float)healrate;
3621 } 3623 }
3622 3624
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
index d652b0d1..16b87b3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
@@ -39,6 +39,7 @@ using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory; 39using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC; 40using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.CoreModules.World.Permissions;
42using OpenSim.Region.ScriptEngine.Shared; 43using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api; 44using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Region.ScriptEngine.Shared.Instance; 45using OpenSim.Region.ScriptEngine.Shared.Instance;
@@ -63,12 +64,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
63 base.SetUp(); 64 base.SetUp();
64 65
65 IConfigSource initConfigSource = new IniConfigSource(); 66 IConfigSource initConfigSource = new IniConfigSource();
66 IConfig config = initConfigSource.AddConfig("XEngine"); 67 IConfig config = initConfigSource.AddConfig("Startup");
68 config.Set("serverside_object_permissions", true);
69 config =initConfigSource.AddConfig("Permissions");
70 config.Set("permissionmodules", "DefaultPermissionsModule");
71 config.Set("serverside_object_permissions", true);
72 config.Set("propagate_permissions", true);
73
74 config = initConfigSource.AddConfig("XEngine");
67 config.Set("Enabled", "true"); 75 config.Set("Enabled", "true");
68 76
69 m_scene = new SceneHelpers().SetupScene(); 77 m_scene = new SceneHelpers().SetupScene();
70 SceneHelpers.SetupSceneModules(m_scene, initConfigSource); 78 SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new object[] { new DefaultPermissionsModule() });
71
72 m_engine = new XEngine.XEngine(); 79 m_engine = new XEngine.XEngine();
73 m_engine.Initialise(initConfigSource); 80 m_engine.Initialise(initConfigSource);
74 m_engine.AddRegion(m_scene); 81 m_engine.AddRegion(m_scene);