From fd7e9cae0e54aa1fba9fbd114cbdd8450f7f3ea7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Fri, 20 Feb 2009 14:59:30 +0000
Subject: [PATCH] Add support for filtering tabs in discopower module...

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1291 44740490-163a-0410-bde0-09ae8108e29a
---
 .../config-templates/module_discopower.php        |  5 +++++
 modules/discopower/dictionaries/tabs.php          | 15 ++++++++++++---
 modules/discopower/lib/PowerIdPDisco.php          |  3 +++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/modules/discopower/config-templates/module_discopower.php b/modules/discopower/config-templates/module_discopower.php
index 0837bf76c..50ca7aaba 100644
--- a/modules/discopower/config-templates/module_discopower.php
+++ b/modules/discopower/config-templates/module_discopower.php
@@ -15,6 +15,11 @@ $config = array (
 	 * All other available tabs will be listed after the ones specified below.
 	 */
 	'taborder' => array('norway'),
+	/*
+	 * the 'tab' parameter allows you to limit the tabs to a specific list. (excluding unlisted tags)
+	 *
+	 * 'tabs' => array('norway', 'finland'),
+	 */
 
 );
 
diff --git a/modules/discopower/dictionaries/tabs.php b/modules/discopower/dictionaries/tabs.php
index e792fb2b6..6a4ccc709 100644
--- a/modules/discopower/dictionaries/tabs.php
+++ b/modules/discopower/dictionaries/tabs.php
@@ -8,16 +8,25 @@ $lang = array(
 	),
 
 	'kalmar' => array (
-		'no' => 'Kalmar',
 		'en' => 'Kalmar',
+		'no' => 'Kalmar',
 	),
 
-	'haka' => array (
+	'finland' => array (
 		'no' => 'Finnland',
 		'en' => 'Finland',
 	),
+
+	'sweden' => array (
+		'no' => 'Sverige',
+		'en' => 'Sweden',
+	),
 	
-	'switch' => array (
+	'denmark' => array (
+		'no' => 'Danmark',
+		'en' => 'Denmark',
+	),
+	'switzerland' => array (
 		'no' => 'Sveits',
 		'en' => 'Switzerland',
 	),
diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php
index 0cafc8b1d..54875c2f9 100644
--- a/modules/discopower/lib/PowerIdPDisco.php
+++ b/modules/discopower/lib/PowerIdPDisco.php
@@ -58,12 +58,15 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco {
 			}
 		}
 		
+		$enableTabs = $this->discoconfig->getValue('tabs', NULL);
+		
 		foreach($list AS $key => $val) {
 			$tags = array('misc');
 			if (array_key_exists('tags', $val)) {
 				$tags = $val['tags'];
 			}
 			foreach ($tags AS $tag) {
+				if (!empty($enableTabs) && !in_array($tag, $enableTabs)) continue;
 				$slist[$tag][$key] = $val;
 			}
 		}
-- 
GitLab