diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Auth.php b/module/VuFind/src/VuFind/View/Helper/Root/Auth.php index 0d0edb2b274743be7fc538575fbba132251405fe..958580bd340bdaa2169a5cd12c1a4fa8f8c16d1d 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Auth.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Auth.php @@ -47,14 +47,24 @@ class Auth extends \Zend\View\Helper\AbstractHelper */ protected $manager; + /** + * ILS Authenticator + * + * @var \VuFind\Auth\ILSAuthenticator + */ + protected $ilsAuthenticator; + /** * Constructor * - * @param \VuFind\Auth\Manager $manager Authentication manager + * @param \VuFind\Auth\Manager $manager Authentication manager + * @param \VuFind\Auth\ILSAuthenticator $ilsAuthenticator ILS Authenticator */ - public function __construct(\VuFind\Auth\Manager $manager) - { + public function __construct(\VuFind\Auth\Manager $manager, + \VuFind\Auth\ILSAuthenticator $ilsAuthenticator + ) { $this->manager = $manager; + $this->ilsAuthenticator = $ilsAuthenticator; } /** @@ -135,6 +145,16 @@ class Auth extends \Zend\View\Helper\AbstractHelper return $this->renderTemplate('create.phtml', $context); } + /** + * Get ILS patron record for the currently logged-in user. + * + * @return array|bool Patron array if available, false otherwise. + */ + public function getILSPatron() + { + return $this->ilsAuthenticator->storedCatalogLogin(); + } + /** * Render the login form fields. * diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php index 74148b05e1cc474b578f14536f84ffc66a08b2f3..406e4fc94dbcdb58709bc693fb152b6c502e5a15 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Factory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Factory.php @@ -92,7 +92,10 @@ class Factory */ public static function getAuth(ServiceManager $sm) { - return new Auth($sm->getServiceLocator()->get('VuFind\AuthManager')); + return new Auth( + $sm->getServiceLocator()->get('VuFind\AuthManager'), + $sm->getServiceLocator()->get('VuFind\ILSAuthenticator') + ); } /** diff --git a/themes/bootstrap3/templates/myresearch/menu.phtml b/themes/bootstrap3/templates/myresearch/menu.phtml index 21ed8cc4ab3f1274124d42810ffc3552e9ae3dd1..bee1ddcb6128b27ea07d38e7dca786e3d21851e2 100644 --- a/themes/bootstrap3/templates/myresearch/menu.phtml +++ b/themes/bootstrap3/templates/myresearch/menu.phtml @@ -1,3 +1,8 @@ +<? + $user = $this->auth()->isLoggedIn(); + $patron = $user ? $this->auth()->getILSPatron() : false; + $capabilityParams = $patron ? ['patron' => $patron] : []; +?> <h4><?=$this->transEsc('Your Account')?></h4> <div class="myresearch-menu"> <? if ($this->userlist()->getMode() !== 'disabled'): ?> @@ -6,37 +11,37 @@ </a> <? endif; ?> <? if ('ils-none' !== $this->ils()->getOfflineMode()): ?> - <? if ($this->ils()->checkCapability('getMyTransactions')): ?> + <? if ($this->ils()->checkCapability('getMyTransactions', $capabilityParams)): ?> <a href="<?=$this->url('myresearch-checkedout')?>"<?=$this->active == 'checkedout' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-book" aria-hidden="true"></i> <?=$this->transEsc('Checked Out Items')?> </a> <? endif; ?> - <? if ($this->ils()->checkCapability('getMyHolds')): ?> + <? if ($this->ils()->checkCapability('getMyHolds', $capabilityParams)): ?> <a href="<?=$this->url('myresearch-holds')?>"<?=$this->active == 'holds' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-flag" aria-hidden="true"></i> <?=$this->transEsc('Holds and Recalls')?> </a> <? endif; ?> - <? if ($this->ils()->checkFunction('StorageRetrievalRequests')): ?> + <? if ($this->ils()->checkFunction('StorageRetrievalRequests', $capabilityParams)): ?> <a href="<?=$this->url('myresearch-storageretrievalrequests')?>"<?=$this->active == 'storageRetrievalRequests' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-archive" aria-hidden="true"></i> <?=$this->transEsc('Storage Retrieval Requests')?> </a> <? endif; ?> - <? if ($this->ils()->checkFunction('ILLRequests')): ?> + <? if ($this->ils()->checkFunction('ILLRequests', $capabilityParams)): ?> <a href="<?=$this->url('myresearch-illrequests')?>"<?=$this->active == 'ILLRequests' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-exchange" aria-hidden="true"></i> <?=$this->transEsc('Interlibrary Loan Requests')?> </a> <? endif; ?> - <? if ($this->ils()->checkCapability('getMyFines')): ?> + <? if ($this->ils()->checkCapability('getMyFines', $capabilityParams)): ?> <a href="<?=$this->url('myresearch-fines')?>"<?=$this->active == 'fines' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-usd" aria-hidden="true"></i> <?=$this->transEsc('Fines')?> </a> <? endif; ?> - <? if ($this->ils()->checkCapability('getMyProfile')): ?> + <? if ($this->ils()->checkCapability('getMyProfile', $capabilityParams)): ?> <a href="<?=$this->url('myresearch-profile')?>"<?=$this->active == 'profile' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-user" aria-hidden="true"></i> <?=$this->transEsc('Profile')?> </a> <? endif; ?> - <? $user = $this->auth()->isLoggedIn(); if ($user && $user->libraryCardsEnabled()): ?> + <? if ($user && $user->libraryCardsEnabled()): ?> <a href="<?=$this->url('librarycards-home')?>"<?=$this->active == 'librarycards' ? ' class="active"' : ''?>> <i class="fa fa-fw fa-barcode" aria-hidden="true"></i> <?=$this->transEsc('Library Cards')?> </a> @@ -47,13 +52,13 @@ <i class="fa fa-fw fa-search" aria-hidden="true"></i> <?=$this->transEsc('history_saved_searches')?> </a> <? endif; ?> - <? if ($user = $this->auth()->isLoggedIn()): ?> + <? if ($user): ?> <a href="<?=$this->url('myresearch-logout')?>"> <i class="fa fa-fw fa-sign-out" aria-hidden="true"></i> <?=$this->transEsc("Log Out")?> </a> <? endif; ?> </div> -<? if ($this->auth()->isLoggedIn() && $this->auth()->getManager()->supportsPasswordChange()): ?> +<? if ($user && $this->auth()->getManager()->supportsPasswordChange()): ?> <h4><?=$this->transEsc('Preferences')?></h4> <div class="myresearch-menu"> <a href="<?=$this->url('myresearch-changepassword') ?>"<?=$this->active == 'newpassword' ? ' class="active"' : ''?>> @@ -61,7 +66,7 @@ </a> </div> <? endif; ?> -<? if ($this->userlist()->getMode() !== 'disabled' && $user = $this->auth()->isLoggedIn()): ?> +<? if ($user && $this->userlist()->getMode() !== 'disabled'): ?> <h4><?=$this->transEsc('Your Lists')?></h4> <div class="myresearch-menu"> <a href="<?=$this->url('myresearch-favorites')?>"<?=$this->active == 'favorites' ? ' class="active"' : ''?>>