From 066b350d207f9410b2198726bdd71555b08c2d6d Mon Sep 17 00:00:00 2001
From: Charles Krinke
Date: Fri, 23 May 2008 02:45:52 +0000
Subject: Thank you kindly, Melanie, for: Nothing huge, but the new button code
 for producing a new script does well, but the script will not allow for name
 change once created. It reverts back to new script.

---
 OpenSim/Framework/IClientAPI.cs                    |  2 +-
 .../Region/ClientStack/LindenUDP/LLClientView.cs   | 24 ++++++-
 .../Modules/World/Permissions/PermissionsModule.cs |  3 +-
 .../Region/Environment/Scenes/Scene.Inventory.cs   | 73 +++++++++++++---------
 .../Environment/Scenes/SceneExternalChecks.cs      |  1 +
 .../Scenes/SceneObjectPart.Inventory.cs            |  5 +-
 6 files changed, 73 insertions(+), 35 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 109e70b..1a97499 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -566,7 +566,7 @@ namespace OpenSim.Framework
 
     public delegate void RezScript(IClientAPI remoteClient, InventoryItemBase item, LLUUID transactionID, uint localID);
 
-    public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint localID);
+    public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID transactionID, TaskInventoryItem item, uint localID);
 
     public delegate void MoveTaskInventory(IClientAPI remoteClient, LLUUID folderID, uint localID, LLUUID itemID);
 
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index c23369c..93ce29e 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -5075,8 +5075,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
                                 handlerUpdateTaskInventory = OnUpdateTaskInventory;
                                 if (handlerUpdateTaskInventory != null)
                                 {
-                                    handlerUpdateTaskInventory(this, updatetask.InventoryData.ItemID,
-                                                               updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID);
+                                    TaskInventoryItem newTaskItem=new TaskInventoryItem();
+                                    newTaskItem.ItemID=updatetask.InventoryData.ItemID;
+                                    newTaskItem.ParentID=updatetask.InventoryData.FolderID;
+                                    newTaskItem.CreatorID=updatetask.InventoryData.CreatorID;
+                                    newTaskItem.OwnerID=updatetask.InventoryData.OwnerID;
+                                    newTaskItem.GroupID=updatetask.InventoryData.GroupID;
+                                    newTaskItem.BaseMask=updatetask.InventoryData.BaseMask;
+                                    newTaskItem.OwnerMask=updatetask.InventoryData.OwnerMask;
+                                    newTaskItem.GroupMask=updatetask.InventoryData.GroupMask;
+                                    newTaskItem.EveryoneMask=updatetask.InventoryData.EveryoneMask;
+                                    newTaskItem.NextOwnerMask=updatetask.InventoryData.NextOwnerMask;
+                                    //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
+                                    newTaskItem.Type=updatetask.InventoryData.Type;
+                                    newTaskItem.InvType=updatetask.InventoryData.InvType;
+                                    newTaskItem.Flags=updatetask.InventoryData.Flags;
+                                    //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
+                                    //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;;
+                                    newTaskItem.Name=Util.FieldToString(updatetask.InventoryData.Name);
+                                    newTaskItem.Description=Util.FieldToString(updatetask.InventoryData.Description);
+                                    newTaskItem.CreationDate=(uint)updatetask.InventoryData.CreationDate;
+                                    handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
+                                                               newTaskItem, updatetask.UpdateData.LocalID);
                                 }
                             }
                         }
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
index a319119..9dcb88c 100644
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
@@ -301,13 +301,14 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
                   LLObject.ObjectFlags.ObjectMove |   // tells client that you can move the object (only, no mod)
                   LLObject.ObjectFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
                   LLObject.ObjectFlags.ObjectYouOwner | // Tells client that you're the owner of the object
+                  LLObject.ObjectFlags.ObjectOwnerModify | // Tells client that you're the owner of the object
                   LLObject.ObjectFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
                     );
 
             // Creating the three ObjectFlags options for this method to choose from.
             // Customize the OwnerMask
             uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
-            objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner;
+            objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner | (uint)LLObject.ObjectFlags.ObjectOwnerModify;
 
             // Customize the GroupMask
             uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 0e19d96..e92178c 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -897,53 +897,66 @@ namespace OpenSim.Region.Environment.Scenes
         /// This method does not handle scripts, <see>RezScript(IClientAPI, LLUUID, unit)</see>
         /// </summary>
         /// <param name="remoteClient"></param>
-        /// <param name="itemID"></param>
-        /// <param name="folderID"></param>
+        /// <param name="transactionID"></param>
+        /// <param name="itemInfo"></param>
         /// <param name="primLocalID"></param>
-        public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID,
+        public void UpdateTaskInventory(IClientAPI remoteClient, LLUUID transactionID, TaskInventoryItem itemInfo,
                                         uint primLocalID)
         {
+            LLUUID itemID=itemInfo.ItemID;
+            LLUUID folderID=itemInfo.ParentID;
+
+            // Find the prim we're dealing with
             SceneObjectPart part = GetSceneObjectPart(primLocalID);
 
             if (part != null)
             {
-                LLUUID copyID = LLUUID.Random();
-                if (itemID != LLUUID.Zero)
+                TaskInventoryItem currentItem=part.GetInventoryItem(itemID);
+                if(currentItem == null)
                 {
-                    CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
-
-                    if (userInfo != null && userInfo.RootFolder != null)
+                    LLUUID copyID = LLUUID.Random();
+                    if (itemID != LLUUID.Zero)
                     {
-                        InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
+                        CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
 
-                        // Try library
-                        // XXX clumsy, possibly should be one call
-                        if (null == item)
+                        if (userInfo != null && userInfo.RootFolder != null)
                         {
-                            item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(itemID);
-                        }
+                            InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
 
-                        if (item != null)
-                        {
-                            part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID);
-                            m_log.InfoFormat(
-                                "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
-                                item.Name, primLocalID, remoteClient.Name);
-                            part.GetProperties(remoteClient);
-                            if (!ExternalChecks.ExternalChecksBypassPermissions())
+                            // Try library
+                            // XXX clumsy, possibly should be one call
+                            if (null == item)
                             {
-                                if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
-                                    RemoveInventoryItem(remoteClient, itemID);
+                                item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(itemID);
+                            }
+
+                            if (item != null)
+                            {
+                                part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID);
+                                m_log.InfoFormat(
+                                    "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}",
+                                    item.Name, primLocalID, remoteClient.Name);
+                                part.GetProperties(remoteClient);
+                                if (!ExternalChecks.ExternalChecksBypassPermissions())
+                                {
+                                    if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
+                                        RemoveInventoryItem(remoteClient, itemID);
+                                }
+                            }
+                            else
+                            {
+                                m_log.ErrorFormat(
+                                    "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
+                                    itemID, remoteClient.Name);
                             }
-                        }
-                        else
-                        {
-                            m_log.ErrorFormat(
-                                "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!",
-                                itemID, remoteClient.Name);
                         }
                     }
                 }
+                else // Updating existing item with new perms etc
+                {
+                    if(part.UpdateInventoryItem(itemInfo))
+                        part.GetProperties(remoteClient);
+                }
             }
             else
             {
diff --git a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
index 040ee70..2be5ab9 100644
--- a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
@@ -69,6 +69,7 @@ namespace OpenSim.Region.Environment.Scenes
                         (uint)LLObject.ObjectFlags.ObjectMove |
                         (uint)LLObject.ObjectFlags.ObjectTransfer |
                         (uint)LLObject.ObjectFlags.ObjectYouOwner |
+                        (uint)LLObject.ObjectFlags.ObjectOwnerModify |
                         (uint)LLObject.ObjectFlags.ObjectYouOfficer;
 
                 foreach (GenerateClientFlags check in GenerateClientFlagsCheckFunctions)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 51521ff..facf72d 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -286,7 +286,6 @@ namespace OpenSim.Region.Environment.Scenes
         public void AddInventoryItem(TaskInventoryItem item)
         {
             item.ParentID = UUID;
-            item.CreationDate = 1000;
             item.ParentPartID = UUID;
 
             string name=FindAvailableInventoryName(item.Name);
@@ -369,6 +368,10 @@ namespace OpenSim.Region.Environment.Scenes
             {
                 if (m_taskInventory.ContainsKey(item.ItemID))
                 {
+                    item.ParentID = UUID;
+                    item.ParentPartID = UUID;
+                    item.Flags=m_taskInventory[item.ItemID].Flags;
+
                     m_taskInventory[item.ItemID] = item;
                     m_inventorySerial++;
                     TriggerScriptChangedEvent(Changed.INVENTORY);
-- 
cgit v1.1