diff --git a/module/fid/config/address-collection.php b/module/fid/config/address-collection.php index 197008c1e4346ecf84b9b9022f6603bbbb5dd71e..54812fc75e0c94b7eed9ef9fa6c9ad5bdab89d69 100644 --- a/module/fid/config/address-collection.php +++ b/module/fid/config/address-collection.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use fid\InputFilter\RootAwareBaseInputFilter; use Zend\Filter\StringTrim; use Zend\Form\Element\Hidden; diff --git a/module/fid/config/admin-edit-form.php b/module/fid/config/admin-edit-form.php index 55db3fe0391185e81f4bbdbdc3e6a3c62a492824..ecc3a00d29d39b056587e65ffbede5a52620ae11 100644 --- a/module/fid/config/admin-edit-form.php +++ b/module/fid/config/admin-edit-form.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use fid\Hydrator\UserHydrator; use fid\InputFilter\RootAwareBaseInputFilter; use Zend\Form\Element\Collection; @@ -276,4 +275,3 @@ return [ ], ], ]; - diff --git a/module/fid/config/fid-acquisition-digitization-form.php b/module/fid/config/fid-acquisition-digitization-form.php index 6000bfef364916f6655fa7bdd21f1773dd364b91..8c6b516ff6baa79870d758077f82b2bf505f4879 100644 --- a/module/fid/config/fid-acquisition-digitization-form.php +++ b/module/fid/config/fid-acquisition-digitization-form.php @@ -23,8 +23,8 @@ use Zend\Filter\StringTrim; use Zend\Form\Element\Select; use Zend\Form\Element\Submit; use Zend\Form\Element\Textarea; -use Zend\Validator\StringLength; use Zend\Form\Element\Url; +use Zend\Validator\StringLength; return [ 'name' => 'fid-acquisition-form', diff --git a/module/fid/config/fid-acquisition-digitization-missing-record-form.php b/module/fid/config/fid-acquisition-digitization-missing-record-form.php index 40b01e62a85337e60615635589a560f9fc28f34f..80130347baa22d00611e5af88a3cd143eb896bb3 100644 --- a/module/fid/config/fid-acquisition-digitization-missing-record-form.php +++ b/module/fid/config/fid-acquisition-digitization-missing-record-form.php @@ -21,8 +21,8 @@ use fid\Hydrator\OrderMissingRecordHydrator; use Zend\Filter\StringTrim; use Zend\Form\Element\Text; -use Zend\Validator\StringLength; use Zend\Validator\NotEmpty; +use Zend\Validator\StringLength; $main_config = require 'fid-acquisition-digitization-form.php'; unset($main_config['name'], $main_config['hydrator']); diff --git a/module/fid/config/fid-acquisition-form.php b/module/fid/config/fid-acquisition-form.php index 42d6f6c9b1534a698d1869c151b3761e87f34f9f..0f3acd281a2c57f2a80c07b3af3917a5f2616022 100644 --- a/module/fid/config/fid-acquisition-form.php +++ b/module/fid/config/fid-acquisition-form.php @@ -18,7 +18,6 @@ * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use fid\Hydrator\OrderHydrator; use Zend\Form\Element\Submit; @@ -42,4 +41,4 @@ return [ 'required' => true, ], ], -]; \ No newline at end of file +]; diff --git a/module/fid/config/fid-acquisition-subito-partial-copy-form.php b/module/fid/config/fid-acquisition-subito-partial-copy-form.php index 6cf000c82d7cd8dbdf4ff3ebea0c9e5982bec49f..f2141bab6b0bcd4e7d9172bae5e34b8790d6cf74 100644 --- a/module/fid/config/fid-acquisition-subito-partial-copy-form.php +++ b/module/fid/config/fid-acquisition-subito-partial-copy-form.php @@ -18,10 +18,7 @@ * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - -use fid\Controller\RecordController; use fid\Hydrator\OrderHydrator; -use fid\Validator\SubitoPartialCopyPageLimit; use fid\Validator\SubitoPartialCopyPageOrder; use Zend\Filter\PregReplace; use Zend\Filter\StringTrim; @@ -137,4 +134,4 @@ return [ 'required' => true, ], ], -]; \ No newline at end of file +]; diff --git a/module/fid/config/module.config.php b/module/fid/config/module.config.php index bca6c65dbd6880b3885dfb686d62f04ed1ef4eb0..e6e6be49fbcba5efdfe0681c6b88df5b37dcac4f 100644 --- a/module/fid/config/module.config.php +++ b/module/fid/config/module.config.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use fid\Controller\MyResearchController; use fid\Controller\MyResearchControllerFactory; use fid\Controller\RecordController; @@ -29,8 +28,8 @@ use fid\Filter\PermissionsFilter; use fid\Filter\PermissionsFilterFactory; use fid\FormModel\PasswordChangeModel; use fid\FormModel\PasswordResetModel; -use fid\FormModel\UsernameChangeModel; use fid\FormModel\UserDeleteModel; +use fid\FormModel\UsernameChangeModel; use fid\Helper\FormLabel; use fid\Helper\TranslatorDelegator; use fid\Hydrator\OrderHydrator; @@ -38,7 +37,6 @@ use fid\Hydrator\UserHydrator; use fid\Hydrator\UserHydratorDelegatorFactory; use fid\Listener\ClientConfigListener; use fid\Listener\ErrorListener; -use fid\Listener\ErrorListenerFactory; use fid\Listener\LocaleListener; use fid\Serializer\OrderCreationRequestUserNormalizer; use fid\Service\Client; @@ -463,4 +461,4 @@ $recordRoutes = [ $routeGenerator = new \VuFind\Route\RouteGenerator($nonTabRecordActions); $routeGenerator->addRecordRoutes($config, $recordRoutes); -return $config; \ No newline at end of file +return $config; diff --git a/module/fid/config/order-edit-form-basic.php b/module/fid/config/order-edit-form-basic.php index 8f2e97fda941b2cfd7eda803991f7ef23b55e768..79ce1ded385b2eff39d0400e427b672660a6fd46 100644 --- a/module/fid/config/order-edit-form-basic.php +++ b/module/fid/config/order-edit-form-basic.php @@ -20,7 +20,6 @@ */ use fid\Hydrator\OrderUpdateHydrator; use Zend\Form\Element\Submit; -use Zend\Form\Element\Date; return [ 'name' => 'order-edit-form-basic', diff --git a/module/fid/config/password-change-form.php b/module/fid/config/password-change-form.php index afddec4ca6b3114194584e71539dba6b3bfc456e..574e77ea48d027d87e9455765d34db4d9f7490de 100644 --- a/module/fid/config/password-change-form.php +++ b/module/fid/config/password-change-form.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use Zend\Filter\StringTrim; use Zend\Form\Element\Password; use Zend\Form\Element\Submit; @@ -121,4 +120,4 @@ return [ 'required' => true, ], ], -]; \ No newline at end of file +]; diff --git a/module/fid/config/password-reset-form.php b/module/fid/config/password-reset-form.php index e177096ef180c70b3d6330ed516232e9876c55d6..8272755a77392b165c944164214d60593eb15f03 100644 --- a/module/fid/config/password-reset-form.php +++ b/module/fid/config/password-reset-form.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use Zend\Filter\StringTrim; use Zend\Form\Element\Email; use Zend\Form\Element\Submit; @@ -77,4 +76,4 @@ return [ 'required' => true, ], ], -]; \ No newline at end of file +]; diff --git a/module/fid/config/user-create-form.php b/module/fid/config/user-create-form.php index 1966695a5d3b32f62634c07bcb08881478bc7254..f5cbeb6d3adb249bf9c63566dc4977dfe7cd1d55 100644 --- a/module/fid/config/user-create-form.php +++ b/module/fid/config/user-create-form.php @@ -18,9 +18,7 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use fid\Hydrator\UserHydrator; -use fid\InputFilter\RootAwareBaseInputFilter; use fid\InputFilter\UserCreateFormInputFilter; use Zend\Filter\Boolean; use Zend\Filter\StringTrim; diff --git a/module/fid/config/user-delete-form.php b/module/fid/config/user-delete-form.php index c21ba9cd1cac4ac0a0d41a3a80a21568d8db7567..d71596fcf77659ce6c102331483a55af6b633876 100644 --- a/module/fid/config/user-delete-form.php +++ b/module/fid/config/user-delete-form.php @@ -22,7 +22,6 @@ use Zend\Form\Element\Password; use Zend\Form\Element\Submit; use Zend\Hydrator\ClassMethods; - use Zend\Validator\NotEmpty; return [ 'hydrator' => ClassMethods::class, diff --git a/module/fid/config/user-init-form.php b/module/fid/config/user-init-form.php index 61202452f589404b7376d77c8e2f86bda8670012..cc5050700fe326de5e7be9ba9616d68b93171800 100644 --- a/module/fid/config/user-init-form.php +++ b/module/fid/config/user-init-form.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use fid\Hydrator\UserHydrator; use Zend\Filter\Boolean; use Zend\Filter\StringTrim; @@ -216,4 +215,4 @@ return [ 'required' => true, ], ], -]; \ No newline at end of file +]; diff --git a/module/fid/config/user-update-form.php b/module/fid/config/user-update-form.php index c4d653b86b5add96ffc4b2fc1ae9875cbd401e36..52f4a24d1f128c1e211a0e0cff0c724e8d42593a 100644 --- a/module/fid/config/user-update-form.php +++ b/module/fid/config/user-update-form.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use fid\Hydrator\UserHydrator; use fid\InputFilter\RootAwareBaseInputFilter; use Zend\Filter\StringTrim; @@ -226,4 +225,4 @@ return [ 'required' => true, ], ], -]; \ No newline at end of file +]; diff --git a/module/fid/config/username-change-form.php b/module/fid/config/username-change-form.php index 9139e55b080c8b2780e32640170fd0c37ec3dc6a..63a29a4a7274caeb224c7bc1dc918adac3ce132e 100644 --- a/module/fid/config/username-change-form.php +++ b/module/fid/config/username-change-form.php @@ -18,11 +18,9 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - use Zend\Filter\StringTrim; use Zend\Form\Element\Email; use Zend\Form\Element\Submit; -use Zend\Form\Element\Text; use Zend\Hydrator\ClassMethods; use Zend\Validator\EmailAddress; use Zend\Validator\Identical; diff --git a/module/fid/src/AjaxHandler/GetResolverLinks.php b/module/fid/src/AjaxHandler/GetResolverLinks.php index fcf3cce5f6dc8b2987821d8313209e499205191a..ba15d1a8b852306abe4ab6b088255ebb8a21661d 100644 --- a/module/fid/src/AjaxHandler/GetResolverLinks.php +++ b/module/fid/src/AjaxHandler/GetResolverLinks.php @@ -31,8 +31,8 @@ */ namespace fid\AjaxHandler; -use VuFind\Resolver\Driver\PluginManager as ResolverManager; use VuFind\Resolver\Connection; +use VuFind\Resolver\Driver\PluginManager as ResolverManager; use VuFind\Session\Settings as SessionSettings; use Zend\Config\Config; use Zend\Mvc\Controller\Plugin\Params; @@ -62,7 +62,6 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks */ protected $resolverConfig; - /** * Constructor * @@ -106,9 +105,9 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks $resolvers = explode(',', $this->resolverConfig->General->active_resolvers); if (in_array($requestedResolver, $resolvers) - && isset($this->resolverConfig->$requestedResolver)) { - $resolverType = isset($this->resolverConfig->$requestedResolver->resolver) - ? $this->resolverConfig->$requestedResolver->resolver : 'generic'; + && isset($this->resolverConfig->$requestedResolver) + ) { + $resolverType = $this->resolverConfig->$requestedResolver->resolver ?? 'generic'; if (!$this->pluginManager->has($resolverType)) { return $this->formatResponse( $this->translate("Could not load driver for $resolverType"), @@ -141,22 +140,22 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks // Sort the returned links into categories based on service type: $electronic = $print = $services = []; foreach ($result as $link) { - switch (isset($link['service_type']) ? $link['service_type'] : '') { - case 'getHolding': - $print[] = $link; - break; - case 'getWebService': - $services[] = $link; - break; - case 'getDOI': - // Special case -- modify DOI text for special display: - $link['title'] = $this->translate('Get full text'); - $link['coverage'] = ''; - break; - case 'getFullTxt': - default: - $electronic[] = $link; - break; + switch ($link['service_type'] ?? '') { + case 'getHolding': + $print[] = $link; + break; + case 'getWebService': + $services[] = $link; + break; + case 'getDOI': + // Special case -- modify DOI text for special display: + $link['title'] = $this->translate('Get full text'); + $link['coverage'] = ''; + break; + case 'getFullTxt': + default: + $electronic[] = $link; + break; } } @@ -166,7 +165,7 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks ) { // Trim off any parameters (for legacy compatibility -- default config // used to include extraneous parameters): - list($base) = explode( + [$base] = explode( '?', $this->resolverConfig->$requestedResolver->url ); diff --git a/module/fid/src/Controller/CustomTraits/FidAcquisitionTrait.php b/module/fid/src/Controller/CustomTraits/FidAcquisitionTrait.php index 072fa5649344ea7de972bdb342833e93ed81e29c..3afd09184d931a866a397b33d0d808ab9d1551af 100644 --- a/module/fid/src/Controller/CustomTraits/FidAcquisitionTrait.php +++ b/module/fid/src/Controller/CustomTraits/FidAcquisitionTrait.php @@ -54,6 +54,7 @@ trait FidAcquisitionTrait protected $client; protected $type; + protected $formConfig = "fid-acquisition-form"; /** @@ -103,7 +104,9 @@ trait FidAcquisitionTrait return $this->forceLogin(); } - /** @var User $user */ + /** + * @var User $user + */ $user = $this->client->requestUserDetails(); try { @@ -116,7 +119,9 @@ trait FidAcquisitionTrait //store current url in session for multi-step form (edit address) $this->followup()->store(); - /** @var Form $form */ + /** + * @var Form $form + */ $form = $this->serviceLocator->get($this->formConfig); $this->addOptinalFormValidators($form); @@ -166,7 +171,9 @@ trait FidAcquisitionTrait protected function getRecordCitation() { $driver = $this->loadRecord(); - /** @var Citation $helper */ + /** + * @var Citation $helper + */ $helper = $this->getViewRenderer()->plugin('citation'); $helper->__invoke($driver); $priorityFormats = [ 'APA', 'MLA', 'ISBD' ]; @@ -228,9 +235,9 @@ trait FidAcquisitionTrait 'library' => $form->getData()['library'], 'signature' => $form->getData()['signature'], 'external_url' => $form->getData()['external_url'], - 'title' => $form->getData()['title'] ?? '' , + 'title' => $form->getData()['title'] ?? '', 'responsible' => $form->getData()['responsible'] ?? '', - 'year' => $form->getData()['year']?? '', + 'year' => $form->getData()['year'] ?? '', 'language' => $form->getData()['language'] ?? '', ] ]; @@ -249,13 +256,17 @@ trait FidAcquisitionTrait { } - protected function getDefaultStatus() { - /** @var Config $config */ + protected function getDefaultStatus() + { + /** + * @var Config $config + */ $config = $this->getConfig('fid'); - if (isset($config[$this->type.'Edit']['statusOptions'])) { + if (isset($config[$this->type . 'Edit']['statusOptions'])) { return $this->getConfig('fid')[$this->type . 'Edit']['statusOptions'][0]; + } else { + return null; } - else return null; } protected function runDigitizationMissingRecord() @@ -264,14 +275,18 @@ trait FidAcquisitionTrait return $this->forceLogin(); } - /** @var User $user */ + /** + * @var User $user + */ $user = $this->client->requestUserDetails(); try { /* pass if permission is granted, else throw exception and switch to catch block */ $this->permission()->check('fid.Acquisitions', 'exception'); - /** @var Form $form */ + /** + * @var Form $form + */ $form = $this->serviceLocator->get($this->formConfig); $this->addOptinalFormValidators($form); diff --git a/module/fid/src/Controller/MyResearchController.php b/module/fid/src/Controller/MyResearchController.php index 71002c9c96a732bb023cdec61081db0af616c759..e68643dc1d5679a61a3d8b4abd5fadc16e8d46ae 100644 --- a/module/fid/src/Controller/MyResearchController.php +++ b/module/fid/src/Controller/MyResearchController.php @@ -102,10 +102,9 @@ class MyResearchController extends \VuFind\Controller\MyResearchController $view->isDbisAvailable = true; if ($this->fidClient->isLoggedOn() && isset($patron['user'])) { - try { $library = $this->getHomeLibrary($patron); - if (!is_null($library)) { + if (null !== $library) { $view->homeLibrary = $library->getDbis(); } $view->map_bibid_to_dbis = false; @@ -139,7 +138,8 @@ class MyResearchController extends \VuFind\Controller\MyResearchController { // Is module activated? if (!isset($this->mainConfig['ExternalDatabases']['DBIS']) - || $this->mainConfig['ExternalDatabases']['DBIS'] != true) { + || $this->mainConfig['ExternalDatabases']['DBIS'] != true + ) { return false; } @@ -154,15 +154,15 @@ class MyResearchController extends \VuFind\Controller\MyResearchController } /** - * @param $patron + * @param $patron * @return \fid\Service\DataTransferObject\Library | null * @throws \fid\Service\ClientException */ protected function getHomeLibrary($patron): ?Library { if (is_a($patron['user'], 'fid\Service\DataTransferObject\User') - && $homeLibrary = $patron['user']->getHomeLibrary()) - { + && $homeLibrary = $patron['user']->getHomeLibrary() + ) { if (isset($patron['libs'][$homeLibrary])) { return $patron['libs'][$homeLibrary]; } @@ -235,7 +235,8 @@ class MyResearchController extends \VuFind\Controller\MyResearchController // Check for "delete item" request; parameter may be in GET or POST depending // on calling context. $deleteId = $this->params()->fromPost( - 'delete', $this->params()->fromQuery('delete') + 'delete', + $this->params()->fromQuery('delete') ); if ($deleteId) { $deleteSource = $this->params()->fromPost( @@ -245,11 +246,13 @@ class MyResearchController extends \VuFind\Controller\MyResearchController // If the user already confirmed the operation, perform the delete now; // otherwise prompt for confirmation: $confirm = $this->params()->fromPost( - 'confirm', $this->params()->fromQuery('confirm') + 'confirm', + $this->params()->fromQuery('confirm') ); if ($confirm) { $layout = $this->params()->fromPost( - 'layout', $this->params()->fromQuery('layout') + 'layout', + $this->params()->fromQuery('layout') ); /* #17712 not necessary to fetch items after deleting by ajax */ @@ -257,7 +260,6 @@ class MyResearchController extends \VuFind\Controller\MyResearchController if ($layout === 'lightbox' || $success !== true) { return $success; } - } else { return $this->confirmDeleteFavorite($deleteId, $deleteSource); } diff --git a/module/fid/src/Controller/MyResearchControllerFactory.php b/module/fid/src/Controller/MyResearchControllerFactory.php index 73c81142a0dc0c0841b57d272df8fae2c11296ab..8813fafb64981e69d3f823e7eaea3b1779aab40a 100644 --- a/module/fid/src/Controller/MyResearchControllerFactory.php +++ b/module/fid/src/Controller/MyResearchControllerFactory.php @@ -25,7 +25,6 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ - namespace fid\Controller; use fid\Service\Client; @@ -41,7 +40,9 @@ class MyResearchControllerFactory public function __invoke(ContainerInterface $container, $requested_name) { - /** @var ServiceManager $serviceManager */ + /** + * @var ServiceManager $serviceManager + */ $serviceManager = $container->get(ServiceManager::class); $controller = new $requested_name($serviceManager); $controller->setFidClient($container->get(Client::class)); diff --git a/module/fid/src/Controller/RecordController.php b/module/fid/src/Controller/RecordController.php index f559a6d5f181a2b4bb8936c80b373952712e1fcd..91cc2cfc929080f8e982a1060d9c83a6aefc3dbd 100644 --- a/module/fid/src/Controller/RecordController.php +++ b/module/fid/src/Controller/RecordController.php @@ -30,10 +30,10 @@ class RecordController extends \finc\Controller\RecordController { use CustomTraits\FidAcquisitionTrait; - const PAGE_RANGE_PATTERN = '/^(0|[1-9]\d*)-([1-9]\d*)$/'; + public const PAGE_RANGE_PATTERN = '/^(0|[1-9]\d*)-([1-9]\d*)$/'; - const PDA = "pda"; - const SUBITO_ARTICLE = "subito-article"; - const SUBITO_PARTIAL_COPY = "subito-partial-copy"; - const DIGITIZATION = "digitization"; + public const PDA = "pda"; + public const SUBITO_ARTICLE = "subito-article"; + public const SUBITO_PARTIAL_COPY = "subito-partial-copy"; + public const DIGITIZATION = "digitization"; } diff --git a/module/fid/src/Controller/RecordControllerDelegatorFactory.php b/module/fid/src/Controller/RecordControllerDelegatorFactory.php index 84d8577d46bdc4ab2ada12ab15e7b93daeb14fbd..ccc7f51d73505f9a321d7e08d768a803cf3847c0 100644 --- a/module/fid/src/Controller/RecordControllerDelegatorFactory.php +++ b/module/fid/src/Controller/RecordControllerDelegatorFactory.php @@ -9,9 +9,11 @@ class RecordControllerDelegatorFactory implements DelegatorFactoryInterface { public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) { - /** @var RecordController $instance */ + /** + * @var RecordController $instance + */ $instance = call_user_func($callback); $instance->setClient($container->get(Client::class)); return $instance; } -} \ No newline at end of file +} diff --git a/module/fid/src/Controller/UserController.php b/module/fid/src/Controller/UserController.php index 63db4919009f0e511905549777a993f789af7806..2e0e28930c9d30aa221dddd90fd6c69cc6415678 100644 --- a/module/fid/src/Controller/UserController.php +++ b/module/fid/src/Controller/UserController.php @@ -15,16 +15,15 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Controller; -use fid\FormModel\UserDeleteModel; use fid\FormModel\PasswordChangeModel; use fid\FormModel\PasswordResetModel; +use fid\FormModel\UserDeleteModel; use fid\FormModel\UsernameChangeModel; use fid\Service\Client; use fid\Service\ClientException; @@ -83,12 +82,14 @@ class UserController extends AbstractBase /** * @noinspection PhpUnused - * @return ViewModel + * @return ViewModel */ public function initAction() { - /** @var Form $form */ - /** @var Request $request */ + /** + * @var Form $form + * @var Request $request + */ $request = $this->getRequest(); $form = $this->serviceLocator->get('user-init-form'); $forwarded = $this->params()->fromRoute('forwarded', false); @@ -118,30 +119,44 @@ class UserController extends AbstractBase */ protected function init(Form $form) { - /** @var User $user */ + /** + * @var User $user + */ $messenger = $this->getMessenger(); $user = $form->getHydrator()->hydrate($form->getData(), new User()); - /** @noinspection PhpUndefinedFieldInspection */ + /** + * @noinspection PhpUndefinedFieldInspection + */ $query['lng'] = $this->layout()->userLang; $username = $query['username'] = $user->getUsername(); $firstname = $query['firstname'] = $user->getFirstname(); $lastname = $query['lastname'] = $user->getLastname(); - $baseUrl = $this->url()->fromRoute('fid/user/create', - [], ['query' => $query, 'force_canonical' => true]); + $baseUrl = $this->url()->fromRoute( + 'fid/user/create', + [], + ['query' => $query, 'force_canonical' => true] + ); try { - $this->client->requestRegistrationLink($baseUrl, $username, - $firstname, $lastname); + $this->client->requestRegistrationLink( + $baseUrl, + $username, + $firstname, + $lastname + ); } catch (ClientException $exception) { $message = $exception->getCode() === 400 ? 'fid::user_init_error_username' : 'fid::user_init_error'; $messenger->addErrorMessage($this->translate($message)); - return $this->forward()->dispatch(self::class, [ + return $this->forward()->dispatch( + self::class, + [ 'action' => 'init', 'forwarded' => true - ]); + ] + ); } $message = $this->translate('fid::user_init_success'); @@ -151,20 +166,24 @@ class UserController extends AbstractBase protected function getMessenger(): FlashMessenger { - /** @noinspection PhpUndefinedMethodInspection */ - /** @var FlashMessenger $messenger */ + /** + * @noinspection PhpUndefinedMethodInspection + * @var FlashMessenger $messenger + */ return $this->flashMessenger(); } /** * @noinspection PhpUnused - * @return Response|ViewModel + * @return Response|ViewModel */ public function createAction() { - /** @var Form $form */ - /** @var Request $request */ - /** @var Select $homeLibraryElement */ + /** + * @var Form $form + * @var Request $request + * @var Select $homeLibraryElement + */ $request = $this->getRequest(); $query = $request->getQuery(); $messenger = $this->getMessenger(); @@ -181,15 +200,22 @@ class UserController extends AbstractBase } $query->offsetUnset('logon'); - return $this->redirect()->toRoute('fid/user/create', [], [ + return $this->redirect()->toRoute( + 'fid/user/create', + [], + [ 'query' => $query->toArray() - ]); + ] + ); } try { - $libraries = array_map(function (Library $libary) { - return $libary->getLabel(); - }, $this->client->requestLibraryList()); + $libraries = array_map( + function (Library $libary) { + return $libary->getLabel(); + }, + $this->client->requestLibraryList() + ); } catch (ClientException $exception) { $message = 'fid::user_create_error'; $messenger->addErrorMessage($this->translate($message)); @@ -224,7 +250,9 @@ class UserController extends AbstractBase protected function create(Form $form) { - /** @var User $user */ + /** + * @var User $user + */ $messenger = $this->getMessenger(); $user = $form->getHydrator()->hydrate($form->getData(), new User()); @@ -232,7 +260,9 @@ class UserController extends AbstractBase $this->client->requestUserCreation($user); $message = $this->translate('fid::user_create_success'); $messenger->addSuccessMessage($message); - /** @noinspection PhpParamsInspection */ + /** + * @noinspection PhpParamsInspection + */ $this->authManager->create($this->getRequest()); } catch (ClientException $exception) { $message = $this->translate('fid::user_create_error'); @@ -242,9 +272,13 @@ class UserController extends AbstractBase $messenger->addWarningMessage($message); } - return $this->redirect()->toRoute('myresearch-home', [], [ + return $this->redirect()->toRoute( + 'myresearch-home', + [], + [ 'query' => ['redirect' => false] - ]); + ] + ); } /** @@ -253,16 +287,20 @@ class UserController extends AbstractBase */ public function updateAction() { - /** @var Form $form */ - /** @var Request $request */ - /** @var Select $homeLibraryElement */ - + /** + * @var Form $form + * @var Request $request + * @var Select $homeLibraryElement + */ try { $request = $this->getRequest(); $user = $this->client->requestUserDetails(); - $libraries = array_map(function (Library $libary) { - return $libary->getLabel(); - }, $this->client->requestLibraryList()); + $libraries = array_map( + function (Library $libary) { + return $libary->getLabel(); + }, + $this->client->requestLibraryList() + ); } catch (ClientException $exception) { $this->setFollowupUrlToReferer(); $message = $exception->getCode() === 401 @@ -313,7 +351,7 @@ class UserController extends AbstractBase $messenger = $this->getMessenger(); try { - $user = clone($this->client->requestUserDetails($data['id'])); + $user = clone $this->client->requestUserDetails($data['id']); $form->getHydrator()->hydrate($data, $user); $this->client->requestUserUpdate($user); $message = $this->translate('fid::user_update_success'); @@ -322,8 +360,10 @@ class UserController extends AbstractBase $messenger->addInfoMessage($message); } catch (ClientException $exception) { if (in_array($exception->getCode(), [403])) { - $message = $this->translate('fid::user_update_error_' - . $exception->getCode()); + $message = $this->translate( + 'fid::user_update_error_' + . $exception->getCode() + ); } else { $message = $this->translate('fid::user_update_error'); } @@ -338,18 +378,24 @@ class UserController extends AbstractBase return $this->redirect()->toUrl($followUp); } - return $this->redirect()->toRoute($redirect, [], [ + return $this->redirect()->toRoute( + $redirect, + [], + [ 'query' => ['redirect' => false] - ]); + ] + ); } /** * @noinspection PhpUnused - * @return ViewModel + * @return ViewModel */ public function changeUsernameAction() { - /** @var Request $request */ + /** + * @var Request $request + */ $request = $this->getRequest(); $form = $this->serviceLocator->get(UsernameChangeModel::class); $forwarded = $this->params()->fromRoute('forwarded', false); @@ -372,13 +418,20 @@ class UserController extends AbstractBase { $messenger = $this->getMessenger(); $model = $form->getHydrator()->hydrate( - $form->getData(), new UsernameChangeModel()); + $form->getData(), + new UsernameChangeModel() + ); - /** @noinspection PhpUndefinedFieldInspection */ + /** + * @noinspection PhpUndefinedFieldInspection + */ $query['lng'] = $this->layout()->userLang; $username = $query['username'] = $model->getUsername(); - $baseUrl = $this->url()->fromRoute('fid/user/update-username', - [], ['query' => $query, 'force_canonical' => true]); + $baseUrl = $this->url()->fromRoute( + 'fid/user/update-username', + [], + ['query' => $query, 'force_canonical' => true] + ); try { $this->client->requestUsernameLink($baseUrl, $username); @@ -387,10 +440,13 @@ class UserController extends AbstractBase ? 'fid::username_change_error_username' : 'fid::username_change_error'; $messenger->addErrorMessage($this->translate($message)); - return $this->forward()->dispatch(self::class, [ + return $this->forward()->dispatch( + self::class, + [ 'action' => 'changeUsername', 'forwarded' => true - ]); + ] + ); } $message = $this->translate('fid::username_change_success'); @@ -400,11 +456,13 @@ class UserController extends AbstractBase /** * @noinspection PhpUnused - * @return Response + * @return Response */ public function updateUsernameAction() { - /** @var Request $request */ + /** + * @var Request $request + */ $request = $this->getRequest(); $query = $request->getQuery(); $messenger = $this->getMessenger(); @@ -421,13 +479,17 @@ class UserController extends AbstractBase } $query->offsetUnset('logon'); - return $this->redirect()->toRoute('fid/user/update-username', [], [ + return $this->redirect()->toRoute( + 'fid/user/update-username', + [], + [ 'query' => $query->toArray() - ]); + ] + ); } try { - $user = clone($this->client->requestUserDetails()); + $user = clone $this->client->requestUserDetails(); $user->setUsername($query->get('username')); $this->client->requestUserUsernameUpdate($user); $message = $this->translate('fid::username_update_success'); @@ -442,7 +504,7 @@ class UserController extends AbstractBase /** * @noinspection PhpUnused - * @return Response + * @return Response */ public function deleteAction() { @@ -450,22 +512,31 @@ class UserController extends AbstractBase return $this->forceLogin(); } - /** @var User $user */ + /** + * @var User $user + */ $user = $this->client->requestUserDetails(null, true); if ($user->getData()['deleted'] ?? false) { $view = $this->createViewModel(); $messages['html'] = true; - $messages['msg'] = $this->translate("fid::user_delete_error_account_blocked", [ + $messages['msg'] = $this->translate( + "fid::user_delete_error_account_blocked", + [ '%%fidname%%' => $this->translate("fid::acquisition_fid_name") - ]); + ] + ); $this->flashMessenger()->addMessage($messages, 'error'); $view->setTemplate('default/flash-message'); return $view; } - /** @var Request $request */ + /** + * @var Request $request + */ $request = $this->getRequest(); - /** @var Form $form */ + /** + * @var Form $form + */ $form = $this->serviceLocator->get(UserDeleteModel::class); $forwarded = $this->params()->fromRoute('forwarded', false); @@ -486,12 +557,16 @@ class UserController extends AbstractBase protected function deleteUser(Form $form) { $messenger = $this->getMessenger(); - /** @var UserDeleteModel $model */ + /** + * @var UserDeleteModel $model + */ $model = $form->getHydrator()->hydrate($form->getData(), new UserDeleteModel()); $error = []; try { - /** @var User $user */ + /** + * @var User $user + */ $user = $this->client->requestUserDetails(); if ($this->client->checkCredentials($user->getUsername(), $model->getPasswordConfirmation())) { $user->setDeleted(true); @@ -507,7 +582,7 @@ class UserController extends AbstractBase $error['msg'] = $this->translate('fid::user_delete_error_unknown'); } - if(!empty($error)) { + if (!empty($error)) { $error['html'] = true; $messenger->addErrorMessage($error); return $this->redirect()->toRoute('fid/user/delete'); @@ -547,13 +622,15 @@ class UserController extends AbstractBase */ public function resetPasswordAction() { - /** @var Form $form */ - /** @var Request $request */ + /** + * @var Form $form + * @var Request $request + */ $request = $this->getRequest(); $form = $this->serviceLocator->get(PasswordResetModel::class); $forwarded = $this->params()->fromRoute('forwarded', false); - if($this->getUser()) { + if ($this->getUser()) { $form->get('username')->setAttribute('disabled', 'true'); $form->get('username')->setValue($this->client->requestUserDetails()->getUsername()); $form->setValidationGroup(['submit']); @@ -579,17 +656,26 @@ class UserController extends AbstractBase if ($this->getUser()) { $username = $this->client->requestUserDetails()->getUsername(); } else { - /** @var PasswordResetModel $model */ + /** + * @var PasswordResetModel $model + */ $model = $form->getHydrator()->hydrate( - $form->getData(), new PasswordResetModel()); + $form->getData(), + new PasswordResetModel() + ); $username = $model->getUsername(); } try { - /** @noinspection PhpUndefinedFieldInspection */ + /** + * @noinspection PhpUndefinedFieldInspection + */ $query['lng'] = $this->layout()->userLang; - $baseUrl = $this->url()->fromRoute('fid/user/change-password', - [], ['query' => $query, 'force_canonical' => true]); + $baseUrl = $this->url()->fromRoute( + 'fid/user/change-password', + [], + ['query' => $query, 'force_canonical' => true] + ); $this->client->requestPasswordLink($baseUrl, $username); $message = $this->translate('fid::password_reset_success'); $messenger->addSuccessMessage(sprintf($message, $username)); @@ -611,7 +697,9 @@ class UserController extends AbstractBase */ public function changePasswordAction() { - /** @var Request $request */ + /** + * @var Request $request + */ $request = $this->getRequest(); $query = $request->getQuery(); $messenger = $this->getMessenger(); @@ -628,9 +716,13 @@ class UserController extends AbstractBase } $query->offsetUnset('logon'); - return $this->redirect()->toRoute('fid/user/change-password', [], [ + return $this->redirect()->toRoute( + 'fid/user/change-password', + [], + [ 'query' => $query->toArray() - ]); + ] + ); } $form = $this->serviceLocator->get(PasswordChangeModel::class); @@ -653,19 +745,25 @@ class UserController extends AbstractBase protected function changePassword(Form $form) { - /** @var PasswordChangeModel $model */ + /** + * @var PasswordChangeModel $model + */ $messenger = $this->getMessenger(); $model = $form->getHydrator()->hydrate( - $form->getData(), new PasswordChangeModel()); + $form->getData(), + new PasswordChangeModel() + ); try { - $user = clone($this->client->requestUserDetails()); + $user = clone $this->client->requestUserDetails(); $user->setPassword($password = $model->getPassword()); $this->client->requestUserPasswordUpdate($user); $message = $this->translate('fid::password_change_success'); $message = sprintf($message, $username = $user->getUsername()); $messenger->addSuccessMessage($message); - /** @var Request $request */ + /** + * @var Request $request + */ $request = clone $this->getRequest(); $params = clone $request->getPost(); $params->set('username', $username); @@ -680,9 +778,13 @@ class UserController extends AbstractBase $messenger->addErrorMessage($message); } - return $this->redirect()->toRoute('myresearch-home', [], [ + return $this->redirect()->toRoute( + 'myresearch-home', + [], + [ 'query' => ['redirect' => false] - ]); + ] + ); } public function editAction() @@ -691,7 +793,9 @@ class UserController extends AbstractBase return $this->forceLogin(); } - /** @var Request $request */ + /** + * @var Request $request + */ $request = $this->getRequest(); $userId = $this->params()->fromRoute('userid'); if (empty($userId)) { @@ -706,18 +810,29 @@ class UserController extends AbstractBase } catch (UserNotAuthorizedException $ex) { // either user does not exist, or we are not allowed to edit it $this->getMessenger() - ->addErrorMessage($this->translate('fid::user_edit_not_allowed', - ['%%userid%%' => $userId])); + ->addErrorMessage( + $this->translate( + 'fid::user_edit_not_allowed', + ['%%userid%%' => $userId] + ) + ); return $this->redirect()->toRoute('fid/admin/list'); } catch (\Exception $ex) { $this->getMessenger() - ->addErrorMessage($this->translate('fid::user_read_error', - ['%%userid%%' => $userId])); + ->addErrorMessage( + $this->translate( + 'fid::user_read_error', + ['%%userid%%' => $userId] + ) + ); return $this->redirect()->toRoute('fid/admin/list'); } - $libraries = array_map(function (Library $libary) { - return $libary->getLabel(); - }, $this->client->requestLibraryList()); + $libraries = array_map( + function (Library $libary) { + return $libary->getLabel(); + }, + $this->client->requestLibraryList() + ); } catch (ClientException $exception) { $this->setFollowupUrlToReferer(); $message = $exception->getCode() === 401 @@ -727,8 +842,10 @@ class UserController extends AbstractBase return $this->redirect()->toRoute('fid/admin/list'); } - /** @var Form $form */ - /** @var Select $homeLibraryElement */ + /** + * @var Form $form + * @var Select $homeLibraryElement + */ $form = $this->serviceLocator->get('admin-edit-form'); $homeLibraryElement = $form->get('home_library'); $homeLibraryElement->setValueOptions($libraries); @@ -745,9 +862,12 @@ class UserController extends AbstractBase $form->setData($form->getHydrator()->extract($user)); } - $action = $this->url()->fromRoute('fid/admin/edit', [ + $action = $this->url()->fromRoute( + 'fid/admin/edit', + [ 'userid' => $userId - ]); + ] + ); $form->setAttribute('action', $action); $form->prepare(); @@ -795,7 +915,7 @@ class UserController extends AbstractBase $viewModel = $this->createViewModel(); $orders = $user->getOrders(); $displayCols = $this->config['OrderList']['displayCols']; - $viewModel->setVariables(compact('orders','displayCols')); + $viewModel->setVariables(compact('orders', 'displayCols')); $viewModel->setTemplate('fid/user/orders'); return $viewModel; } catch (ClientException $exception) { @@ -813,20 +933,19 @@ class UserController extends AbstractBase $orders = $this->client->requestOrderList(); $viewModel = $this->createViewModel(); $displayCols = $this->config['OrderList']['displayCols']; - $viewModel->setVariables(compact('orders','displayCols')); + $viewModel->setVariables(compact('orders', 'displayCols')); $viewModel->setTemplate('fid/user/admin-orders'); return $viewModel; } catch (UserNotAuthorizedException $exception) { $this->getMessenger()->addErrorMessage('fid::read_order_list_not_allowed'); - } - catch (ClientException $exception) { + } catch (ClientException $exception) { $this->getMessenger()->addErrorMessage('fid::read_order_list_error'); $this->redirect()->toRoute('myresearch-profile'); } } /** - * @param ViewModel $viewModel + * @param ViewModel $viewModel * @return bool */ protected function setBackUrl(ViewModel $viewModel): bool @@ -864,19 +983,20 @@ class UserController extends AbstractBase protected function createExportFile($userList, $fields=null) { - $response = new HttpResponse(); $prefix = $this->config['Admin']['user_list_export_file_prefix'] ?? 'export'; $response->getHeaders()->addHeaders( [ 'Content-type' => 'text/plain', - 'Content-Disposition' => 'attachment; filename="'.$prefix.'_'.date('Ymd_His').'.txt"' + 'Content-Disposition' => 'attachment; filename="' . $prefix . '_' . date('Ymd_His') . '.txt"' ] ); - $output = implode("\t",$fields)."\n"; - /** @var User $user */ + $output = implode("\t", $fields) . "\n"; + /** + * @var User $user + */ foreach ($userList as $user) { - $output .= $user->export($fields)."\n"; + $output .= $user->export($fields) . "\n"; } $response->setContent($output); return $response; @@ -886,10 +1006,10 @@ class UserController extends AbstractBase { if ($jobTitleOptions = $this->config['Forms']['jobTitleOptions'] ?? null) { $options = []; - foreach (explode(',',$jobTitleOptions) as $jobTitleOption) { + foreach (explode(',', $jobTitleOptions) as $jobTitleOption) { $options[] = [ 'value' => $jobTitleOption, - 'label' => 'job_title_'.$jobTitleOption, + 'label' => 'job_title_' . $jobTitleOption, ]; } $jobTitleElement = $form->get('job_title'); @@ -903,7 +1023,9 @@ class UserController extends AbstractBase return $this->forceLogin(); } - /** @var Request $request */ + /** + * @var Request $request + */ $request = $this->getRequest(); $orderId = $this->params()->fromRoute('orderid'); if (empty($orderId)) { @@ -923,12 +1045,14 @@ class UserController extends AbstractBase $recordId = $order->getRecordId(); $driver = $recordId ? $this->getRecordLoader()->load($recordId) : null; - /** @var Form $form */ - /** @var Select $statusElement */ - $form = $this->config[$order->getType()."Edit"]['form'] - ? $this->serviceLocator->get('order-edit-form-'.$this->config[$order->getType()."Edit"]['form']) + /** + * @var Form $form + * @var Select $statusElement + */ + $form = $this->config[$order->getType() . "Edit"]['form'] + ? $this->serviceLocator->get('order-edit-form-' . $this->config[$order->getType() . "Edit"]['form']) : null; - $this->applyStatusOptions($form,$order->getType()); + $this->applyStatusOptions($form, $order->getType()); if ($this->formWasSubmitted()) { $form->setData($request->getPost()); @@ -939,9 +1063,12 @@ class UserController extends AbstractBase $form->setData($form->getHydrator()->extract($order)); } - $action = $this->url()->fromRoute('fid/admin/editOrder', [ + $action = $this->url()->fromRoute( + 'fid/admin/editOrder', + [ 'orderid' => $order->getId() - ]); + ] + ); $form->setAttribute('action', $action); $form->prepare(); @@ -960,7 +1087,7 @@ class UserController extends AbstractBase foreach ($statusOptions as $statusOption) { $options[] = [ 'value' => $statusOption, - 'label' => $this->translate('fid::status_'.$statusOption), + 'label' => $this->translate('fid::status_' . $statusOption), ]; } $statusElement = $form->get('status'); @@ -968,7 +1095,8 @@ class UserController extends AbstractBase } } - protected function updateOrder(Form $form, Order $order) { + protected function updateOrder(Form $form, Order $order) + { $data = $form->getData(); $messenger = $this->getMessenger(); diff --git a/module/fid/src/Controller/UserControllerFactory.php b/module/fid/src/Controller/UserControllerFactory.php index 03febcf316f473a955095e7132e21742c2c02a43..fbe8fefa4c423dca81ebeca91a82c0430cabf262 100644 --- a/module/fid/src/Controller/UserControllerFactory.php +++ b/module/fid/src/Controller/UserControllerFactory.php @@ -15,11 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Controller; use fid\Service\Client; @@ -42,4 +41,4 @@ class UserControllerFactory $config = $container->get(ConfigManager::class)->get('fid')->toArray(); return new UserController($container, $authManager, $client, $config); } -} \ No newline at end of file +} diff --git a/module/fid/src/FormModel/PasswordChangeModel.php b/module/fid/src/FormModel/PasswordChangeModel.php index 23fce4b0053ca1956cebe701f73595c6b736127c..e31add1894f774f92422fe89c5ee0e5f45c17684 100644 --- a/module/fid/src/FormModel/PasswordChangeModel.php +++ b/module/fid/src/FormModel/PasswordChangeModel.php @@ -15,11 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Robert Lange <lange@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\FormModel; class PasswordChangeModel diff --git a/module/fid/src/FormModel/PasswordResetModel.php b/module/fid/src/FormModel/PasswordResetModel.php index a4da7532638c0d8b732ef36550eff7e60c8aefae..d65083b599ef8b9f6795483bf1938ba09a82fd18 100644 --- a/module/fid/src/FormModel/PasswordResetModel.php +++ b/module/fid/src/FormModel/PasswordResetModel.php @@ -15,11 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Robert Lange <lange@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\FormModel; class PasswordResetModel @@ -29,7 +28,6 @@ class PasswordResetModel */ protected $username; - /** * @var string */ diff --git a/module/fid/src/FormModel/UserDeleteModel.php b/module/fid/src/FormModel/UserDeleteModel.php index 8974fd938588674259152e5f9e1b1ad2b6df8261..e66ca692bf662a1f9db3b14b566c218a86c8ec89 100644 --- a/module/fid/src/FormModel/UserDeleteModel.php +++ b/module/fid/src/FormModel/UserDeleteModel.php @@ -15,10 +15,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Robert Lange <lange@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\FormModel; class UserDeleteModel diff --git a/module/fid/src/FormModel/UsernameChangeModel.php b/module/fid/src/FormModel/UsernameChangeModel.php index 940e46d75d40e784b314e11adfc4b8ec361a383b..084f51141997fe6f8b7dd51ee4d9c14aad1e76c0 100644 --- a/module/fid/src/FormModel/UsernameChangeModel.php +++ b/module/fid/src/FormModel/UsernameChangeModel.php @@ -15,11 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\FormModel; class UsernameChangeModel diff --git a/module/fid/src/Helper/FormLabel.php b/module/fid/src/Helper/FormLabel.php index 90c3b067e00bc969c739d5edb73b1f5eb255391f..c6312fd11505a20b61985cc028d0f32fff2207d0 100644 --- a/module/fid/src/Helper/FormLabel.php +++ b/module/fid/src/Helper/FormLabel.php @@ -15,11 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Robert Lange <lange@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Helper; use Zend\Form\Element; @@ -30,12 +29,14 @@ class FormLabel extends Base public function openTag($element = null) { if ($element instanceof Element) { - $element->setLabelAttributes([ + $element->setLabelAttributes( + [ 'data-type' => $element->getAttribute('type'), 'data-name' => $element->getAttribute('name'), 'data-required' => $element->getAttribute('required') ? 'true' : 'false' - ] + $element->getLabelAttributes()); + ] + $element->getLabelAttributes() + ); } return parent::openTag($element); diff --git a/module/fid/src/Helper/SearchTabs.php b/module/fid/src/Helper/SearchTabs.php index 6bc141ea137fd59bf2ece8f453328cfcfbe83d3e..5ee9dc96cb426982ccebe580ca199db1746519f5 100644 --- a/module/fid/src/Helper/SearchTabs.php +++ b/module/fid/src/Helper/SearchTabs.php @@ -28,7 +28,6 @@ */ namespace fid\Helper; - /** * "Search tabs" view helper * @@ -73,7 +72,7 @@ class SearchTabs extends \VuFind\View\Helper\Root\SearchTabs { $retval = parent::createSelectedTab($id, $class, $label, $permissionName); $retval['hiddenFilters'] = $this->helper->getTabFilterConfig()[$id] ?? null; - $retval['shortLabel'] = 'SearchTabs::'.$label; + $retval['shortLabel'] = 'SearchTabs::' . $label; return $retval; } diff --git a/module/fid/src/Helper/TranslatorDelegator.php b/module/fid/src/Helper/TranslatorDelegator.php index 76fe0c9105f8bcb11e8926d8a8b8163b5ef6a0fb..66735db524edf8612343691f6ae03e662331618a 100644 --- a/module/fid/src/Helper/TranslatorDelegator.php +++ b/module/fid/src/Helper/TranslatorDelegator.php @@ -15,10 +15,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Robert Lange <lange@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Helper; use Psr\Container\ContainerInterface; diff --git a/module/fid/src/Hydrator/OrderHydrator.php b/module/fid/src/Hydrator/OrderHydrator.php index e1acefc7b887e929320100e5e3ba631aeff2698c..e85feda8d1f2803defed3a4d9951e045923e94d8 100644 --- a/module/fid/src/Hydrator/OrderHydrator.php +++ b/module/fid/src/Hydrator/OrderHydrator.php @@ -1,27 +1,28 @@ <?php - namespace fid\Hydrator; use fid\Service\DataTransferObject\Order; use VuFind\RecordDriver\DefaultRecord; use Zend\Hydrator\AbstractHydrator; -class OrderHydrator extends AbstractHydrator { - +class OrderHydrator extends AbstractHydrator +{ public function extract($object) { - return; + // TODO: Implement extract() method. } /** - * @param array $data - * @param Order|object $object + * @param array $data + * @param Order|object $object * @return Order|object|void */ public function hydrate(array $data, $object) { - /** @var DefaultRecord $driver */ + /** + * @var DefaultRecord $driver + */ $driver = $data['driver']; $object->setType($data['type']); @@ -71,16 +72,15 @@ class OrderHydrator extends AbstractHydrator { 'url' ); - $object->setData(compact('record','partialCopy','digitization','pda')); + $object->setData(compact('record', 'partialCopy', 'digitization', 'pda')); $object->setStatus($data['status']); $object->setLabel($data['label']); - return; } - public function toArray ($object) : array { - $array = (array) $object; - $keys = str_replace( '*', '', array_keys( $array ) ); - return array_combine( $keys, array_values( $array ) ); + public function toArray($object) : array + { + $array = (array)$object; + $keys = str_replace('*', '', array_keys($array)); + return array_combine($keys, array_values($array)); } - -} \ No newline at end of file +} diff --git a/module/fid/src/Hydrator/OrderMissingRecordHydrator.php b/module/fid/src/Hydrator/OrderMissingRecordHydrator.php index de31875fc123b7b1776952d239cd9ed729df10a6..debe7570ed9e275d3a89c9287b5f63c2fa98d58a 100644 --- a/module/fid/src/Hydrator/OrderMissingRecordHydrator.php +++ b/module/fid/src/Hydrator/OrderMissingRecordHydrator.php @@ -1,21 +1,20 @@ <?php - namespace fid\Hydrator; use fid\Service\DataTransferObject\Order; use Zend\Hydrator\AbstractHydrator; -class OrderMissingRecordHydrator extends AbstractHydrator { - +class OrderMissingRecordHydrator extends AbstractHydrator +{ public function extract($object) { - return; + // TODO: Implement extract() method. } /** - * @param array $data - * @param Order|object $object + * @param array $data + * @param Order|object $object * @return Order|object|void */ public function hydrate(array $data, $object) @@ -28,9 +27,8 @@ class OrderMissingRecordHydrator extends AbstractHydrator { $pda = null; $record = null; - $object->setData(compact('record','partialCopy','digitization','pda')); + $object->setData(compact('record', 'partialCopy', 'digitization', 'pda')); $object->setStatus($data['status']); $object->setLabel($data['label']); - return; } -} \ No newline at end of file +} diff --git a/module/fid/src/Hydrator/OrderUpdateHydrator.php b/module/fid/src/Hydrator/OrderUpdateHydrator.php index 8a28353c8b1f303c61c10b1ec3e5b3740c05f067..c098d7d6162601a89e0647d66877598a9fda7c0a 100644 --- a/module/fid/src/Hydrator/OrderUpdateHydrator.php +++ b/module/fid/src/Hydrator/OrderUpdateHydrator.php @@ -4,9 +4,9 @@ namespace fid\Hydrator; use fid\Service\DataTransferObject\Order; use Zend\Hydrator\AbstractHydrator; -class OrderUpdateHydrator extends AbstractHydrator { - - const DATE_FORMAT = 'Y-m-d'; +class OrderUpdateHydrator extends AbstractHydrator +{ + public const DATE_FORMAT = 'Y-m-d'; public function extract($object) { @@ -16,8 +16,8 @@ class OrderUpdateHydrator extends AbstractHydrator { } /** - * @param array $data - * @param Order|object $object + * @param array $data + * @param Order|object $object * @return Order|object|void */ public function hydrate(array $data, $object) diff --git a/module/fid/src/Hydrator/Strategy/UserDataStrategy.php b/module/fid/src/Hydrator/Strategy/UserDataStrategy.php index e16fd25bfaf1769a8b23bb4c9848a1e541fec855..48808dff111933b1d9bec83827f062bcb362be9d 100644 --- a/module/fid/src/Hydrator/Strategy/UserDataStrategy.php +++ b/module/fid/src/Hydrator/Strategy/UserDataStrategy.php @@ -15,11 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Hydrator\Strategy; use Zend\Hydrator\NamingStrategy\NamingStrategyInterface; @@ -64,4 +63,4 @@ class UserDataStrategy implements StrategyInterface return $result ?? []; } -} \ No newline at end of file +} diff --git a/module/fid/src/Hydrator/UserHydrator.php b/module/fid/src/Hydrator/UserHydrator.php index 264dfe9cdb2a235206e669e6aa9535036ccfdc41..f8f922c0d6d3fbca91db5825af60a754930b8024 100644 --- a/module/fid/src/Hydrator/UserHydrator.php +++ b/module/fid/src/Hydrator/UserHydrator.php @@ -15,11 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Hydrator; use Zend\Hydrator\ClassMethods; diff --git a/module/fid/src/Hydrator/UserHydratorDelegatorFactory.php b/module/fid/src/Hydrator/UserHydratorDelegatorFactory.php index 823d81475692e03ba95c2a8df0f65ac107cd2859..6ee434ffe801706ae16b1a3c101b3594c468e3f2 100644 --- a/module/fid/src/Hydrator/UserHydratorDelegatorFactory.php +++ b/module/fid/src/Hydrator/UserHydratorDelegatorFactory.php @@ -15,10 +15,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Hydrator; use fid\Hydrator\Strategy\UserDataStrategy; @@ -37,7 +36,9 @@ class UserHydratorDelegatorFactory implements DelegatorFactoryInterface callable $callback, array $options = null ) { - /** @var AbstractHydrator $hydrator */ + /** + * @var AbstractHydrator $hydrator + */ $hydrator = call_user_func($callback); $namingStrategy = $hydrator->getNamingStrategy(); $hydrator->addStrategy('data', new UserDataStrategy($namingStrategy)); diff --git a/module/fid/src/InputFilter/RootAwareBaseInputFilter.php b/module/fid/src/InputFilter/RootAwareBaseInputFilter.php index 193dd8809ee8f5a2d127c834d02bfafdf77d18b9..f85be6465fd86bee16a50c35968eff450192a193 100644 --- a/module/fid/src/InputFilter/RootAwareBaseInputFilter.php +++ b/module/fid/src/InputFilter/RootAwareBaseInputFilter.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\InputFilter; use Zend\InputFilter\BaseInputFilter; @@ -34,4 +33,4 @@ class RootAwareBaseInputFilter extends BaseInputFilter return parent::isValid($values); } -} \ No newline at end of file +} diff --git a/module/fid/src/InputFilter/UserCreateFormInputFilter.php b/module/fid/src/InputFilter/UserCreateFormInputFilter.php index 05d623704f481eaf4e984b4651a58d15c9b5ba47..a48cfe20d7072d9d6d2dc3116133eaae21ff390a 100644 --- a/module/fid/src/InputFilter/UserCreateFormInputFilter.php +++ b/module/fid/src/InputFilter/UserCreateFormInputFilter.php @@ -20,7 +20,6 @@ * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\InputFilter; class UserCreateFormInputFilter extends RootAwareBaseInputFilter @@ -33,4 +32,4 @@ class UserCreateFormInputFilter extends RootAwareBaseInputFilter ]; return compact('permissions') + parent::getValues(); } -} \ No newline at end of file +} diff --git a/module/fid/src/Listener/ClientConfigListener.php b/module/fid/src/Listener/ClientConfigListener.php index 8f5bf8300e14326c4e2de8d81eceb5fbfc66dd69..4933f652946e274b5afff46958fcf4e0c3d96022 100644 --- a/module/fid/src/Listener/ClientConfigListener.php +++ b/module/fid/src/Listener/ClientConfigListener.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Listener; use fid\Service\ClientException; @@ -68,9 +67,11 @@ class ClientConfigListener extends AbstractListenerAggregate */ public function onDispatch(MvcEvent $event) { - /** @var Config $config */ - /** @var PluginManager $configManager */ - /** @var ContainerInterface $container */ + /** + * @var Config $config + * @var PluginManager $configManager + * @var ContainerInterface $container + */ $request = $event->getRequest(); $container = $event->getApplication()->getServiceManager(); $configManager = $container->get(PluginManager::class); @@ -97,8 +98,10 @@ class ClientConfigListener extends AbstractListenerAggregate $baseUrl = $config->baseUrl; } - /** @var ViewModel $viewModel */ - /** @var CookieManager $cookieManager */ + /** + * @var ViewModel $viewModel + * @var CookieManager $cookieManager + */ $this->config['baseUrl'] = $baseUrl; $cookieManager = $container->get(CookieManager::class); $cookieManager->set(self::PARAM, $baseUrl); @@ -106,4 +109,4 @@ class ClientConfigListener extends AbstractListenerAggregate $fidisStatus = sprintf(self::STATUS, $valid ? '' : '!', $baseUrl); $viewModel->setVariable('fidisStatus', $fidisStatus); } -} \ No newline at end of file +} diff --git a/module/fid/src/Listener/ErrorListener.php b/module/fid/src/Listener/ErrorListener.php index 8fe6e0ce741d38c622ddf3481222ac110d689290..6b68145f75eedc70b151fef1fb4d554b16b1ab12 100644 --- a/module/fid/src/Listener/ErrorListener.php +++ b/module/fid/src/Listener/ErrorListener.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Listener; use Zend\EventManager\AbstractListenerAggregate; @@ -46,6 +45,5 @@ class ErrorListener extends AbstractListenerAggregate */ public function onError(EventInterface $event): void { - return; } -} \ No newline at end of file +} diff --git a/module/fid/src/Listener/LocaleListener.php b/module/fid/src/Listener/LocaleListener.php index f69a9613582f971656068531c89ee35c0baebc21..3634bf9813f9dbc8551d05975db0608769df81ca 100644 --- a/module/fid/src/Listener/LocaleListener.php +++ b/module/fid/src/Listener/LocaleListener.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Listener; use fid\Service\Client; @@ -42,9 +41,11 @@ class LocaleListener extends AbstractListenerAggregate public function onDispatch(MvcEvent $event) { $container = $event->getApplication()->getServiceManager(); - /** @var Client $client */ + /** + * @var Client $client + */ $client = $container->get(Client::class); $locale = $container->get(Translator::class)->getLocale(); $client->setLocale($locale); } -} \ No newline at end of file +} diff --git a/module/fid/src/Module.php b/module/fid/src/Module.php index 4f7205c813e1b4f2de2acb33dff19d14cd6c0946..fb66a87277306ce5c95975854b6885e185624f11 100644 --- a/module/fid/src/Module.php +++ b/module/fid/src/Module.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid; use Zend\ModuleManager\Feature\ConfigProviderInterface; @@ -27,6 +26,6 @@ class Module implements ConfigProviderInterface { public function getConfig(): array { - return require __DIR__ . '/../config/module.config.php'; + return include __DIR__ . '/../config/module.config.php'; } } diff --git a/module/fid/src/RecordTab/Worldcat.php b/module/fid/src/RecordTab/Worldcat.php index 8186f93b79f5d139cc6780a444c60103d98ad25b..dfd75e5d04099f02ea2e0e5e0b880daa680b4d81 100644 --- a/module/fid/src/RecordTab/Worldcat.php +++ b/module/fid/src/RecordTab/Worldcat.php @@ -65,7 +65,7 @@ class Worldcat extends \VuFind\RecordTab\AbstractBase */ public function isActive() { - if (!$this->getRecordDriver()->tryMethod('hasRecordPermission',[$this->accessPermission])) { + if (!$this->getRecordDriver()->tryMethod('hasRecordPermission', [$this->accessPermission])) { return false; } $oclc = $this->getRecordDriver()->tryMethod('getOCLC'); diff --git a/module/fid/src/Role/PermissionProvider/FidApiPermission.php b/module/fid/src/Role/PermissionProvider/FidApiPermission.php index 61b9b55535e3ddf18af30c9355fc7a63f4c7c042..ce7763537a3663f275f6eb0a339184437a88781d 100644 --- a/module/fid/src/Role/PermissionProvider/FidApiPermission.php +++ b/module/fid/src/Role/PermissionProvider/FidApiPermission.php @@ -31,8 +31,9 @@ */ namespace fid\Role\PermissionProvider; -use VuFind\Role\PermissionProvider\PermissionProviderInterface; use fid\Service\Client as FidApiClient; +use VuFind\Role\PermissionProvider\PermissionProviderInterface; + /** * Permission provider authorizing FID API roles * @@ -67,12 +68,12 @@ class FidApiPermission implements PermissionProviderInterface */ public function getPermissions($options) { - $authorized = FALSE; + $authorized = false; foreach ((array)$options as $option) { if ($this->client->isAuthorized($option)) { // a user having any of the provided roles // will be authorized - $authorized = TRUE; + $authorized = true; break; } } diff --git a/module/fid/src/Serializer/OrderCreationRequestUserNormalizer.php b/module/fid/src/Serializer/OrderCreationRequestUserNormalizer.php index cee9d122a1c754336d7498ae048c05dc04394dd0..6eafa10b22379f4c5a6dfb92d597b9b7172c63ed 100644 --- a/module/fid/src/Serializer/OrderCreationRequestUserNormalizer.php +++ b/module/fid/src/Serializer/OrderCreationRequestUserNormalizer.php @@ -15,11 +15,10 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Serializer; use fid\Service\DataTransferObject\User; @@ -52,4 +51,4 @@ class OrderCreationRequestUserNormalizer implements { return $object->getId(); } -} \ No newline at end of file +} diff --git a/module/fid/src/Service/Client.php b/module/fid/src/Service/Client.php index ca678cb2781eeaa67a2e0087990003ef8809b93b..5a37773170db70839b5a45686e810946546d77d3 100644 --- a/module/fid/src/Service/Client.php +++ b/module/fid/src/Service/Client.php @@ -151,26 +151,26 @@ class Client $this->logoff(); switch (count($credentials)) { - case 1: - $credentials = base64_decode(urldecode($credentials[0])); - $logon = $this->storeLogon($this->parseLogon($credentials)); - return $this->refreshLogon($logon); - - case 2: - list($username, $password) = $credentials; - $body = json_encode(compact('username', 'password')); - $request = $this->buildRequest('post', 'logons', $body); - $response = $this->sendRequest($request); - - if ($response->getStatusCode() !== 201) { - $this->throwException($response); - } + case 1: + $credentials = base64_decode(urldecode($credentials[0])); + $logon = $this->storeLogon($this->parseLogon($credentials)); + return $this->refreshLogon($logon); + + case 2: + [$username, $password] = $credentials; + $body = json_encode(compact('username', 'password')); + $request = $this->buildRequest('post', 'logons', $body); + $response = $this->sendRequest($request); + + if ($response->getStatusCode() !== 201) { + $this->throwException($response); + } - $logon = $this->parseLogon((string)$response->getBody()); - return $this->storeLogon($logon); + $logon = $this->parseLogon((string)$response->getBody()); + return $this->storeLogon($logon); - default: - throw new InvalidArgumentException(); + default: + throw new InvalidArgumentException(); } } @@ -213,11 +213,11 @@ class Client $response = $this->sendRequest($request); switch ($response->getStatusCode()) { - case 404: - case 204: - break; - default: - $this->throwException($response); + case 404: + case 204: + break; + default: + $this->throwException($response); } } @@ -229,9 +229,13 @@ class Client */ public function requestOrderCreation(Order $order): Order { - $body = $this->serializer->serialize($order, 'json', [ + $body = $this->serializer->serialize( + $order, + 'json', + [ 'groups' => ['order:creation:request'], - ]); + ] + ); $request = $this->buildRequest('post', 'orders', $body); $response = $this->sendAuthenticatedRequest($request); @@ -239,9 +243,15 @@ class Client if ($response->getStatusCode() !== 201) { $this->throwException($response); } - /** @var Order $result */ - $result = $this->serializer->deserialize((string)$response->getBody(), - Order::class, 'json', ['groups' => ['order:creation:response']]); + /** + * @var Order $result + */ + $result = $this->serializer->deserialize( + (string)$response->getBody(), + Order::class, + 'json', + ['groups' => ['order:creation:response']] + ); /* refresh user details */ $this->requestUserDetails(); @@ -257,9 +267,14 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** @var Record $record */ - $record = $this->serializer->deserialize((string)$response->getBody(), - Record::class, 'json'); + /** + * @var Record $record + */ + $record = $this->serializer->deserialize( + (string)$response->getBody(), + Record::class, + 'json' + ); return $record; } @@ -276,13 +291,21 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** @var Order[] $list */ - $list = $this->serializer->deserialize((string)$response->getBody(), - Order::class . '[]', 'json'); - - $keys = array_map(function (Order $order) { - return $order->getId(); - }, $list); + /** + * @var Order[] $list + */ + $list = $this->serializer->deserialize( + (string)$response->getBody(), + Order::class . '[]', + 'json' + ); + + $keys = array_map( + function (Order $order) { + return $order->getId(); + }, + $list + ); return array_combine($keys, $list); } @@ -301,15 +324,20 @@ class Client $this->throwException($response); } - /** @var Order $order */ - $order = $this->serializer->deserialize((string)$response->getBody(), - Order::class, 'json'); + /** + * @var Order $order + */ + $order = $this->serializer->deserialize( + (string)$response->getBody(), + Order::class, + 'json' + ); return $order; } /** - * @param Order $user + * @param Order $user * @return bool * @throws ClientException */ @@ -341,8 +369,14 @@ class Client string $firstname, string $lastname ): void { - $body = json_encode(compact('baseUrl', 'username', 'firstname', - 'lastname')); + $body = json_encode( + compact( + 'baseUrl', + 'username', + 'firstname', + 'lastname' + ) + ); $request = $this->buildRequest('post', 'mail/registration', $body); $response = $this->sendRequest($request); @@ -395,7 +429,9 @@ class Client { $logon = $this->restoreLogon(); - /** @var User $user */ + /** + * @var User $user + */ $user = $this->session['user'] ?? null; $ownId = $logon->getOwnerId(); @@ -417,9 +453,15 @@ class Client $this->throwException($response); } - /** @var User $user */ - $user = $this->serializer->deserialize((string)$response->getBody(), - User::class, 'json', ['groups' => ['user:details:response']]); + /** + * @var User $user + */ + $user = $this->serializer->deserialize( + (string)$response->getBody(), + User::class, + 'json', + ['groups' => ['user:details:response']] + ); if ($ownId === $userId) { $this->session['user'] = $user; @@ -435,9 +477,13 @@ class Client */ public function requestUserCreation(User $user): User { - $body = $this->serializer->serialize($user, 'json', [ + $body = $this->serializer->serialize( + $user, + 'json', + [ 'groups' => ['user:creation:request'] - ]); + ] + ); $request = $this->buildRequest('post', 'users', $body); $response = $this->sendAuthenticatedRequest($request); @@ -445,9 +491,15 @@ class Client if ($response->getStatusCode() !== 201) { $this->throwException($response); } - /** @var User $result */ - $result = $this->serializer->deserialize((string)$response->getBody(), - User::class, 'json', ['groups' => ['user:creation:response']]); + /** + * @var User $result + */ + $result = $this->serializer->deserialize( + (string)$response->getBody(), + User::class, + 'json', + ['groups' => ['user:creation:response']] + ); return $result; } @@ -471,8 +523,10 @@ class Client */ public function requestUserPasswordUpdate(User $user): User { - return $this->doRequestUserUpdate($user, - ['user:update-password:request']); + return $this->doRequestUserUpdate( + $user, + ['user:update-password:request'] + ); } /** @@ -483,9 +537,12 @@ class Client */ public function requestUserUsernameUpdate(User $user): User { - return $this->doRequestUserUpdate($user, [ + return $this->doRequestUserUpdate( + $user, + [ 'user:update-username:request' - ]); + ] + ); } /** @@ -509,13 +566,21 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** @var Library[] $list */ + /** + * @var Library[] $list + */ $list = $this->serializer->deserialize( - (string)$response->getBody(), User::class . '[]', 'json'); - - $keys = array_map(function (User $libary) { - return $libary->getId(); - }, $list); + (string)$response->getBody(), + User::class . '[]', + 'json' + ); + + $keys = array_map( + function (User $libary) { + return $libary->getId(); + }, + $list + ); return $this->session['users'] = array_combine($keys, $list); } @@ -528,8 +593,9 @@ class Client /** * throws an Exception in case the user does not have the requested permission * or the permission cannot be verified - * @param String $permission Name of the permission - * @param User|null $user user object or null if we want to validate the currently logged in user + * + * @param String $permission Name of the permission + * @param User|null $user user object or null if we want to validate the currently logged in user * @throws ClientException * @throws UserNotLoggedinException * @throws UserNotAuthorizedException @@ -584,24 +650,34 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** @var Library[] $list */ + /** + * @var Library[] $list + */ $list = $this->serializer->deserialize( - (string)$response->getBody(), Library::class . '[]', 'json'); - - $keys = array_map(function (Library $libary) { - return $libary->getId(); - }, $list); + (string)$response->getBody(), + Library::class . '[]', + 'json' + ); + + $keys = array_map( + function (Library $libary) { + return $libary->getId(); + }, + $list + ); if (empty($this->session->libraries)) { $this->session->libraries = []; } - return $this->session->libraries[$this->locale] = array_combine($keys, - $list); + return $this->session->libraries[$this->locale] = array_combine( + $keys, + $list + ); } /** - * @param $id + * @param $id * @return Library * @throws ClientException */ @@ -618,13 +694,21 @@ class Client $this->throwException($response); } - /** @var Library $list */ + /** + * @var Library $list + */ $library = $this->serializer->deserialize( - (string)$response->getBody(), Library::class, 'json'); - - $phpTypeCasting = array_map(function (Library $library) { - return $library->getId(); - }, [$library]); + (string)$response->getBody(), + Library::class, + 'json' + ); + + $phpTypeCasting = array_map( + function (Library $library) { + return $library->getId(); + }, + [$library] + ); if (empty($this->session->homeLibrary)) { $this->session->homeLibrary = []; @@ -649,9 +733,15 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** @var User $result */ - $result = $this->serializer->deserialize((string)$response->getBody(), - User::class, 'json', ['groups' => ['user:update:response']]); + /** + * @var User $result + */ + $result = $this->serializer->deserialize( + (string)$response->getBody(), + User::class, + 'json', + ['groups' => ['user:update:response']] + ); $logon = $this->restoreLogon(); if ($logon->getOwnerId() === $user->getId()) { @@ -750,7 +840,7 @@ class Client return APPLICATION_ENV === 'production' ? $request : $request->withHeader('Cookie', "XDEBUG_SESSION=$xdebugSession") - ->withHeader('X-xdebug-remote-addr', $xdebugRemoteAddr); + ->withHeader('X-xdebug-remote-addr', $xdebugRemoteAddr); } /** @@ -771,7 +861,9 @@ class Client */ protected function restoreLogon(): Logon { - /** @var Logon $logon */ + /** + * @var Logon $logon + */ if ($logon = $this->session['logon'] ?? null) { $logon->setToken($this->cookies->get('finc_fid_logon')); if (time() < $logon->getExpiresAt()) { @@ -796,7 +888,9 @@ class Client protected function parseLogon(string $logon): Logon { $logon = $this->serializer->deserialize($logon, Logon::class, 'json'); - /** @var Logon $logon */ + /** + * @var Logon $logon + */ return $logon; } } diff --git a/module/fid/src/Service/ClientException.php b/module/fid/src/Service/ClientException.php index 6566710e1383f9b7a90598593ea43c9adbebf209..3e10451c98f830c1976a782a0e962d7599b127d5 100644 --- a/module/fid/src/Service/ClientException.php +++ b/module/fid/src/Service/ClientException.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service; class ClientException extends \Exception diff --git a/module/fid/src/Service/ClientFactory.php b/module/fid/src/Service/ClientFactory.php index 08398aeadeda3d1c7513aa0a19629d1bde7bf5b5..5e9af766797de45af4fd1b567614d32fa69d5055 100644 --- a/module/fid/src/Service/ClientFactory.php +++ b/module/fid/src/Service/ClientFactory.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service; use fid\Listener\ClientConfigListener; @@ -41,27 +40,49 @@ class ClientFactory */ public function __invoke(ContainerInterface $container): Client { - /** @var ClientConfigListener $clientConfigListener */ + /** + * @var ClientConfigListener $clientConfigListener + */ $clientConfigListener = $container->get(ClientConfigListener::class); - /** @var SessionManager $sessionManager */ + /** + * @var SessionManager $sessionManager + */ $sessionManager = $container->get(SessionManager::class); $session = new Session(Client::class, $sessionManager); - /** @var CookieManager $cookies */ + /** + * @var CookieManager $cookies + */ $cookies = $container->get(CookieManager::class); - /** @var SerializerInterface $serializer */ + /** + * @var SerializerInterface $serializer + */ $serializer = $container->get(SerializerInterface::class); - /** @var HttpClientInterface $httpClient */ + /** + * @var HttpClientInterface $httpClient + */ $httpClient = $container->get(HttpClientInterface::class); - /** @var UriFactoryInterface $uriFactory */ + /** + * @var UriFactoryInterface $uriFactory + */ $uriFactory = $container->get(UriFactoryInterface::class); - /** @var StreamFactoryInterface $streamFactory */ + /** + * @var StreamFactoryInterface $streamFactory + */ $streamFactory = $container->get(StreamFactoryInterface::class); - /** @var RequestFactoryInterface $requestFactory */ + /** + * @var RequestFactoryInterface $requestFactory + */ $requestFactory = $container->get(RequestFactoryInterface::class); return new Client( - $clientConfigListener->getConfig(), $session, $cookies, $serializer, - $httpClient, $uriFactory, $streamFactory, $requestFactory + $clientConfigListener->getConfig(), + $session, + $cookies, + $serializer, + $httpClient, + $uriFactory, + $streamFactory, + $requestFactory ); } -} \ No newline at end of file +} diff --git a/module/fid/src/Service/DataTransferObject/Address.php b/module/fid/src/Service/DataTransferObject/Address.php index b9fdf0c696d8be2ba2eb659d2959844a7f2b0184..8b1ea9129940ec73d7be78d9faa69d92682c75cb 100644 --- a/module/fid/src/Service/DataTransferObject/Address.php +++ b/module/fid/src/Service/DataTransferObject/Address.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service\DataTransferObject; use Symfony\Component\Serializer\Annotation\Groups; @@ -26,7 +25,7 @@ use Symfony\Component\Serializer\Annotation\Groups; class Address { /** - * @var string|null + * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", @@ -42,7 +41,7 @@ class Address protected $user; /** - * @var string|null + * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", @@ -54,7 +53,7 @@ class Address protected $line1; /** - * @var string|null + * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", @@ -66,7 +65,7 @@ class Address protected $line2; /** - * @var string|null + * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", @@ -78,7 +77,7 @@ class Address protected $zip; /** - * @var string|null + * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", @@ -90,7 +89,7 @@ class Address protected $city; /** - * @var string|null + * @var string|null * @Groups({ * "user:details:response", * "user:creation:response", @@ -215,10 +214,11 @@ class Address public function __toString() { - return $this->id.': '. $this->line1.' '.$this->line2.'; '.$this->zip.' '.$this->city.'; '.$this->country; + return $this->id . ': ' . $this->line1 . ' ' . $this->line2 . '; ' . $this->zip . ' ' . $this->city . '; ' . $this->country; } - public function isCompleteAddress () : bool { + public function isCompleteAddress() : bool + { return strlen($this->line1) > 0 && strlen($this->zip) > 0 && strlen($this->city) > 0; diff --git a/module/fid/src/Service/DataTransferObject/Library.php b/module/fid/src/Service/DataTransferObject/Library.php index 12c7de2d4aa164773d9e18060f28d8cd5375eb01..56a0e84bb5e9ff1c1cc267843fc47f357dbf08c6 100644 --- a/module/fid/src/Service/DataTransferObject/Library.php +++ b/module/fid/src/Service/DataTransferObject/Library.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license https://opensource.org/licenses/GPL-3.0 GNU GPLv3 */ - namespace fid\Service\DataTransferObject; class Library @@ -169,4 +168,4 @@ class Library { $this->label = $label; } -} \ No newline at end of file +} diff --git a/module/fid/src/Service/DataTransferObject/Logon.php b/module/fid/src/Service/DataTransferObject/Logon.php index bdefe036d16b0c0772a769b027b96b604a4030d4..25afa7aec6e4e11bd1d43539ff4bb06753933de0 100644 --- a/module/fid/src/Service/DataTransferObject/Logon.php +++ b/module/fid/src/Service/DataTransferObject/Logon.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service\DataTransferObject; class Logon diff --git a/module/fid/src/Service/DataTransferObject/Order.php b/module/fid/src/Service/DataTransferObject/Order.php index caf48778a971acf3b7f7e449259199a89cbcea08..e368c3dee042f8a6972fecfdf617bc4d96ae0db0 100644 --- a/module/fid/src/Service/DataTransferObject/Order.php +++ b/module/fid/src/Service/DataTransferObject/Order.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service\DataTransferObject; namespace fid\Service\DataTransferObject; @@ -28,7 +27,7 @@ use Symfony\Component\Serializer\Annotation\Groups; class Order { /** - * @var string|null + * @var string|null * @Groups({ * "order:creation:response", * "order:list:response", @@ -41,7 +40,7 @@ class Order protected $id; /** - * @var string + * @var string * @Groups({ * "order:creation:request", * "order:creation:response", @@ -55,7 +54,7 @@ class Order protected $type = ''; /** - * @var string + * @var string * @Groups({ * "order:creation:request", * "order:creation:response", @@ -69,7 +68,7 @@ class Order protected $label = ''; /** - * @var User|null + * @var User|null * @Groups({ * "order:creation:request", * "order:creation:response", @@ -83,7 +82,7 @@ class Order protected $user; /** - * @var array + * @var array * @Groups({ * "order:creation:request", * "order:creation:response", @@ -97,7 +96,7 @@ class Order protected $data = []; /** - * @var \DateTime + * @var \DateTime * @Groups({ * "order:creation:response", * "order:list:response", @@ -109,7 +108,7 @@ class Order */ protected $createdAt; - const DATETIME_FORMAT = 'Y-m-d H:i:s'; + public const DATETIME_FORMAT = 'Y-m-d H:i:s'; /** * @return string|null @@ -215,7 +214,7 @@ class Order public function getDueDate(): ? \DateTime { return (!empty($this->data['dueDate'])) - ? \DateTime::createFromFormat(self::DATETIME_FORMAT,$this->data['dueDate']) + ? \DateTime::createFromFormat(self::DATETIME_FORMAT, $this->data['dueDate']) : null; } @@ -234,14 +233,12 @@ class Order return $this->getDueDate() ? $this->getDueDate()->format('d.m.Y') : ''; } - public function isOverdue () : bool + public function isOverdue() : bool { - if ($duedate = $this->getDueDate()) - { + if ($duedate = $this->getDueDate()) { $now = new \DateTime(); return $now > $duedate ? true : false; - } - else { + } else { return false; } } @@ -259,12 +256,13 @@ class Order */ public function setStatus(?string $status): void { - if($status != null) { + if ($status != null) { $this->data['status'] = $status; } } - public function getRecordId() { + public function getRecordId() + { return $this->data['record']['id'] ?? null; } -} \ No newline at end of file +} diff --git a/module/fid/src/Service/DataTransferObject/Record.php b/module/fid/src/Service/DataTransferObject/Record.php index 0d0a8f9e3a19f85f8cf5e8ce80125177f1a777b2..f2981bd704e6d24c7016b9c8347fab79c41905f4 100644 --- a/module/fid/src/Service/DataTransferObject/Record.php +++ b/module/fid/src/Service/DataTransferObject/Record.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license https://opensource.org/licenses/GPL-3.0 GNU GPLv3 */ - namespace fid\Service\DataTransferObject; class Record @@ -64,4 +63,4 @@ class Record { $this->ordered = $ordered; } -} \ No newline at end of file +} diff --git a/module/fid/src/Service/DataTransferObject/User.php b/module/fid/src/Service/DataTransferObject/User.php index 7da55a719956b78bf8ff78e35c634d1d18a7c3c1..42c642eff19f7021201f166c714d6c327253f62c 100644 --- a/module/fid/src/Service/DataTransferObject/User.php +++ b/module/fid/src/Service/DataTransferObject/User.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service\DataTransferObject; use Symfony\Component\Serializer\Annotation\Groups; @@ -26,7 +25,7 @@ use Symfony\Component\Serializer\Annotation\Groups; class User { /** - * @var null|string + * @var null|string * @Groups({ * "order:creation:response", * "order:details:response", @@ -39,7 +38,7 @@ class User protected $id; /** - * @var null|string + * @var null|string * @Groups({ * "order:creation:response", * "order:details:response", @@ -54,7 +53,7 @@ class User protected $username; /** - * @var null|string + * @var null|string * @Groups({ * "user:details:response", * "user:creation:request", @@ -64,7 +63,7 @@ class User protected $password; /** - * @var string + * @var string * @Groups({ * "user:details:response", * "user:creation:request", @@ -76,7 +75,7 @@ class User protected $salutation; /** - * @var string + * @var string * @Groups({ * "user:details:response", * "user:creation:request", @@ -88,7 +87,7 @@ class User protected $academicTitle; /** - * @var null|string + * @var null|string * @Groups({ * "order:creation:response", * "order:details:response", @@ -103,7 +102,7 @@ class User protected $firstname; /** - * @var null|string + * @var null|string * @Groups({ * "order:creation:response", * "order:details:response", @@ -118,7 +117,7 @@ class User protected $lastname; /** - * @var null|string + * @var null|string * @Groups({ * "user:details:response", * "user:creation:request", @@ -130,7 +129,7 @@ class User protected $homeLibrary; /** - * @var string + * @var string * @Groups({ * "user:details:response", * "user:creation:request", @@ -142,7 +141,7 @@ class User protected $college = ''; /** - * @var string + * @var string * @Groups({ * "user:details:response", * "user:creation:request", @@ -154,7 +153,7 @@ class User protected $jobTitle = ''; /** - * @var Address[] + * @var Address[] * @Groups({ * "user:details:response", * "user:creation:request", @@ -166,7 +165,7 @@ class User protected $addresses = []; /** - * @var Order[] + * @var Order[] * @Groups({ * "user:details:response", * "user:creation:response", @@ -176,7 +175,7 @@ class User protected $orders = []; /** - * @var array[] + * @var array[] * @Groups({ * "user:details:response", * "user:creation:request", @@ -188,7 +187,7 @@ class User protected $permissions = []; /** - * @var array + * @var array * @Groups({ * "user:details:response", * "user:creation:request", @@ -390,7 +389,9 @@ class User */ public function getDeliveryAddress(): ?Address { - if (empty($addresses = $this->getAddresses())) return null; + if (empty($addresses = $this->getAddresses())) { + return null; + } $addressIndex = !empty($this->getData()["deliveryAddress"]) ? $this->getData()["deliveryAddress"] : 0; return $addresses[$addressIndex]; } @@ -415,7 +416,7 @@ class User } /** - * @param string $deletedAt + * @param string $deletedAt * @return void */ public function setDeletedAt(string $deletedAt): void @@ -431,8 +432,7 @@ class User $addressIndex = !empty($this->getData()["deliveryAddress"]) ? $this->getData()["deliveryAddress"] : 0; if ($addressIndex == 0) { return true; - } - else { + } else { return false; } } @@ -478,7 +478,8 @@ class User /** * @param Order $order */ - public function addOrder($order): void { + public function addOrder($order): void + { $this->orders[] = $order; } @@ -500,8 +501,7 @@ class User public function hasPermission($permission): bool { - if ( - isset($this->permissions[$permission]) + if (isset($this->permissions[$permission]) && $this->permissions[$permission] === 'granted' ) { return true; @@ -528,43 +528,46 @@ class User /** * @return string */ - public function getLiberoId () : string { - return 'FID'.str_pad($this->getId(),10,"0",STR_PAD_LEFT); + public function getLiberoId() : string + { + return 'FID' . str_pad($this->getId(), 10, "0", STR_PAD_LEFT); } public function getFieldList() { $fields = []; foreach ($this as $property => $value) { - if ($property === 'password') continue; + if ($property === 'password') { + continue; + } $fields[] = $property; } return $fields; } - public function export($fields,$delimiter="\t") { - + public function export($fields, $delimiter="\t") + { $output = ''; foreach ($fields as $property) { - if ($property === 'password') continue; + if ($property === 'password') { + continue; + } if ($property === 'permissions') { $value = []; $permissions = $this->getPermissions(); foreach ($permissions as $key => $perm) { - $value[] = $key.' ('.$perm.')'; + $value[] = $key . ' (' . $perm . ')'; } } else { $value = $this->{$property} ?? ''; - if ($property === 'data' && is_array($value)) - { + if ($property === 'data' && is_array($value)) { array_walk( $value, - function(&$data,$key) { - if($key == 'phone') { - $data = $key.': '.($data ? $data: 'no'); - } - else { - $data = $key.': '.($data ? 'yes': 'no'); + function (&$data, $key) { + if ($key == 'phone') { + $data = $key . ': ' . ($data ? $data : 'no'); + } else { + $data = $key . ': ' . ($data ? 'yes' : 'no'); } } ); @@ -575,6 +578,6 @@ class User } $output .= $value . $delimiter; } - return rtrim($output,$delimiter); + return rtrim($output, $delimiter); } } diff --git a/module/fid/src/Service/UserAuthorizationException.php b/module/fid/src/Service/UserAuthorizationException.php index 33d2772ba94072b56c4e95fb33714e3b6c65ead1..e8557c35035783c0b923ea53087e8f07cfe93fd5 100644 --- a/module/fid/src/Service/UserAuthorizationException.php +++ b/module/fid/src/Service/UserAuthorizationException.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service; class UserAuthorizationException extends \Exception diff --git a/module/fid/src/Service/UserNotAuthorizedException.php b/module/fid/src/Service/UserNotAuthorizedException.php index 8d7dadc44f1c4589b18d7c01062d720583cd0547..f0845ad537c38887d04e87581e53ba7d70c0d5d5 100644 --- a/module/fid/src/Service/UserNotAuthorizedException.php +++ b/module/fid/src/Service/UserNotAuthorizedException.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service; class UserNotAuthorizedException extends UserAuthorizationException diff --git a/module/fid/src/Service/UserNotLoggedinException.php b/module/fid/src/Service/UserNotLoggedinException.php index dced38c128d139e60562b60f3466af2aede2a373..37a27dbbbf5153586f3ea910a564ac9d203ae85b 100644 --- a/module/fid/src/Service/UserNotLoggedinException.php +++ b/module/fid/src/Service/UserNotLoggedinException.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Service; class UserNotLoggedinException extends UserAuthorizationException diff --git a/module/fid/src/Validator/SubitoPartialCopyPageBounds.php b/module/fid/src/Validator/SubitoPartialCopyPageBounds.php index 18a68db0487722adb87f0dce19fefb8156738d3e..35bc8a99f5372974f73ec0dbfafe0cafcd82692f 100644 --- a/module/fid/src/Validator/SubitoPartialCopyPageBounds.php +++ b/module/fid/src/Validator/SubitoPartialCopyPageBounds.php @@ -18,7 +18,6 @@ * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Validator; use Zend\Validator\AbstractValidator; @@ -40,19 +39,15 @@ class SubitoPartialCopyPageBounds extends AbstractValidator public function isValid($value) { - if ($this->options['numberPages'] == null) - { + if ($this->options['numberPages'] == null) { return false; } $this->extractPages($value); - if (($this->pageEnd > $this->options['numberPages']) || ($this->pageStart < 1)) - { + if (($this->pageEnd > $this->options['numberPages']) || ($this->pageStart < 1)) { $this->error(self::PAGE_BOUNDS); return false; - } - else - { + } else { return true; } } diff --git a/module/fid/src/Validator/SubitoPartialCopyPageOrder.php b/module/fid/src/Validator/SubitoPartialCopyPageOrder.php index 74961ec79e83af7728ab74658f16ccff8bac6b07..0415c5a348decedb3bc25eb9ce008bc2b1d67d57 100644 --- a/module/fid/src/Validator/SubitoPartialCopyPageOrder.php +++ b/module/fid/src/Validator/SubitoPartialCopyPageOrder.php @@ -18,7 +18,6 @@ * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Validator; use Zend\Validator\AbstractValidator; @@ -37,12 +36,10 @@ class SubitoPartialCopyPageOrder extends AbstractValidator { $this->extractPages($value); - if($this->pageStart > $this->pageEnd) { + if ($this->pageStart > $this->pageEnd) { $this->error(self::PAGES_ORDER); return false; - } - else - { + } else { return true; } } diff --git a/module/fid/src/Validator/SubitoPartialCopyPageRangeValidatorTrait.php b/module/fid/src/Validator/SubitoPartialCopyPageRangeValidatorTrait.php index f828b0693901007ab2fa2361b2707b86e696cd2b..ee91dbc6a10d4366d49b771cd921d22493defd55 100644 --- a/module/fid/src/Validator/SubitoPartialCopyPageRangeValidatorTrait.php +++ b/module/fid/src/Validator/SubitoPartialCopyPageRangeValidatorTrait.php @@ -18,7 +18,6 @@ * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Validator; use fid\Controller\RecordController; @@ -26,12 +25,13 @@ use fid\Controller\RecordController; trait SubitoPartialCopyPageRangeValidatorTrait { private $pageStart = null; + private $pageEnd = null; - private function extractPages ($value) + private function extractPages($value) { preg_match(RecordController::PAGE_RANGE_PATTERN, $value, $matches); - $this->pageStart = (int) $matches[1]; - $this->pageEnd = (int) $matches[2]; + $this->pageStart = (int)$matches[1]; + $this->pageEnd = (int)$matches[2]; } -} \ No newline at end of file +} diff --git a/module/fid/src/Validator/SubitoPartialCopyPageSelection.php b/module/fid/src/Validator/SubitoPartialCopyPageSelection.php index 2818ab17a8215788a75535c59c4332a9143d1025..00f5be4679e4718861cef7d83cde59568965f266 100644 --- a/module/fid/src/Validator/SubitoPartialCopyPageSelection.php +++ b/module/fid/src/Validator/SubitoPartialCopyPageSelection.php @@ -18,7 +18,6 @@ * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\Validator; use Zend\Validator\AbstractValidator; @@ -40,23 +39,19 @@ class SubitoPartialCopyPageSelection extends AbstractValidator 'percentagedLimit' => 10 ]; - public function isValid ($value) + public function isValid($value) { - if ($this->options['numberPages'] == null) - { + if ($this->options['numberPages'] == null) { return false; } $this->extractPages($value); $selection = $this->pageEnd - $this->pageStart; $permittedSelection = (($this->options['percentagedLimit'] / 100) * $this->options['numberPages']) + $this->options['tolerancePages']; - if ($selection > $permittedSelection) - { + if ($selection > $permittedSelection) { $this->error(self::PAGE_SELECTION); return false; - } - else - { + } else { return true; } } diff --git a/module/fid/src/View/Helper/Root/GetIt.php b/module/fid/src/View/Helper/Root/GetIt.php index 3e581db500dce409566682c914deecb1392b7622..af1f8c9e2be8c3ae10504eaba074ee1d071e01a1 100644 --- a/module/fid/src/View/Helper/Root/GetIt.php +++ b/module/fid/src/View/Helper/Root/GetIt.php @@ -88,73 +88,99 @@ class GetIt extends AbstractHelper /** * Solr field source_id + * * @var */ protected $sid; + /** * Solr field format * or instance specific configuration + * * @var */ protected $format; + /** * Solr field facet_avail + * * @var */ protected $facetAvail; + /** * Solr field multipart_set + * * @var */ protected $multipart; + /** * Has a hierarchy parent title + * * @var */ protected $isCollection; + /** * Solr field institution + * * @var */ protected $institution; + /** * Solr field mega_collection + * * @var */ protected $megacollection; + /** * Solr field collection + * * @var */ protected $collection; + /** * Solr field isbn + * * @var */ protected $isbn; + /** * Solr field issn + * * @var */ protected $issn; /** * Default color of a accordeon + * * @var */ protected $accordeonColorDefault; + /** * second color of the accordeon + * * @var */ protected $accordeonColorAlternative; + /** * Default headline text of the get it box + * * @var */ protected $accordeonHeadlineDefault; + /** * second headline text of the get it box + * * @var */ protected $accordeonHeadlineAlternative; @@ -164,7 +190,7 @@ class GetIt extends AbstractHelper * * @param Config $getItConfig Get It box Configuration */ - public function __construct($getItConfig, $fidClient,$permissionManager) + public function __construct($getItConfig, $fidClient, $permissionManager) { $this->config = $getItConfig; $this->fidClient = $fidClient; @@ -198,7 +224,8 @@ class GetIt extends AbstractHelper return $this; } - protected function hasPermission($permission) { + protected function hasPermission($permission) + { return $this->permissionManager->isAuthorized($permission); } @@ -296,25 +323,23 @@ class GetIt extends AbstractHelper } /** - * * Open Access * * Configuration of SIDs 13,22,26,28,30,34,53,80,84,87,88,99,101,150,153,170 * - * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV1( &$accordeonColor, @@ -337,24 +362,23 @@ class GetIt extends AbstractHelper } /** - * * Magazine Articles * * Configuration of SID 49,55,68,105 * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV3( &$accordeonColor, @@ -376,29 +400,27 @@ class GetIt extends AbstractHelper $boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); $notice = ''; $isAiSidRecord = true; - $showArticleButton = isset($this->config->Permission->allowSubitoArticleCopy) ? - $this->config->Permission->allowSubitoArticleCopy : true; + $showArticleButton = $this->config->Permission->allowSubitoArticleCopy ?? true; } /** - * * PDA * * Configuration of SID 51 * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV4( &$accordeonColor, @@ -422,29 +444,27 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_2'); $noticeLinkType = "register"; } - $showOrderButton = isset($this->config->Permission->allowPDA) ? - $this->config->Permission->allowPDA : true; + $showOrderButton = $this->config->Permission->allowPDA ?? true; } /** - * * EBL * * Configuration of SID 76 * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV5( &$accordeonColor, @@ -484,24 +504,23 @@ class GetIt extends AbstractHelper } /** - * * IZI Database * * Configuration of SID 78 * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV6( &$accordeonColor, @@ -522,24 +541,23 @@ class GetIt extends AbstractHelper } /** - * * Margaret Herrick Library * * Configuration of SID 103 * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV7( &$accordeonColor, @@ -562,24 +580,23 @@ class GetIt extends AbstractHelper } /** - * * VK Film collection * * Configuration of SID 0,109,117,119,127,142,148,151,155 * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV8( &$accordeonColor, @@ -602,8 +619,8 @@ class GetIt extends AbstractHelper $accordeonColor = $this->accordeonColorAlternative; } elseif (in_array('Online', $this->facetAvail) && (preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format)) + || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format) + || preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format)) ) { $accordeonHeadline = $this->accordeonHeadlineAlternative; $accordeonColor = $this->accordeonColorAlternative; @@ -617,9 +634,8 @@ class GetIt extends AbstractHelper $isLogin = true; } elseif (in_array('Local', $this->facetAvail) && ((preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - && !in_array($this->_getNonSourceIds('source_idsV8_9'), $this->institution)) - || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format) - ) + && !in_array($this->_getNonSourceIds('source_idsV8_9'), $this->institution)) + || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) ) { $isLogin = true; } elseif (in_array('Online', $this->facetAvail) @@ -647,7 +663,7 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_1'); } elseif (in_array('Local', $this->facetAvail) && (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) + || preg_grep($this->_getNonSourceIds('source_idsV8_3'), $this->format)) ) { if (!$this->fidClient->isLoggedOn()) { $notice = $this->translate('getit_text_10'); @@ -665,7 +681,7 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_1'); } elseif (in_array('Online', $this->facetAvail) && (preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format)) + || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format)) ) { $notice = $this->translate('getit_text_9'); } elseif (in_array('Online', $this->facetAvail) @@ -697,7 +713,7 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_1'); } elseif (in_array('Online', $this->facetAvail) && (preg_grep($this->_getNonSourceIds('source_idsV8_5'), $this->format) - || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format)) + || preg_grep($this->_getNonSourceIds('source_idsV8_6'), $this->format)) ) { $notice = $this->translate('getit_text_9'); } elseif (in_array('Online', $this->facetAvail) @@ -720,8 +736,7 @@ class GetIt extends AbstractHelper && preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) ) { if (!$this->isCollection) { - $showPartCopyButton = isset($this->config->Permission->allowSubitoPartialCopy) ? - $this->config->Permission->allowSubitoPartialCopy : true; + $showPartCopyButton = $this->config->Permission->allowSubitoPartialCopy ?? true; } } if (preg_grep($this->_getNonSourceIds('source_idsV8_1'), $this->format) @@ -753,24 +768,23 @@ class GetIt extends AbstractHelper } /** - * * VK Film collection * * Configuration of SID 0 (special cases) * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV9( &$accordeonColor, @@ -796,8 +810,7 @@ class GetIt extends AbstractHelper } //END accordeon //showLinks - if ( - preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) + if (preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) ) { if (!$this->fidClient->isLoggedOn()) { $showLinks = false; @@ -811,8 +824,7 @@ class GetIt extends AbstractHelper && !$this->isCollection && !preg_grep($this->_getNonSourceIds('source_idsV8_8'), $this->collection) ) { - $showOrderButton = isset($this->config->Permission->allowPDA) ? - $this->config->Permission->allowPDA : true; + $showOrderButton = $this->config->Permission->allowPDA ?? true; } //END orderButton //EBCEbooks @@ -825,24 +837,23 @@ class GetIt extends AbstractHelper } /** - * * MediathekViewWeb * * Configuration of SID 169 * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV10( &$accordeonColor, @@ -865,24 +876,23 @@ class GetIt extends AbstractHelper } /** - * * Bielefeld Academic Search Engine (BASE) * * Configuration of SID 126 * - * @param $accordeonColor string accordeon color - * @param $accordeonHeadline string accordeon headline - * @param $boxHeadline string headline text get it box - * @param $notice string text of box version - * @param $showLinks boolean display links - * @param $showOrderButton boolean display order button - * @param $showPartCopyButton boolean display part copy button - * @param $showArticleButton boolean display part copy button - * @param $bossData boolean display data of BOSS webservice - * @param $isEBCEBooks boolean is given record UBL-FID-EBC - * @param $hideNotice boolean hide notice - * @param $isAiSidRecord boolean is given record an ai record - * @param $noticeLinkType string type of link + * @param $accordeonColor string accordeon color + * @param $accordeonHeadline string accordeon headline + * @param $boxHeadline string headline text get it box + * @param $notice string text of box version + * @param $showLinks boolean display links + * @param $showOrderButton boolean display order button + * @param $showPartCopyButton boolean display part copy button + * @param $showArticleButton boolean display part copy button + * @param $bossData boolean display data of BOSS webservice + * @param $isEBCEBooks boolean is given record UBL-FID-EBC + * @param $hideNotice boolean hide notice + * @param $isAiSidRecord boolean is given record an ai record + * @param $noticeLinkType string type of link */ public function get_config_source_idsV11( &$accordeonColor, @@ -903,7 +913,6 @@ class GetIt extends AbstractHelper } /** - * * Has User ordered certain Record (SID 51) * * @return bool diff --git a/module/fid/src/View/Helper/Root/UserGroups.php b/module/fid/src/View/Helper/Root/UserGroups.php index 1b286b567e1ab9eb3ef8aabf2f20782a40fa21fc..e3fe6d2dfe83b6941a1a11189646f256671354f7 100644 --- a/module/fid/src/View/Helper/Root/UserGroups.php +++ b/module/fid/src/View/Helper/Root/UserGroups.php @@ -55,7 +55,7 @@ class UserGroups extends AbstractHelper { $this->displayRoles = $fidConfig->UserProfile['role_display']->toArray() ?? []; foreach ($fidConfig->UserProfile['role_display_priority'] ?? [] as $prios) { - $roles = explode('>',$prios); + $roles = explode('>', $prios); while (count($roles) > 1) { $current = array_pop($roles); if (!empty($roles)) { @@ -63,16 +63,16 @@ class UserGroups extends AbstractHelper } } } - $this->displayOrder = explode('>',$fidConfig->UserProfile['role_display_order'] ?? ''); + $this->displayOrder = explode('>', $fidConfig->UserProfile['role_display_order'] ?? ''); } public function __invoke($permissions) { $this->groups['requested'] = - $this->groups['granted'] = array_fill_keys($this->displayOrder,null); + $this->groups['granted'] = array_fill_keys($this->displayOrder, null); foreach ($permissions as $permission => $status) { // $status is in ['granted','requested'] - if (in_array($permission,$this->displayRoles)) { + if (in_array($permission, $this->displayRoles)) { $this->groups[$status][$permission] = $this->translate('fid::label_access_level_' . $permission); } @@ -94,11 +94,13 @@ class UserGroups extends AbstractHelper return $this; } - public function granted() { - return !empty($this->groups['granted']) ? implode("; ",$this->groups['granted']) : null; + public function granted() + { + return !empty($this->groups['granted']) ? implode("; ", $this->groups['granted']) : null; } - public function requested() { - return !empty($this->groups['requested']) ? implode('; ',$this->groups['requested']) : null; + public function requested() + { + return !empty($this->groups['requested']) ? implode('; ', $this->groups['requested']) : null; } } diff --git a/module/fid/src/VuFind/Auth/Authenticator.php b/module/fid/src/VuFind/Auth/Authenticator.php index bda67c1efad3cbebbd17eae04d4a2b431bc8134c..ccefd6dc9ba5db5f1d568e260cab1c7485ad7df4 100644 --- a/module/fid/src/VuFind/Auth/Authenticator.php +++ b/module/fid/src/VuFind/Auth/Authenticator.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\VuFind\Auth; use fid\Service\Client; @@ -66,7 +65,6 @@ class Authenticator extends AbstractBase return $this->authenticate($request); } - /** * @param Request $request * @@ -84,10 +82,10 @@ class Authenticator extends AbstractBase $logon = $this->client->logon($username, $password); } catch (ClientException $exception) { switch ($exception->getCode()) { - case 401: - throw new AuthException(self::AUTH_ERROR_BAD_CREDENTIALS); - default: - throw new AuthException(self::AUTH_ERROR_UNKNOWN_REASON); + case 401: + throw new AuthException(self::AUTH_ERROR_BAD_CREDENTIALS); + default: + throw new AuthException(self::AUTH_ERROR_UNKNOWN_REASON); } } @@ -96,7 +94,9 @@ class Authenticator extends AbstractBase throw new AuthException(self::AUTH_ERROR_ACCOUNT_BLOCKED); } - /** @var User $user */ + /** + * @var User $user + */ $user = $this->client->requestUserDetails(); if ($user->isDeleted()) { $this->client->logoff(); @@ -104,7 +104,9 @@ class Authenticator extends AbstractBase } if ($ownerId = $logon->getOwnerId()) { - /** @var VuFindUser $userRow */ + /** + * @var VuFindUser $userRow + */ $userRow = $this->getUserTable()->getByUsername($ownerId); return $userRow; @@ -143,4 +145,4 @@ class Authenticator extends AbstractBase { return true; } -} \ No newline at end of file +} diff --git a/module/fid/src/VuFind/Auth/AuthenticatorFactory.php b/module/fid/src/VuFind/Auth/AuthenticatorFactory.php index 21c868cfb64c9a966416c19ea0c4d622e5617034..e939baa19c23c446e0a0a355af60182d98b2870a 100644 --- a/module/fid/src/VuFind/Auth/AuthenticatorFactory.php +++ b/module/fid/src/VuFind/Auth/AuthenticatorFactory.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\VuFind\Auth; use fid\Service\Client; @@ -28,9 +27,11 @@ class AuthenticatorFactory { public function __invoke(ContainerInterface $container) { - /** @var Client $client */ + /** + * @var Client $client + */ $client = $container->get(Client::class); - + return new Authenticator($client); } -} \ No newline at end of file +} diff --git a/module/fid/src/VuFind/Auth/ILSAuthenticator.php b/module/fid/src/VuFind/Auth/ILSAuthenticator.php index 8ccc5c2d07e2f0876af02a5386e1431482ba43b0..bfa7533bc3dfa6fef7465e30fb52e9fd423d3405 100644 --- a/module/fid/src/VuFind/Auth/ILSAuthenticator.php +++ b/module/fid/src/VuFind/Auth/ILSAuthenticator.php @@ -18,12 +18,10 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\VuFind\Auth; use fid\Service\Client; use fid\Service\ClientException; -use fid\Service\DataTransferObject\Address; use fid\Service\UserNotAuthorizedException; class ILSAuthenticator @@ -80,15 +78,19 @@ class ILSAuthenticator ]; foreach ($user->getAddresses() as $index => $address) { - $data['address' . ($index + 1)] = implode(", ", array_filter([ - $address->getLine1(), - $address->getLine2(), - trim("{$address->getZip()} {$address->getCity()}"), - $address->getCountry() - ])); + $data['address' . ($index + 1)] = implode( + ", ", + array_filter( + [ + $address->getLine1(), + $address->getLine2(), + trim("{$address->getZip()} {$address->getCity()}"), + $address->getCountry() + ] + ) + ); } return $data; } - } diff --git a/module/fid/src/VuFind/Auth/ILSAuthenticatorFactory.php b/module/fid/src/VuFind/Auth/ILSAuthenticatorFactory.php index 322e7c9f640f056bb0b90aa90bb36387a164da65..a651d05a8e0fe39c05cd2ac5c302fd6fd2eb409c 100644 --- a/module/fid/src/VuFind/Auth/ILSAuthenticatorFactory.php +++ b/module/fid/src/VuFind/Auth/ILSAuthenticatorFactory.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\VuFind\Auth; use fid\Service\Client; @@ -32,12 +31,13 @@ class ILSAuthenticatorFactory { $factory = new LazyLoadingValueHolderFactory(); - return $factory->createProxy(ProxyClass::class, - function (&$object, $proxy, $method, $params, &$initializer) - use ($container) { + return $factory->createProxy( + ProxyClass::class, + function (&$object, $proxy, $method, $params, &$initializer) use ($container) { $initializer = null; $client = $container->get(Client::class); $object = new ILSAuthenticator($client); - }); + } + ); } -} \ No newline at end of file +} diff --git a/module/fid/src/VuFind/Db/Row/User.php b/module/fid/src/VuFind/Db/Row/User.php index 408cb215232c0ba2ba64070f926f718b990b0e53..a41643383b84db31882f3a8bc6b6dc00b9938398 100644 --- a/module/fid/src/VuFind/Db/Row/User.php +++ b/module/fid/src/VuFind/Db/Row/User.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\VuFind\Db\Row; use fid\Service\Client; @@ -45,27 +44,27 @@ class User extends BaseUser */ public function offsetGet($offset) { - return $this->readUserFields($offset) ? : parent::offsetGet($offset); + return $this->readUserFields($offset) ?: parent::offsetGet($offset); } - public function __get($name) { - - return $this->readUserFields($name) ? : parent::__get($name); + public function __get($name) + { + return $this->readUserFields($name) ?: parent::__get($name); } - protected function readUserFields($offset) { - + protected function readUserFields($offset) + { $user = $this->client->requestUserDetails(); switch ($offset) { - case 'firstname': - return $user->getFirstname(); - case 'lastname': - return $user->getLastname(); - case 'email': - return $user->getUsername(); + case 'firstname': + return $user->getFirstname(); + case 'lastname': + return $user->getLastname(); + case 'email': + return $user->getUsername(); } return false; } -} \ No newline at end of file +} diff --git a/module/fid/src/VuFind/Db/Row/UserDelegatorFactory.php b/module/fid/src/VuFind/Db/Row/UserDelegatorFactory.php index 4b55845265723a0d2ba745a5bf7c65a9460f6ccc..e7464ac313cb08ecb505a01e9c1a558762b539de 100644 --- a/module/fid/src/VuFind/Db/Row/UserDelegatorFactory.php +++ b/module/fid/src/VuFind/Db/Row/UserDelegatorFactory.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\VuFind\Db\Row; use fid\Service\Client; @@ -31,10 +30,12 @@ class UserDelegatorFactory $name, callable $callback ) { - /** @var User $user */ + /** + * @var User $user + */ $user = call_user_func($callback); $user->setClient($container->get(Client::class)); return $user; } -} \ No newline at end of file +} diff --git a/module/fid/src/VuFind/ILS/Fid.php b/module/fid/src/VuFind/ILS/Fid.php index 43ff21450b23702a321b83cded331f638580ec2c..c9d40e9f06b0a3a20e4b7568bcb63ae32e25f0d2 100644 --- a/module/fid/src/VuFind/ILS/Fid.php +++ b/module/fid/src/VuFind/ILS/Fid.php @@ -18,7 +18,6 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\VuFind\ILS; use fid\Service\Client; @@ -48,7 +47,6 @@ class Fid extends AbstractBase */ public function patronLogin(): ?array { - $user = $this->client->requestUserDetails(); if (!$user) { @@ -82,5 +80,4 @@ class Fid extends AbstractBase { return $patron; } - -} \ No newline at end of file +} diff --git a/module/fid/src/VuFind/ILS/FidFactory.php b/module/fid/src/VuFind/ILS/FidFactory.php index 0bdca0af98f9fb2e69689773936ea422372fb5b6..fa66f0983097712c99d40d04510d743b3d31131c 100644 --- a/module/fid/src/VuFind/ILS/FidFactory.php +++ b/module/fid/src/VuFind/ILS/FidFactory.php @@ -18,20 +18,20 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ - namespace fid\VuFind\ILS; use fid\Service\Client; use Psr\Container\ContainerInterface; -use VuFind\Config\PluginManager as ConfigManager; class FidFactory { public function __invoke(ContainerInterface $container): Fid { - /** @var Client $client */ + /** + * @var Client $client + */ $client = $container->get(Client::class); return new Fid($client); } -} \ No newline at end of file +} diff --git a/module/fid/src/VuFind/Resolver/Driver/Ezb.php b/module/fid/src/VuFind/Resolver/Driver/Ezb.php index 4ded9fc32cbf086281b4e453193831bc40fdccda..152f4f4c983f9aba3127921b18f3fbd2f540c01a 100644 --- a/module/fid/src/VuFind/Resolver/Driver/Ezb.php +++ b/module/fid/src/VuFind/Resolver/Driver/Ezb.php @@ -15,21 +15,21 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License */ - namespace fid\VuFind\Resolver\Driver; use DOMDocument; use DOMXpath; use fid\Service\Client; -use VuFind\ILS\Connection; use finc\Resolver\Driver\Ezb as BaseEzb; +use VuFind\ILS\Connection; use Zend\Config\Config; /** * Class Ezb + * * @package fid\VuFind\Resolver\Driver */ class Ezb extends BaseEzb @@ -61,6 +61,7 @@ class Ezb extends BaseEzb protected $baseUrl; protected $messages = []; + protected $stateOfResults = []; /** @@ -99,7 +100,7 @@ class Ezb extends BaseEzb * Fetch Links * Fetches a set of links corresponding to an OpenURL * - * @param string $openURL openURL (url-encoded)* + * @param string $openURL openURL (url-encoded)* * @return string raw XML returned by resolver */ public function fetchLinks($openURL) @@ -194,8 +195,7 @@ class Ezb extends BaseEzb $libraries = $this->fidClient->requestLibraryList(); $homeLibrary = $user->getHomeLibrary(); // Obtain user information from ILS: - $libInfo = isset($libraries[$homeLibrary]) ? - $libraries[$homeLibrary] : $libraries['AAAAA']; + $libInfo = $libraries[$homeLibrary] ?? $libraries['AAAAA']; $bibId = $libInfo->getEzb(); $isil = $libInfo->getIsil(); } else { @@ -209,8 +209,7 @@ class Ezb extends BaseEzb } elseif (isset($this->config->bibid)) { $openURL .= '&pid=' . 'bibid%3D' . $this->config->bibid; - } elseif ( - isset($this->config->useClientIp) + } elseif (isset($this->config->useClientIp) && $this->config->useClientIp ) { // make the request IP-based to allow automatic @@ -266,7 +265,7 @@ class Ezb extends BaseEzb foreach ($results as $result) { $record = []; $accessLevelXP = "/OpenURLResponseXML/Full/ElectronicData/ResultList/" . - "Result[@state={$state}][".($i+1)."]/AccessLevel"; + "Result[@state={$state}][" . ($i + 1) . "]/AccessLevel"; $accessLevel = $xpath->query($accessLevelXP, $result)->item(0); if (isset($accessLevel)) { $record['title'] = $accessLevel_mapping[strip_tags($accessLevel->nodeValue)]; @@ -276,10 +275,10 @@ class Ezb extends BaseEzb $this->messages[] = $message[$state]; $accessUrlXP = "/OpenURLResponseXML/Full/ElectronicData/ResultList/" . - "Result[@state={$state}][".($i+1)."]/AccessURL"; + "Result[@state={$state}][" . ($i + 1) . "]/AccessURL"; $accessUrl = $xpath->query($accessUrlXP, $result)->item(0); $journalUrlXP = "/OpenURLResponseXML/Full/ElectronicData/ResultList/" . - "Result[@state={$state}][".($i+1)."]/JournalURL"; + "Result[@state={$state}][" . ($i + 1) . "]/JournalURL"; $journalUrl = $xpath->query($journalUrlXP, $result)->item(0); if (isset($accessUrl->nodeValue)) { $record['href'] = $accessUrl->nodeValue; @@ -334,13 +333,13 @@ class Ezb extends BaseEzb $record = []; $resultXP = "/OpenURLResponseXML/Full/PrintData/ResultList/" . - "Result[@state={$state}][".($i+1)."]"; + "Result[@state={$state}][" . ($i + 1) . "]"; $resultElements = [ 'Title', 'Location', 'Signature', 'Period', 'Holding_comment' ]; // store data in separate array field fid-specific foreach ($resultElements as $element) { - $elem = $xpath->query($resultXP . "/".$element, $result)->item(0); + $elem = $xpath->query($resultXP . "/" . $element, $result)->item(0); if (isset($elem->nodeValue)) { $record[$element] = strip_tags($elem->nodeValue); } @@ -361,4 +360,4 @@ class Ezb extends BaseEzb $i++; } } -} \ No newline at end of file +} diff --git a/module/fid/src/VuFind/Resolver/Driver/EzbDelegatorFactory.php b/module/fid/src/VuFind/Resolver/Driver/EzbDelegatorFactory.php index 8d8c5c3331c168ae7c02fb22fcdb0da0268e902a..bf012de4f3564b70435a27305f12ee4f921b4c29 100644 --- a/module/fid/src/VuFind/Resolver/Driver/EzbDelegatorFactory.php +++ b/module/fid/src/VuFind/Resolver/Driver/EzbDelegatorFactory.php @@ -15,10 +15,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License */ - namespace fid\VuFind\Resolver\Driver; use fid\Service\Client; @@ -28,20 +27,24 @@ use Zend\ServiceManager\Factory\DelegatorFactoryInterface; class EzbDelegatorFactory implements DelegatorFactoryInterface { /** - * @param ContainerInterface $container - * @param string $name - * @param callable $callback - * @param array|null $options + * @param ContainerInterface $container + * @param string $name + * @param callable $callback + * @param array|null $options * @return Ezb|object */ public function __invoke( - ContainerInterface $container, $name, - callable $callback, array $options = null + ContainerInterface $container, + $name, + callable $callback, + array $options = null ) { $ezbConfig = $container->get('VuFind\Config')->get('Resolver'); $fidClient = $container->get(Client::class); $ils = $container->get('VuFind\ILS\Connection'); - /** @var Ezb $ezb */ + /** + * @var Ezb $ezb + */ $ezb = call_user_func($callback); $ezb->setConfig($ezbConfig->Ezb); $ezb->setFidClient($fidClient); @@ -49,4 +52,4 @@ class EzbDelegatorFactory implements DelegatorFactoryInterface $ezb->setBaseUrl($ezbConfig->Ezb->url); return $ezb; } -} \ No newline at end of file +}