From be375f76469f941fe2e9d78542131a7d48259591 Mon Sep 17 00:00:00 2001
From: Dean Reilly <dean.reilly@gmail.com>
Date: Thu, 15 Nov 2012 17:23:33 +0000
Subject: [PATCH] Issue #1841782 by Dean Reilly: Force reverting a mini panel
 deletes block configuration.

---
 panels_mini/panels_mini.module | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/panels_mini/panels_mini.module b/panels_mini/panels_mini.module
index 7b42fc4..4d1d7a3 100644
--- a/panels_mini/panels_mini.module
+++ b/panels_mini/panels_mini.module
@@ -217,13 +217,20 @@ function panels_mini_save(&$mini) {
 
 /**
  * Remove a mini panel.
+ *
+ * @param object $mini
+ *   The mini panel to be deleted.
+ * @param bool $delete_block_settings = TRUE
+ *   Whether block settings should be deleted too. This is used when deleting
+ *   a mini panel to revert it's configuration and we don't want to lose the 
+ *   block configuration.
  */
-function panels_mini_delete($mini) {
+function panels_mini_delete($mini, $delete_block_settings = TRUE) {
   db_query("DELETE FROM {panels_mini} WHERE name = '%s'", $mini->name);
-  if ($mini->type != t('Overridden')) {
+  if ($delete_block_settings && $mini->type != t('Overridden')) {
     db_query("DELETE FROM {blocks} WHERE module = 'panels_mini' AND delta = '%s'", $mini->name);
   }
-  return panels_delete_display($mini->did);
+  panels_delete_display($mini->did);
 }
 
 /**
@@ -395,3 +402,19 @@ function panels_mini_panels_dashboard_blocks(&$vars) {
   );
 
 }
+
+/**
+ * Implementation of hook_feature_revert()
+ *
+ * Override the default revert functionality to prevent block configuration
+ * from being deleted.
+ *
+ * @param string $module
+ */
+function panels_mini_features_revert($module) {
+  if ($objects = features_get_default('panels_mini', $module)) {
+    foreach ($objects as $object) {
+      panels_mini_delete($component, FALSE);
+    }
+  }
+}
-- 
1.7.11.msysgit.0

