From aa7cb7cf9735cd8b8de370b046688e797c4deedd Mon Sep 17 00:00:00 2001
From: Alexander Purr <purr@ub.uni-leipzig.de>
Date: Wed, 18 Jan 2023 14:48:26 +0100
Subject: [PATCH] refs #22938 [finc] search history: more consistent behavior *
 not logged in: ** don't show offcancas-toggler and profile menu ** breadcrumb
 like: Home -> History * logged in: ** show offcancas-toggler and profile menu
 ** breadcrumb like: Home -> My Account -> History

---
 themes/finc/templates/search/history.phtml | 39 +++++++++++++++-------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/themes/finc/templates/search/history.phtml b/themes/finc/templates/search/history.phtml
index d1716c94b49..a5888f90d8a 100644
--- a/themes/finc/templates/search/history.phtml
+++ b/themes/finc/templates/search/history.phtml
@@ -1,22 +1,36 @@
 <!-- finc - templates - search - history -->
+<?php
+/**
+origin:                            vufind
+called by view helper/controller:  --
+usage:                             (saved) search history
+modified for finc:                 special finc behavior:
+                                   * not logged in:
+                                   ** don't show offcancas-toggler and profile menu
+                                   ** breadcrumb like: Home -> History
+                                   * logged in:
+                                   ** show offcancas-toggler and profile menu
+                                   ** breadcrumb like: Home -> My Account -> History
+configured in:                     --
+ */
+?>
 <?php
   // Set page title.
   $this->headTitle($this->translate('Search History'));
 
-  // finc: handle disable account capabilities
-  $loginEnabled = is_object($account = $this->auth()->getManager()) && $account->loginEnabled();
+$saveSupported = $this->accountCapabilities()->getSavedSearchSetting() === 'enabled';
+$isLoggedIn = $this->auth()->isLoggedIn();
 
   // Set up breadcrumbs:
-  // finc: check for $loginEnabled
-  $this->layout()->breadcrumbs = ($loginEnabled ? '<li><a href="' . $this->url('myresearch-home') . '">' . $this->transEsc('Your Account') . '</a></li>'
+  // finc: check for $isLoggedIn
+  $this->layout()->breadcrumbs = (
+      $isLoggedIn ? '<li><a href="' . $this->url('myresearch-home') . '">' . $this->transEsc('Your Account') . '</a></li>'
     : '') . '<li class="active">' . $this->transEsc('History') . '</li>';
-
-  $saveSupported = $this->accountCapabilities()->getSavedSearchSetting() === 'enabled';
 ?>
 
 <div class="<?=$this->layoutClass('mainbody')?>">
-  <?php /* finc: show only when if $saveSupported */ ?>
-  <?php if ($saveSupported): ?>
+  <?php /* finc: show offcanvas-toggler and profile-menu only when if $isLoggedIn */ ?>
+  <?php if ($isLoggedIn): ?>
     <?=$this->render('RecordDriver/DefaultRecord/offcanvas-toggler-myresearch'); ?>
   <?php endif; ?>
 
@@ -27,7 +41,7 @@
         (<a href="<?=$this->url('myresearch-profile');?>"><?=$this->transEsc("edit");?></a>)
       <?php endif; ?>
     </div>
-  <?php elseif (!empty($this->schedule) && $this->auth()->isLoggedIn()): ?>
+  <?php elseif (!empty($this->schedule) && $isLoggedIn): ?>
     <div class="alert alert-danger alert-email-notification">
       <?=$this->transEsc("no_email_address") . ' ';?><a href="<?=$this->url('myresearch-profile');?>"><?=$this->transEsc("check_profile");?></a>
     </div>
@@ -49,12 +63,13 @@
   <?php endif; ?>
 </div>
 
-<?php if ($saveSupported): ?>
+<?php /* finc: show offcanvas-toggler and profile-menu only if $isLoggedIn */ ?>
+<?php if ($isLoggedIn): ?>
   <div class="<?=$this->layoutClass('sidebar')?>" id="myresearch-sidebar">
     <?=$this->context($this)->renderInContext(
         "myresearch/menu.phtml",
-        // Only activate search history in account menu if user is logged in.
-        $this->auth()->isLoggedIn() ? ['active' => 'history'] : []
+        // apply active highlighting in profile-menu
+        ['active' => 'history']
      );
      ?>
   </div>
-- 
GitLab