From 1918428e66b63d66260717f581e865b472f821ea Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Thu, 25 Dec 2014 20:36:07 +0200
Subject: MAINT-1863 FIXED 'Delete' button is always disabled for Notecard that
 was opened from object's content

---
 indra/newview/llpreviewnotecard.cpp | 42 ++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 10 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index 337a63e627..307fd55875 100755
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -215,9 +215,12 @@ void LLPreviewNotecard::loadAsset()
 
 	if(item)
 	{
-		if (gAgent.allowOperation(PERM_COPY, item->getPermissions(),
-									GP_OBJECT_MANIPULATE)
-			|| gAgent.isGodlike())
+		LLPermissions perm(item->getPermissions());
+		BOOL is_owner = gAgent.allowOperation(PERM_OWNER, perm, GP_OBJECT_MANIPULATE);
+		BOOL allow_copy = gAgent.allowOperation(PERM_COPY, perm, GP_OBJECT_MANIPULATE);
+		BOOL allow_modify = gAgent.allowOperation(PERM_MODIFY, perm, GP_OBJECT_MANIPULATE);
+
+		if (allow_copy || gAgent.isGodlike())
 		{
 			mAssetID = item->getAssetUUID();
 			if(mAssetID.isNull())
@@ -271,12 +274,17 @@ void LLPreviewNotecard::loadAsset()
 			editor->setEnabled(FALSE);
 			mAssetStatus = PREVIEW_ASSET_LOADED;
 		}
-		if(!gAgent.allowOperation(PERM_MODIFY, item->getPermissions(),
-								GP_OBJECT_MANIPULATE))
+
+		if(!allow_modify)
 		{
 			editor->setEnabled(FALSE);
 			getChildView("lock")->setVisible( TRUE);
 		}
+
+		if(allow_modify || is_owner)
+		{
+			getChildView("Delete")->setEnabled(TRUE);
+		}
 	}
 	else
 	{
@@ -492,13 +500,27 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 
 void LLPreviewNotecard::deleteNotecard()
 {
-	LLViewerInventoryItem* item = gInventory.getItem(mItemUUID);
-	if (item != NULL)
+	if (mObjectUUID.isNull())
 	{
-		const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
-		gInventory.changeItemParent(item, trash_id, FALSE);
+		LLViewerInventoryItem* item = gInventory.getItem(mItemUUID);
+		if (item != NULL)
+		{
+			const LLUUID trash_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_TRASH);
+			gInventory.changeItemParent(item, trash_id, FALSE);
+		}
+	}
+	else
+	{
+		LLViewerObject* object = gObjectList.findObject(mObjectUUID);
+		if(object)
+		{
+			LLViewerInventoryItem* item = dynamic_cast<LLViewerInventoryItem*>(object->getInventoryObject(mItemUUID));
+			if (item != NULL)
+			{
+				object->removeInventory(mItemUUID);
+			}
+		}
 	}
-
 	closeFloater();
 }
 
-- 
cgit v1.2.3