From d7e4dad78417e69e3f2fd1e86b812bffb14593f5 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 20 Aug 2014 12:11:03 -0400
Subject: [PATCH] Fixed lightbox login / Your Account link bug. - Resolves
 VUFIND-1019.

---
 .../VuFind/src/VuFind/Controller/MyResearchController.php  | 7 ++++++-
 themes/blueprint/templates/header.phtml                    | 2 +-
 themes/bootprint/templates/header.phtml                    | 2 +-
 themes/bootstrap/templates/header.phtml                    | 2 +-
 themes/bootstrap3/templates/header.phtml                   | 2 +-
 5 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php
index c71d25f494c..7769210f482 100644
--- a/module/VuFind/src/VuFind/Controller/MyResearchController.php
+++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php
@@ -113,7 +113,12 @@ class MyResearchController extends AbstractBase
         // or default action (if no followup provided):
         if ($url = $this->getFollowupUrl()) {
             $this->clearFollowupUrl();
-            return $this->redirect()->toUrl($url);
+            // If a user clicks on the "Your Account" link, we want to be sure
+            // they get to their account rather than being redirected to an old
+            // followup URL. We'll use a redirect=0 GET flag to indicate this:
+            if ($this->params()->fromQuery('redirect', true)) {
+                return $this->redirect()->toUrl($url);
+            }
         }
 
         $config = $this->getConfig();
diff --git a/themes/blueprint/templates/header.phtml b/themes/blueprint/templates/header.phtml
index 52bba0e2114..b4b67c070b1 100644
--- a/themes/blueprint/templates/header.phtml
+++ b/themes/blueprint/templates/header.phtml
@@ -10,7 +10,7 @@
     <? endif; ?>
     <? if (is_object($account) && $account->loginEnabled()): // hide login/logout if unavailable ?>
       <div id="logoutOptions"<?=!$account->isLoggedIn() ? ' class="hide"' : ''?>>
-        <a class="account" href="<?=$this->url('myresearch-home')?>"><?=$this->transEsc("Your Account")?></a> |
+        <a class="account" href="<?=$this->url('myresearch-home', array(), array('query' => array('redirect' => 0)))?>"><?=$this->transEsc("Your Account")?></a> |
         <a class="logout" href="<?=$this->url('myresearch-logout')?>"><?=$this->transEsc("Log Out")?></a>
       </div>
       <div id="loginOptions"<?=$account->isLoggedIn() ? ' class="hide"' : ''?>>
diff --git a/themes/bootprint/templates/header.phtml b/themes/bootprint/templates/header.phtml
index bff7bcf7acb..b3ef234f820 100644
--- a/themes/bootprint/templates/header.phtml
+++ b/themes/bootprint/templates/header.phtml
@@ -17,7 +17,7 @@
     <? endif; ?>
     <? if (is_object($account) && $account->loginEnabled()): // hide login/logout if unavailable ?>
       <span class="logoutOptions<? if(!$account->isLoggedIn()): ?> hide<? endif ?>">
-        <i class="icon-home"></i> <a href="<?=$this->url('myresearch-home')?>" class="modal-link" title="<?=$this->transEsc("Your Account")?>"><?=$this->transEsc("Your Account")?></a>
+        <i class="icon-home"></i> <a href="<?=$this->url('myresearch-home', array(), array('query' => array('redirect' => 0)))?>" class="modal-link" title="<?=$this->transEsc("Your Account")?>"><?=$this->transEsc("Your Account")?></a>
         <span class="muted">&nbsp;/&nbsp;</span>
         <i class="icon-signout"></i> <a href="<?=$this->url('myresearch-logout')?>" class="modal-link" title="<?=$this->transEsc("Log Out")?>"><?=$this->transEsc("Log Out")?></a>
       </span>
diff --git a/themes/bootstrap/templates/header.phtml b/themes/bootstrap/templates/header.phtml
index 3131990ddd0..6f34290f823 100644
--- a/themes/bootstrap/templates/header.phtml
+++ b/themes/bootstrap/templates/header.phtml
@@ -17,7 +17,7 @@
     <? endif; ?>
     <? if (is_object($account) && $account->loginEnabled()): // hide login/logout if unavailable ?>
       <span class="logoutOptions<? if(!$account->isLoggedIn()): ?> hide<? endif ?>">
-        <i class="icon-home"></i> <a href="<?=$this->url('myresearch-home')?>" class="modal-link" title="<?=$this->transEsc("Your Account")?>"><?=$this->transEsc("Your Account")?></a>
+        <i class="icon-home"></i> <a href="<?=$this->url('myresearch-home', array(), array('query' => array('redirect' => 0)))?>" class="modal-link" title="<?=$this->transEsc("Your Account")?>"><?=$this->transEsc("Your Account")?></a>
         <span class="divider">&nbsp;/&nbsp;</span>
         <i class="icon-signout"></i><a href="<?=$this->url('myresearch-logout')?>" class="modal-link" title="<?=$this->transEsc("Log Out")?>"><?=$this->transEsc("Log Out")?></a>
       </span>
diff --git a/themes/bootstrap3/templates/header.phtml b/themes/bootstrap3/templates/header.phtml
index 79a863a8387..54a2a2b90da 100644
--- a/themes/bootstrap3/templates/header.phtml
+++ b/themes/bootstrap3/templates/header.phtml
@@ -26,7 +26,7 @@
       <? endif; ?>
       <? if (is_object($account) && $account->loginEnabled()): // hide login/logout if unavailable ?>
         <li class="logoutOptions<? if(!$account->isLoggedIn()): ?> hidden<? endif ?>">
-          <a href="<?=$this->url('myresearch-home')?>" class="modal-link" title="<?=$this->transEsc("Your Account")?>"><i class="fa fa-home"></i> <?=$this->transEsc("Your Account")?></a>
+          <a href="<?=$this->url('myresearch-home', array(), array('query' => array('redirect' => 0)))?>" class="modal-link" title="<?=$this->transEsc("Your Account")?>"><i class="fa fa-home"></i> <?=$this->transEsc("Your Account")?></a>
         </li>
         <li class="logoutOptions<? if(!$account->isLoggedIn()): ?> hidden<? endif ?>">
           <a href="<?=$this->url('myresearch-logout')?>" class="modal-link" title="<?=$this->transEsc("Log Out")?>"><i class="fa fa-sign-out"></i> <?=$this->transEsc("Log Out")?></a>
-- 
GitLab