From b8fa088ac7894fdbccc025fbb391e16491bcdb65 Mon Sep 17 00:00:00 2001
From: Dean Reilly <dean.reilly@gmail.com>
Date: Thu, 15 Nov 2012 17:14:44 +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 a0aa662..e7446f0 100644
--- a/panels_mini/panels_mini.module
+++ b/panels_mini/panels_mini.module
@@ -305,20 +305,27 @@ 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_delete('panels_mini')
     ->condition('name', $mini->name)
     ->execute();
 
-  if (db_table_exists('block') && $mini->type != t('Overridden')) {
+  if ($delete_block_settings && db_table_exists('block') && $mini->type != t('Overridden')) {
     // Also remove from block table as long as there isn't a default that may appear.
     db_delete('block')
       ->condition('delta', $mini->name)
       ->condition('module', 'panels_mini')
       ->execute();
   }
-  return panels_delete_display($mini->did);
+  panels_delete_display($mini->did);
 }
 
 /**
@@ -479,3 +486,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

