From 099ed7065591b4716c08ed9f6ffc8edfcaacfae0 Mon Sep 17 00:00:00 2001
From: Cho <cho@lindenlab.com>
Date: Sat, 31 May 2014 00:12:14 +0100
Subject: Fixed ACME-1436 and ACME-1501

---
 indra/newview/llfloaterregioninfo.cpp | 74 ++++++++++++++++++++++++++++++++++-
 indra/newview/llfloaterregioninfo.h   |  3 ++
 2 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index d2e8a4907b..2249088b24 100755
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -3642,6 +3642,76 @@ public:
 };
 
 
+// Used for both access add and remove operations, depending on the flag
+// passed in (ESTATE_EXPERIENCE_ALLOWED_ADD, ESTATE_EXPERIENCE_ALLOWED_REMOVE, etc.)
+// static
+bool LLPanelRegionExperiences::experienceCoreConfirm(const LLSD& notification, const LLSD& response)
+{
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	const U32 originalFlags = (U32)notification["payload"]["operation"].asInteger();
+
+	LLViewerRegion* region = gAgent.getRegion();
+	
+	LLSD::array_const_iterator end_it = notification["payload"]["allowed_ids"].endArray();
+
+	for (LLSD::array_const_iterator iter = notification["payload"]["allowed_ids"].beginArray();
+		iter != end_it;
+	     iter++)
+	{
+		U32 flags = originalFlags;
+		if (iter + 1 != end_it)
+			flags |= ESTATE_ACCESS_NO_REPLY;
+
+		const LLUUID id = iter->asUUID();
+		switch(option)
+		{
+			case 0:
+			    // This estate
+			    sendEstateExperienceDelta(flags, id);
+			    break;
+			case 1:
+			{
+				// All estates, either than I own or manage for this owner.  
+				// This will be verified on simulator. JC
+				if (!region) break;
+				if (region->getOwner() == gAgent.getID()
+				    || gAgent.isGodlike())
+				{
+					flags |= ESTATE_ACCESS_APPLY_TO_ALL_ESTATES;
+					sendEstateExperienceDelta(flags, id);
+				}
+				else if (region->isEstateManager())
+				{
+					flags |= ESTATE_ACCESS_APPLY_TO_MANAGED_ESTATES;
+					sendEstateExperienceDelta(flags, id);
+				}
+				break;
+			}
+			case 2:
+			default:
+			    break;
+		}
+	}
+	return false;
+}
+
+
+// Send the actual "estateexperiencedelta" message
+void LLPanelRegionExperiences::sendEstateExperienceDelta(U32 flags, const LLUUID& experience_id)
+{
+	strings_t str(3, std::string());
+	gAgent.getID().toString(str[0]);
+	str[1] = llformat("%u", flags);
+	experience_id.toString(str[2]);
+
+	LLPanelRegionExperiences* panel = LLFloaterRegionInfo::getPanelExperiences();
+	if (panel)
+	{
+		panel->sendEstateOwnerMessage(gMessageSystem, "estateexperiencedelta", LLFloaterRegionInfo::getLastInvoice(), str);
+	}
+}
+
+
 void LLPanelRegionExperiences::infoCallback(LLHandle<LLPanelRegionExperiences> handle, const LLSD& content)
 {	
 	if(handle.isDead())
@@ -3744,7 +3814,7 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id )
 			break;
 
 		case ESTATE_EXPERIENCE_BLOCKED_REMOVE:
-			dialog_name = "EstateAllowedExperienceAdd";
+			dialog_name = "EstateBlockedExperienceRemove";
 			break;
 
 		default:
@@ -3762,7 +3832,7 @@ void LLPanelRegionExperiences::itemChanged( U32 event_type, const LLUUID& id )
 	LLNotification::Params params(dialog_name);
 	params.payload(payload)
 		.substitutions(args)
-		.functor.function(LLPanelEstateInfo::accessCoreConfirm);
+		.functor.function(LLPanelRegionExperiences::experienceCoreConfirm);
 	if (LLPanelEstateInfo::isLindenEstate())
 	{
 		LLNotifications::instance().forceResponse(params, 0);
diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h
index 7bba183ed2..15eeb5ed7e 100755
--- a/indra/newview/llfloaterregioninfo.h
+++ b/indra/newview/llfloaterregioninfo.h
@@ -463,6 +463,9 @@ public:
 	LLPanelRegionExperiences(){}
 	/*virtual*/ BOOL postBuild();
 	virtual BOOL sendUpdate();
+	
+	static bool experienceCoreConfirm(const LLSD& notification, const LLSD& response);
+	static void sendEstateExperienceDelta(U32 flags, const LLUUID& agent_id);
 
 	static void infoCallback(LLHandle<LLPanelRegionExperiences> handle, const LLSD& content);
 	bool refreshFromRegion(LLViewerRegion* region);
-- 
cgit v1.2.3