From 4d5a3d46193e3810008533dc0f23bd6270a03828 Mon Sep 17 00:00:00 2001
From: Hanne Moa <hanne.moa@uninett.no>
Date: Wed, 31 Aug 2016 11:48:19 +0200
Subject: [PATCH] Split logic and data for negotiate-module

For: #454
---
 modules/negotiate/templates/disable.php | 5 +----
 modules/negotiate/templates/enable.php  | 5 +----
 modules/negotiate/www/disable.php       | 1 +
 modules/negotiate/www/enable.php        | 5 +++--
 4 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/modules/negotiate/templates/disable.php b/modules/negotiate/templates/disable.php
index cffa20c76..f9e2d5508 100644
--- a/modules/negotiate/templates/disable.php
+++ b/modules/negotiate/templates/disable.php
@@ -10,10 +10,7 @@
 $this->includeAtTemplateBase('includes/header.php');
 ?>
 <h1><?php echo $this->t('{negotiate:negotiate:disable_title}'); ?></h1>
-<?php
-$url = SimpleSAML\Module::getModuleURL('negotiate/enable.php');
-?>
-<?php echo $this->t('{negotiate:negotiate:disable_info_pre}', array('URL' => htmlspecialchars($url))); ?>
+<?php echo $this->t('{negotiate:negotiate:disable_info_pre}', array('URL' => htmlspecialchars($this->data['url']))); ?>
 
 <?php echo $this->t('{negotiate:negotiate:info_post}'); ?>
 
diff --git a/modules/negotiate/templates/enable.php b/modules/negotiate/templates/enable.php
index 225597b16..939af6fb6 100644
--- a/modules/negotiate/templates/enable.php
+++ b/modules/negotiate/templates/enable.php
@@ -11,10 +11,7 @@ $this->includeAtTemplateBase('includes/header.php');
 ?>
 <h1><?php echo $this->t('{negotiate:negotiate:enable_title}'); ?></h1>
 
-<?php
-$url = SimpleSAML\Module::getModuleURL('negotiate/disable.php');
-?>
-<?php echo $this->t('{negotiate:negotiate:enable_info_pre}', array('URL' => htmlspecialchars($url))); ?>
+<?php echo $this->t('{negotiate:negotiate:enable_info_pre}', array('URL' => htmlspecialchars($this->data['url']))); ?>
 
 <?php echo $this->t('{negotiate:negotiate:info_post}'); ?>
 
diff --git a/modules/negotiate/www/disable.php b/modules/negotiate/www/disable.php
index e392cac05..9cf8c592b 100644
--- a/modules/negotiate/www/disable.php
+++ b/modules/negotiate/www/disable.php
@@ -19,4 +19,5 @@ $globalConfig = SimpleSAML_Configuration::getInstance();
 $session = SimpleSAML_Session::getSessionFromRequest();
 $session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 $t = new SimpleSAML_XHTML_Template($globalConfig, 'negotiate:disable.php');
+$t->data['url'] = SimpleSAML\Module::getModuleURL('negotiate/enable.php');
 $t->show();
diff --git a/modules/negotiate/www/enable.php b/modules/negotiate/www/enable.php
index c58159cfe..04c5e16ff 100644
--- a/modules/negotiate/www/enable.php
+++ b/modules/negotiate/www/enable.php
@@ -9,8 +9,8 @@
  */
 
 $params = array(
-	'secure' => FALSE,
-	'httponly' => TRUE,
+    'secure' => FALSE,
+    'httponly' => TRUE,
 );
 \SimpleSAML\Utils\HTTP::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', NULL, $params, FALSE);
 
@@ -18,4 +18,5 @@ $globalConfig = SimpleSAML_Configuration::getInstance();
 $session = SimpleSAML_Session::getSessionFromRequest();
 $session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 $t = new SimpleSAML_XHTML_Template($globalConfig, 'negotiate:enable.php');
+$t->data['url'] = SimpleSAML\Module::getModuleURL('negotiate/disable.php');
 $t->show();
-- 
GitLab