From b133940dd3d5abc4aaf6e0386a174637d1a2bc1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaime=20P=C3=A9rez=20Crespo?= <jaime.perez@uninett.no>
Date: Wed, 3 Apr 2013 11:27:50 +0000
Subject: [PATCH] Small fix for issue #537 and refactor to make code more
 clear.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3231 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/saml/www/sp/metadata.php | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php
index 6a33ba04d..7fcbd9c88 100644
--- a/modules/saml/www/sp/metadata.php
+++ b/modules/saml/www/sp/metadata.php
@@ -119,28 +119,16 @@ $name = $spconfig->getLocalizedString('name', NULL);
 $attributes = $spconfig->getArray('attributes', array());
 
 if ($name !== NULL && !empty($attributes)) {
-
-	$attributesrequired = $spconfig->getArray('attributes.required', array());
-
-	$nameFormat = $spconfig->getString('attributes.NameFormat', NULL);
-	foreach ($attributes as $attribute) {
-		$a = new SAML2_XML_md_RequestedAttribute();
-		$a->Name = $attribute;
-		$a->NameFormat = $nameFormat;
-		// Is the attribute required
-		if (in_array($attribute, $attributesrequired))
-			$a->isRequired = true;
-
-	}
-
-	$metaArray20['attributes.required'] = $attributesrequired;
-
 	$metaArray20['name'] = $name;
+	$metaArray20['attributes'] = $attributes;
+	$metaArray20['attributes.required'] = $spconfig->getArray('attributes.required', array());
+	
+	$description = $spconfig->getArray('description', NULL);
 	if ($description !== NULL) {
 		$metaArray20['description'] = $description;
 	}
 
-	$metaArray20['attributes'] = $attributes;
+	$nameFormat = $spconfig->getString('attributes.NameFormat', NULL);
 	if ($nameFormat !== NULL) {
 		$metaArray20['attributes.NameFormat'] = $nameFormat;
 	}
-- 
GitLab