From 71454b1bca0accd1ab5d7628169d4714bb682030 Mon Sep 17 00:00:00 2001
From: Christian Reiner <github@christian-reiner.info>
Date: Fri, 28 Sep 2012 18:57:20 +0200
Subject: [PATCH] Fix to preserve backward compatibility for apps creating
 static links containing the request token (currently the contacts app and
 maybe some 3rd party implementations)

---
 core/templates/layout.user.php | 4 ++--
 lib/template.php               | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index 25af64c8d5..b6d8a7604a 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -11,8 +11,8 @@
 			var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
 			var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
 			var oc_current_user = '<?php echo OC_User::getUser() ?>';
-			var oc_requesttoken = '<?php echo OC_Util::callRegister(); ?>';
-			var oc_requestlifespan = '<?php echo OC_Util::$callLifespan; ?>';
+			var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
+			var oc_requestlifespan = '<?php echo $_['requestlifespan']; ?>';
 		</script>
 		<?php foreach($_['jsfiles'] as $jsfile): ?>
 			<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
diff --git a/lib/template.php b/lib/template.php
index 0033683b66..681b3f0b14 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -155,6 +155,10 @@ class OC_Template{
 		$this->renderas = $renderas;
 		$this->application = $app;
 		$this->vars = array();
+		if($renderas == 'user') {
+			$this->vars['requesttoken'] = OC_Util::callRegister();
+			$this->vars['requestlifespan'] = OC_Util::$callLifespan;
+		}
 		$parts = explode('/', $app); // fix translation when app is something like core/lostpassword
 		$this->l10n = OC_L10N::get($parts[0]);
                 header('X-Frame-Options: Sameorigin');
@@ -369,6 +373,10 @@ class OC_Template{
 
 		if( $this->renderas ) {
 			$page = new OC_TemplateLayout($this->renderas);
+			if($this->renderas == 'user') {
+				$page->assign('requesttoken', $this->vars['requesttoken']);
+				$page->assign('requestlifespan', $this->vars['requestlifespan']);
+			}
 
 			// Add custom headers
 			$page->assign('headers',$this->headers, false);
-- 
GitLab