From b34174fa01f4b9d55a9436d449faf9931b4ac931 Mon Sep 17 00:00:00 2001
From: Axel Rutz <axel.rutz@clever-systems.net>
Date: Thu, 22 May 2014 04:00:52 +0200
Subject: [PATCH] Issue #1588212 by stevector, axel.rutz | akamaus: Add
 "optional" checkbox to require contexts within mini panels.

---
 panels_mini/plugins/content_types/panels_mini.inc |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/panels_mini/plugins/content_types/panels_mini.inc b/panels_mini/plugins/content_types/panels_mini.inc
index 2170111..66188cc 100644
--- a/panels_mini/plugins/content_types/panels_mini.inc
+++ b/panels_mini/plugins/content_types/panels_mini.inc
@@ -68,8 +68,13 @@ function _panels_mini_panels_mini_content_type_content_type($mini) {
     $type['required context'] = array();
     foreach ($mini->requiredcontexts as $context) {
       $info = ctools_get_context($context['name']);
-      // TODO: allow an optional setting
-      $type['required context'][] = new ctools_context_required($context['identifier'], $info['context name']);
+      // Check if the required context is actually required.
+      if (!empty($context['optional'])) {
+        $type['required context'][] = new ctools_context_optional($context['identifier'], $info['context name']);
+      }
+      else {
+        $type['required context'][] = new ctools_context_required($context['identifier'], $info['context name']);
+      }
     }
   }
   return $type;
-- 
1.7.9.5

