From 81f9a7c5849f9f484e36c083aff286c9a2fd110a Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Tue, 26 Jan 2010 09:03:39 +0000
Subject: [PATCH] consent: Reintroduce %SPENTITYID% replacement in privacy
 policy URL.

Fixes issue 241.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2134 44740490-163a-0410-bde0-09ae8108e29a
---
 docs/simplesamlphp-reference-idp-hosted.txt | 2 ++
 docs/simplesamlphp-reference-sp-remote.txt  | 2 ++
 modules/consent/www/getconsent.php          | 4 ++++
 3 files changed, 8 insertions(+)

diff --git a/docs/simplesamlphp-reference-idp-hosted.txt b/docs/simplesamlphp-reference-idp-hosted.txt
index 1c1973808..759c41b8f 100644
--- a/docs/simplesamlphp-reference-idp-hosted.txt
+++ b/docs/simplesamlphp-reference-idp-hosted.txt
@@ -56,6 +56,8 @@ Common options
 `privacypolicy`
 :   This is an absolute URL for where an user can find a
     privacypolicy. If set, this will be shown on the consent page.
+    `%SPENTITYID%` in the URL will be replaced with the entity id of
+    the service the user is accessing.
 
 :   Note that this option also exists in the SP-remote metadata, and
     any value in the SP-remote metadata overrides the one configured
diff --git a/docs/simplesamlphp-reference-sp-remote.txt b/docs/simplesamlphp-reference-sp-remote.txt
index 6954a00d6..f0cb1979f 100644
--- a/docs/simplesamlphp-reference-sp-remote.txt
+++ b/docs/simplesamlphp-reference-sp-remote.txt
@@ -58,6 +58,8 @@ and Shibboleth 1.3 protocol:
 `privacypolicy`
 :   This is an absolute URL for where an user can find a privacypolicy
     for this SP. If set, this will be shown on the consent page.
+    `%SPENTITYID%` in the URL will be replaced with the entity id of
+    this service provider.
 
 :   Note that this option also exists in the IdP-hosted metadata. This
     entry in the SP-remote metadata overrides the option in the
diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php
index d600f0936..fab2c41ae 100644
--- a/modules/consent/www/getconsent.php
+++ b/modules/consent/www/getconsent.php
@@ -124,6 +124,10 @@ if (array_key_exists('privacypolicy', $state['Destination'])) {
 } else {
 	$privacypolicy = FALSE;
 }
+if($privacypolicy !== FALSE) {
+	$privacypolicy = str_replace('%SPENTITYID%', urlencode($spentityid),
+		$privacypolicy);
+}
 $t->data['sppp'] = $privacypolicy;
 
 
-- 
GitLab