From edaa46203310dbadda39f68f4a546ba836074fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lahmann?= <lahmann@ub.uni-leipzig.de> Date: Tue, 13 Dec 2022 14:09:06 +0100 Subject: [PATCH] refs #22140 [finc] * add canEditAccount to FincILS driver * adapt getIgnoredProfileFields for FincILS driver * extend FincILS configuration with settings for getIgnoredProfileFields * some code refactoring --- local/config/vufind/FincILS.ini | 15 +++++++ .../finc/Controller/MyResearchController.php | 7 +-- module/finc/src/finc/ILS/Driver/FincILS.php | 45 +++++++++++++++++++ .../src/finc/ILS/Driver/LiberoWachtlTrait.php | 6 ++- 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/local/config/vufind/FincILS.ini b/local/config/vufind/FincILS.ini index f7bc8fa4615..407dc87bef5 100644 --- a/local/config/vufind/FincILS.ini +++ b/local/config/vufind/FincILS.ini @@ -103,6 +103,21 @@ queryIls[] = 'getFacetAvail:Local' ;root_username = 'root' ;root_password = '' +; Profile fields listed here will never be allowed to be edited if the necessary +; scope is missing for a patron +; disabled profile fields for missing scope: update_patron_name +;disabledProfileFieldsForMissingUpdateNameScope[] = "firstname" +;disabledProfileFieldsForMissingUpdateNameScope[] = "lastname" + +; disabled profile fields for missing scope: update_patron_email +;disabledProfileFieldsForMissingUpdateEmailScope[] = "email" + +; disabled profile fields for missing scope: update_patron_address +;disabledProfileFieldsForMissingUpdateAddressScope[] = "address1" +;disabledProfileFieldsForMissingUpdateAddressScope[] = "zip" +;disabledProfileFieldsForMissingUpdateAddressScope[] = "city" +;disabledProfileFieldsForMissingUpdateAddressScope[] = "country" + ; Driver configuration, usually you can leave it untouched ; Without customization the PAIA driver will offer to place a recall for items with diff --git a/module/finc/src/finc/Controller/MyResearchController.php b/module/finc/src/finc/Controller/MyResearchController.php index e1499f47372..6e95b173f7b 100644 --- a/module/finc/src/finc/Controller/MyResearchController.php +++ b/module/finc/src/finc/Controller/MyResearchController.php @@ -53,11 +53,12 @@ class MyResearchController extends \VuFind\Controller\MyResearchController imple /** * Execute the request * - * @param MvcEvent $e + * @param \Zend\Mvc\MvcEvent $event Event + * * @return mixed * @throws Exception\DomainException */ - public function onDispatch(MvcEvent $e) + public function onDispatch(MvcEvent $event) { if ($redirect = $this->getRequest()->getQuery()->get('redirect')) { $redirect = urldecode($redirect); @@ -74,7 +75,7 @@ class MyResearchController extends \VuFind\Controller\MyResearchController imple $this->followup()->store(['finc-redirect' => $redirect]); } } - return parent::onDispatch($e); + return parent::onDispatch($event); } /** diff --git a/module/finc/src/finc/ILS/Driver/FincILS.php b/module/finc/src/finc/ILS/Driver/FincILS.php index 036bb03fe6a..786db5ce3cc 100644 --- a/module/finc/src/finc/ILS/Driver/FincILS.php +++ b/module/finc/src/finc/ILS/Driver/FincILS.php @@ -1770,4 +1770,49 @@ class FincILS extends PAIA implements LoggerAwareInterface return []; } + + /** + * Helper function to check whether the patron is allowed to edit + * patron information + * + * @return bool + */ + public function canEditAccount() + { + return $this->paiaCheckScope(self::SCOPE_UPDATE_PATRON) + && ( + $this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_NAME) + || $this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_EMAIL) + || $this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_ADDRESS) + ); + } + + /** + * Returns Array with profile fields that are never allowed to be edited + * + * @return array + */ + public function getIgnoredProfileFields() + { + $ignoredProfileFields = []; + if (!$this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_NAME)) { + $ignoredProfileFields = array_merge( + $ignoredProfileFields, + $this->config['PAIA']['disabledProfileFieldsForMissingUpdateNameScope'] ?? [] + ); + } + if (!$this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_EMAIL)) { + $ignoredProfileFields = array_merge( + $ignoredProfileFields, + $this->config['PAIA']['disabledProfileFieldsForMissingUpdateEmailScope'] ?? [] + ); + } + if (!$this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_ADDRESS)) { + $ignoredProfileFields = array_merge( + $ignoredProfileFields, + $this->config['PAIA']['disabledProfileFieldsForMissingUpdateAddressScope'] ?? [] + ); + } + return $ignoredProfileFields; + } } diff --git a/module/finc/src/finc/ILS/Driver/LiberoWachtlTrait.php b/module/finc/src/finc/ILS/Driver/LiberoWachtlTrait.php index b7488b994e4..d15ced6d27d 100644 --- a/module/finc/src/finc/ILS/Driver/LiberoWachtlTrait.php +++ b/module/finc/src/finc/ILS/Driver/LiberoWachtlTrait.php @@ -346,7 +346,11 @@ trait LiberoWachtlTrait */ public function getIgnoredProfileFields() { - return $this->config['LiberoWachtl']['ignoredProfileFields'] ?? []; + $ignoredProfileFields = parent::getIgnoredProfileFields(); + return array_merge( + $ignoredProfileFields, + $this->config['LiberoWachtl']['ignoredProfileFields'] ?? [] + ); } /** -- GitLab