diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index ff2024c9ac46b4ea1ee319ac873eccb5789a6b9b..b96a9f96a0f92bc4f9d168f8e0ccb551375dad54 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -386,38 +386,39 @@ class MyResearchController extends AbstractBase */ public function profileAction() { - // Stop now if the user does not have valid catalog credentials available: - if (!is_array($patron = $this->catalogLogin())) { - return $patron; - } - - // User must be logged in at this point, so we can assume this is non-false: - $user = $this->getUser(); - - // Process home library parameter (if present): - $homeLibrary = $this->params()->fromPost('home_library', false); - if (!empty($homeLibrary)) { - $user->changeHomeLibrary($homeLibrary); - $this->getAuthManager()->updateSession($user); - $this->flashMessenger()->addMessage('profile_update', 'success'); + if (!($user = $this->getUser())) { + return $this->forceLogin(); } // Begin building view object: - $view = $this->createViewModel(); + $view = $this->createViewModel(['user' => $user]); + + $patron = $this->catalogLogin(); + if (is_array($patron)) { + // Process home library parameter (if present): + $homeLibrary = $this->params()->fromPost('home_library', false); + if (!empty($homeLibrary)) { + $user->changeHomeLibrary($homeLibrary); + $this->getAuthManager()->updateSession($user); + $this->flashMessenger()->addMessage('profile_update', 'success'); + } - // Obtain user information from ILS: - $catalog = $this->getILS(); - $this->addAccountBlocksToFlashMessenger($catalog, $patron); - $profile = $catalog->getMyProfile($patron); - $profile['home_library'] = $user->home_library; - $view->profile = $profile; - try { - $view->pickup = $catalog->getPickUpLocations($patron); - $view->defaultPickupLocation - = $catalog->getDefaultPickUpLocation($patron); - } catch (\Exception $e) { - // Do nothing; if we're unable to load information about pickup - // locations, they are not supported and we should ignore them. + // Obtain user information from ILS: + $catalog = $this->getILS(); + $this->addAccountBlocksToFlashMessenger($catalog, $patron); + $profile = $catalog->getMyProfile($patron); + $profile['home_library'] = $user->home_library; + $view->profile = $profile; + try { + $view->pickup = $catalog->getPickUpLocations($patron); + $view->defaultPickupLocation + = $catalog->getDefaultPickUpLocation($patron); + } catch (\Exception $e) { + // Do nothing; if we're unable to load information about pickup + // locations, they are not supported and we should ignore them. + } + } else { + $view->patronLoginView = $patron; } return $view; diff --git a/themes/bootstrap3/templates/myresearch/menu.phtml b/themes/bootstrap3/templates/myresearch/menu.phtml index 89a90645647fcce8d3276c47047f862f0f0dfc0b..76afa8f2cd1a7f76ff54d6020d6606587b95840b 100644 --- a/themes/bootstrap3/templates/myresearch/menu.phtml +++ b/themes/bootstrap3/templates/myresearch/menu.phtml @@ -63,14 +63,6 @@ </a> <?php endif; ?> </div> -<?php 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"' : ''?>> - <i class="fa fa-fw fa-lock" aria-hidden="true"></i> <?=$this->transEsc('Change Password') ?> - </a> - </div> -<?php endif; ?> <?php if ($user && $this->userlist()->getMode() !== 'disabled'): ?> <h4><?=$this->transEsc('Your Lists')?></h4> <div class="myresearch-menu"> diff --git a/themes/bootstrap3/templates/myresearch/profile.phtml b/themes/bootstrap3/templates/myresearch/profile.phtml index d082dc1b054fe01210412583110891d4ce2d4bb7..3cea4b681637d8b6c507bd275d08ec2759cd9f09 100644 --- a/themes/bootstrap3/templates/myresearch/profile.phtml +++ b/themes/bootstrap3/templates/myresearch/profile.phtml @@ -12,14 +12,13 @@ <h2><?=$this->transEsc('Your Profile')?></h2> <?=$this->flashmessages();?> - <?=$this->context($this)->renderInContext('librarycards/selectcard.phtml', ['user' => $this->auth()->isLoggedIn()]); ?> - <table class="table table-striped"> <?=$this->renderArray( - $arrTemplate, $this->profile, + $arrTemplate, $this->user, [ $this->transEsc('First Name') => 'firstname', - $this->transEsc('Last Name') => 'lastname' + $this->transEsc('Last Name') => 'lastname', + $this->transEsc('Email') => 'email', ] )?> <?php if (count($this->pickup ?? []) > 1): // Skip form if only one location: ?> @@ -39,21 +38,42 @@ </form> </td> <?php endif; ?> - <?=$this->renderArray( - $arrTemplate, $this->profile, - [ - $this->transEsc('Address') . ' 1' => 'address1', - $this->transEsc('Address') . ' 2' => 'address2', - $this->transEsc('Zip') => 'zip', - $this->transEsc('City') => 'city', - $this->transEsc('Country') => 'country', - $this->transEsc('Phone Number') => 'phone', - $this->transEsc('Mobile Number') => 'mobile_phone', - $this->transEsc('Group') => 'group', - $this->transEsc('Expires') => 'expiration_date' - ] - )?> </table> + + <?php if ($this->auth()->getManager()->supportsPasswordChange()): ?> + <p> + <a class="btn btn-default" href="<?=$this->url('myresearch-changepassword') ?>"> + <i class="fa fa-fw fa-lock" aria-hidden="true"></i> <?=$this->transEsc('Change Password') ?> + </a> + </p> + <?php endif; ?> + + <?php if (is_array($this->profile)): ?> + <h3><?=$this->transEsc('Library Catalog Profile')?></h3> + <p> + <?=$this->context($this)->renderInContext('librarycards/selectcard.phtml', ['user' => $this->user]); ?> + </p> + <table class="table table-striped"> + <?=$this->renderArray( + $arrTemplate, $this->profile, + [ + $this->transEsc('First Name') => 'firstname', + $this->transEsc('Last Name') => 'lastname', + $this->transEsc('Address') . ' 1' => 'address1', + $this->transEsc('Address') . ' 2' => 'address2', + $this->transEsc('Zip') => 'zip', + $this->transEsc('City') => 'city', + $this->transEsc('Country') => 'country', + $this->transEsc('Phone Number') => 'phone', + $this->transEsc('Mobile Number') => 'mobile_phone', + $this->transEsc('Group') => 'group', + $this->transEsc('Expires') => 'expiration_date' + ] + )?> + </table> + <?php elseif ('ils-none' !== $this->ils()->getOfflineMode()): ?> + <?=$this->partial($this->patronLoginView);?> + <?php endif; ?> </div> <div class="<?=$this->layoutClass('sidebar')?>">