# HG changeset patch
# User Web-Beest
# Date 1383224946 -3600
# Node ID 389c5029307c0f29e47bb4d50c72a544a10320aa
# Parent  979dc0fd5896d84d450476e84645dd83ccb90786
Patch so that this module can co-exist with context. In the default situation, the regions are cleared which undoes the context settings. With this patch, the block reaction of the context is re-inserted in the block-array so it renders the blocks as requested.

diff --git a/sites/all/modules/custom/block_manager/block_manager.module b/sites/all/modules/custom/block_manager/block_manager.module
--- a/sites/all/modules/custom/block_manager/block_manager.module
+++ b/sites/all/modules/custom/block_manager/block_manager.module
@@ -116,11 +116,15 @@
 
   // Get all the managed blocks for these regions.
   $blocks = _block_manager_get_region_blocks($managed_regions, $paths, $theme);
-
+  
   // Blocks array will hold the render arrays for all the blocks we need.
   // This is done to avoid re-rendering blocks that have already been processed.
   $blocks_array = array();
 
+  if( module_exists('context')) {
+    $reaction = context_get_plugin('reaction', 'block');
+  }
+  
   foreach ($managed_regions as $region) {
     // In existing regions, remove the blocks (collect them in $blocks_array for
     // later use, if need be).
@@ -143,11 +147,20 @@
         }
       }
     }
+    
+    if( module_exists('context')) {
+      $context_blocks = $reaction->block_get_blocks_by_region($region);
+      
+      foreach( $context_blocks as $key => $block ) {
+        $blocks[$region][$block['#block']->bid] = array('weight' => -100);
+        $blocks_array[$block['#block']->bid] = array( 'key' => $key, 'block' => $block);
+      }
+    }
 
     // Remove the region from the page, so that if empty, it doesn't display.
     unset($page[$region]);
   }
-
+  
   // Gather up blocks that need to be rendered separately by the block module.
   $render_blocks = array();
   $bids = array();
