From 7d57f46f20deeff9a4cf56d553ae26c5fc4c6625 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer <88720542+epx-anpf@users.noreply.github.com> Date: Fri, 19 Nov 2021 10:10:20 +0100 Subject: [PATCH 01/81] Create composer file --- composer.json | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..15fbfb1 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "slub/slub-profile-account", + "type": "typo3-cms-extension", + "description": "SLUB profile service account extension for TYPO3", + "authors": [ + { + "name": "Andreas Pfeiffer", + "role": "Developer" + } + ], + "version": "0.1.0", + "license": "GPL-2.0-or-later", + "require": { + "typo3/cms-core": "^11" + }, + "replace": { + "typo3-ter/slub-profile-account": "self.version" + }, + "autoload": { + "psr-4": { + "Slub\\SlubProfileAccount\\": "Classes/" + } + }, + "extra": { + "typo3/cms": { + "extension-key": "slub_profile_account" + } + } +} From 2615b1040009c69f98efbfef4c360225001341f5 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 19 Nov 2021 13:21:57 +0100 Subject: [PATCH 02/81] [TASK] Basic extension configuration --- .editorconfig | 56 +++++++++++++++++ Classes/Controller/AccountController.php | 38 +++++++++++ Classes/Mvc/View/JsonView.php | 44 +++++++++++++ Classes/Utility/ConstantsUtility.php | 18 ++++++ Configuration/Icons.php | 14 +++++ Configuration/Services.yaml | 8 +++ Configuration/TCA/Overrides/sys_template.php | 10 +++ Configuration/TCA/Overrides/tt_content.php | 63 +++++++++++++++++++ Configuration/TsConfig/Page.tsconfig | 18 ++++++ Configuration/TypoScript/constants.typoscript | 4 ++ Configuration/TypoScript/setup.typoscript | 10 +++ README.md | 32 +++++++++- .../Private/Language/de.locallang_backend.xlf | 21 +++++++ .../Private/Language/locallang_backend.xlf | 18 ++++++ Resources/Public/Icons/Extension.svg | 1 + Resources/Public/Icons/Overlay/extension.svg | 6 ++ .../Public/Icons/Wizard/account-detail.svg | 10 +++ ext_emconf.php | 28 +++++++++ ext_localconf.php | 25 ++++++++ 19 files changed, 422 insertions(+), 2 deletions(-) create mode 100644 .editorconfig create mode 100644 Classes/Controller/AccountController.php create mode 100644 Classes/Mvc/View/JsonView.php create mode 100644 Classes/Utility/ConstantsUtility.php create mode 100644 Configuration/Icons.php create mode 100644 Configuration/Services.yaml create mode 100644 Configuration/TCA/Overrides/sys_template.php create mode 100644 Configuration/TCA/Overrides/tt_content.php create mode 100644 Configuration/TsConfig/Page.tsconfig create mode 100644 Configuration/TypoScript/constants.typoscript create mode 100644 Configuration/TypoScript/setup.typoscript create mode 100644 Resources/Private/Language/de.locallang_backend.xlf create mode 100644 Resources/Private/Language/locallang_backend.xlf create mode 100644 Resources/Public/Icons/Extension.svg create mode 100644 Resources/Public/Icons/Overlay/extension.svg create mode 100644 Resources/Public/Icons/Wizard/account-detail.svg create mode 100644 ext_emconf.php create mode 100644 ext_localconf.php diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b0b42d7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,56 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +# TS/JS-Files +[*.{ts,js}] +indent_size = 2 + +# JSON-Files +[*.json] +indent_style = tab + +# ReST-Files +[*.rst] +indent_size = 4 +max_line_length = 80 + +# YAML-Files +[*.{yaml,yml}] +indent_size = 2 + +# NEON-Files +[*.neon] +indent_size = 2 +indent_style = tab + +# package.json +[package.json] +indent_size = 2 + +# TypoScript +[*.{typoscript,tsconfig}] +indent_size = 2 + +# XLF-Files +[*.xlf] +indent_style = tab + +# SQL-Files +[*.sql] +indent_style = tab +indent_size = 2 + +# .htaccess +[{_.htaccess,.htaccess}] +indent_style = tab \ No newline at end of file diff --git a/Classes/Controller/AccountController.php b/Classes/Controller/AccountController.php new file mode 100644 index 0000000..7c42443 --- /dev/null +++ b/Classes/Controller/AccountController.php @@ -0,0 +1,38 @@ + 'test', + 'lastname' => 'daten' + ]; + + $this->view->setVariablesToRender(['account']); + $this->view->assign('account', $account); + + return $this->jsonResponse(); + } +} diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php new file mode 100644 index 0000000..2223c4a --- /dev/null +++ b/Classes/Mvc/View/JsonView.php @@ -0,0 +1,44 @@ + [ + * '_descendAll' => [ + * '_exclude' => [ + * 'categories', + * 'contact', + * 'discipline' + * ] + * ] + * ] + */ + protected array $accountConfiguration = [ + 'account' => [ + ], + ]; + + public function __construct() + { + $this->setConfiguration($this->accountConfiguration); + } +} diff --git a/Classes/Utility/ConstantsUtility.php b/Classes/Utility/ConstantsUtility.php new file mode 100644 index 0000000..b62bb72 --- /dev/null +++ b/Classes/Utility/ConstantsUtility.php @@ -0,0 +1,18 @@ + [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/account-detail.svg' + ], + 'slubprofileaccount-overlay-extension' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Overlay/extension.svg' + ] +]; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000..1c36dc5 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,8 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + Slub\SlubProfileAccount\: + resource: '../Classes/*' diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php new file mode 100644 index 0000000..6841a6d --- /dev/null +++ b/Configuration/TCA/Overrides/sys_template.php @@ -0,0 +1,10 @@ + 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_backend.xlf', + 'core' => 'LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf', + 'frontend' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf', + ]; + + // Add new group to ctype selector + TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItemGroup( + 'tt_content', + 'CType', + $extensionName, + $ll['backend'] . ':plugin.title', + 'after:default' // Should be the same like "common" in page tsconfig + ); + + foreach ($pluginNames as $pluginName) { + // Merge content element definition + TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['tt_content'], [ + 'ctrl' => [ + 'typeicon_classes' => [ + $extensionName . '_' . $pluginName => $extensionName . '-wizard-' . $pluginName, + ], + ], + 'types' => [ + $extensionName . '_' . $pluginName => [ + 'showitem' => ' + --div--;' . $ll['core'] . ':general, + --palette--;;general, + --palette--;;headers, + --div--;' . $ll['core'] . ':language, + --palette--;;language, + --div--;' . $ll['core'] . ':access, + --palette--;;hidden, + --palette--;;access, + --div--;' . $ll['core'] . ':notes, + rowDescription, + --div--;' . $ll['core'] . ':extended', + ], + ], + ]); + + // Add item to select field list (ctype) + TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem( + 'tt_content', + 'CType', + [ + $ll['backend'] . ':plugin.' . $pluginName . '.title', // Title + $extensionName . '_' . $pluginName, // CType + $extensionName . '-wizard-' . $pluginName, // Icon identifier + $extensionName // Item group id + ] + ); + } +})( + 'slub_profile_account', + ['accountdetail'] +); diff --git a/Configuration/TsConfig/Page.tsconfig b/Configuration/TsConfig/Page.tsconfig new file mode 100644 index 0000000..93ddc5a --- /dev/null +++ b/Configuration/TsConfig/Page.tsconfig @@ -0,0 +1,18 @@ +mod { + wizards.newContentElement.wizardItems.slubprofileaccount { + after = common + header = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.title + + elements { + slubprofileaccount_accountdetail { + iconIdentifier = slubprofileaccount-wizard-accountdetail + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.accountdetail.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.accountdetail.description + tt_content_defValues.CType = slubprofileaccount_accountdetail + } + } + + show := addToList(slubprofileaccount_accountdetail) + } +} diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript new file mode 100644 index 0000000..a0e9322 --- /dev/null +++ b/Configuration/TypoScript/constants.typoscript @@ -0,0 +1,4 @@ +plugin.tx_slubprofileaccount { + # cat=plugin.tx_slubprofileaccount//a; type=string; label=Default storage PID + settings.storagePid = 0 +} diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript new file mode 100644 index 0000000..647b5ff --- /dev/null +++ b/Configuration/TypoScript/setup.typoscript @@ -0,0 +1,10 @@ +plugin.tx_slubprofileaccount { + mvc { + callDefaultActionIfActionCantBeResolved = 1 + throwPageNotFoundExceptionIfActionCantBeResolved = 1 + } + + features { + skipDefaultArguments = 1 + } +} diff --git a/README.md b/README.md index 759fb87..885a649 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ -# slub-profile-account -SLUB Profile Account +# TYPO3 Extension `slub_profile_account` + +[![TYPO3](https://img.shields.io/badge/TYPO3-11-orange.svg)](https://typo3.org/) + +SLUB profile service account extension for TYPO3. + +## 1 Usage + +### 1.1 Installation using Composer + +The recommended way to install the extension is using [Composer][1]. + +Run the following command within your Composer based TYPO3 project: + +``` +composer require slub/slub-profile-account +``` + +## 2 Administration corner + +### 2.1 Release Management + +News uses [semantic versioning][2], which means, that +* **bugfix updates** (e.g. 1.0.0 => 1.0.1) just includes small bugfixes or security relevant stuff without breaking changes, +* **minor updates** (e.g. 1.0.0 => 1.1.0) includes new features and smaller tasks without breaking changes, +* **major updates** (e.g. 1.0.0 => 2.0.0) breaking changes wich can be refactorings, features or bugfixes. + +[1]: https://getcomposer.org/ +[2]: https://semver.org/ + diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf new file mode 100644 index 0000000..b640e3d --- /dev/null +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -0,0 +1,21 @@ + + + +
+ + + User account + Benutzerkonto + + + + User account details + Benutzerkontodetails + + + Details of a specific user account / user. + Details zu einem spezifischen Benutzerkonto / Benutzer. + + + + diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf new file mode 100644 index 0000000..d7893cc --- /dev/null +++ b/Resources/Private/Language/locallang_backend.xlf @@ -0,0 +1,18 @@ + + + +
+ + + User account + + + + User account details + + + Details of a specific user account / user. + + + + diff --git a/Resources/Public/Icons/Extension.svg b/Resources/Public/Icons/Extension.svg new file mode 100644 index 0000000..0d84024 --- /dev/null +++ b/Resources/Public/Icons/Extension.svg @@ -0,0 +1 @@ + diff --git a/Resources/Public/Icons/Overlay/extension.svg b/Resources/Public/Icons/Overlay/extension.svg new file mode 100644 index 0000000..f02a902 --- /dev/null +++ b/Resources/Public/Icons/Overlay/extension.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/Resources/Public/Icons/Wizard/account-detail.svg b/Resources/Public/Icons/Wizard/account-detail.svg new file mode 100644 index 0000000..bb48eb6 --- /dev/null +++ b/Resources/Public/Icons/Wizard/account-detail.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ext_emconf.php b/ext_emconf.php new file mode 100644 index 0000000..17a5f79 --- /dev/null +++ b/ext_emconf.php @@ -0,0 +1,28 @@ + 'SLUB profile account', + 'description' => 'SLUB profile service account extension for TYPO3', + 'category' => 'fe', + 'author' => 'Andreas Pfeiffer', + 'author_email' => 'andreas.pfeiffer@e-pixler.com', + 'author_company' => 'e-pixler', + 'shy' => '', + 'priority' => '', + 'module' => '', + 'state' => 'stable', + 'internal' => '', + 'uploadfolder' => 1, + 'createDirs' => '', + 'modify_tables' => '', + 'clearCacheOnLoad' => 1, + 'lockType' => '', + 'version' => '0.1.0', + 'constraints' => [ + 'depends' => [ + 'typo3' => '11.0.0-11.5.99' + ], + 'conflicts' => [], + 'suggests' => [], + ], +]; diff --git a/ext_localconf.php b/ext_localconf.php new file mode 100644 index 0000000..785b474 --- /dev/null +++ b/ext_localconf.php @@ -0,0 +1,25 @@ + 'detail' + ], + [ + AccountController::class => 'detail' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); From 3733284d5d4348310dbe0f0909b895d16838670d Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 25 Nov 2021 16:42:03 +0100 Subject: [PATCH 03/81] [FEATURE] Add user detail api --- ...countController.php => UserController.php} | 21 ++-- Classes/Domain/Model/Dto/ApiConfiguration.php | 61 +++++++++++ Classes/Http/Request.php | 102 ++++++++++++++++++ Classes/Mvc/View/JsonView.php | 2 +- Classes/Service/UserService.php | 53 +++++++++ Classes/Utility/ApiUtility.php | 29 +++++ .../Validation/AccountArgumentValidator.php | 41 +++++++ Configuration/Icons.php | 4 +- Configuration/Routes/Default.yaml | 4 + Configuration/Routes/UserDetail.yaml | 9 ++ Configuration/Services.yaml | 6 ++ Configuration/TCA/Overrides/tt_content.php | 2 +- Configuration/TsConfig/Page.tsconfig | 12 +-- Configuration/TypoScript/constants.typoscript | 15 ++- Configuration/TypoScript/setup.typoscript | 9 ++ README.md | 12 +++ .../Private/Language/de.locallang_backend.xlf | 12 +-- .../Private/Language/locallang_backend.xlf | 8 +- .../{account-detail.svg => user-detail.svg} | 0 ext_localconf.php | 10 +- 20 files changed, 378 insertions(+), 34 deletions(-) rename Classes/Controller/{AccountController.php => UserController.php} (57%) create mode 100644 Classes/Domain/Model/Dto/ApiConfiguration.php create mode 100644 Classes/Http/Request.php create mode 100644 Classes/Service/UserService.php create mode 100644 Classes/Utility/ApiUtility.php create mode 100644 Classes/Validation/AccountArgumentValidator.php create mode 100644 Configuration/Routes/Default.yaml create mode 100644 Configuration/Routes/UserDetail.yaml rename Resources/Public/Icons/Wizard/{account-detail.svg => user-detail.svg} (100%) diff --git a/Classes/Controller/AccountController.php b/Classes/Controller/UserController.php similarity index 57% rename from Classes/Controller/AccountController.php rename to Classes/Controller/UserController.php index 7c42443..31241c5 100644 --- a/Classes/Controller/AccountController.php +++ b/Classes/Controller/UserController.php @@ -13,25 +13,32 @@ use Psr\Http\Message\ResponseInterface; use Slub\SlubProfileAccount\Mvc\View\JsonView; +use Slub\SlubProfileAccount\Service\UserService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -class AccountController extends ActionController +class UserController extends ActionController { protected $view; protected $defaultViewObjectName = JsonView::class; + protected UserService $userService; + + /** + * @param UserService $userService + */ + public function __construct(UserService $userService) + { + $this->userService = $userService; + } /** * @return ResponseInterface */ public function detailAction(): ResponseInterface { - $account = [ - 'firstname' => 'test', - 'lastname' => 'daten' - ]; + $user = $this->userService->getUser($this->request->getArguments()); - $this->view->setVariablesToRender(['account']); - $this->view->assign('account', $account); + $this->view->setVariablesToRender(['userDetail']); + $this->view->assign('userDetail', $user); return $this->jsonResponse(); } diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php new file mode 100644 index 0000000..5b2b54e --- /dev/null +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -0,0 +1,61 @@ +getPluginSettings(); + + $this->setUserUri($settings['api']['path']['user']); + } + + /** + * @return string + */ + public function getUserUri(): string + { + return $this->userUri; + } + + /** + * @param string $userUri + */ + public function setUserUri($userUri = ''): void + { + $this->userUri = $userUri; + } + + /** + * @return array + */ + protected function getPluginSettings(): array + { + /** @var ConfigurationManagerInterface $configurationManager */ + $configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class); + + return $configurationManager->getConfiguration( + ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, + ConstantsUtility::EXTENSION_NAME + ); + } +} diff --git a/Classes/Http/Request.php b/Classes/Http/Request.php new file mode 100644 index 0000000..f86f51b --- /dev/null +++ b/Classes/Http/Request.php @@ -0,0 +1,102 @@ + ['Cache-Control' => 'no-cache'], + 'allow_redirects' => false + ]; + protected RequestFactory $requestFactory; + + /** + * Request constructor. + * @param RequestFactory $requestFactory + */ + public function __construct(RequestFactory $requestFactory) + { + $this->requestFactory = $requestFactory; + } + + /** + * @param string $uri + * @param string $method + * @param array $options + * @return array|null + */ + public function process($uri = '', $method = 'GET', array $options = []): ?array + { + try { + $options = $this->mergeOptions($this->options, $options); + $response = $this->requestFactory->request($uri, $method, $options); + + return $this->getContent($response, $uri); + } catch (RequestException $e) { + $this->logger->error($e->getMessage()); + + return null; + } + } + + /** + * @param array $default + * @param array $new + * @return array + */ + protected function mergeOptions(array $default, array $new): array + { + if (count($new) > 0) { + ArrayUtility::mergeRecursiveWithOverrule($default, $new); + } + + return $default; + } + + /** + * @param ResponseInterface $response + * @param string $uri + * @return array|null + */ + protected function getContent(ResponseInterface $response, $uri = ''): ?array + { + $content = ''; + + if ($response->getStatusCode() === 200 && strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { + $content = (array)json_decode($response->getBody()->getContents(), true); + } + + if (empty($content)) { + $this->logger->warning( + 'Requesting {request} was not successful, got status code {status} ({reason})', + [ + 'request' => $uri, + 'status' => $response->getStatusCode(), + 'reason' => $response->getReasonPhrase(), + ] + ); + + return null; + } + + return $content; + } +} diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index 2223c4a..a751bc6 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -33,7 +33,7 @@ class JsonView extends ExtbaseJsonView * ] */ protected array $accountConfiguration = [ - 'account' => [ + 'userDetail' => [ ], ]; diff --git a/Classes/Service/UserService.php b/Classes/Service/UserService.php new file mode 100644 index 0000000..1abca2a --- /dev/null +++ b/Classes/Service/UserService.php @@ -0,0 +1,53 @@ +accountArgumentValidator = $accountArgumentValidator; + $this->apiConfiguration = $apiConfiguration; + $this->request = $request; + } + + /** + * @param array $arguments + * @return array + */ + public function getUser(array $arguments): array + { + $validatedArguments = $this->accountArgumentValidator->validateAccountArguments($arguments); + + $uri = $this->apiConfiguration->getUserUri(); + $uri = ApiUtility::replaceUriPlaceholder([$validatedArguments['user']], $uri); + + return $this->request->process($uri) ?? []; + } +} diff --git a/Classes/Utility/ApiUtility.php b/Classes/Utility/ApiUtility.php new file mode 100644 index 0000000..9cd04ae --- /dev/null +++ b/Classes/Utility/ApiUtility.php @@ -0,0 +1,29 @@ + 0]; + } + + $this->validateInteger('user', $arguments['user']); + + return $this->validArguments; + } + + /** + * @param string $key + * @param string $value + */ + protected function validateInteger($key = '', $value = ''): void + { + empty($value) ?: $this->validArguments[$key] = (int)$value; + } +} diff --git a/Configuration/Icons.php b/Configuration/Icons.php index f1df996..61f6d66 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -3,9 +3,9 @@ defined('TYPO3') || die(); return [ - 'slubprofileaccount-wizard-accountdetail' => [ + 'slubprofileaccount-wizard-userdetail' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/account-detail.svg' + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-detail.svg' ], 'slubprofileaccount-overlay-extension' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml new file mode 100644 index 0000000..9e64b77 --- /dev/null +++ b/Configuration/Routes/Default.yaml @@ -0,0 +1,4 @@ +# This route enhancer config is not final +# But you can simply include it in your site configuration: +imports: + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDetail.yaml' diff --git a/Configuration/Routes/UserDetail.yaml b/Configuration/Routes/UserDetail.yaml new file mode 100644 index 0000000..18f4afa --- /dev/null +++ b/Configuration/Routes/UserDetail.yaml @@ -0,0 +1,9 @@ +routeEnhancers: + SlubAccountUserDetail: + type: Simple + limitToPages: [11] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userdetail/user' diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 1c36dc5..8b9a28c 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -6,3 +6,9 @@ services: Slub\SlubProfileAccount\: resource: '../Classes/*' + + Slub\SlubProfileAccount\Http\Request: + public: true + + Slub\SlubProfileAccount\Service\ApiService: + public: true diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 2e28974..68d6ff6 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -59,5 +59,5 @@ } })( 'slub_profile_account', - ['accountdetail'] + ['userdetail'] ); diff --git a/Configuration/TsConfig/Page.tsconfig b/Configuration/TsConfig/Page.tsconfig index 93ddc5a..0468de6 100644 --- a/Configuration/TsConfig/Page.tsconfig +++ b/Configuration/TsConfig/Page.tsconfig @@ -4,15 +4,15 @@ mod { header = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.title elements { - slubprofileaccount_accountdetail { - iconIdentifier = slubprofileaccount-wizard-accountdetail + slubprofileaccount_userdetail { + iconIdentifier = slubprofileaccount-wizard-userdetail iconOverlay = slubprofileaccount-overlay-extension - title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.accountdetail.title - description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.accountdetail.description - tt_content_defValues.CType = slubprofileaccount_accountdetail + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userdetail.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userdetail.description + tt_content_defValues.CType = slubprofileaccount_userdetail } } - show := addToList(slubprofileaccount_accountdetail) + show := addToList(slubprofileaccount_userdetail) } } diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index a0e9322..e674a1b 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -1,4 +1,15 @@ +# customsubcategory=76595002_Api=API + plugin.tx_slubprofileaccount { - # cat=plugin.tx_slubprofileaccount//a; type=string; label=Default storage PID - settings.storagePid = 0 + settings { + # cat=plugin.tx_slubprofileaccount//a; type=string; label=Default storage PID + storagePid = 0 + + api { + path { + # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for user + user = https://ddev-slub-katalog.ddev.site/libero/core/###USER_ID###/ + } + } + } } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 647b5ff..a22a9e7 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -7,4 +7,13 @@ plugin.tx_slubprofileaccount { features { skipDefaultArguments = 1 } + + settings { + api { + path { + # cat=plugin.tx_slubprofileaccount//a; type=string; label=Api path for user + user = https://ddev-slub-katalog.ddev.site/libero/core/###USER_ID###/index.json + } + } + } } diff --git a/README.md b/README.md index 885a649..dd69aad 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,18 @@ News uses [semantic versioning][2], which means, that * **minor updates** (e.g. 1.0.0 => 1.1.0) includes new features and smaller tasks without breaking changes, * **major updates** (e.g. 1.0.0 => 2.0.0) breaking changes wich can be refactorings, features or bugfixes. +## 3 Api + +### 3.1 Routes + +Please check the routes' configuration. You have to set the matching page (limitToPages). If not the routes will not work properly. + +### 3.2 Typoscript + +Setup / Constant | Comment +---------------- | ------- +plugin.tx_slubprofile_account.settings.api.path.user | Path to get user info / detail. + [1]: https://getcomposer.org/ [2]: https://semver.org/ diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index b640e3d..175bc5b 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -8,13 +8,13 @@ Benutzerkonto - - User account details - Benutzerkontodetails + + User detail + Benutzerdetails - - Details of a specific user account / user. - Details zu einem spezifischen Benutzerkonto / Benutzer. + + Details of a specific user. + Details zu einem spezifischen Benutzer. diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index d7893cc..60cedf5 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -7,11 +7,11 @@ User account - - User account details + + User detail - - Details of a specific user account / user. + + Details of a specific user. diff --git a/Resources/Public/Icons/Wizard/account-detail.svg b/Resources/Public/Icons/Wizard/user-detail.svg similarity index 100% rename from Resources/Public/Icons/Wizard/account-detail.svg rename to Resources/Public/Icons/Wizard/user-detail.svg diff --git a/ext_localconf.php b/ext_localconf.php index 785b474..1d713bf 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,6 +1,6 @@ 'detail' + UserController::class => 'detail' ], [ - AccountController::class => 'detail' + UserController::class => 'detail' ], ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); From 3a0ff145559e0badd926e5862717f473caba84db Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 6 Dec 2021 15:44:54 +0100 Subject: [PATCH 04/81] [BUGFIX] User array does not work with json view --- Classes/Service/UserService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/Service/UserService.php b/Classes/Service/UserService.php index 1abca2a..84098e1 100644 --- a/Classes/Service/UserService.php +++ b/Classes/Service/UserService.php @@ -48,6 +48,7 @@ public function getUser(array $arguments): array $uri = $this->apiConfiguration->getUserUri(); $uri = ApiUtility::replaceUriPlaceholder([$validatedArguments['user']], $uri); - return $this->request->process($uri) ?? []; + // Wrap with brackets for array, if not mvc -> json -> view does not work + return [$this->request->process($uri)] ?? []; } } From fbe199418bd5c41abc5cd1e51b72be537e9aca8e Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 17 Dec 2021 16:40:00 +0100 Subject: [PATCH 05/81] [TASK] Add content element for user update --- Classes/Controller/UserController.php | 24 +++++++++++++++++++ Classes/Http/Request.php | 10 +++++--- Classes/Mvc/View/JsonView.php | 2 ++ Configuration/Icons.php | 4 ++++ Configuration/Routes/Default.yaml | 1 + Configuration/Routes/UserUpdate.yaml | 9 +++++++ Configuration/TCA/Overrides/tt_content.php | 2 +- Configuration/TsConfig/Page.tsconfig | 10 +++++++- .../Private/Language/de.locallang_backend.xlf | 9 +++++++ .../Private/Language/locallang_backend.xlf | 7 ++++++ Resources/Public/Icons/Wizard/user-update.svg | 6 +++++ ext_localconf.php | 13 ++++++++++ 12 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 Configuration/Routes/UserUpdate.yaml create mode 100644 Resources/Public/Icons/Wizard/user-update.svg diff --git a/Classes/Controller/UserController.php b/Classes/Controller/UserController.php index 31241c5..f8a3c02 100644 --- a/Classes/Controller/UserController.php +++ b/Classes/Controller/UserController.php @@ -42,4 +42,28 @@ public function detailAction(): ResponseInterface return $this->jsonResponse(); } + + /** + * @return ResponseInterface + * @throws \JsonException + */ + public function updateAction(): ResponseInterface + { + $user = $this->userService->getUser($this->request->getArguments()); + $receivedData = json_decode(file_get_contents('php://input'), true, 512, JSON_THROW_ON_ERROR) ?? []; + + $data = [ + 'user' => $user, + 'receivedData' => $receivedData + ]; + + // @todo just send the received data back to check if the circle works. Next step: save the data here + // create domain model, dashboard_widgets colon separated string, external user data as array to separate data? + // the update needs to accept the "widgets" array + + $this->view->setVariablesToRender(['userUpdate']); + $this->view->assign('userUpdate', $data); + + return $this->jsonResponse(); + } } diff --git a/Classes/Http/Request.php b/Classes/Http/Request.php index f86f51b..af21020 100644 --- a/Classes/Http/Request.php +++ b/Classes/Http/Request.php @@ -23,7 +23,9 @@ class Request implements LoggerAwareInterface use LoggerAwareTrait; public array $options = [ - 'headers' => ['Cache-Control' => 'no-cache'], + 'headers' => [ + 'Cache-Control' => 'no-cache' + ], 'allow_redirects' => false ]; protected RequestFactory $requestFactory; @@ -42,6 +44,7 @@ public function __construct(RequestFactory $requestFactory) * @param string $method * @param array $options * @return array|null + * @throws \JsonException */ public function process($uri = '', $method = 'GET', array $options = []): ?array { @@ -75,18 +78,19 @@ protected function mergeOptions(array $default, array $new): array * @param ResponseInterface $response * @param string $uri * @return array|null + * @throws \JsonException */ protected function getContent(ResponseInterface $response, $uri = ''): ?array { $content = ''; if ($response->getStatusCode() === 200 && strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { - $content = (array)json_decode($response->getBody()->getContents(), true); + $content = (array)json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); } if (empty($content)) { $this->logger->warning( - 'Requesting {request} was not successful, got status code {status} ({reason})', + 'Requesting request was not successful.', [ 'request' => $uri, 'status' => $response->getStatusCode(), diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index a751bc6..9ba606d 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -35,6 +35,8 @@ class JsonView extends ExtbaseJsonView protected array $accountConfiguration = [ 'userDetail' => [ ], + 'userUpdate' => [ + ], ]; public function __construct() diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 61f6d66..bafcd05 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -7,6 +7,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-detail.svg' ], + 'slubprofileaccount-wizard-userupdate' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-update.svg' + ], 'slubprofileaccount-overlay-extension' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Overlay/extension.svg' diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index 9e64b77..78f523e 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -2,3 +2,4 @@ # But you can simply include it in your site configuration: imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDetail.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserUpdate.yaml' diff --git a/Configuration/Routes/UserUpdate.yaml b/Configuration/Routes/UserUpdate.yaml new file mode 100644 index 0000000..2508f11 --- /dev/null +++ b/Configuration/Routes/UserUpdate.yaml @@ -0,0 +1,9 @@ +routeEnhancers: + SlubAccountUserUpdate: + type: Simple + limitToPages: [13] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userupdate/user' diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 68d6ff6..cb2b450 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -59,5 +59,5 @@ } })( 'slub_profile_account', - ['userdetail'] + ['userdetail', 'userupdate'] ); diff --git a/Configuration/TsConfig/Page.tsconfig b/Configuration/TsConfig/Page.tsconfig index 0468de6..973b9ee 100644 --- a/Configuration/TsConfig/Page.tsconfig +++ b/Configuration/TsConfig/Page.tsconfig @@ -11,8 +11,16 @@ mod { description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userdetail.description tt_content_defValues.CType = slubprofileaccount_userdetail } + + slubprofileaccount_userupdate { + iconIdentifier = slubprofileaccount-wizard-userupdate + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userupdate.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userupdate.description + tt_content_defValues.CType = slubprofileaccount_userupdate + } } - show := addToList(slubprofileaccount_userdetail) + show := addToList(slubprofileaccount_userdetail, slubprofileaccount_userupdate) } } diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 175bc5b..0357337 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -16,6 +16,15 @@ Details of a specific user. Details zu einem spezifischen Benutzer. + + + User update + Benutzer aktualisieren + + + Update data of a specific user. + Daten zu einem spezifischen Benutzer aktualisieren. + diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 60cedf5..1c3ff64 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -13,6 +13,13 @@ Details of a specific user. + + + User update + + + Update data of a specific user. + diff --git a/Resources/Public/Icons/Wizard/user-update.svg b/Resources/Public/Icons/Wizard/user-update.svg new file mode 100644 index 0000000..f5508f9 --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-update.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index 1d713bf..4729089 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -23,3 +23,16 @@ ], ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); + +// Configure plugin - user update +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserUpdate', + [ + UserController::class => 'update' + ], + [ + UserController::class => 'update' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); From 227a7b114d04f828ef525d2359c76e6adde3faba Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 20 Dec 2021 10:50:14 +0100 Subject: [PATCH 06/81] [TASK] Mark folder as part of extension "account" --- Configuration/Icons.php | 12 ++++++++---- Configuration/TCA/Overrides/pages.php | 17 +++++++++++++++++ Resources/Public/Icons/PageTree/user-folder.svg | 4 ++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 Configuration/TCA/Overrides/pages.php create mode 100644 Resources/Public/Icons/PageTree/user-folder.svg diff --git a/Configuration/Icons.php b/Configuration/Icons.php index bafcd05..fe7dc5a 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -3,6 +3,14 @@ defined('TYPO3') || die(); return [ + 'slubprofileaccount-overlay-extension' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Overlay/extension.svg' + ], + 'slubprofileaccount-pagetree-userfolder' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/PageTree/user-folder.svg' + ], 'slubprofileaccount-wizard-userdetail' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-detail.svg' @@ -11,8 +19,4 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-update.svg' ], - 'slubprofileaccount-overlay-extension' => [ - 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Overlay/extension.svg' - ] ]; diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php new file mode 100644 index 0000000..c18950b --- /dev/null +++ b/Configuration/TCA/Overrides/pages.php @@ -0,0 +1,17 @@ + + + + From f9e964efec2e455e655ce76cea2b1291dc5847f2 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 20 Dec 2021 11:23:40 +0100 Subject: [PATCH 07/81] [TASK] Initialize user data structure --- Configuration/Icons.php | 4 + ...x_slubprofileaccount_domain_model_user.php | 194 ++++++++++++++++++ Resources/Public/Icons/Model/user.svg | 5 + ext_tables.sql | 6 + 4 files changed, 209 insertions(+) create mode 100644 Configuration/TCA/tx_slubprofileaccount_domain_model_user.php create mode 100644 Resources/Public/Icons/Model/user.svg create mode 100644 ext_tables.sql diff --git a/Configuration/Icons.php b/Configuration/Icons.php index fe7dc5a..fa98998 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -7,6 +7,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Overlay/extension.svg' ], + 'slubprofileaccount-model-user' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Model/user.svg' + ], 'slubprofileaccount-pagetree-userfolder' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/PageTree/user-folder.svg' diff --git a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php new file mode 100644 index 0000000..dba2de6 --- /dev/null +++ b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php @@ -0,0 +1,194 @@ + [ + 'tabs' => 'LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf', + 'general' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf' + ], + 'frontend' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf', + 'slubProfileAccount' => [ + 'db' => 'LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_db.xlf', + 'tca' => 'LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_tca.xlf' + ] + + /* + * + --palette--;' . $ll['slubProfileAccount']['tca'] . ':palette.hidden;hidden, + --palette--;' . $ll['slubProfileAccount']['tca'] . ':palette.access;access, + */ +]; + +return [ + 'ctrl' => [ + 'title' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user', + 'label' => 'title', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'delete' => 'deleted', + 'sortby' => 'title', + 'default_sortby' => 'title', + 'enablecolumns' => [ + 'disabled' => 'hidden', + 'starttime' => 'starttime', + 'endtime' => 'endtime', + 'fe_group' => 'fe_group' + ], + 'languageField' => 'sys_language_uid', + 'transOrigPointerField' => 'l18n_parent', + 'transOrigDiffSourceField' => 'l10n_diffsource', + 'descriptionColumn' => 'description', + 'editlock' => 'editlock', + 'translationSource' => 'l10n_source', + 'origUid' => 't3_origuid', + 'versioningWS' => true, + 'searchFields' => 'uid,title', + 'typeicon_classes' => [ + 'default' => 'slubprofileaccount-model-user' + ], + ], + 'types' => [ + '0' => [ + 'showitem' => ' + --div--;' . $ll['core']['tabs'] . ':general, + title, + --div--;' . $ll['core']['tabs'] . ':language, + --palette--;;language, + --div--;' . $ll['core']['tabs'] . ':access, + --palette--;;hidden, + --palette--;;access, + --div--;' . $ll['core']['tabs'] . ':extended' + ] + ], + 'palettes' => [ + 'access' => [ + 'label' => $ll['frontend'] . ':palette.access', + 'showitem' => ' + starttime;' . $ll['frontend'] . ':starttime_formlabel, + endtime;' . $ll['frontend'] . ':endtime_formlabel + ', + ], + 'hidden' => [ + 'showitem' => ' + hidden;' . $ll['frontend'] . ':field.default.hidden + ', + ], + 'language' => [ + 'showitem' => ' + sys_language_uid;' . $ll['frontend'] . ':sys_language_uid_formlabel, + l18n_parent + ', + ], + ], + 'columns' => [ + 'sys_language_uid' => [ + 'exclude' => true, + 'label' => $ll['core']['general'] . ':LGL.language', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'foreign_table' => 'sys_language', + 'foreign_table_where' => 'ORDER BY sys_language.title', + 'items' => [ + [$ll['core']['general'] . ':LGL.allLanguages', -1], + [$ll['core']['general'] . ':LGL.default_value', 0] + ], + 'default' => 0, + 'fieldWizard' => [ + 'selectIcons' => [ + 'disabled' => false, + ], + ], + ] + ], + 'l18n_parent' => [ + 'displayCond' => 'FIELD:sys_language_uid:>:0', + 'label' => $ll['core']['general'] . ':LGL.l18n_parent', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0] + ], + 'foreign_table' => 'tx_slubprofileaccount_domain_model_user', + 'foreign_table_where' => 'AND tx_slubprofileaccount_domain_model_user.pid=###CURRENT_PID### AND tx_slubprofileaccount_domain_model_user.sys_language_uid IN (-1,0)', + 'default' => 0 + ] + ], + 'l10n_diffsource' => [ + 'config' => [ + 'type' => 'passthrough', + 'default' => '' + ] + ], + 'hidden' => [ + 'exclude' => true, + 'label' => $ll['core']['general'] . ':LGL.hidden', + 'config' => [ + 'type' => 'check', + 'renderType' => 'checkboxToggle', + 'items' => [ + [ + 0 => '', + 1 => '', + 'invertStateDisplay' => true + ] + ] + ] + ], + 'starttime' => [ + 'exclude' => true, + 'l10n_mode' => 'exclude', + 'l10n_display' => 'defaultAsReadonly', + 'label' => $ll['frontend'] . ':starttime_formlabel', + 'config' => [ + 'type' => 'input', + 'renderType' => 'inputDateTime', + 'eval' => 'datetime', + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + 'behaviour' => [ + 'allowLanguageSynchronization' => true, + ] + ] + ], + 'endtime' => [ + 'exclude' => true, + 'l10n_mode' => 'exclude', + 'l10n_display' => 'defaultAsReadonly', + 'label' => $ll['frontend'] . ':endtime_formlabel', + 'config' => [ + 'type' => 'input', + 'renderType' => 'inputDateTime', + 'eval' => 'datetime', + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + 'behaviour' => [ + 'allowLanguageSynchronization' => true, + ] + ] + ], + 'sorting' => [ + 'config' => [ + 'type' => 'passthrough' + ] + ], + 'title' => [ + 'exclude' => true, + 'l10n_mode' => 'prefixLangTitle', + 'l10n_cat' => 'text', + 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user.title', + 'config' => [ + 'type' => 'input', + 'size' => 50, + 'max' => 255, + 'eval' => 'unique,trim,required' + ] + ], + ] +]; diff --git a/Resources/Public/Icons/Model/user.svg b/Resources/Public/Icons/Model/user.svg new file mode 100644 index 0000000..259cc13 --- /dev/null +++ b/Resources/Public/Icons/Model/user.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/ext_tables.sql b/ext_tables.sql new file mode 100644 index 0000000..7ad3fd9 --- /dev/null +++ b/ext_tables.sql @@ -0,0 +1,6 @@ +# +# Table structure for table 'tx_slubprofileservice_domain_model_user' +# +CREATE TABLE tx_slubprofileservice_domain_model_user ( + title varchar(255) DEFAULT '' NOT NULL, +); From a01ec08b24213429e58e41a2504dbe39b9f30bd8 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 21 Dec 2021 15:36:09 +0100 Subject: [PATCH 08/81] [TASK] Update dashboard widgets --- Classes/Controller/UserController.php | 42 ++++--- Classes/Domain/Model/User.php | 69 +++++++++++ Classes/Domain/Repository/UserRepository.php | 18 +++ Classes/Mvc/View/JsonView.php | 8 +- Classes/Service/AccountService.php | 62 ++++++++++ Classes/Service/UserService.php | 113 ++++++++++++++---- Classes/Utility/ApiUtility.php | 11 ++ Classes/Validation/WidgetValidator.php | 44 +++++++ Configuration/Services.yaml | 6 + Configuration/TCA/Overrides/pages.php | 3 +- ...x_slubprofileaccount_domain_model_user.php | 68 ++++++----- Configuration/TypoScript/constants.typoscript | 5 +- Configuration/TypoScript/setup.typoscript | 5 +- .../Private/Language/de.locallang_db.xlf | 20 ++++ Resources/Private/Language/locallang_db.xlf | 17 +++ ext_tables.sql | 22 +++- 16 files changed, 435 insertions(+), 78 deletions(-) create mode 100644 Classes/Domain/Model/User.php create mode 100644 Classes/Domain/Repository/UserRepository.php create mode 100644 Classes/Service/AccountService.php create mode 100644 Classes/Validation/WidgetValidator.php create mode 100644 Resources/Private/Language/de.locallang_db.xlf create mode 100644 Resources/Private/Language/locallang_db.xlf diff --git a/Classes/Controller/UserController.php b/Classes/Controller/UserController.php index f8a3c02..8818d51 100644 --- a/Classes/Controller/UserController.php +++ b/Classes/Controller/UserController.php @@ -12,14 +12,17 @@ namespace Slub\SlubProfileAccount\Controller; use Psr\Http\Message\ResponseInterface; +use Slub\SlubProfileAccount\Domain\Model\User; use Slub\SlubProfileAccount\Mvc\View\JsonView; use Slub\SlubProfileAccount\Service\UserService; +use Slub\SlubProfileAccount\Utility\ApiUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; class UserController extends ActionController { protected $view; protected $defaultViewObjectName = JsonView::class; + protected ?User $user; protected UserService $userService; /** @@ -35,10 +38,8 @@ public function __construct(UserService $userService) */ public function detailAction(): ResponseInterface { - $user = $this->userService->getUser($this->request->getArguments()); - $this->view->setVariablesToRender(['userDetail']); - $this->view->assign('userDetail', $user); + $this->view->assign('userDetail', $this->user); return $this->jsonResponse(); } @@ -49,21 +50,32 @@ public function detailAction(): ResponseInterface */ public function updateAction(): ResponseInterface { - $user = $this->userService->getUser($this->request->getArguments()); - $receivedData = json_decode(file_get_contents('php://input'), true, 512, JSON_THROW_ON_ERROR) ?? []; + $content = $this->getContent(); + $user = $this->userService->updateUser($this->user, $content); + $status = $user instanceof User ? 200 : 500; - $data = [ - 'user' => $user, - 'receivedData' => $receivedData - ]; + $this->view->setVariablesToRender(['status']); + $this->view->assign('status', ApiUtility::STATUS[$status]); - // @todo just send the received data back to check if the circle works. Next step: save the data here - // create domain model, dashboard_widgets colon separated string, external user data as array to separate data? - // the update needs to accept the "widgets" array + return $this->jsonResponse(); + } - $this->view->setVariablesToRender(['userUpdate']); - $this->view->assign('userUpdate', $data); + /** + * @return array + * @throws \JsonException + */ + protected function getContent(): array + { + return json_decode( + file_get_contents('php://input'), + true, + 512, + JSON_THROW_ON_ERROR + ) ?? []; + } - return $this->jsonResponse(); + protected function initializeAction(): void + { + $this->user = $this->userService->getUser($this->request->getArguments()); } } diff --git a/Classes/Domain/Model/User.php b/Classes/Domain/Model/User.php new file mode 100644 index 0000000..1dff8da --- /dev/null +++ b/Classes/Domain/Model/User.php @@ -0,0 +1,69 @@ +accountId; + } + + /** + * @param int $accountId + */ + public function setAccountId(int $accountId): void + { + $this->accountId = $accountId; + } + + /** + * @return array $accountData + */ + public function getAccountData(): array + { + return $this->accountData; + } + + /** + * @param array $accountData + */ + public function setAccountData(array $accountData): void + { + $this->accountData = $accountData; + } + + /** + * @return string $dashboardWidgets + */ + public function getDashboardWidgets(): string + { + return $this->dashboardWidgets; + } + + /** + * @param string $dashboardWidgets + */ + public function setDashboardWidgets(string $dashboardWidgets): void + { + $this->dashboardWidgets = $dashboardWidgets; + } +} diff --git a/Classes/Domain/Repository/UserRepository.php b/Classes/Domain/Repository/UserRepository.php new file mode 100644 index 0000000..b0138c7 --- /dev/null +++ b/Classes/Domain/Repository/UserRepository.php @@ -0,0 +1,18 @@ + [ + '_only' => [ + 'accountData' + ], + '_descend' => [ + 'accountData' => [] + ] ], - 'userUpdate' => [ + 'status' => [ ], ]; diff --git a/Classes/Service/AccountService.php b/Classes/Service/AccountService.php new file mode 100644 index 0000000..e121373 --- /dev/null +++ b/Classes/Service/AccountService.php @@ -0,0 +1,62 @@ +accountArgumentValidator = $accountArgumentValidator; + $this->apiConfiguration = $apiConfiguration; + $this->request = $request; + } + + /** + * @param array $arguments + * @return array|null + */ + public function getAccountData(array $arguments): ?array + { + $this->accountId = (int)$this->accountArgumentValidator->validateAccountArguments($arguments)['user']; + + $uri = $this->apiConfiguration->getUserUri(); + $uri = ApiUtility::replaceUriPlaceholder([$this->accountId], $uri); + + return $this->request->process($uri); + } + + /** + * @return int + */ + public function getAccountId(): int + { + return $this->accountId; + } +} diff --git a/Classes/Service/UserService.php b/Classes/Service/UserService.php index 84098e1..6382aec 100644 --- a/Classes/Service/UserService.php +++ b/Classes/Service/UserService.php @@ -11,44 +11,111 @@ namespace Slub\SlubProfileAccount\Service; -use Slub\SlubProfileAccount\Domain\Model\Dto\ApiConfiguration; -use Slub\SlubProfileAccount\Utility\ApiUtility; -use Slub\SlubProfileAccount\Validation\AccountArgumentValidator; -use Slub\SlubProfileEvents\Http\Request; +use Slub\SlubProfileAccount\Domain\Model\User; +use Slub\SlubProfileAccount\Domain\Repository\UserRepository; +use Slub\SlubProfileAccount\Validation\WidgetValidator; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; +use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; +use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; class UserService { - protected AccountArgumentValidator $accountArgumentValidator; - protected ApiConfiguration $apiConfiguration; - protected Request $request; + protected AccountService $accountService; + protected PersistenceManager $persistenceManager; + protected UserRepository $userRepository; + protected WidgetValidator $widgetValidator; /** - * @param AccountArgumentValidator $accountArgumentValidator - * @param ApiConfiguration $apiConfiguration - * @param Request $request + * @param AccountService $accountService + * @param PersistenceManager $persistenceManager + * @param UserRepository $userRepository + * @param WidgetValidator $widgetValidator */ public function __construct( - AccountArgumentValidator $accountArgumentValidator, - ApiConfiguration $apiConfiguration, - Request $request + AccountService $accountService, + PersistenceManager $persistenceManager, + UserRepository $userRepository, + WidgetValidator $widgetValidator ) { - $this->accountArgumentValidator = $accountArgumentValidator; - $this->apiConfiguration = $apiConfiguration; - $this->request = $request; + $this->accountService = $accountService; + $this->persistenceManager = $persistenceManager; + $this->userRepository = $userRepository; + $this->widgetValidator = $widgetValidator; } /** * @param array $arguments - * @return array + * @return User|null + * @throws IllegalObjectTypeException */ - public function getUser(array $arguments): array + public function getUser(array $arguments): ?User { - $validatedArguments = $this->accountArgumentValidator->validateAccountArguments($arguments); + $user = null; - $uri = $this->apiConfiguration->getUserUri(); - $uri = ApiUtility::replaceUriPlaceholder([$validatedArguments['user']], $uri); + $accountData = $this->accountService->getAccountData($arguments); + $accountId = $this->accountService->getAccountId(); - // Wrap with brackets for array, if not mvc -> json -> view does not work - return [$this->request->process($uri)] ?? []; + !is_array($accountData) ?: $user = $this->findUser($accountId); + $user === null ?: $user->setAccountData($accountData); + + return $user; + } + + /** + * @param User $user + * @param array $data + * @return User + * @throws IllegalObjectTypeException + * @throws UnknownObjectException + */ + public function updateUser(User $user, array $data): User + { + $hasChanges = false; + + if (is_array($data['widgets'])) { + $hasChanges = true; + $dashboardWidgets = implode(',', $this->widgetValidator->validate($data['widgets'])); + + $user->setDashboardWidgets($dashboardWidgets); + } + + if ($hasChanges) { + $this->userRepository->update($user); + $this->persistenceManager->persistAll(); + } + + return $user; + } + + /** + * @param int $accountId + * @return User + * @throws IllegalObjectTypeException + */ + protected function findUser(int $accountId): User + { + /** @var User|null $user */ + $user = $this->userRepository->findOneByAccountId($accountId); + $user instanceof User ?: $user = $this->createUser($accountId); + + return $user; + } + + /** + * @param int $accountId + * @return User + * @throws IllegalObjectTypeException + */ + protected function createUser(int $accountId): User + { + /** @var User $user */ + $user = GeneralUtility::makeInstance(User::class); + $user->setAccountId($accountId); + + $this->userRepository->add($user); + $this->persistenceManager->persistAll(); + + return $user; } } diff --git a/Classes/Utility/ApiUtility.php b/Classes/Utility/ApiUtility.php index 9cd04ae..91300dc 100644 --- a/Classes/Utility/ApiUtility.php +++ b/Classes/Utility/ApiUtility.php @@ -13,6 +13,17 @@ class ApiUtility { + public const STATUS = [ + 200 => [ + 'code' => 200, + 'message' => 'OK' + ], + 500 => [ + 'code' => 500, + 'message' => 'Internal Server Error' + ] + ]; + public const URI_PLACEHOLDER = [ '###USER_ID###' ]; diff --git a/Classes/Validation/WidgetValidator.php b/Classes/Validation/WidgetValidator.php new file mode 100644 index 0000000..13c5aee --- /dev/null +++ b/Classes/Validation/WidgetValidator.php @@ -0,0 +1,44 @@ +validateString($widget); + } + + return $validWidgets; + } + + /** + * @param string $string + * @return string + */ + protected function validateString($string = ''): string + { + return preg_replace($this->pattern, '', $string); + } +} diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 8b9a28c..d150ae3 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -10,5 +10,11 @@ services: Slub\SlubProfileAccount\Http\Request: public: true + Slub\SlubProfileAccount\Service\AccountService: + public: true + Slub\SlubProfileAccount\Service\ApiService: public: true + + Slub\SlubProfileAccount\Service\UserService: + public: true diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index c18950b..3a90fcc 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -1,10 +1,11 @@ [ 'tabs' => 'LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf', + 'tca' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf', 'general' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf' ], 'frontend' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf', - 'slubProfileAccount' => [ - 'db' => 'LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_db.xlf', - 'tca' => 'LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_tca.xlf' - ] - - /* - * - --palette--;' . $ll['slubProfileAccount']['tca'] . ':palette.hidden;hidden, - --palette--;' . $ll['slubProfileAccount']['tca'] . ':palette.access;access, - */ + 'slubProfileAccount' => 'LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_db.xlf' ]; return [ 'ctrl' => [ - 'title' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user', - 'label' => 'title', + 'title' => $ll['slubProfileAccount'] . ':tx_slubprofileaccount_domain_model_user', + 'label' => 'account_id', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', + 'editlock' => 'editlock', 'delete' => 'deleted', - 'sortby' => 'title', - 'default_sortby' => 'title', + //'sortby' => 'account_id', + 'default_sortby' => 'account_id DESC', 'enablecolumns' => [ 'disabled' => 'hidden', 'starttime' => 'starttime', @@ -37,13 +31,12 @@ ], 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l18n_parent', - 'transOrigDiffSourceField' => 'l10n_diffsource', + 'transOrigDiffSourceField' => 'l18n_diffsource', 'descriptionColumn' => 'description', - 'editlock' => 'editlock', 'translationSource' => 'l10n_source', 'origUid' => 't3_origuid', 'versioningWS' => true, - 'searchFields' => 'uid,title', + 'searchFields' => 'account_id, dashboard_widgets', 'typeicon_classes' => [ 'default' => 'slubprofileaccount-model-user' ], @@ -52,7 +45,7 @@ '0' => [ 'showitem' => ' --div--;' . $ll['core']['tabs'] . ':general, - title, + account_id, dashboard_widgets, --div--;' . $ll['core']['tabs'] . ':language, --palette--;;language, --div--;' . $ll['core']['tabs'] . ':access, @@ -66,7 +59,9 @@ 'label' => $ll['frontend'] . ':palette.access', 'showitem' => ' starttime;' . $ll['frontend'] . ':starttime_formlabel, - endtime;' . $ll['frontend'] . ':endtime_formlabel + endtime;' . $ll['frontend'] . ':endtime_formlabel, + --linebreak--, + editlock ', ], 'hidden' => [ @@ -82,6 +77,15 @@ ], ], 'columns' => [ + 'editlock' => [ + 'exclude' => true, + 'displayCond' => 'HIDE_FOR_NON_ADMINS', + 'label' => $ll['core']['tca'] . ':editlock', + 'config' => [ + 'type' => 'check', + 'renderType' => 'checkboxToggle', + ], + ], 'sys_language_uid' => [ 'exclude' => true, 'label' => $ll['core']['general'] . ':LGL.language', @@ -116,7 +120,7 @@ 'default' => 0 ] ], - 'l10n_diffsource' => [ + 'l18n_diffsource' => [ 'config' => [ 'type' => 'passthrough', 'default' => '' @@ -173,16 +177,11 @@ ] ] ], - 'sorting' => [ - 'config' => [ - 'type' => 'passthrough' - ] - ], - 'title' => [ + 'account_id' => [ 'exclude' => true, - 'l10n_mode' => 'prefixLangTitle', - 'l10n_cat' => 'text', - 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user.title', + 'l10n_mode' => 'exclude', + 'l10n_display' => 'defaultAsReadonly', + 'label' => $ll['slubProfileAccount'] . ':tx_slubprofileaccount_domain_model_user.account_id', 'config' => [ 'type' => 'input', 'size' => 50, @@ -190,5 +189,16 @@ 'eval' => 'unique,trim,required' ] ], + 'dashboard_widgets' => [ + 'exclude' => true, + 'l10n_mode' => 'exclude', + 'l10n_display' => 'defaultAsReadonly', + 'label' => $ll['slubProfileAccount'] . ':tx_slubprofileaccount_domain_model_user.dashboard_widgets', + 'config' => [ + 'type' => 'text', + 'rows' => 5, + 'cols' => 30, + ] + ], ] ]; diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index e674a1b..7e22571 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -1,10 +1,9 @@ # customsubcategory=76595002_Api=API plugin.tx_slubprofileaccount { - settings { - # cat=plugin.tx_slubprofileaccount//a; type=string; label=Default storage PID - storagePid = 0 + persistence.storagePid = 14 + settings { api { path { # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for user diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index a22a9e7..96f55e6 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -4,9 +4,8 @@ plugin.tx_slubprofileaccount { throwPageNotFoundExceptionIfActionCantBeResolved = 1 } - features { - skipDefaultArguments = 1 - } + features.skipDefaultArguments = 1 + persistence.storagePid = {$plugin.tx_slubprofileaccount.persistence.storagePid} settings { api { diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf new file mode 100644 index 0000000..9bcfa73 --- /dev/null +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -0,0 +1,20 @@ + + + +
+ + + User + Benutzer + + + Account ID + Benutzerkonto ID + + + Dashboard widget + Dashboard Widgets + + + + diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf new file mode 100644 index 0000000..59293ad --- /dev/null +++ b/Resources/Private/Language/locallang_db.xlf @@ -0,0 +1,17 @@ + + + +
+ + + User + + + Account ID + + + Dashboard widget + + + + diff --git a/ext_tables.sql b/ext_tables.sql index 7ad3fd9..af20f72 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -1,6 +1,22 @@ # -# Table structure for table 'tx_slubprofileservice_domain_model_user' +# Table structure for table 'tx_slubprofileaccount_domain_model_user' # -CREATE TABLE tx_slubprofileservice_domain_model_user ( - title varchar(255) DEFAULT '' NOT NULL, +CREATE TABLE tx_slubprofileaccount_domain_model_user ( + uid int(11) unsigned DEFAULT 0 NOT NULL auto_increment, + pid int(11) DEFAULT 0 NOT NULL, + + account_id varchar(255) NOT NULL, + dashboard_widgets text, + + tstamp int(11) unsigned DEFAULT 0 NOT NULL, + crdate int(11) unsigned DEFAULT 0 NOT NULL, + deleted tinyint(4) unsigned DEFAULT 0 NOT NULL, + hidden tinyint(4) unsigned DEFAULT 0 NOT NULL, + sys_language_uid int(11) DEFAULT 0 NOT NULL, + l18n_parent int(11) DEFAULT 0 NOT NULL, + l18n_diffsource mediumblob NOT NULL, + fe_group int(11) DEFAULT 0 NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), ); From 5a6196e9ef8b401de0b6d0f989e38b1ab83db5b1 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 22 Dec 2021 08:48:33 +0100 Subject: [PATCH 09/81] [TASK] Fulfill update suggestions --- Classes/Http/Request.php | 1 + .../tx_slubprofileaccount_domain_model_user.php | 15 +-------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/Classes/Http/Request.php b/Classes/Http/Request.php index af21020..78318b4 100644 --- a/Classes/Http/Request.php +++ b/Classes/Http/Request.php @@ -54,6 +54,7 @@ public function process($uri = '', $method = 'GET', array $options = []): ?array return $this->getContent($response, $uri); } catch (RequestException $e) { + /** @extensionScannerIgnoreLine */ $this->logger->error($e->getMessage()); return null; diff --git a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php index b0d2359..6ef45c8 100644 --- a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php +++ b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php @@ -90,20 +90,7 @@ 'exclude' => true, 'label' => $ll['core']['general'] . ':LGL.language', 'config' => [ - 'type' => 'select', - 'renderType' => 'selectSingle', - 'foreign_table' => 'sys_language', - 'foreign_table_where' => 'ORDER BY sys_language.title', - 'items' => [ - [$ll['core']['general'] . ':LGL.allLanguages', -1], - [$ll['core']['general'] . ':LGL.default_value', 0] - ], - 'default' => 0, - 'fieldWizard' => [ - 'selectIcons' => [ - 'disabled' => false, - ], - ], + 'type' => 'language' ] ], 'l18n_parent' => [ From 88541b4df1da42814aa555f91b6869ec197d311a Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 23 Dec 2021 12:22:50 +0100 Subject: [PATCH 10/81] [TASK] Extend backend list view with account data via api --- Classes/Form/Element/AccountDataElement.php | 68 +++++++++++ Classes/Service/AccountService.php | 29 ++++- Classes/Service/UserService.php | 2 +- Classes/Utility/ConstantsUtility.php | 1 + Classes/Utility/LanguageUtility.php | 25 ++++ Classes/ViewHelpers/Php/IsArrayViewHelper.php | 60 ++++++++++ ...x_slubprofileaccount_domain_model_user.php | 26 ++-- Configuration/TypoScript/setup.typoscript | 3 + .../Private/Language/de.locallang_backend.xlf | 31 +++++ .../Private/Language/de.locallang_db.xlf | 6 +- .../Private/Language/de.locallang_tabs.xlf | 12 ++ .../Private/Language/locallang_backend.xlf | 27 +++++ Resources/Private/Language/locallang_db.xlf | 3 + Resources/Private/Language/locallang_tabs.xlf | 11 ++ .../Private/Layouts/Backend/FormElement.html | 1 + .../Form/Element/AccountDataItems.html | 57 +++++++++ .../Backend/Form/Element/AccountData.html | 112 ++++++++++++++++++ ext_localconf.php | 8 ++ 18 files changed, 468 insertions(+), 14 deletions(-) create mode 100644 Classes/Form/Element/AccountDataElement.php create mode 100644 Classes/Utility/LanguageUtility.php create mode 100644 Classes/ViewHelpers/Php/IsArrayViewHelper.php create mode 100644 Resources/Private/Language/de.locallang_tabs.xlf create mode 100644 Resources/Private/Language/locallang_tabs.xlf create mode 100644 Resources/Private/Layouts/Backend/FormElement.html create mode 100644 Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html create mode 100644 Resources/Private/Templates/Backend/Form/Element/AccountData.html diff --git a/Classes/Form/Element/AccountDataElement.php b/Classes/Form/Element/AccountDataElement.php new file mode 100644 index 0000000..009865e --- /dev/null +++ b/Classes/Form/Element/AccountDataElement.php @@ -0,0 +1,68 @@ +getAccountData((int)$this->data['databaseRow']['account_id']); + $result['html'] = $this->getHtml($accountData); + + return $result; + } + + /** + * @param array $account + * @return string + */ + protected function getHtml(array $account): string + { + $root = 'EXT:' . ConstantsUtility::EXTENSION_KEY . '/Resources/Private/'; + + /** @var StandaloneView $standaloneView */ + $standaloneView = GeneralUtility::makeInstance(StandaloneView::class); + $standaloneView->setPartialRootPaths([$root . $this->partialRootPath]); + $standaloneView->setTemplateRootPaths([$root . $this->templateRootPath]); + $standaloneView->setLayoutRootPaths([$root . $this->layoutRootPath]); + $standaloneView->setTemplate($this->template); + $standaloneView->assign('account', $account); + + return $standaloneView->render(); + } + + /** + * @param int $accountId + * @return array + */ + protected function getAccountData(int $accountId): array + { + /** @var AccountService $accountService */ + $accountService = GeneralUtility::makeInstance(AccountService::class); + + return $accountService->getAccountDataById($accountId) ?? []; + } +} diff --git a/Classes/Service/AccountService.php b/Classes/Service/AccountService.php index e121373..9c8617d 100644 --- a/Classes/Service/AccountService.php +++ b/Classes/Service/AccountService.php @@ -38,18 +38,26 @@ public function __construct( $this->request = $request; } + /** + * @param int $id + * @return array|null + */ + public function getAccountDataById(int $id): ?array + { + $this->accountId = $id; + + return $this->getAccount(); + } + /** * @param array $arguments * @return array|null */ - public function getAccountData(array $arguments): ?array + public function getAccountDataByArguments(array $arguments): ?array { $this->accountId = (int)$this->accountArgumentValidator->validateAccountArguments($arguments)['user']; - $uri = $this->apiConfiguration->getUserUri(); - $uri = ApiUtility::replaceUriPlaceholder([$this->accountId], $uri); - - return $this->request->process($uri); + return $this->getAccount(); } /** @@ -59,4 +67,15 @@ public function getAccountId(): int { return $this->accountId; } + + /** + * @return array|null + */ + protected function getAccount(): ?array + { + $uri = $this->apiConfiguration->getUserUri(); + $uri = ApiUtility::replaceUriPlaceholder([$this->accountId], $uri); + + return $this->request->process($uri); + } } diff --git a/Classes/Service/UserService.php b/Classes/Service/UserService.php index 6382aec..1b60388 100644 --- a/Classes/Service/UserService.php +++ b/Classes/Service/UserService.php @@ -53,7 +53,7 @@ public function getUser(array $arguments): ?User { $user = null; - $accountData = $this->accountService->getAccountData($arguments); + $accountData = $this->accountService->getAccountDataByArguments($arguments); $accountId = $this->accountService->getAccountId(); !is_array($accountData) ?: $user = $this->findUser($accountId); diff --git a/Classes/Utility/ConstantsUtility.php b/Classes/Utility/ConstantsUtility.php index b62bb72..a3848cb 100644 --- a/Classes/Utility/ConstantsUtility.php +++ b/Classes/Utility/ConstantsUtility.php @@ -15,4 +15,5 @@ class ConstantsUtility { public const EXTENSION_NAME = 'slubprofileaccount'; public const EXTENSION_KEY = 'slub_profile_account'; + public const LANGUAGE_PATH_BACKEND = 'LLL:EXT:' . self::EXTENSION_KEY . '/Resources/Private/Language/locallang_backend.xlf'; } diff --git a/Classes/Utility/LanguageUtility.php b/Classes/Utility/LanguageUtility.php new file mode 100644 index 0000000..40e841e --- /dev/null +++ b/Classes/Utility/LanguageUtility.php @@ -0,0 +1,25 @@ + + * + * Inline syntax + * ------------- + * + * {data -> slub:php.isArray()} + */ +class IsArrayViewHelper extends AbstractViewHelper +{ + public function initializeArguments(): void + { + $this->registerArgument('data', 'mixed', 'Data to check if it is an array.', true); + } + + /** + * @param array $arguments + * @param Closure $renderChildrenClosure + * @param RenderingContextInterface $renderingContext + * @return bool + */ + public static function renderStatic( + array $arguments, + Closure $renderChildrenClosure, + RenderingContextInterface $renderingContext + ): bool { + $data = $renderChildrenClosure(); + + if ($data === null) { + $data = $arguments['data']; + } + + return is_array($data); + } +} diff --git a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php index 6ef45c8..020b556 100644 --- a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php +++ b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php @@ -4,17 +4,20 @@ $ll = [ 'core' => [ + 'general' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf', 'tabs' => 'LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf', - 'tca' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf', - 'general' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf' + 'tca' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf' ], 'frontend' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf', - 'slubProfileAccount' => 'LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_db.xlf' + 'slubProfileAccount' => [ + 'db' => 'LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_db.xlf', + 'tabs' => 'LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_tabs.xlf' + ] ]; return [ 'ctrl' => [ - 'title' => $ll['slubProfileAccount'] . ':tx_slubprofileaccount_domain_model_user', + 'title' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user', 'label' => 'account_id', 'tstamp' => 'tstamp', 'crdate' => 'crdate', @@ -45,7 +48,9 @@ '0' => [ 'showitem' => ' --div--;' . $ll['core']['tabs'] . ':general, - account_id, dashboard_widgets, + dashboard_widgets, + --div--;' . $ll['slubProfileAccount']['tabs'] . ':account, + account_id, account_overview, --div--;' . $ll['core']['tabs'] . ':language, --palette--;;language, --div--;' . $ll['core']['tabs'] . ':access, @@ -168,7 +173,7 @@ 'exclude' => true, 'l10n_mode' => 'exclude', 'l10n_display' => 'defaultAsReadonly', - 'label' => $ll['slubProfileAccount'] . ':tx_slubprofileaccount_domain_model_user.account_id', + 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user.account_id', 'config' => [ 'type' => 'input', 'size' => 50, @@ -176,11 +181,18 @@ 'eval' => 'unique,trim,required' ] ], + 'account_overview' => [ + 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user.account_overview', + 'config' => [ + 'type' => 'user', + 'renderType' => 'accountData', + ], + ], 'dashboard_widgets' => [ 'exclude' => true, 'l10n_mode' => 'exclude', 'l10n_display' => 'defaultAsReadonly', - 'label' => $ll['slubProfileAccount'] . ':tx_slubprofileaccount_domain_model_user.dashboard_widgets', + 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user.dashboard_widgets', 'config' => [ 'type' => 'text', 'rows' => 5, diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 96f55e6..2206d21 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -16,3 +16,6 @@ plugin.tx_slubprofileaccount { } } } + +# Event this extension has not module, this is used to call the api from backend in general. +module.tx_slubprofileaccount.settings < plugin.tx_slubprofileaccount.settings diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 0357337..d978275 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -3,6 +3,11 @@
+ + + User account Benutzerkonto @@ -25,6 +30,32 @@ Update data of a specific user. Daten zu einem spezifischen Benutzer aktualisieren. + + + + + Error connect user account + Fehler bei Verbindung mit Benutzerkonto + + + A connection to the account api was not possible. Please check your settings. + Eine Verbindung zum Benutzerkonto konnte nicht hergestellt werden. Bitte prüfen Sie die Einstellungen. + + + + + + ID + ID + + + Value + Wert + diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 9bcfa73..de8b15f 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -9,7 +9,11 @@ Account ID - Benutzerkonto ID + Konto ID + + + Account overview + Kontoübersicht Dashboard widget diff --git a/Resources/Private/Language/de.locallang_tabs.xlf b/Resources/Private/Language/de.locallang_tabs.xlf new file mode 100644 index 0000000..851877e --- /dev/null +++ b/Resources/Private/Language/de.locallang_tabs.xlf @@ -0,0 +1,12 @@ + + + +
+ + + Account + Konto + + + + diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 1c3ff64..ac70c04 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -3,6 +3,11 @@
+ + + User account @@ -20,6 +25,28 @@ Update data of a specific user. + + + + + Error connect user account + + + A connection to the account api was not possible. Please check your settings. + + + + + + ID + + + Value + diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 59293ad..92bc79c 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -9,6 +9,9 @@ Account ID + + Account overview + Dashboard widget diff --git a/Resources/Private/Language/locallang_tabs.xlf b/Resources/Private/Language/locallang_tabs.xlf new file mode 100644 index 0000000..c40cee2 --- /dev/null +++ b/Resources/Private/Language/locallang_tabs.xlf @@ -0,0 +1,11 @@ + + + +
+ + + Account + + + + diff --git a/Resources/Private/Layouts/Backend/FormElement.html b/Resources/Private/Layouts/Backend/FormElement.html new file mode 100644 index 0000000..24f730c --- /dev/null +++ b/Resources/Private/Layouts/Backend/FormElement.html @@ -0,0 +1 @@ + diff --git a/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html b/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html new file mode 100644 index 0000000..57a4b0f --- /dev/null +++ b/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
{key} + + + + + + + + +
+
+ + + + {value} + - + + diff --git a/Resources/Private/Templates/Backend/Form/Element/AccountData.html b/Resources/Private/Templates/Backend/Form/Element/AccountData.html new file mode 100644 index 0000000..cd0bb58 --- /dev/null +++ b/Resources/Private/Templates/Backend/Form/Element/AccountData.html @@ -0,0 +1,112 @@ +{namespace slub=Slub\SlubProfileAccount\ViewHelpers} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ + + +
+
+ + + + + +
+ +
+
+ +
+
+
+ +
+ + + +
+
+ + + {key} + + + {item} + - + + + + diff --git a/ext_localconf.php b/ext_localconf.php index 4729089..3685fa9 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,6 +1,7 @@ 'accountData', + 'priority' => 40, + 'class' => AccountDataElement::class, +]; From c5cca82ca0dd9dd1aaaec8728ec217adfcc96ddd Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 27 Dec 2021 10:31:44 +0100 Subject: [PATCH 11/81] [TASK] Change layout at backend list for account --- .../Backend/Form/Element/AccountDataItems.html | 11 ++--------- .../Templates/Backend/Form/Element/AccountData.html | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html b/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html index 57a4b0f..512271c 100644 --- a/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html +++ b/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html @@ -1,17 +1,10 @@ - - - - - - - - +
-
+ diff --git a/Resources/Private/Templates/Backend/Form/Element/AccountData.html b/Resources/Private/Templates/Backend/Form/Element/AccountData.html index cd0bb58..64b570b 100644 --- a/Resources/Private/Templates/Backend/Form/Element/AccountData.html +++ b/Resources/Private/Templates/Backend/Form/Element/AccountData.html @@ -76,7 +76,7 @@

-
+
+ User detail Benutzerdetails - + Details of a specific user. Details zu einem spezifischen Benutzer. - + User update Benutzer aktualisieren - + Update data of a specific user. Daten zu einem spezifischen Benutzer aktualisieren. diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index ac70c04..bccc1d6 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -12,17 +12,17 @@ User account - + User detail - + Details of a specific user. - + User update - + Update data of a specific user. diff --git a/Resources/Public/Icons/Wizard/user-detail.svg b/Resources/Public/Icons/Wizard/user-account-detail.svg similarity index 100% rename from Resources/Public/Icons/Wizard/user-detail.svg rename to Resources/Public/Icons/Wizard/user-account-detail.svg diff --git a/Resources/Public/Icons/Wizard/user-update.svg b/Resources/Public/Icons/Wizard/user-dashboard-update.svg similarity index 100% rename from Resources/Public/Icons/Wizard/user-update.svg rename to Resources/Public/Icons/Wizard/user-dashboard-update.svg diff --git a/ext_localconf.php b/ext_localconf.php index 3685fa9..ab60856 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,6 +1,7 @@ 'detail' + UserAccountController::class => 'detail' ], [ - UserController::class => 'detail' + UserAccountController::class => 'detail' ], ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); @@ -28,12 +29,12 @@ // Configure plugin - user update ExtensionUtility::configurePlugin( 'SlubProfileAccount', - 'UserUpdate', + 'UserDashboardUpdate', [ - UserController::class => 'update' + UserDashboardController::class => 'update' ], [ - UserController::class => 'update' + UserDashboardController::class => 'update' ], ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); From cdb6db4fe740a5a4f36df338b95da208453fbb65 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 27 Dec 2021 15:16:16 +0100 Subject: [PATCH 13/81] [TASK] Simplify code --- Classes/Controller/UserAccountController.php | 5 +++++ Classes/Controller/UserDashboardController.php | 13 +++++++++---- Classes/Service/UserAccountService.php | 15 +++++++++++---- Classes/Service/UserDashboardService.php | 16 +++++++++++----- Classes/Validation/AccountArgumentValidator.php | 4 +++- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Classes/Controller/UserAccountController.php b/Classes/Controller/UserAccountController.php index 6937c3e..4e2fcfa 100644 --- a/Classes/Controller/UserAccountController.php +++ b/Classes/Controller/UserAccountController.php @@ -11,6 +11,7 @@ namespace Slub\SlubProfileAccount\Controller; +use Exception; use Psr\Http\Message\ResponseInterface; use Slub\SlubProfileAccount\Domain\Model\User\Account as UserAccount; use Slub\SlubProfileAccount\Mvc\View\JsonView; @@ -44,6 +45,9 @@ public function detailAction(): ResponseInterface return $this->jsonResponse(); } + /** + * @throws Exception + */ protected function initializeAction(): void { try { @@ -51,6 +55,7 @@ protected function initializeAction(): void $this->request->getArguments() ); } catch (IllegalObjectTypeException $e) { + throw new Exception($e->getMessage()); } } } diff --git a/Classes/Controller/UserDashboardController.php b/Classes/Controller/UserDashboardController.php index 11783e2..84f09de 100644 --- a/Classes/Controller/UserDashboardController.php +++ b/Classes/Controller/UserDashboardController.php @@ -11,14 +11,15 @@ namespace Slub\SlubProfileAccount\Controller; +use Exception; use Psr\Http\Message\ResponseInterface; use Slub\SlubProfileAccount\Domain\Model\User\Dashboard as UserDashboard; use Slub\SlubProfileAccount\Mvc\View\JsonView; use Slub\SlubProfileAccount\Service\UserDashboardService; use Slub\SlubProfileAccount\Utility\ApiUtility; -use Slub\SlubProfileAccount\Utility\FileUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; +use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; class UserDashboardController extends ActionController { @@ -37,12 +38,12 @@ public function __construct(UserDashboardService $userDashboardService) /** * @return ResponseInterface - * @throws \JsonException + * @throws UnknownObjectException|\JsonException + * @throws IllegalObjectTypeException */ public function updateAction(): ResponseInterface { - $content = FileUtility::getContent(); - $userDashboard = $this->userDashboardService->updateUser($this->userDashboard, $content); + $userDashboard = $this->userDashboardService->updateUser($this->userDashboard); $status = $userDashboard instanceof UserDashboard ? 200 : 500; $this->view->setVariablesToRender(['status']); @@ -51,6 +52,9 @@ public function updateAction(): ResponseInterface return $this->jsonResponse(); } + /** + * @throws Exception + */ protected function initializeAction(): void { try { @@ -58,6 +62,7 @@ protected function initializeAction(): void $this->request->getArguments() ); } catch (IllegalObjectTypeException $e) { + throw new Exception($e->getMessage()); } } } diff --git a/Classes/Service/UserAccountService.php b/Classes/Service/UserAccountService.php index 5ffef46..1aa5ef5 100644 --- a/Classes/Service/UserAccountService.php +++ b/Classes/Service/UserAccountService.php @@ -46,12 +46,16 @@ public function __construct( public function getUser(array $arguments): ?User { $user = null; - $accountData = $this->accountService->getAccountDataByArguments($arguments); $accountId = $this->accountService->getAccountId(); - ($accountId === 0) ?: $user = $this->findUser($accountId); - $user === null ?: $user->setAccountData($accountData); + if ($accountId > 0 && is_array($accountData)) { + $user = $this->findUser($accountId); + } + + if ($user instanceof User) { + $user->setAccountData($accountData); + } return $user; } @@ -65,7 +69,10 @@ protected function findUser(int $accountId): User { /** @var User|null $userAccount */ $userAccount = $this->userRepository->findOneByAccountId($accountId); - $userAccount instanceof User ?: $userAccount = $this->createUser($accountId); + + if ($userAccount === null) { + $userAccount = $this->createUser($accountId); + } return $userAccount; } diff --git a/Classes/Service/UserDashboardService.php b/Classes/Service/UserDashboardService.php index b77618d..e175af3 100644 --- a/Classes/Service/UserDashboardService.php +++ b/Classes/Service/UserDashboardService.php @@ -13,6 +13,7 @@ use Slub\SlubProfileAccount\Domain\Model\User\Dashboard as User; use Slub\SlubProfileAccount\Domain\Repository\User\DashboardRepository as UserRepository; +use Slub\SlubProfileAccount\Utility\FileUtility; use Slub\SlubProfileAccount\Validation\WidgetValidator; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; @@ -52,25 +53,27 @@ public function __construct( public function getUser(array $arguments): ?User { $user = null; - $accountData = $this->accountService->getAccountDataByArguments($arguments); $accountId = $this->accountService->getAccountId(); - !is_array($accountData) ?: $user = $this->findUser($accountId); + if ($accountId > 0 && is_array($accountData)) { + $user = $this->findUser($accountId); + } return $user; } /** * @param User $user - * @param array $data * @return User * @throws IllegalObjectTypeException * @throws UnknownObjectException + * @throws \JsonException */ - public function updateUser(User $user, array $data): User + public function updateUser(User $user): User { $hasChanges = false; + $data = FileUtility::getContent(); if (is_array($data['widgets'])) { $hasChanges = true; @@ -96,7 +99,10 @@ protected function findUser(int $accountId): User { /** @var User|null $user */ $user = $this->userRepository->findOneByAccountId($accountId); - $user instanceof User ?: $user = $this->createUser($accountId); + + if ($user === null) { + $user = $this->createUser($accountId); + } return $user; } diff --git a/Classes/Validation/AccountArgumentValidator.php b/Classes/Validation/AccountArgumentValidator.php index e1ab1ea..f85b8f0 100644 --- a/Classes/Validation/AccountArgumentValidator.php +++ b/Classes/Validation/AccountArgumentValidator.php @@ -36,6 +36,8 @@ public function validateAccountArguments(array $arguments): array */ protected function validateInteger($key = '', $value = ''): void { - empty($value) ?: $this->validArguments[$key] = (int)$value; + if (!empty($value)) { + $this->validArguments[$key] = (int)$value; + } } } From 3a3643cef10322838169ab36ec0afefc536f8069 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 27 Dec 2021 15:31:24 +0100 Subject: [PATCH 14/81] [TASK] Replace validate with sanitize --- .../AccountArgumentSanitization.php} | 16 ++++++++-------- .../WidgetSanitization.php} | 14 +++++++------- Classes/Service/AccountService.php | 12 ++++++------ Classes/Service/UserDashboardService.php | 12 ++++++------ 4 files changed, 27 insertions(+), 27 deletions(-) rename Classes/{Validation/AccountArgumentValidator.php => Sanitization/AccountArgumentSanitization.php} (56%) rename Classes/{Validation/WidgetValidator.php => Sanitization/WidgetSanitization.php} (64%) diff --git a/Classes/Validation/AccountArgumentValidator.php b/Classes/Sanitization/AccountArgumentSanitization.php similarity index 56% rename from Classes/Validation/AccountArgumentValidator.php rename to Classes/Sanitization/AccountArgumentSanitization.php index f85b8f0..364776d 100644 --- a/Classes/Validation/AccountArgumentValidator.php +++ b/Classes/Sanitization/AccountArgumentSanitization.php @@ -9,35 +9,35 @@ * LICENSE file that was distributed with this source code. */ -namespace Slub\SlubProfileAccount\Validation; +namespace Slub\SlubProfileAccount\Sanitization; -class AccountArgumentValidator +class AccountArgumentSanitization { - protected array $validArguments = []; + protected array $sanitizedArguments = []; /** * @param array $arguments * @return array */ - public function validateAccountArguments(array $arguments): array + public function sanitizeAccountArguments(array $arguments): array { if (count($arguments) === 0) { return ['user' => 0]; } - $this->validateInteger('user', $arguments['user']); + $this->sanitizeInteger('user', $arguments['user']); - return $this->validArguments; + return $this->sanitizedArguments; } /** * @param string $key * @param string $value */ - protected function validateInteger($key = '', $value = ''): void + protected function sanitizeInteger($key = '', $value = ''): void { if (!empty($value)) { - $this->validArguments[$key] = (int)$value; + $this->sanitizedArguments[$key] = (int)$value; } } } diff --git a/Classes/Validation/WidgetValidator.php b/Classes/Sanitization/WidgetSanitization.php similarity index 64% rename from Classes/Validation/WidgetValidator.php rename to Classes/Sanitization/WidgetSanitization.php index 13c5aee..bb4027e 100644 --- a/Classes/Validation/WidgetValidator.php +++ b/Classes/Sanitization/WidgetSanitization.php @@ -9,9 +9,9 @@ * LICENSE file that was distributed with this source code. */ -namespace Slub\SlubProfileAccount\Validation; +namespace Slub\SlubProfileAccount\Sanitization; -class WidgetValidator +class WidgetSanitization { protected array $pattern = [ '/[^_a-zA-Z\s]/', @@ -22,22 +22,22 @@ class WidgetValidator * @param array $widgets * @return array */ - public function validate(array $widgets): array + public function sanitize(array $widgets): array { - $validWidgets = []; + $sanitizedWidgets = []; foreach ($widgets as $widget) { - $validWidgets[] = $this->validateString($widget); + $sanitizedWidgets[] = $this->sanitizeString($widget); } - return $validWidgets; + return $sanitizedWidgets; } /** * @param string $string * @return string */ - protected function validateString($string = ''): string + protected function sanitizeString($string = ''): string { return preg_replace($this->pattern, '', $string); } diff --git a/Classes/Service/AccountService.php b/Classes/Service/AccountService.php index eb90c6d..cd24a3c 100644 --- a/Classes/Service/AccountService.php +++ b/Classes/Service/AccountService.php @@ -12,28 +12,28 @@ namespace Slub\SlubProfileAccount\Service; use Slub\SlubProfileAccount\Domain\Model\Dto\ApiConfiguration; +use Slub\SlubProfileAccount\Sanitization\AccountArgumentSanitization; use Slub\SlubProfileAccount\Utility\ApiUtility; -use Slub\SlubProfileAccount\Validation\AccountArgumentValidator; use Slub\SlubProfileEvents\Http\Request; class AccountService { - protected AccountArgumentValidator $accountArgumentValidator; + protected AccountArgumentSanitization $accountArgumentSanitization; protected ApiConfiguration $apiConfiguration; protected Request $request; protected int $accountId; /** - * @param AccountArgumentValidator $accountArgumentValidator + * @param AccountArgumentSanitization $accountArgumentSanitization * @param ApiConfiguration $apiConfiguration * @param Request $request */ public function __construct( - AccountArgumentValidator $accountArgumentValidator, + AccountArgumentSanitization $accountArgumentSanitization, ApiConfiguration $apiConfiguration, Request $request ) { - $this->accountArgumentValidator = $accountArgumentValidator; + $this->accountArgumentSanitization = $accountArgumentSanitization; $this->apiConfiguration = $apiConfiguration; $this->request = $request; } @@ -55,7 +55,7 @@ public function getAccountDataById(int $id): ?array */ public function getAccountDataByArguments(array $arguments): ?array { - $id = (int)$this->accountArgumentValidator->validateAccountArguments($arguments)['user']; + $id = (int)$this->accountArgumentSanitization->sanitizeAccountArguments($arguments)['user']; $this->accountId = $id; return $this->getAccount($id); diff --git a/Classes/Service/UserDashboardService.php b/Classes/Service/UserDashboardService.php index e175af3..8c3cb4c 100644 --- a/Classes/Service/UserDashboardService.php +++ b/Classes/Service/UserDashboardService.php @@ -13,8 +13,8 @@ use Slub\SlubProfileAccount\Domain\Model\User\Dashboard as User; use Slub\SlubProfileAccount\Domain\Repository\User\DashboardRepository as UserRepository; +use Slub\SlubProfileAccount\Sanitization\WidgetSanitization; use Slub\SlubProfileAccount\Utility\FileUtility; -use Slub\SlubProfileAccount\Validation\WidgetValidator; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; @@ -25,24 +25,24 @@ class UserDashboardService protected AccountService $accountService; protected PersistenceManager $persistenceManager; protected UserRepository $userRepository; - protected WidgetValidator $widgetValidator; + protected WidgetSanitization $widgetSanitization; /** * @param AccountService $accountService * @param PersistenceManager $persistenceManager * @param UserRepository $userRepository - * @param WidgetValidator $widgetValidator + * @param WidgetSanitization $widgetSanitization */ public function __construct( AccountService $accountService, PersistenceManager $persistenceManager, UserRepository $userRepository, - WidgetValidator $widgetValidator + WidgetSanitization $widgetSanitization ) { $this->accountService = $accountService; $this->persistenceManager = $persistenceManager; $this->userRepository = $userRepository; - $this->widgetValidator = $widgetValidator; + $this->widgetSanitization = $widgetSanitization; } /** @@ -77,7 +77,7 @@ public function updateUser(User $user): User if (is_array($data['widgets'])) { $hasChanges = true; - $dashboardWidgets = implode(',', $this->widgetValidator->validate($data['widgets'])); + $dashboardWidgets = implode(',', $this->widgetSanitization->sanitize($data['widgets'])); $user->setDashboardWidgets($dashboardWidgets); } From a83524eae519988bb45b8542da3981afa34ffad4 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 28 Dec 2021 11:17:55 +0100 Subject: [PATCH 15/81] [TASK] Add user dashboard api --- .../Controller/UserDashboardController.php | 11 ++++++++ Classes/Mvc/View/JsonView.php | 5 ++++ Configuration/Icons.php | 4 +++ Configuration/Routes/Default.yaml | 1 + Configuration/Routes/UserDashboardDetail.yaml | 9 +++++++ Configuration/TCA/Overrides/tt_content.php | 2 +- Configuration/TsConfig/Page.tsconfig | 10 +++++++- README.md | 2 +- .../Private/Language/de.locallang_backend.xlf | 25 +++++++++++++------ .../Private/Language/locallang_backend.xlf | 8 +++--- .../Icons/Wizard/user-dashboard-detail.svg | 10 ++++++++ ext_localconf.php | 17 +++++++++++-- 12 files changed, 87 insertions(+), 17 deletions(-) create mode 100644 Configuration/Routes/UserDashboardDetail.yaml create mode 100644 Resources/Public/Icons/Wizard/user-dashboard-detail.svg diff --git a/Classes/Controller/UserDashboardController.php b/Classes/Controller/UserDashboardController.php index 84f09de..ad29cea 100644 --- a/Classes/Controller/UserDashboardController.php +++ b/Classes/Controller/UserDashboardController.php @@ -36,6 +36,17 @@ public function __construct(UserDashboardService $userDashboardService) $this->userDashboardService = $userDashboardService; } + /** + * @return ResponseInterface + */ + public function detailAction(): ResponseInterface + { + $this->view->setVariablesToRender(['userDashboardDetail']); + $this->view->assign('userDashboardDetail', $this->userDashboard); + + return $this->jsonResponse(); + } + /** * @return ResponseInterface * @throws UnknownObjectException|\JsonException diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index c76f81c..02b0cab 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -41,6 +41,11 @@ class JsonView extends ExtbaseJsonView 'accountData' => [] ] ], + 'userDashboardDetail' => [ + '_only' => [ + 'dashboardWidgets' + ], + ], 'status' => [ ], ]; diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 3c6436b..31944ae 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -19,6 +19,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-account-detail.svg' ], + 'slubprofileaccount-wizard-userdashboarddetail' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-detail.svg' + ], 'slubprofileaccount-wizard-userdashboardupdate' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-update.svg' diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index d11b7f4..b789cb9 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -2,4 +2,5 @@ # But you can simply include it in your site configuration: imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserAccountDetail.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardUpdate.yaml' diff --git a/Configuration/Routes/UserDashboardDetail.yaml b/Configuration/Routes/UserDashboardDetail.yaml new file mode 100644 index 0000000..0dda17b --- /dev/null +++ b/Configuration/Routes/UserDashboardDetail.yaml @@ -0,0 +1,9 @@ +routeEnhancers: + SlubAccountUserDashboardDetail: + type: Simple + limitToPages: [15] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userdashboarddetail/user' diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index f12bb4c..e82d0bd 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -59,5 +59,5 @@ } })( 'slub_profile_account', - ['useraccountdetail', 'userdashboardupdate'] + ['useraccountdetail', 'userdashboarddetail', 'userdashboardupdate'] ); diff --git a/Configuration/TsConfig/Page.tsconfig b/Configuration/TsConfig/Page.tsconfig index 8ec178d..4d71e90 100644 --- a/Configuration/TsConfig/Page.tsconfig +++ b/Configuration/TsConfig/Page.tsconfig @@ -12,6 +12,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_useraccountdetail } + slubprofileaccount_userdashboarddetail { + iconIdentifier = slubprofileaccount-wizard-userdashboarddetail + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userdashboarddetail.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userdashboarddetail.description + tt_content_defValues.CType = slubprofileaccount_userdashboarddetail + } + slubprofileaccount_userdashboardupdate { iconIdentifier = slubprofileaccount-wizard-userdashboardupdate iconOverlay = slubprofileaccount-overlay-extension @@ -21,6 +29,6 @@ mod { } } - show := addToList(slubprofileaccount_useraccountdetail, slubprofileaccount_userdashboardupdate) + show := addToList(slubprofileaccount_useraccountdetail, slubprofileaccount_userdashboardupdate, slubprofileaccount_userdashboarddetail) } } diff --git a/README.md b/README.md index dd69aad..788afce 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ composer require slub/slub-profile-account News uses [semantic versioning][2], which means, that * **bugfix updates** (e.g. 1.0.0 => 1.0.1) just includes small bugfixes or security relevant stuff without breaking changes, * **minor updates** (e.g. 1.0.0 => 1.1.0) includes new features and smaller tasks without breaking changes, -* **major updates** (e.g. 1.0.0 => 2.0.0) breaking changes wich can be refactorings, features or bugfixes. +* **major updates** (e.g. 1.0.0 => 2.0.0) breaking changes which can be refactorings, features or bugfixes. ## 3 Api diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 925c225..3b7f8d4 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -14,21 +14,30 @@ - User detail - Benutzerdetails + User detail (constraint: account) + Details eines Benutzers (Einschränkung: Account) - Details of a specific user. - Details zu einem spezifischen Benutzer. + Details of a specific user (account). Returns only the user constraint "account" data. + Details zu einem spezifischen Benutzer (Account). Gibt nur die Daten des Benutzers mit der Einschränkung "Account" zurück. + + + + User detail (constraint: dashboard) + Details eines Benutzers (Einschränkung: Dashboard) + + + Details of a specific user (dashboard). Returns only the user constraint "dashboard" data. + Details zu einem spezifischen Benutzer (Dashboard). Gibt nur die Daten des Benutzers mit der Einschränkung "Dashboard" zurück. - User update - Benutzer aktualisieren + User update (dashboard) + Benutzer aktualisieren (Dashboard) - Update data of a specific user. - Daten zu einem spezifischen Benutzer aktualisieren. + Update data of a specific dashboard user. + Daten zu einem spezifischen Benutzerdashboard aktualisieren. + User Benutzer @@ -19,6 +24,35 @@ Dashboard widget Dashboard Widgets + + Search queries + Suchanfragen + + + + + + Search query + Suchanfrage + + + Title + Titel + + + Type + Typ + + + Query + Anfrage + + + User + Benutzer + diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 52968bc..f427f14 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -26,6 +26,20 @@ Update data of a specific dashboard user. + + User dashboard - update + + + Update data of dashboard to user. + + + + User search query - add + + + Add data of user search to user. + + diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 92bc79c..22d227c 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -3,6 +3,11 @@
+ + + User @@ -15,6 +20,29 @@ Dashboard widget + + Search queries + + + + + + Search query + + + Title + + + Type + + + Query + + + User + diff --git a/Resources/Public/Icons/Model/search-query.svg b/Resources/Public/Icons/Model/search-query.svg new file mode 100644 index 0000000..3b9dc0b --- /dev/null +++ b/Resources/Public/Icons/Model/search-query.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/Resources/Public/Icons/Wizard/user-dashboard-update.svg b/Resources/Public/Icons/Wizard/user-dashboard-update.svg index f5508f9..87b9366 100644 --- a/Resources/Public/Icons/Wizard/user-dashboard-update.svg +++ b/Resources/Public/Icons/Wizard/user-dashboard-update.svg @@ -2,5 +2,7 @@ - + + + diff --git a/Resources/Public/Icons/Wizard/user-search-query-add.svg b/Resources/Public/Icons/Wizard/user-search-query-add.svg new file mode 100644 index 0000000..d9ffa5c --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-search-query-add.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index 8614ee3..9b10f57 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,6 +2,7 @@ use Slub\SlubProfileAccount\Controller\UserAccountController; use Slub\SlubProfileAccount\Controller\UserDashboardController; +use Slub\SlubProfileAccount\Controller\UserSearchQueryController; use Slub\SlubProfileAccount\Form\Element\AccountDataElement; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Extbase\Utility\ExtensionUtility; @@ -52,7 +53,20 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); -// Register new renderType - accountData" +// Configure plugin - user search query add +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserSearchQueryAdd', + [ + UserSearchQueryController::class => 'add' + ], + [ + UserSearchQueryController::class => 'add' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + +// Register new renderType - accountData $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][time()] = [ 'nodeName' => 'accountData', 'priority' => 40, diff --git a/ext_tables.sql b/ext_tables.sql index af20f72..61d5670 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -6,6 +6,7 @@ CREATE TABLE tx_slubprofileaccount_domain_model_user ( pid int(11) DEFAULT 0 NOT NULL, account_id varchar(255) NOT NULL, + search_query int(11) unsigned DEFAULT 0 NOT NULL, dashboard_widgets text, tstamp int(11) unsigned DEFAULT 0 NOT NULL, @@ -20,3 +21,42 @@ CREATE TABLE tx_slubprofileaccount_domain_model_user ( PRIMARY KEY (uid), KEY parent (pid), ); + +# +# Table structure for table 'tx_slubprofileaccount_domain_model_searchquery' +# +CREATE TABLE tx_slubprofileaccount_domain_model_searchquery ( + uid int(11) unsigned DEFAULT 0 NOT NULL auto_increment, + pid int(11) DEFAULT 0 NOT NULL, + + title varchar(255) NOT NULL, + type varchar(255) NOT NULL, + user int(11) unsigned DEFAULT 0 NOT NULL, + query text, + + tstamp int(11) unsigned DEFAULT 0 NOT NULL, + crdate int(11) unsigned DEFAULT 0 NOT NULL, + deleted tinyint(4) unsigned DEFAULT 0 NOT NULL, + hidden tinyint(4) unsigned DEFAULT 0 NOT NULL, + sys_language_uid int(11) DEFAULT 0 NOT NULL, + l18n_parent int(11) DEFAULT 0 NOT NULL, + l18n_diffsource mediumblob NOT NULL, + fe_group int(11) DEFAULT 0 NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), +); + +# +# Table structure for table 'tx_slubprofileaccount_domain_model_user_mm' +# +CREATE TABLE tx_slubprofileaccount_domain_model_user_mm ( + uid int(11) AUTO_INCREMENT NOT NULL, + uid_local int(11) NOT NULL DEFAULT '0', + uid_foreign int(11) NOT NULL DEFAULT '0', + sorting int(11) NOT NULL DEFAULT '0', + sorting_foreign int(11) NOT NULL DEFAULT '0', + tablenames varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + + PRIMARY KEY (uid) +); From 641ac07c3f761c0d45af087157ea3ba9ca73b085 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 17 Jan 2022 13:23:00 +0100 Subject: [PATCH 20/81] [TASK] Refactor code; Add number of results; Reorganize user profile --- Classes/Domain/Model/SearchQuery.php | 17 ++++++ Classes/Service/DashboardService.php | 39 ++++++++++++++ Classes/Service/SearchQueryService.php | 52 +++++++++++++++++++ Classes/Service/UserDashboardService.php | 14 +++-- Classes/Service/UserSearchQueryService.php | 24 +++------ Configuration/Services.yaml | 3 ++ ...rofileaccount_domain_model_searchquery.php | 15 +++++- ...x_slubprofileaccount_domain_model_user.php | 11 ++-- Configuration/TsConfig/Page.tsconfig | 4 ++ .../Private/Language/de.locallang_db.xlf | 4 ++ .../Private/Language/de.locallang_tabs.xlf | 10 ++-- Resources/Private/Language/locallang_db.xlf | 3 ++ Resources/Private/Language/locallang_tabs.xlf | 7 ++- ext_tables.sql | 1 + 14 files changed, 168 insertions(+), 36 deletions(-) create mode 100644 Classes/Service/DashboardService.php create mode 100644 Classes/Service/SearchQueryService.php diff --git a/Classes/Domain/Model/SearchQuery.php b/Classes/Domain/Model/SearchQuery.php index 695df38..cb8af63 100644 --- a/Classes/Domain/Model/SearchQuery.php +++ b/Classes/Domain/Model/SearchQuery.php @@ -19,6 +19,7 @@ class SearchQuery extends AbstractEntity protected string $type = ''; protected string $query = ''; protected int $user = 0; + protected int $numberOfResults = 0; /** * @return string $title @@ -83,4 +84,20 @@ public function setUser(int $user): void { $this->user = $user; } + + /** + * @return int $numberOfResults + */ + public function getNumberOfResults(): int + { + return $this->numberOfResults; + } + + /** + * @param int $numberOfResults + */ + public function setNumberOfResults(int $numberOfResults): void + { + $this->numberOfResults = $numberOfResults; + } } diff --git a/Classes/Service/DashboardService.php b/Classes/Service/DashboardService.php new file mode 100644 index 0000000..355f030 --- /dev/null +++ b/Classes/Service/DashboardService.php @@ -0,0 +1,39 @@ +widgetSanitization = $widgetSanitization; + } + + /** + * @param array $widgets + * @return string + * @throws \JsonException + */ + public function setDashboardWidgets(array $widgets): string + { + $dashboardWidgets = $this->widgetSanitization->sanitize($widgets); + + return implode(',', $dashboardWidgets); + } +} diff --git a/Classes/Service/SearchQueryService.php b/Classes/Service/SearchQueryService.php new file mode 100644 index 0000000..2bdec01 --- /dev/null +++ b/Classes/Service/SearchQueryService.php @@ -0,0 +1,52 @@ +getTitle($query['query']); + + $searchQuery->setType($query['type']); + $searchQuery->setNumberOfResults((int)$query['numberOfResults']); + $searchQuery->setQuery(json_encode($query['query'], JSON_THROW_ON_ERROR)); + $searchQuery->setTitle($title); + + return $searchQuery; + } + + /** + * @param array $query + * @return string + */ + public function getTitle(array $query): string + { + $titles = []; + + foreach ($query as $queryItem) { + $titles[] = $queryItem['input']; + } + + return implode(', ', $titles); + } +} diff --git a/Classes/Service/UserDashboardService.php b/Classes/Service/UserDashboardService.php index 011372e..0ae5240 100644 --- a/Classes/Service/UserDashboardService.php +++ b/Classes/Service/UserDashboardService.php @@ -20,31 +20,30 @@ use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; class UserDashboardService { protected AccountService $accountService; + protected DashboardService $dashboardService; protected PersistenceManager $persistenceManager; protected UserRepository $userRepository; - protected WidgetSanitization $widgetSanitization; /** * @param AccountService $accountService + * @param DashboardService $dashboardService * @param PersistenceManager $persistenceManager * @param UserRepository $userRepository - * @param WidgetSanitization $widgetSanitization */ public function __construct( AccountService $accountService, + DashboardService $dashboardService, PersistenceManager $persistenceManager, - UserRepository $userRepository, - WidgetSanitization $widgetSanitization + UserRepository $userRepository ) { $this->accountService = $accountService; + $this->dashboardService = $dashboardService; $this->persistenceManager = $persistenceManager; $this->userRepository = $userRepository; - $this->widgetSanitization = $widgetSanitization; } /** @@ -79,8 +78,7 @@ public function updateUser(User $user): User if (is_array($data['widgets'])) { $hasChanges = true; - $dashboardWidgets = $this->widgetSanitization->sanitize($data['widgets']); - $dashboardWidgets = implode(',', $dashboardWidgets); + $dashboardWidgets = $this->dashboardService->setDashboardWidgets($data['widgets']); $user->setDashboardWidgets($dashboardWidgets); } diff --git a/Classes/Service/UserSearchQueryService.php b/Classes/Service/UserSearchQueryService.php index 379fc89..54617d9 100644 --- a/Classes/Service/UserSearchQueryService.php +++ b/Classes/Service/UserSearchQueryService.php @@ -11,40 +11,37 @@ namespace Slub\SlubProfileAccount\Service; -use Slub\SlubProfileAccount\Domain\Model\SearchQuery; use Slub\SlubProfileAccount\Domain\Model\User\SearchQuery as User; use Slub\SlubProfileAccount\Domain\Repository\User\SearchQueryRepository as UserRepository; -use Slub\SlubProfileAccount\Sanitization\WidgetSanitization; use Slub\SlubProfileAccount\Utility\FileUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; use TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; class UserSearchQueryService { protected AccountService $accountService; protected PersistenceManager $persistenceManager; + protected SearchQueryService $searchQueryService; protected UserRepository $userRepository; -protected WidgetSanitization $widgetSanitization; /** * @param AccountService $accountService * @param PersistenceManager $persistenceManager + * @param SearchQueryService $searchQueryService * @param UserRepository $userRepository - * @param WidgetSanitization $widgetSanitization */ public function __construct( AccountService $accountService, PersistenceManager $persistenceManager, - UserRepository $userRepository, -WidgetSanitization $widgetSanitization + SearchQueryService $searchQueryService, + UserRepository $userRepository ) { $this->accountService = $accountService; + $this->searchQueryService = $searchQueryService; $this->persistenceManager = $persistenceManager; $this->userRepository = $userRepository; -$this->widgetSanitization = $widgetSanitization; } /** @@ -77,16 +74,9 @@ public function addUser(User $user): User $hasChanges = false; $data = FileUtility::getContent(); - if (is_array($data['searchQuery'])) { + if (count($data['searchQuery']['query']) > 0) { $hasChanges = true; - //$dashboardWidgets = $this->widgetSanitization->sanitize($data['widgets']); - - /** @var SearchQuery $searchQuery */ - $searchQuery = GeneralUtility::makeInstance(SearchQuery::class); - $searchQuery->setTitle($data['searchQuery']['query'][0]['input']); - $searchQuery->setType($data['searchQuery']['type']); - $searchQuery->setQuery(json_encode($data['searchQuery']['query'], JSON_THROW_ON_ERROR)); - + $searchQuery = $this->searchQueryService->setSearchQuery($data['searchQuery']); $user->addSearchQuery($searchQuery); } diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index ac49452..bf2827f 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -13,6 +13,9 @@ services: Slub\SlubProfileAccount\Service\AccountService: public: true + Slub\SlubProfileAccount\Service\DashboardService: + public: true + Slub\SlubProfileAccount\Service\UserAccountService: public: true diff --git a/Configuration/TCA/tx_slubprofileaccount_domain_model_searchquery.php b/Configuration/TCA/tx_slubprofileaccount_domain_model_searchquery.php index 21bb227..30c3a2d 100644 --- a/Configuration/TCA/tx_slubprofileaccount_domain_model_searchquery.php +++ b/Configuration/TCA/tx_slubprofileaccount_domain_model_searchquery.php @@ -38,7 +38,7 @@ 'translationSource' => 'l10n_source', 'origUid' => 't3_origuid', 'versioningWS' => true, - 'searchFields' => 'title, type, query, user', + 'searchFields' => 'title, type, query, number_of_results, user', 'typeicon_classes' => [ 'default' => 'slubprofileaccount-model-searchquery' ], @@ -47,7 +47,7 @@ '0' => [ 'showitem' => ' --div--;' . $ll['core']['tabs'] . ':general, - title, type, query, user, + title, type, query, number_of_results, user, --div--;' . $ll['core']['tabs'] . ':language, --palette--;;language, --div--;' . $ll['core']['tabs'] . ':access, @@ -182,6 +182,7 @@ 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_searchquery.type', 'config' => [ 'type' => 'input', + 'eval' => 'trim,required', ] ], 'query' => [ @@ -193,6 +194,16 @@ 'type' => 'text', 'rows' => 5, 'cols' => 30, + 'eval' => 'trim,required', + ] + ], + 'number_of_results' => [ + 'exclude' => true, + 'l10n_mode' => 'prefixLangTitle', + 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_searchquery.numberOfResults', + 'config' => [ + 'type' => 'input', + 'eval' => 'trim,int,required', ] ], 'user' => [ diff --git a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php index fe893b9..6d1b090 100644 --- a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php +++ b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php @@ -48,9 +48,11 @@ '0' => [ 'showitem' => ' --div--;' . $ll['core']['tabs'] . ':general, - dashboard_widgets, search_query, - --div--;' . $ll['slubProfileAccount']['tabs'] . ':account, account_id, account_overview, + --div--;' . $ll['slubProfileAccount']['tabs'] . ':dashboard, + dashboard_widgets, + --div--;' . $ll['slubProfileAccount']['tabs'] . ':searchQuery, + search_query, --div--;' . $ll['core']['tabs'] . ':language, --palette--;;language, --div--;' . $ll['core']['tabs'] . ':access, @@ -206,9 +208,10 @@ 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user.search_query', 'config' => [ 'type' => 'inline', - 'foreign_field' => 'uid_foreign', + 'foreign_field' => 'user', 'foreign_table' => 'tx_slubprofileaccount_domain_model_searchquery', - 'foreign_table_where' => 'AND tx_slubprofileaccount_domain_model_searchquery.sys_language_uid IN (-1,0) AND tx_slubprofileaccount_domain_model_searchquery.hidden = 0 AND tx_slubprofileaccount_domain_model_searchquery.deleted = 0 ORDER BY tx_slubprofileaccount_domain_model_searchquery.sorting', + 'foreign_table_where' => 'AND tx_slubprofileaccount_domain_model_searchquery.sys_language_uid IN (-1,0) AND tx_slubprofileaccount_domain_model_searchquery.hidden = 0 AND tx_slubprofileaccount_domain_model_searchquery.deleted = 0', + 'foreign_sortby' => 'sorting', 'MM' => 'tx_slubprofileaccount_domain_model_user_mm', 'MM_match_fields' => [ 'tablenames' => 'tx_slubprofileaccount_domain_model_searchquery' diff --git a/Configuration/TsConfig/Page.tsconfig b/Configuration/TsConfig/Page.tsconfig index 0a4496c..2d94dd9 100644 --- a/Configuration/TsConfig/Page.tsconfig +++ b/Configuration/TsConfig/Page.tsconfig @@ -39,4 +39,8 @@ mod { show := addToList(slubprofileaccount_useraccountdetail, slubprofileaccount_userdashboardupdate, slubprofileaccount_userdashboarddetail, slubprofileaccount_usersearchqueryadd) } + + web_list.tableDisplayOrder { + tx_slubprofileaccount_domain_model_user.before = tx_slubprofileaccount_domain_model_searchquery + } } diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 0ca1311..44a1899 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -49,6 +49,10 @@ Query Anfrage + + Number of results + Anzahl der Ergebnisse + User Benutzer diff --git a/Resources/Private/Language/de.locallang_tabs.xlf b/Resources/Private/Language/de.locallang_tabs.xlf index 851877e..3bbfc63 100644 --- a/Resources/Private/Language/de.locallang_tabs.xlf +++ b/Resources/Private/Language/de.locallang_tabs.xlf @@ -3,9 +3,13 @@
- - Account - Konto + + Dashboard + Dashboard + + + Search query + Suchanfragen diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 22d227c..81f84d1 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -40,6 +40,9 @@ Query + + Number of results + User diff --git a/Resources/Private/Language/locallang_tabs.xlf b/Resources/Private/Language/locallang_tabs.xlf index c40cee2..afd9adb 100644 --- a/Resources/Private/Language/locallang_tabs.xlf +++ b/Resources/Private/Language/locallang_tabs.xlf @@ -3,8 +3,11 @@
- - Account + + Dashboard + + + Search query diff --git a/ext_tables.sql b/ext_tables.sql index 61d5670..8bf330c 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -33,6 +33,7 @@ CREATE TABLE tx_slubprofileaccount_domain_model_searchquery ( type varchar(255) NOT NULL, user int(11) unsigned DEFAULT 0 NOT NULL, query text, + number_of_results int(11) unsigned DEFAULT 0 NOT NULL, tstamp int(11) unsigned DEFAULT 0 NOT NULL, crdate int(11) unsigned DEFAULT 0 NOT NULL, From 3390af4334f52fc8d112bf0352afccb4e693a05e Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 17 Jan 2022 13:34:24 +0100 Subject: [PATCH 21/81] [TASK] Optimize code quality --- Classes/Mvc/View/JsonView.php | 2 -- Classes/Service/UserDashboardService.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index c1c26c9..5ee91a5 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -11,9 +11,7 @@ namespace Slub\SlubProfileAccount\Mvc\View; -use Slub\SlubProfileAccount\Domain\Model\User\Dashboard; use TYPO3\CMS\Extbase\Mvc\View\JsonView as ExtbaseJsonView; -use TYPO3\CMS\Extbase\Persistence\ObjectStorage; class JsonView extends ExtbaseJsonView { diff --git a/Classes/Service/UserDashboardService.php b/Classes/Service/UserDashboardService.php index 0ae5240..c6e8f63 100644 --- a/Classes/Service/UserDashboardService.php +++ b/Classes/Service/UserDashboardService.php @@ -12,9 +12,7 @@ namespace Slub\SlubProfileAccount\Service; use Slub\SlubProfileAccount\Domain\Model\User\Dashboard as User; -use Slub\SlubProfileAccount\Domain\Repository\User\DashboardRepository; use Slub\SlubProfileAccount\Domain\Repository\User\DashboardRepository as UserRepository; -use Slub\SlubProfileAccount\Sanitization\WidgetSanitization; use Slub\SlubProfileAccount\Utility\FileUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; From 522198ad612031f00d232606844e22e24e92d729 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 17 Jan 2022 13:53:42 +0100 Subject: [PATCH 22/81] [TASK] Optimize code; Make even with dashboard --- Classes/Controller/UserSearchQueryController.php | 4 ++-- Classes/Service/UserSearchQueryService.php | 2 +- Configuration/Icons.php | 4 ++-- Configuration/Routes/Default.yaml | 2 +- ...earchQueryAdd.yaml => UserSearchQueryUpdate.yaml} | 4 ++-- Configuration/TCA/Overrides/tt_content.php | 2 +- Configuration/TsConfig/Page.tsconfig | 12 ++++++------ Resources/Private/Language/de.locallang_backend.xlf | 12 ++++++------ Resources/Private/Language/locallang_backend.xlf | 8 ++++---- ...ch-query-add.svg => user-search-query-update.svg} | 0 ext_localconf.php | 8 ++++---- 11 files changed, 29 insertions(+), 29 deletions(-) rename Configuration/Routes/{UserSearchQueryAdd.yaml => UserSearchQueryUpdate.yaml} (58%) rename Resources/Public/Icons/Wizard/{user-search-query-add.svg => user-search-query-update.svg} (100%) diff --git a/Classes/Controller/UserSearchQueryController.php b/Classes/Controller/UserSearchQueryController.php index f73c2aa..45c2bfb 100644 --- a/Classes/Controller/UserSearchQueryController.php +++ b/Classes/Controller/UserSearchQueryController.php @@ -42,9 +42,9 @@ public function __construct(UserService $userService) * @throws UnknownObjectException * @throws \JsonException */ - public function addAction(): ResponseInterface + public function updateAction(): ResponseInterface { - $user = $this->userService->addUser($this->user); + $user = $this->userService->updateUser($this->user); $status = $user instanceof User ? 200 : 500; $this->view->setVariablesToRender(['status']); diff --git a/Classes/Service/UserSearchQueryService.php b/Classes/Service/UserSearchQueryService.php index 54617d9..ac43661 100644 --- a/Classes/Service/UserSearchQueryService.php +++ b/Classes/Service/UserSearchQueryService.php @@ -69,7 +69,7 @@ public function getUser(array $arguments): ?User * @throws UnknownObjectException * @throws \JsonException */ - public function addUser(User $user): User + public function updateUser(User $user): User { $hasChanges = false; $data = FileUtility::getContent(); diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 23e017c..ce3018d 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -31,8 +31,8 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-update.svg' ], - 'slubprofileaccount-wizard-usersearchqueryadd' => [ + 'slubprofileaccount-wizard-usersearchqueryupdate' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-search-query-add.svg' + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-search-query-update.svg' ], ]; diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index 0a0cea6..4955106 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -4,4 +4,4 @@ imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserAccountDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardUpdate.yaml' - - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryAdd.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryUpdate.yaml' diff --git a/Configuration/Routes/UserSearchQueryAdd.yaml b/Configuration/Routes/UserSearchQueryUpdate.yaml similarity index 58% rename from Configuration/Routes/UserSearchQueryAdd.yaml rename to Configuration/Routes/UserSearchQueryUpdate.yaml index e560cee..775e7af 100644 --- a/Configuration/Routes/UserSearchQueryAdd.yaml +++ b/Configuration/Routes/UserSearchQueryUpdate.yaml @@ -1,9 +1,9 @@ routeEnhancers: - SlubAccountUserSearchQueryAdd: + SlubAccountUserSearchQueryUpdate: type: Simple limitToPages: [17] routePath: '/{user}' requirements: user: '[0-9]{1,10}' _arguments: - user: 'tx_slubprofileaccount_usersearchqueryadd/user' + user: 'tx_slubprofileaccount_usersearchqueryupdate/user' diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 8d2f5f4..7c747a9 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -59,5 +59,5 @@ } })( 'slub_profile_account', - ['useraccountdetail', 'userdashboarddetail', 'userdashboardupdate', 'usersearchqueryadd'] + ['useraccountdetail', 'userdashboarddetail', 'userdashboardupdate', 'usersearchqueryupdate'] ); diff --git a/Configuration/TsConfig/Page.tsconfig b/Configuration/TsConfig/Page.tsconfig index 2d94dd9..f4b3158 100644 --- a/Configuration/TsConfig/Page.tsconfig +++ b/Configuration/TsConfig/Page.tsconfig @@ -28,16 +28,16 @@ mod { tt_content_defValues.CType = slubprofileaccount_userdashboardupdate } - slubprofileaccount_usersearchqueryadd { - iconIdentifier = slubprofileaccount-wizard-usersearchqueryadd + slubprofileaccount_usersearchqueryupdate { + iconIdentifier = slubprofileaccount-wizard-usersearchqueryupdate iconOverlay = slubprofileaccount-overlay-extension - title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.usersearchqueryadd.title - description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.usersearchqueryadd.description - tt_content_defValues.CType = slubprofileaccount_usersearchqueryadd + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.usersearchqueryupdate.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.usersearchqueryupdate.description + tt_content_defValues.CType = slubprofileaccount_usersearchqueryupdate } } - show := addToList(slubprofileaccount_useraccountdetail, slubprofileaccount_userdashboardupdate, slubprofileaccount_userdashboarddetail, slubprofileaccount_usersearchqueryadd) + show := addToList(slubprofileaccount_useraccountdetail, slubprofileaccount_userdashboardupdate, slubprofileaccount_userdashboarddetail, slubprofileaccount_usersearchqueryupdate) } web_list.tableDisplayOrder { diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index f2682dd..8ecea86 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -40,13 +40,13 @@ Daten einer Dashboardeinstellung eines Benutzers aktualisieren. - - User search query - add - Benutzersuchanfrage - hinzufügen + + User search query - update + Benutzersuchanfrage - aktualisieren - - Add data of user search to user. - Daten einer Benutzersuchanfrage dem Benutzer hinzufügen. + + Update data of user search to user. + Daten einer Benutzersuchanfrage dem Benutzer aktualisieren. + + + Code + Code + diff --git a/Resources/Private/Language/de.locallang_tabs.xlf b/Resources/Private/Language/de.locallang_tabs.xlf index 62ec923..89e2235 100644 --- a/Resources/Private/Language/de.locallang_tabs.xlf +++ b/Resources/Private/Language/de.locallang_tabs.xlf @@ -3,6 +3,10 @@
+ + Account + Konto + Dashboard Dashboard diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 21c6ec2..e24f3ef 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -14,6 +14,9 @@ Account ID + + User category description + Account overview @@ -49,6 +52,14 @@ User + + + + + Code + diff --git a/Resources/Private/Language/locallang_tabs.xlf b/Resources/Private/Language/locallang_tabs.xlf index 0c21bcc..758e067 100644 --- a/Resources/Private/Language/locallang_tabs.xlf +++ b/Resources/Private/Language/locallang_tabs.xlf @@ -3,6 +3,9 @@
+ + Account + Dashboard diff --git a/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html b/Resources/Private/Partials/Backend/Form/Element/AccountOverviewItems.html similarity index 96% rename from Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html rename to Resources/Private/Partials/Backend/Form/Element/AccountOverviewItems.html index 512271c..86dc496 100644 --- a/Resources/Private/Partials/Backend/Form/Element/AccountDataItems.html +++ b/Resources/Private/Partials/Backend/Form/Element/AccountOverviewItems.html @@ -20,7 +20,7 @@
Date: Wed, 22 Jun 2022 14:15:48 +0200 Subject: [PATCH 40/81] [TASK] Refresh api documentation --- postman_collection.json | 62 +++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/postman_collection.json b/postman_collection.json index ce79e8e..9c1fa92 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -9,7 +9,7 @@ "name": "Account", "item": [ { - "name": "Get", + "name": "Get - Default", "request": { "method": "GET", "header": [], @@ -48,28 +48,66 @@ } ] }, + { + "name": "Get - English", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}/en/user/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "en", + "user", + "{{user}}" + ] + } + }, + "response": [ + { + "name": "Unknown user", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}/benutzer/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "{{user}}" + ] + } + }, + "_postman_previewlanguage": "json", + "header": null, + "cookie": [], + "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" + } + ] + }, { "name": "Update", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { - "method": "POST", + "method": "GET", "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"account\": {\r\n \"EmailAddress\": \"heike.suetterlin@slub-dresden.de\",\r\n \"PostalAddress1\": \"\",\r\n \"PostalAddress2\": \"\",\r\n \"PostalCity\": \"\",\r\n \"PostalPostCode\": \"\",\r\n \"PostalCountry\": \"\",\r\n \"ResAddress1\": \"\",\r\n \"ResAddress2\": \"\",\r\n \"ResAddressCity\": \"\",\r\n \"ResAddressPostCode\": \"\",\r\n \"ResAddressCountry\": \"\"\r\n }\r\n}", - "options": { - "raw": { - "language": "json" - } - } + "raw": "{\r\n \"account\": {\r\n \"EmailAddress\": \"heike.suetterlin@slub-dresden.de\",\r\n \"PostalAddress1\": \"\",\r\n \"PostalAddress2\": \"\",\r\n \"PostalCity\": \"Berlin\",\r\n \"PostalPostCode\": \"12345\",\r\n \"PostalCountry\": \"\",\r\n \"ResAddress1\": \"\",\r\n \"ResAddress2\": \"\",\r\n \"ResAddressCity\": \"\",\r\n \"ResAddressPostCode\": \"\",\r\n \"ResAddressCountry\": \"\"\r\n }\r\n}" }, "url": { - "raw": "{{domain}}/benutzer/aktualisieren/{{user}}", + "raw": "{{domain}}/benutzer/{{user}}", "host": [ "{{domain}}" ], "path": [ "benutzer", - "aktualisieren", "{{user}}" ] } @@ -109,7 +147,7 @@ "name": "Dashboard", "item": [ { - "name": "Get", + "name": "Get - Default", "request": { "method": "GET", "header": [], @@ -162,7 +200,7 @@ "name": "Search query", "item": [ { - "name": "Get", + "name": "Get - Default", "request": { "method": "GET", "header": [], From bae30befbb8c5ddb3304d0285714b33c90a6d2e6 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 27 Jun 2022 10:37:02 +0200 Subject: [PATCH 41/81] [TASK] Refresh postman --- postman_collection.json | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/postman_collection.json b/postman_collection.json index 9c1fa92..4a4655e 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "b4dcb360-8cf5-4df6-85a3-65cc2d896e92", + "_postman_id": "ce58ca83-8870-485e-b3d9-4458316539c2", "name": "SLUB - Profile Service - Account (slub_profile_account)", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -42,7 +42,7 @@ } }, "_postman_previewlanguage": "json", - "header": null, + "header": [], "cookie": [], "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" } @@ -83,7 +83,7 @@ } }, "_postman_previewlanguage": "json", - "header": null, + "header": [], "cookie": [], "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" } @@ -91,23 +91,21 @@ }, { "name": "Update", - "protocolProfileBehavior": { - "disableBodyPruning": true - }, "request": { - "method": "GET", + "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\r\n \"account\": {\r\n \"EmailAddress\": \"heike.suetterlin@slub-dresden.de\",\r\n \"PostalAddress1\": \"\",\r\n \"PostalAddress2\": \"\",\r\n \"PostalCity\": \"Berlin\",\r\n \"PostalPostCode\": \"12345\",\r\n \"PostalCountry\": \"\",\r\n \"ResAddress1\": \"\",\r\n \"ResAddress2\": \"\",\r\n \"ResAddressCity\": \"\",\r\n \"ResAddressPostCode\": \"\",\r\n \"ResAddressCountry\": \"\"\r\n }\r\n}" }, "url": { - "raw": "{{domain}}/benutzer/{{user}}", + "raw": "{{domain}}/benutzer/aktualisieren/{{user}}", "host": [ "{{domain}}" ], "path": [ "benutzer", + "aktualisieren", "{{user}}" ] } @@ -135,7 +133,7 @@ } }, "_postman_previewlanguage": "json", - "header": null, + "header": [], "cookie": [], "body": "{\n \"code\": 400,\n \"message\": \"Bad Request\",\n \"error\": {\n \"EmailAddress\": {\n \"code\": \"is_invalid\",\n \"message\": \"This field is invalid\"\n }\n }\n}" } From 255ac9618ab600d2d1f3c92e5ed86d93416a9775 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 8 Aug 2022 13:04:33 -0500 Subject: [PATCH 42/81] [BUGFIX] Postman has a wrong url set for get user data --- postman_collection.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/postman_collection.json b/postman_collection.json index 4a4655e..2a0fc3a 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -10,9 +10,16 @@ "item": [ { "name": "Get - Default", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, "request": { "method": "GET", "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"account\": {\r\n \"EmailAddress\": \"heike.suetterlin@slub-dresden.de\",\r\n \"PostalAddress1\": \"\",\r\n \"PostalAddress2\": \"\",\r\n \"PostalCity\": \"Berlin\",\r\n \"PostalPostCode\": \"12345\",\r\n \"PostalCountry\": \"\",\r\n \"ResAddress1\": \"\",\r\n \"ResAddress2\": \"\",\r\n \"ResAddressCity\": \"\",\r\n \"ResAddressPostCode\": \"\",\r\n \"ResAddressCountry\": \"\"\r\n }\r\n}" + }, "url": { "raw": "{{domain}}/benutzer/{{user}}", "host": [ @@ -309,4 +316,4 @@ "type": "default" } ] -} \ No newline at end of file +} From 44372c07ead2101b2c0e74903b7e2df092374ac6 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 28 Jun 2022 15:54:35 +0200 Subject: [PATCH 43/81] [FEATURE] Password api --- Classes/Controller/UserPasswordController.php | 70 +++++++++++++++++++ Classes/Domain/Model/Dto/ApiConfiguration.php | 21 +++++- Classes/Service/PasswordService.php | 70 +++++++++++++++++++ Configuration/Icons.php | 4 ++ Configuration/Routes/Default.yaml | 1 + Configuration/Routes/UserPasswordUpdate.yaml | 9 +++ Configuration/Services.yaml | 3 + Configuration/TCA/Overrides/tt_content.php | 1 + Configuration/TsConfig/Page/mod.tsconfig | 16 ++++- Configuration/TypoScript/constants.typoscript | 8 ++- Configuration/TypoScript/setup.typoscript | 6 +- .../Private/Language/de.locallang_backend.xlf | 9 +++ .../Private/Language/locallang_backend.xlf | 7 ++ .../Icons/Wizard/user-password-update.svg | 7 ++ ext_localconf.php | 14 ++++ 15 files changed, 239 insertions(+), 7 deletions(-) create mode 100644 Classes/Controller/UserPasswordController.php create mode 100644 Classes/Service/PasswordService.php create mode 100644 Configuration/Routes/UserPasswordUpdate.yaml create mode 100644 Resources/Public/Icons/Wizard/user-password-update.svg diff --git a/Classes/Controller/UserPasswordController.php b/Classes/Controller/UserPasswordController.php new file mode 100644 index 0000000..d6ae07a --- /dev/null +++ b/Classes/Controller/UserPasswordController.php @@ -0,0 +1,70 @@ +passwordService = $passwordService; + $this->userService = $userService; + } + + /** + * @return ResponseInterface + * @throws \JsonException + */ + public function updateAction(): ResponseInterface + { + $status = $this->passwordService->update($this->user); + + $this->view->setVariablesToRender(['status']); + $this->view->assign('status', $status); + + return $this->jsonResponse(); + } + + /** + * @throws Exception + */ + protected function initializeAction(): void + { + try { + $this->user = $this->userService->getUser( + $this->request->getArguments() + ); + } catch (IllegalObjectTypeException $e) { + throw new Exception($e->getMessage()); + } + } +} diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index 5e87199..d65bb87 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -15,16 +15,15 @@ class ApiConfiguration { - /** - * @var string - */ protected string $userUri = ''; + protected string $passwordUpdateUri = ''; public function __construct() { $settings = SettingsUtility::getPluginSettings(); $this->setUserUri($settings['api']['path']['user']); + $this->setPasswordUpdateUri($settings['api']['path']['passwordUpdate']); } /** @@ -42,4 +41,20 @@ public function setUserUri(string $userUri = ''): void { $this->userUri = $userUri; } + + /** + * @return string + */ + public function getPasswordUpdateUri(): string + { + return $this->passwordUpdateUri; + } + + /** + * @param string $passwordUpdateUri + */ + public function setPasswordUpdateUri(string $passwordUpdateUri = ''): void + { + $this->passwordUpdateUri = $passwordUpdateUri; + } } diff --git a/Classes/Service/PasswordService.php b/Classes/Service/PasswordService.php new file mode 100644 index 0000000..2899a97 --- /dev/null +++ b/Classes/Service/PasswordService.php @@ -0,0 +1,70 @@ +apiConfiguration = $apiConfiguration; + $this->request = $request; + } + + /** + * @param User $user + * @return array + * @throws \JsonException + */ + public function update(User $user): array + { + $accountId = $user->getAccountId(); + $data = FileUtility::getContent()['password']; + + if ($data === null) { + return ApiUtility::STATUS[400]; + } + + $uri = $this->apiConfiguration->getPasswordUpdateUri(); + $uri = ApiUtility::replaceUriPlaceholder([$accountId], $uri); + + $processed = $this->request->process($uri, 'POST', [ + 'body' => json_encode([ + 'new_password' => $data['newPassword'], + 'patron' => (string)$accountId + ]) + ]); +DebuggerUtility::var_dump($uri); +DebuggerUtility::var_dump($processed); +exit(); + if ($processed['status'] === 1) { + return ApiUtility::STATUS[200]; + } + + return ApiUtility::STATUS[500]; + } +} diff --git a/Configuration/Icons.php b/Configuration/Icons.php index c94502c..6e41c6f 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -35,6 +35,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-update.svg' ], + 'slubprofileaccount-wizard-userpasswordupdate' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-password-update.svg' + ], 'slubprofileaccount-wizard-usersearchquerydetail' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-search-query-detail.svg' diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index 3671ae0..2d91de9 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -5,5 +5,6 @@ imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserAccountUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardUpdate.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPasswordUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryUpdate.yaml' diff --git a/Configuration/Routes/UserPasswordUpdate.yaml b/Configuration/Routes/UserPasswordUpdate.yaml new file mode 100644 index 0000000..9c568f5 --- /dev/null +++ b/Configuration/Routes/UserPasswordUpdate.yaml @@ -0,0 +1,9 @@ +routeEnhancers: + SlubAccountUserPasswordUpdate: + type: Simple + limitToPages: [28] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userpasswordupdate/user' diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index a5292f0..101d03d 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -29,6 +29,9 @@ services: Slub\SlubProfileAccount\Service\UserDashboardService: public: true + Slub\SlubProfileAccount\Service\UserPasswordService: + public: true + Slub\SlubProfileAccount\Service\UserSearchQueryService: public: true diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 500117e..605f6bb 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -63,6 +63,7 @@ 'useraccountupdate', 'userdashboarddetail', 'userdashboardupdate', + 'userpasswordupdate', 'usersearchquerydetail', 'usersearchqueryupdate' ] diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index b600c7f..6ae2c80 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -36,6 +36,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_userdashboardupdate } + slubprofileaccount_userpasswordupdate { + iconIdentifier = slubprofileaccount-wizard-userpasswordupdate + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userpasswordupdate.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userpasswordupdate.description + tt_content_defValues.CType = slubprofileaccount_userpasswordupdate + } + slubprofileaccount_usersearchquerydetail { iconIdentifier = slubprofileaccount-wizard-usersearchquerydetail iconOverlay = slubprofileaccount-overlay-extension @@ -53,7 +61,13 @@ mod { } } - show := addToList(slubprofileaccount_useraccountdetail, slubprofileaccount_useraccountupdate, slubprofileaccount_userdashboardupdate, slubprofileaccount_userdashboarddetail, slubprofileaccount_usersearchqueryupdate, slubprofileaccount_usersearchquerydetail) + show := addToList(slubprofileaccount_useraccountdetail) + show := addToList(slubprofileaccount_useraccountupdate) + show := addToList(slubprofileaccount_userdashboardupdate) + show := addToList(slubprofileaccount_userdashboarddetail) + show := addToList(slubprofileaccount_userpasswordupdate) + show := addToList(slubprofileaccount_usersearchqueryupdate) + show := addToList(slubprofileaccount_usersearchquerydetail) } web_list.tableDisplayOrder { diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 52457f2..efbc024 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -5,8 +5,12 @@ plugin.tx_slubprofileaccount { persistence.storagePid = 14 settings { - # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for user - api.path.user = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID### + api.path { + # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for user + user = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID### + # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for update password + passwordUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/change + } # cat=plugin.tx_slubprofileaccount/76595003_Cache/100; type=int; label=Life time account cache in seconds cache.account.lifeTime = 3600 diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index efe32a7..7d80e6f 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -8,7 +8,11 @@ plugin.tx_slubprofileaccount { persistence.storagePid = {$plugin.tx_slubprofileaccount.persistence.storagePid} settings { - api.path.user = {$plugin.tx_slubprofileaccount.settings.api.path.user} + api.path { + user = {$plugin.tx_slubprofileaccount.settings.api.path.user} + passwordUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.passwordUpdate} + } + cache.account.lifeTime = {$plugin.tx_slubprofileaccount.settings.cache.account.lifeTime} } } diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 21eac2f..db67b95 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -49,6 +49,15 @@ Daten der Dashboardeinstellung eines Benutzers aktualisieren. + + Update password + Passwort aktualisieren + + + Update the password of a specific user. + Das Passwort eines spezifischen Benutzers aktualisieren. + + User detail (constraint: search query) Details eines Benutzers (Einschränkung: Suchanfrage) diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index b8df67c..54b11fd 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -40,6 +40,13 @@ Update data of dashboard user. + + Update password + + + Update the password of a specific user. + + User detail (constraint: search query) diff --git a/Resources/Public/Icons/Wizard/user-password-update.svg b/Resources/Public/Icons/Wizard/user-password-update.svg new file mode 100644 index 0000000..6a4a32b --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-password-update.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index 858344b..35999b5 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,6 +2,7 @@ use Slub\SlubProfileAccount\Controller\UserAccountController; use Slub\SlubProfileAccount\Controller\UserDashboardController; +use Slub\SlubProfileAccount\Controller\UserPasswordController; use Slub\SlubProfileAccount\Controller\UserSearchQueryController; use Slub\SlubProfileAccount\Form\Element\AccountOverviewElement; use Slub\SlubProfileAccount\Form\Element\UserCategoryDescriptionElement; @@ -41,6 +42,19 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); +// Configure plugin - user password update +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserPasswordUpdate', + [ + UserPasswordController::class => 'update' + ], + [ + UserPasswordController::class => 'update' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user dashboard detail ExtensionUtility::configurePlugin( 'SlubProfileAccount', From 6e1fbf3c16f63ff352d3b2ab731efb70c2feb98b Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 28 Jun 2022 15:57:28 +0200 Subject: [PATCH 44/81] [POSTMAN] Add page for update password --- postman_collection.json | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/postman_collection.json b/postman_collection.json index 2a0fc3a..14560e5 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "ce58ca83-8870-485e-b3d9-4458316539c2", + "_postman_id": "8b8facb3-ab8d-4f06-980d-531159a5714b", "name": "SLUB - Profile Service - Account (slub_profile_account)", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -99,7 +99,7 @@ { "name": "Update", "request": { - "method": "POST", + "method": "PATCH", "header": [], "body": { "mode": "raw", @@ -282,6 +282,40 @@ "response": [] } ] + }, + { + "name": "Password", + "item": [ + { + "name": "Update", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"password\": {\r\n \"newPassword\": \"test\",\r\n \"patron\": \"4998866\"\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{domain}}/benutzer/passwort/aktualisieren/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "passwort", + "aktualisieren", + "{{user}}" + ] + } + }, + "response": [] + } + ] } ], "event": [ From e96270fdc4546ad8168f533bc7026b3c4f15a9c8 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 4 Jul 2022 12:16:56 +0200 Subject: [PATCH 45/81] [TASK] Code clean up --- Classes/Service/PasswordService.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Classes/Service/PasswordService.php b/Classes/Service/PasswordService.php index 2899a97..2286d8d 100644 --- a/Classes/Service/PasswordService.php +++ b/Classes/Service/PasswordService.php @@ -13,10 +13,9 @@ use Slub\SlubProfileAccount\Domain\Model\Dto\ApiConfiguration; use Slub\SlubProfileAccount\Domain\Model\User\Account as User; +use Slub\SlubProfileAccount\Http\Request; use Slub\SlubProfileAccount\Utility\ApiUtility; use Slub\SlubProfileAccount\Utility\FileUtility; -use Slub\SlubProfileEvents\Http\Request; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; class PasswordService { @@ -58,9 +57,7 @@ public function update(User $user): array 'patron' => (string)$accountId ]) ]); -DebuggerUtility::var_dump($uri); -DebuggerUtility::var_dump($processed); -exit(); + if ($processed['status'] === 1) { return ApiUtility::STATUS[200]; } From eb3445a389c106a8299f90c46ce692d6f76d8845 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 22 Sep 2022 14:12:32 +0200 Subject: [PATCH 46/81] [TASK] Add required fields for account --- .../Validation/AccountArgumentValidation.php | 55 +++++++++++++++++-- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/Classes/Validation/AccountArgumentValidation.php b/Classes/Validation/AccountArgumentValidation.php index 1c73206..7f07ed4 100644 --- a/Classes/Validation/AccountArgumentValidation.php +++ b/Classes/Validation/AccountArgumentValidation.php @@ -15,20 +15,27 @@ class AccountArgumentValidation { + protected const REQUIRED_ARGUMENTS = [ + 'PostalAddress1', + 'PostalCity', + 'PostalPostCode', + 'PostalCountry' + ]; + /** * @param array $arguments * @return array */ public function validateUpdateArguments(array $arguments): array { - $error = []; - - if (isset($arguments['EmailAddress']) && empty($arguments['EmailAddress'])) { - $error['EmailAddress'] = ApiUtility::VALIDATION['isEmpty']; + if (count($arguments) === 0) { + return []; } - if (isset($arguments['EmailAddress']) && !filter_var($arguments['EmailAddress'], FILTER_VALIDATE_EMAIL)) { - $error['EmailAddress'] = ApiUtility::VALIDATION['isInvalid']; + $error = $this->isEmpty($arguments) ?? []; + + if (isset($arguments['EmailAddress'])) { + $error = array_merge($error, $this->validateEMail($arguments['EmailAddress'])); } if (count($error) > 0) { @@ -40,4 +47,40 @@ public function validateUpdateArguments(array $arguments): array return []; } + + /** + * @param string $email + * @return array + */ + private function validateEMail(string $email = ''): array + { + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + return [ + 'EmailAddress' => ApiUtility::VALIDATION['isInvalid'] + ]; + } + + return []; + } + + /** + * @param array $arguments + * @return array + */ + private function isEmpty(array $arguments): array + { + if (count($arguments) === 0) { + return []; + } + + $error = []; + + foreach ($arguments as $key => $value) { + if (in_array($key, self::REQUIRED_ARGUMENTS) && empty($value)) { + $error[$key] = ApiUtility::VALIDATION['isEmpty']; + } + } + + return $error; + } } From d006241cb5bfa01c06340359be22f3b3c83eb564 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 22 Sep 2022 14:14:57 +0200 Subject: [PATCH 47/81] [POSTMAN] Refresh config file --- postman_collection.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postman_collection.json b/postman_collection.json index 14560e5..01cce82 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -350,4 +350,4 @@ "type": "default" } ] -} +} \ No newline at end of file From e25ddc6e5d34b2657e1398983e734cfcc1a6aa12 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 26 Sep 2022 16:03:58 +0200 Subject: [PATCH 48/81] [FEATURE] Add pin api --- Classes/Controller/UserPasswordController.php | 12 +- Classes/Controller/UserPinController.php | 70 +++++++++ Classes/Domain/Model/Dto/ApiConfiguration.php | 36 +++++ ...ordService.php => UserPasswordService.php} | 2 +- Classes/Service/UserPinService.php | 77 +++++++++ Classes/Utility/ApiUtility.php | 19 ++- Classes/Validation/PinArgumentValidation.php | 146 ++++++++++++++++++ Configuration/Icons.php | 4 + Configuration/Routes/Default.yaml | 1 + Configuration/Routes/UserPinUpdate.yaml | 9 ++ Configuration/Services.yaml | 3 + Configuration/TCA/Overrides/tt_content.php | 1 + Configuration/TsConfig/Page/mod.tsconfig | 9 ++ Configuration/TypoScript/constants.typoscript | 6 +- Configuration/TypoScript/setup.typoscript | 2 + .../Private/Language/de.locallang_backend.xlf | 9 ++ .../Private/Language/locallang_backend.xlf | 7 + .../Public/Icons/Wizard/user-pin-update.svg | 6 + ext_localconf.php | 14 ++ 19 files changed, 422 insertions(+), 11 deletions(-) create mode 100644 Classes/Controller/UserPinController.php rename Classes/Service/{PasswordService.php => UserPasswordService.php} (98%) create mode 100644 Classes/Service/UserPinService.php create mode 100644 Classes/Validation/PinArgumentValidation.php create mode 100644 Configuration/Routes/UserPinUpdate.yaml create mode 100644 Resources/Public/Icons/Wizard/user-pin-update.svg diff --git a/Classes/Controller/UserPasswordController.php b/Classes/Controller/UserPasswordController.php index d6ae07a..b42cf2c 100644 --- a/Classes/Controller/UserPasswordController.php +++ b/Classes/Controller/UserPasswordController.php @@ -15,7 +15,7 @@ use Psr\Http\Message\ResponseInterface; use Slub\SlubProfileAccount\Domain\Model\User\Account as User; use Slub\SlubProfileAccount\Mvc\View\JsonView; -use Slub\SlubProfileAccount\Service\PasswordService; +use Slub\SlubProfileAccount\Service\UserPasswordService; use Slub\SlubProfileAccount\Service\UserAccountService as UserService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; @@ -25,18 +25,18 @@ class UserPasswordController extends ActionController protected $view; protected $defaultViewObjectName = JsonView::class; protected ?User $user; - protected PasswordService $passwordService; + protected UserPasswordService $userPasswordService; protected UserService $userService; /** - * @param PasswordService $passwordService + * @param UserPasswordService $userPasswordService * @param UserService $userService */ public function __construct( - PasswordService $passwordService, + UserPasswordService $userPasswordService, UserService $userService ) { - $this->passwordService = $passwordService; + $this->userPasswordService = $userPasswordService; $this->userService = $userService; } @@ -46,7 +46,7 @@ public function __construct( */ public function updateAction(): ResponseInterface { - $status = $this->passwordService->update($this->user); + $status = $this->userPasswordService->update($this->user); $this->view->setVariablesToRender(['status']); $this->view->assign('status', $status); diff --git a/Classes/Controller/UserPinController.php b/Classes/Controller/UserPinController.php new file mode 100644 index 0000000..9ecbf57 --- /dev/null +++ b/Classes/Controller/UserPinController.php @@ -0,0 +1,70 @@ +userPinService = $userPinService; + $this->userService = $userService; + } + + /** + * @return ResponseInterface + * @throws \JsonException + */ + public function updateAction(): ResponseInterface + { + $status = $this->userPinService->update($this->user); + + $this->view->setVariablesToRender(['status']); + $this->view->assign('status', $status); + + return $this->jsonResponse(); + } + + /** + * @throws Exception + */ + protected function initializeAction(): void + { + try { + $this->user = $this->userService->getUser( + $this->request->getArguments() + ); + } catch (IllegalObjectTypeException $e) { + throw new Exception($e->getMessage()); + } + } +} diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index d65bb87..0c1f800 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -15,15 +15,35 @@ class ApiConfiguration { + protected string $login = ''; protected string $userUri = ''; protected string $passwordUpdateUri = ''; + protected string $pinUpdateUri = ''; public function __construct() { $settings = SettingsUtility::getPluginSettings(); + $this->setLoginUri($settings['api']['path']['login']); $this->setUserUri($settings['api']['path']['user']); $this->setPasswordUpdateUri($settings['api']['path']['passwordUpdate']); + $this->setPinUpdateUri($settings['api']['path']['pinUpdate']); + } + + /** + * @return string + */ + public function getLoginUri(): string + { + return $this->login; + } + + /** + * @param string $loginUri + */ + public function setLoginUri(string $loginUri = ''): void + { + $this->login = $loginUri; } /** @@ -57,4 +77,20 @@ public function setPasswordUpdateUri(string $passwordUpdateUri = ''): void { $this->passwordUpdateUri = $passwordUpdateUri; } + + /** + * @return string + */ + public function getPinUpdateUri(): string + { + return $this->pinUpdateUri; + } + + /** + * @param string $pinUpdateUri + */ + public function setPinUpdateUri(string $pinUpdateUri = ''): void + { + $this->pinUpdateUri = $pinUpdateUri; + } } diff --git a/Classes/Service/PasswordService.php b/Classes/Service/UserPasswordService.php similarity index 98% rename from Classes/Service/PasswordService.php rename to Classes/Service/UserPasswordService.php index 2286d8d..87ba5ab 100644 --- a/Classes/Service/PasswordService.php +++ b/Classes/Service/UserPasswordService.php @@ -17,7 +17,7 @@ use Slub\SlubProfileAccount\Utility\ApiUtility; use Slub\SlubProfileAccount\Utility\FileUtility; -class PasswordService +class UserPasswordService { protected ApiConfiguration $apiConfiguration; protected Request $request; diff --git a/Classes/Service/UserPinService.php b/Classes/Service/UserPinService.php new file mode 100644 index 0000000..0d129c9 --- /dev/null +++ b/Classes/Service/UserPinService.php @@ -0,0 +1,77 @@ +apiConfiguration = $apiConfiguration; + $this->pinArgumentValidation = $pinArgumentValidation; + $this->request = $request; + } + + /** + * @param User $user + * @return array + * @throws \JsonException + */ + public function update(User $user): array + { + $accountId = $user->getAccountId(); + $data = FileUtility::getContent()['pin']; + + if ($data === null) { + return ApiUtility::STATUS[400]; + } + + $validated = $this->pinArgumentValidation->validateUpdateArguments($data, $accountId); + + if ($validated['code'] === 400) { + return $validated; + } + + $uri = $this->apiConfiguration->getPinUpdateUri(); + $uri = ApiUtility::replaceUriPlaceholder([$accountId], $uri); + + $processed = $this->request->process($uri, 'POST', [ + 'body' => json_encode([ + 'SelfCheckPin' => $data['pin'] + ]) + ]); + + if ($processed['status'] === 1) { + return ApiUtility::STATUS[200]; + } + + return ApiUtility::STATUS[500]; + } +} diff --git a/Classes/Utility/ApiUtility.php b/Classes/Utility/ApiUtility.php index 99b263c..3de47c1 100644 --- a/Classes/Utility/ApiUtility.php +++ b/Classes/Utility/ApiUtility.php @@ -31,12 +31,25 @@ class ApiUtility public const VALIDATION = [ 'isEmpty' => [ 'code' => 'is_empty', - 'message' => 'This field is required' + 'message' => 'This field is required.' ], 'isInvalid' => [ 'code' => 'is_invalid', - 'message' => 'This field is invalid' - ] + 'message' => 'This field is invalid.' + ], + 'isInvalidLogin' => [ + 'code' => 'is_invalid_login', + 'message' => 'This field is invalid.' + ], + 'isInvalidPin' => [ + 'code' => 'is_invalid_pin', + 'message' => 'This field is invalid', + 'info' => 'Only four numbers exactly.' + ], + 'isInvalidPinRepeat' => [ + 'code' => 'is_invalid_pin_repeat', + 'message' => 'This field is not even with pin.' + ], ]; public const URI_PLACEHOLDER = [ diff --git a/Classes/Validation/PinArgumentValidation.php b/Classes/Validation/PinArgumentValidation.php new file mode 100644 index 0000000..98e2229 --- /dev/null +++ b/Classes/Validation/PinArgumentValidation.php @@ -0,0 +1,146 @@ +isEmpty($arguments) ?? []; + + if (isset($arguments['password'])) { + $error = array_merge($error, $this->validatePassword((string)$accountId, $arguments['password'])); + } + + if (isset($arguments['pin'])) { + $error = array_merge($error, $this->validatePin('pin', $arguments['pin'])); + } + + if (isset($arguments['pinRepeat'])) { + $error = array_merge($error, $this->validatePin('pinRepeat', $arguments['pinRepeat'])); + } + + if (isset($arguments['pin']) && isset($arguments['pinRepeat']) && !isset($error['pinRepeat'])) { + $error = array_merge($error, $this->comparePins([$arguments['pin'], $arguments['pinRepeat']])); + } + + if (count($error) > 0) { + $status = ApiUtility::STATUS[400]; + $status['error'] = $error; + + return $status; + } + + return []; + } + + /** + * @param array $pins + * @return array + */ + private function comparePins(array $pins): array + { + if ($pins[0] !== $pins[1]) { + return [ + 'pinRepeat' => ApiUtility::VALIDATION['isInvalidPinRepeat'] + ]; + } + + return []; + } + + /** + * @param string $username + * @param string $password + * @return array + * @throws \JsonException + */ + private function validatePassword(string $username, string $password): array + { + $uri = GeneralUtility::makeInstance(ApiConfiguration::class) + ->getLoginUri(); + + $processed = GeneralUtility::makeInstance(Request::class) + ->process($uri, 'POST', [ + 'body' => json_encode([ + 'username' => $username, + 'password' => $password + ]) + ]); + + if ($processed['code'] !== 200) { + return [ + 'password' => ApiUtility::VALIDATION['isInvalidLogin'] + ]; + } + + return []; + } + + /** + * @param string $field + * @param string $pin + * @return array + */ + private function validatePin(string $field, string $pin = ''): array + { + if (strlen($pin) !== 4) { + return [ + $field => ApiUtility::VALIDATION['isInvalidPin'] + ]; + } + + return []; + } + + /** + * @param array $arguments + * @return array + */ + private function isEmpty(array $arguments): array + { + if (count($arguments) === 0) { + return []; + } + + $error = []; + + foreach ($arguments as $key => $value) { + if (in_array($key, self::REQUIRED_ARGUMENTS) && empty($value)) { + $error[$key] = ApiUtility::VALIDATION['isEmpty']; + } + } + + return $error; + } +} diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 6e41c6f..85fdd1a 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -35,6 +35,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-update.svg' ], + 'slubprofileaccount-wizard-userpinupdate' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-pin-update.svg' + ], 'slubprofileaccount-wizard-userpasswordupdate' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-password-update.svg' diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index 2d91de9..8f898fa 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -6,5 +6,6 @@ imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPasswordUpdate.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPinUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryUpdate.yaml' diff --git a/Configuration/Routes/UserPinUpdate.yaml b/Configuration/Routes/UserPinUpdate.yaml new file mode 100644 index 0000000..53ece1f --- /dev/null +++ b/Configuration/Routes/UserPinUpdate.yaml @@ -0,0 +1,9 @@ +routeEnhancers: + SlubAccountUserPinUpdate: + type: Simple + limitToPages: [30] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userpinupdate/user' diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 101d03d..ce7f607 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -32,6 +32,9 @@ services: Slub\SlubProfileAccount\Service\UserPasswordService: public: true + Slub\SlubProfileAccount\Service\UserPinService: + public: true + Slub\SlubProfileAccount\Service\UserSearchQueryService: public: true diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 605f6bb..7a407d2 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -63,6 +63,7 @@ 'useraccountupdate', 'userdashboarddetail', 'userdashboardupdate', + 'userpinupdate', 'userpasswordupdate', 'usersearchquerydetail', 'usersearchqueryupdate' diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index 6ae2c80..1d08170 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -36,6 +36,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_userdashboardupdate } + slubprofileaccount_userpindupdate { + iconIdentifier = slubprofileaccount-wizard-userpinupdate + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userpinupdate.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userpinupdate.description + tt_content_defValues.CType = slubprofileaccount_userpinupdate + } + slubprofileaccount_userpasswordupdate { iconIdentifier = slubprofileaccount-wizard-userpasswordupdate iconOverlay = slubprofileaccount-overlay-extension @@ -66,6 +74,7 @@ mod { show := addToList(slubprofileaccount_userdashboardupdate) show := addToList(slubprofileaccount_userdashboarddetail) show := addToList(slubprofileaccount_userpasswordupdate) + show := addToList(slubprofileaccount_userpindupdate) show := addToList(slubprofileaccount_usersearchqueryupdate) show := addToList(slubprofileaccount_usersearchquerydetail) } diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index efbc024..ec19fea 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -6,10 +6,14 @@ plugin.tx_slubprofileaccount { settings { api.path { + # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for login + login = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/auth/login # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for user user = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID### - # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for update password + # cat=plugin.tx_slubprofileaccount/76595002_Api/105; type=string; label=Path to update password passwordUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/change + # cat=plugin.tx_slubprofileaccount/76595002_Api/110; type=string; label=Path to update pin + pinUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/###USER_ID###/pin } # cat=plugin.tx_slubprofileaccount/76595003_Cache/100; type=int; label=Life time account cache in seconds diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 7d80e6f..187a098 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -9,8 +9,10 @@ plugin.tx_slubprofileaccount { settings { api.path { + login = {$plugin.tx_slubprofileaccount.settings.api.path.login} user = {$plugin.tx_slubprofileaccount.settings.api.path.user} passwordUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.passwordUpdate} + pinUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.pinUpdate} } cache.account.lifeTime = {$plugin.tx_slubprofileaccount.settings.cache.account.lifeTime} diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index db67b95..43fcba4 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -58,6 +58,15 @@ Das Passwort eines spezifischen Benutzers aktualisieren. + + Update pin + PIN aktualisieren + + + Update the pin of a specific user. + Die PIN eines spezifischen Benutzers aktualisieren. + + User detail (constraint: search query) Details eines Benutzers (Einschränkung: Suchanfrage) diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 54b11fd..5a36329 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -47,6 +47,13 @@ Update the password of a specific user. + + Update pin + + + Update the pin of a specific user. + + User detail (constraint: search query) diff --git a/Resources/Public/Icons/Wizard/user-pin-update.svg b/Resources/Public/Icons/Wizard/user-pin-update.svg new file mode 100644 index 0000000..7c14af9 --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-pin-update.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index 35999b5..7761a14 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -3,6 +3,7 @@ use Slub\SlubProfileAccount\Controller\UserAccountController; use Slub\SlubProfileAccount\Controller\UserDashboardController; use Slub\SlubProfileAccount\Controller\UserPasswordController; +use Slub\SlubProfileAccount\Controller\UserPinController; use Slub\SlubProfileAccount\Controller\UserSearchQueryController; use Slub\SlubProfileAccount\Form\Element\AccountOverviewElement; use Slub\SlubProfileAccount\Form\Element\UserCategoryDescriptionElement; @@ -42,6 +43,19 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); +// Configure plugin - user pin update +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserPinUpdate', + [ + UserPinController::class => 'update' + ], + [ + UserPinController::class => 'update' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user password update ExtensionUtility::configurePlugin( 'SlubProfileAccount', From 719bcf983ba48b984081f3b4d7259d0dc18c5798 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 27 Sep 2022 12:32:26 +0200 Subject: [PATCH 49/81] [TASK] Improve code quality --- Classes/Controller/UserPasswordController.php | 2 +- Classes/Controller/UserPinController.php | 2 +- Classes/Service/UserAccountService.php | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Classes/Controller/UserPasswordController.php b/Classes/Controller/UserPasswordController.php index b42cf2c..7bd1dc6 100644 --- a/Classes/Controller/UserPasswordController.php +++ b/Classes/Controller/UserPasswordController.php @@ -15,8 +15,8 @@ use Psr\Http\Message\ResponseInterface; use Slub\SlubProfileAccount\Domain\Model\User\Account as User; use Slub\SlubProfileAccount\Mvc\View\JsonView; -use Slub\SlubProfileAccount\Service\UserPasswordService; use Slub\SlubProfileAccount\Service\UserAccountService as UserService; +use Slub\SlubProfileAccount\Service\UserPasswordService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; diff --git a/Classes/Controller/UserPinController.php b/Classes/Controller/UserPinController.php index 9ecbf57..a4b982c 100644 --- a/Classes/Controller/UserPinController.php +++ b/Classes/Controller/UserPinController.php @@ -15,8 +15,8 @@ use Psr\Http\Message\ResponseInterface; use Slub\SlubProfileAccount\Domain\Model\User\Account as User; use Slub\SlubProfileAccount\Mvc\View\JsonView; -use Slub\SlubProfileAccount\Service\UserPinService; use Slub\SlubProfileAccount\Service\UserAccountService as UserService; +use Slub\SlubProfileAccount\Service\UserPinService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; diff --git a/Classes/Service/UserAccountService.php b/Classes/Service/UserAccountService.php index 9f7c853..434a5ea 100644 --- a/Classes/Service/UserAccountService.php +++ b/Classes/Service/UserAccountService.php @@ -116,14 +116,14 @@ protected function findUser(int $accountId): User */ protected function createUser(int $accountId): User { - /** @var User $userAccount */ - $userAccount = GeneralUtility::makeInstance(User::class); - $userAccount = LanguageUtility::setLanguageProperty($userAccount); - $userAccount->setAccountId($accountId); + /** @var User $user */ + $user = GeneralUtility::makeInstance(User::class); + $user = LanguageUtility::setLanguageProperty($user); + $user->setAccountId($accountId); - $this->userRepository->add($userAccount); + $this->userRepository->add($user); $this->persistenceManager->persistAll(); - return $userAccount; + return $user; } } From 6979b0e6d415420dbc4a16211c0b52a3715f8e7a Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 27 Sep 2022 12:33:27 +0200 Subject: [PATCH 50/81] [POSTMAN] Add loan history --- postman_collection.json | 90 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/postman_collection.json b/postman_collection.json index 01cce82..5f19f8c 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -18,7 +18,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"account\": {\r\n \"EmailAddress\": \"heike.suetterlin@slub-dresden.de\",\r\n \"PostalAddress1\": \"\",\r\n \"PostalAddress2\": \"\",\r\n \"PostalCity\": \"Berlin\",\r\n \"PostalPostCode\": \"12345\",\r\n \"PostalCountry\": \"\",\r\n \"ResAddress1\": \"\",\r\n \"ResAddress2\": \"\",\r\n \"ResAddressCity\": \"\",\r\n \"ResAddressPostCode\": \"\",\r\n \"ResAddressCountry\": \"\"\r\n }\r\n}" + "raw": "" }, "url": { "raw": "{{domain}}/benutzer/{{user}}", @@ -201,6 +201,60 @@ } ] }, + { + "name": "Loan History", + "item": [ + { + "name": "Get - Default", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihhistorie", + "{{user}}" + ] + } + }, + "response": [ + { + "name": "Unknown user", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihhistorie", + "{{user}}" + ] + } + }, + "_postman_previewlanguage": "json", + "header": [], + "cookie": [], + "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" + } + ] + } + ] + }, { "name": "Search query", "item": [ @@ -316,6 +370,40 @@ "response": [] } ] + }, + { + "name": "PIN", + "item": [ + { + "name": "Update", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"pin\": {\r\n \"password\": \"test\",\r\n \"pin\": \"1234\",\r\n \"pinRepeat\": \"1234\"\r\n }\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{domain}}/benutzer/pin/aktualisieren/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "pin", + "aktualisieren", + "{{user}}" + ] + } + }, + "response": [] + } + ] } ], "event": [ From 21779405c8ef3c0850ba3919cc8dab06e7582ff4 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 28 Sep 2022 09:24:31 +0200 Subject: [PATCH 51/81] [FEATURE] Api for loan history --- .../Controller/UserLoanHistoryController.php | 49 ++++++++++ Classes/Domain/Model/Dto/ApiConfiguration.php | 24 ++++- Classes/Mvc/View/JsonView.php | 5 + Classes/Service/UserLoanHistoryService.php | 94 +++++++++++++++++++ Configuration/Icons.php | 8 +- Configuration/Routes/Default.yaml | 1 + .../Routes/UserLoanHistoryDetail.yaml | 9 ++ Configuration/Services.yaml | 3 + Configuration/TCA/Overrides/tt_content.php | 1 + Configuration/TsConfig/Page/mod.tsconfig | 9 ++ Configuration/TypoScript/constants.typoscript | 8 +- Configuration/TypoScript/setup.typoscript | 1 + .../Private/Language/de.locallang_backend.xlf | 9 ++ .../Private/Language/locallang_backend.xlf | 7 ++ .../Icons/Wizard/user-loan-history-detail.svg | 10 ++ ext_localconf.php | 14 +++ 16 files changed, 244 insertions(+), 8 deletions(-) create mode 100644 Classes/Controller/UserLoanHistoryController.php create mode 100644 Classes/Service/UserLoanHistoryService.php create mode 100644 Configuration/Routes/UserLoanHistoryDetail.yaml create mode 100644 Resources/Public/Icons/Wizard/user-loan-history-detail.svg diff --git a/Classes/Controller/UserLoanHistoryController.php b/Classes/Controller/UserLoanHistoryController.php new file mode 100644 index 0000000..0c20975 --- /dev/null +++ b/Classes/Controller/UserLoanHistoryController.php @@ -0,0 +1,49 @@ +userService = $userService; + } + + /** + * @return ResponseInterface + * @throws JsonException + */ + public function detailAction(): ResponseInterface + { + $loanHistory = $this->userService->getData( + $this->request->getArguments() + ); + + $this->view->setVariablesToRender(['userLoanHistoryDetail']); + $this->view->assign('userLoanHistoryDetail', $loanHistory); + + return $this->jsonResponse(); + } +} diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index 0c1f800..62fa1f2 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -15,10 +15,11 @@ class ApiConfiguration { - protected string $login = ''; + protected string $loginUri = ''; protected string $userUri = ''; protected string $passwordUpdateUri = ''; protected string $pinUpdateUri = ''; + protected string $loanHistoryUri = ''; public function __construct() { @@ -28,6 +29,7 @@ public function __construct() $this->setUserUri($settings['api']['path']['user']); $this->setPasswordUpdateUri($settings['api']['path']['passwordUpdate']); $this->setPinUpdateUri($settings['api']['path']['pinUpdate']); + $this->setLoanHistoryUri($settings['api']['path']['loanHistory']); } /** @@ -35,7 +37,7 @@ public function __construct() */ public function getLoginUri(): string { - return $this->login; + return $this->loginUri; } /** @@ -43,7 +45,7 @@ public function getLoginUri(): string */ public function setLoginUri(string $loginUri = ''): void { - $this->login = $loginUri; + $this->loginUri = $loginUri; } /** @@ -93,4 +95,20 @@ public function setPinUpdateUri(string $pinUpdateUri = ''): void { $this->pinUpdateUri = $pinUpdateUri; } + + /** + * @return string + */ + public function getLoanHistoryUri(): string + { + return $this->loanHistoryUri; + } + + /** + * @param string $loanHistoryUri + */ + public function setLoanHistoryUri(string $loanHistoryUri = ''): void + { + $this->loanHistoryUri = $loanHistoryUri; + } } diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index fc58aa9..aac1f7c 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -50,6 +50,11 @@ class JsonView extends ExtbaseJsonView 'dashboardWidgets' ] ], + 'userLoanHistoryDetail' => [ + '_only' => [ + 'loanHistory' + ] + ], 'userSearchQueryDetail' => [ '_only' => [ 'searchQuery' diff --git a/Classes/Service/UserLoanHistoryService.php b/Classes/Service/UserLoanHistoryService.php new file mode 100644 index 0000000..c9aeebc --- /dev/null +++ b/Classes/Service/UserLoanHistoryService.php @@ -0,0 +1,94 @@ +apiConfiguration = $apiConfiguration; + $this->accountService = $accountService; + $this->request = $request; + } + + /** + * @param array $arguments + * @return array|null + * @throws \JsonException + */ + public function getData(array $arguments): ?array + { + $account = $this->accountService->getAccountByArguments($arguments); + $accountId = $this->accountService->getAccountId(); + + if ($accountId > 0 && is_array($account)) { + $processed = $this->requestData($accountId); + $prepared = $this->prepareHistory($processed['history'] ?? []); + + return ['loanHistory' => $prepared]; + } + + return []; + } + + /** + * @param array $data + * @return array + */ + protected function prepareHistory(array $data): array + { + if (count($data) === 0) { + return []; + } + + krsort($data); + + return $data; + } + + /** + * @param int $id + * @return array|null + * @throws \JsonException + */ + protected function requestData(int $id): ?array + { + $uri = $this->apiConfiguration->getLoanHistoryUri(); + $uri = ApiUtility::replaceUriPlaceholder([$id], $uri); + + return $this->request->process($uri, 'GET', [ + 'headers' => [ + 'X-SLUB-Standard' => 'paia_ext', + 'X-SLUB-pretty' => '1', + 'X-SLUB-sort' => 'ASC', + //'X-SLUB-count' => '10', + //'X-SLUB-offset' => 0 + ] + ]); + } +} diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 85fdd1a..3e632a6 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -35,14 +35,18 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-update.svg' ], - 'slubprofileaccount-wizard-userpinupdate' => [ + 'slubprofileaccount-wizard-userloanhistorydetail' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-pin-update.svg' + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-loan-history-detail.svg' ], 'slubprofileaccount-wizard-userpasswordupdate' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-password-update.svg' ], + 'slubprofileaccount-wizard-userpinupdate' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-pin-update.svg' + ], 'slubprofileaccount-wizard-usersearchquerydetail' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-search-query-detail.svg' diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index 8f898fa..17bd2f1 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -5,6 +5,7 @@ imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserAccountUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardUpdate.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserLoanHistoryDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPasswordUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPinUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryDetail.yaml' diff --git a/Configuration/Routes/UserLoanHistoryDetail.yaml b/Configuration/Routes/UserLoanHistoryDetail.yaml new file mode 100644 index 0000000..f539fdf --- /dev/null +++ b/Configuration/Routes/UserLoanHistoryDetail.yaml @@ -0,0 +1,9 @@ +routeEnhancers: + SlubAccountUserLoanHistoryDetail: + type: Simple + limitToPages: [31] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userloanhistorydetail/user' diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index ce7f607..24ec46b 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -29,6 +29,9 @@ services: Slub\SlubProfileAccount\Service\UserDashboardService: public: true + Slub\SlubProfileAccount\Service\UserLoanHistoryService: + public: true + Slub\SlubProfileAccount\Service\UserPasswordService: public: true diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 7a407d2..589e3ef 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -63,6 +63,7 @@ 'useraccountupdate', 'userdashboarddetail', 'userdashboardupdate', + 'userloanhistorydetail', 'userpinupdate', 'userpasswordupdate', 'usersearchquerydetail', diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index 1d08170..bbba6db 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -36,6 +36,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_userdashboardupdate } + slubprofileaccount_userloanhistorydetail { + iconIdentifier = slubprofileaccount-wizard-userloanhistorydetail + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloanhistorydetail.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloanhistorydetail.description + tt_content_defValues.CType = slubprofileaccount_userloanhistorydetail + } + slubprofileaccount_userpindupdate { iconIdentifier = slubprofileaccount-wizard-userpinupdate iconOverlay = slubprofileaccount-overlay-extension @@ -73,6 +81,7 @@ mod { show := addToList(slubprofileaccount_useraccountupdate) show := addToList(slubprofileaccount_userdashboardupdate) show := addToList(slubprofileaccount_userdashboarddetail) + show := addToList(slubprofileaccount_userloanhistorydetail) show := addToList(slubprofileaccount_userpasswordupdate) show := addToList(slubprofileaccount_userpindupdate) show := addToList(slubprofileaccount_usersearchqueryupdate) diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index ec19fea..3a8e941 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -8,12 +8,14 @@ plugin.tx_slubprofileaccount { api.path { # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for login login = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/auth/login - # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for user + # cat=plugin.tx_slubprofileaccount/76595002_Api/105; type=string; label=Path for user user = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID### - # cat=plugin.tx_slubprofileaccount/76595002_Api/105; type=string; label=Path to update password + # cat=plugin.tx_slubprofileaccount/76595002_Api/110; type=string; label=Path to update password passwordUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/change - # cat=plugin.tx_slubprofileaccount/76595002_Api/110; type=string; label=Path to update pin + # cat=plugin.tx_slubprofileaccount/76595002_Api/115; type=string; label=Path to update pin pinUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/###USER_ID###/pin + # cat=plugin.tx_slubprofileaccount/76595002_Api/120; type=string; label=Path to loan history + loanHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/history } # cat=plugin.tx_slubprofileaccount/76595003_Cache/100; type=int; label=Life time account cache in seconds diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 187a098..044bf38 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -13,6 +13,7 @@ plugin.tx_slubprofileaccount { user = {$plugin.tx_slubprofileaccount.settings.api.path.user} passwordUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.passwordUpdate} pinUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.pinUpdate} + loanHistory = {$plugin.tx_slubprofileaccount.settings.api.path.loanHistory} } cache.account.lifeTime = {$plugin.tx_slubprofileaccount.settings.cache.account.lifeTime} diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 43fcba4..256c9c2 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -49,6 +49,15 @@ Daten der Dashboardeinstellung eines Benutzers aktualisieren. + + User detail (constraint: loan history) + Details eines Benutzers (Einschränkung: Ausleihhistorie) + + + Details of a specific user (loan history). Returns only the user constraint "loan history" data. + Details zu einem spezifischen Benutzer (Ausleihhistorie). Gibt nur die Daten des Benutzers mit der Einschränkung "Ausleihhistorie" zurück. + + Update password Passwort aktualisieren diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 5a36329..2fef0ae 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -40,6 +40,13 @@ Update data of dashboard user. + + User detail (constraint: loan history) + + + Details of a specific user (loan history). Returns only the user constraint "loan history" data. + + Update password diff --git a/Resources/Public/Icons/Wizard/user-loan-history-detail.svg b/Resources/Public/Icons/Wizard/user-loan-history-detail.svg new file mode 100644 index 0000000..bb48eb6 --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-loan-history-detail.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index 7761a14..7e62604 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,6 +2,7 @@ use Slub\SlubProfileAccount\Controller\UserAccountController; use Slub\SlubProfileAccount\Controller\UserDashboardController; +use Slub\SlubProfileAccount\Controller\UserLoanHistoryController; use Slub\SlubProfileAccount\Controller\UserPasswordController; use Slub\SlubProfileAccount\Controller\UserPinController; use Slub\SlubProfileAccount\Controller\UserSearchQueryController; @@ -95,6 +96,19 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); +// Configure plugin - user search query detail +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserLoanHistoryDetail', + [ + UserLoanHistoryController::class => 'detail' + ], + [ + UserLoanHistoryController::class => 'detail' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user search query detail ExtensionUtility::configurePlugin( 'SlubProfileAccount', From 1e0c3af88b22a408b03dde6a27364240cc02c9ae Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 28 Sep 2022 09:50:57 +0200 Subject: [PATCH 52/81] [TASK] Change order of loan history (latest to old) --- Classes/Service/UserLoanHistoryService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/Service/UserLoanHistoryService.php b/Classes/Service/UserLoanHistoryService.php index c9aeebc..f719fc5 100644 --- a/Classes/Service/UserLoanHistoryService.php +++ b/Classes/Service/UserLoanHistoryService.php @@ -68,7 +68,8 @@ protected function prepareHistory(array $data): array krsort($data); - return $data; + // Set natural keys again + return array_values($data); } /** From 2da3c73a97dffc86a75701cf60e07a08fbb5e522 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 29 Sep 2022 12:12:40 +0200 Subject: [PATCH 53/81] [DOCUMENTATION] Add missing apis and general information --- README.md | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 397b18c..5edfcab 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,18 @@ News uses [semantic versioning][2], which means, that ### 3.1 Routes Please check the routes' configuration. You have to set the matching page (limitToPages). If not the routes will not work properly. +Furthermore, have a look at postman and import the "postman_collection" file. This explains the possible APIs very well. ### 3.2 Typoscript -| Setup / Constant | Comment | -|---------------------------------------------------------------|----------------------------------| -| plugin.tx_slubprofile_account.settings.api.path.user | Path to get user info / detail. | -| plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data. | +| Setup / Constant | Comment | +|-----------------------------------------------------------------|----------------------------------| +| plugin.tx_slubprofile_account.settings.api.path.user | Path to get user info / detail | +| plugin.tx_slubprofile_account.settings.api.path.login | Path to login | +| plugin.tx_slubprofile_account.settings.api.path.passwordUpdate | Path to change password | +| plugin.tx_slubprofile_account.settings.api.path.pinUpdate | Path to change pin | +| plugin.tx_slubprofile_account.settings.api.path.loanHistory | path tp loan history | +| plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data. | ### 3.3 Update account data @@ -45,17 +50,35 @@ To update data via external form you have to send an array called "account" via | Field name | Comment | |--------------------|------------| | EmailAddress | Obligation | -| PostalAddress1 | | +| PostalAddress1 | Obligation | | PostalAddress2 | | -| PostalCity | | -| PostalPostCode | | -| PostalCountry | | +| PostalCity | Obligation | +| PostalPostCode | Obligation | +| PostalCountry | Obligation | | ResAddress1 | | | ResAddress2 | | | ResAddressCity | | | ResAddressPostCode | | | ResAddressCountry | | +### 3.4 Update pin + +To update pin via external form you have to send an array called "pin" via post with the following fields: + +| Field name | Comment | +|------------|------------| +| pin | Obligation | +| pinRepeat | Obligation | +| password | Obligation | + +### 3.5 Update password + +To update password via external form you have to send a string called "password" via post with the following fields: + +| Field name | Comment | +|------------|------------| +| password | Obligation | + [1]: https://getcomposer.org/ [2]: https://semver.org/ From fedf4c308e0eae6aed99484cba9eec132f0bf343 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 30 Sep 2022 11:14:14 +0200 Subject: [PATCH 54/81] [TASK] Set sorting via api --- Classes/Service/UserLoanHistoryService.php | 23 +++------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/Classes/Service/UserLoanHistoryService.php b/Classes/Service/UserLoanHistoryService.php index f719fc5..1017271 100644 --- a/Classes/Service/UserLoanHistoryService.php +++ b/Classes/Service/UserLoanHistoryService.php @@ -47,31 +47,14 @@ public function getData(array $arguments): ?array $accountId = $this->accountService->getAccountId(); if ($accountId > 0 && is_array($account)) { - $processed = $this->requestData($accountId); - $prepared = $this->prepareHistory($processed['history'] ?? []); + $processed = $this->requestData($accountId)['history'] ?? []; - return ['loanHistory' => $prepared]; + return ['loanHistory' => $processed]; } return []; } - /** - * @param array $data - * @return array - */ - protected function prepareHistory(array $data): array - { - if (count($data) === 0) { - return []; - } - - krsort($data); - - // Set natural keys again - return array_values($data); - } - /** * @param int $id * @return array|null @@ -86,7 +69,7 @@ protected function requestData(int $id): ?array 'headers' => [ 'X-SLUB-Standard' => 'paia_ext', 'X-SLUB-pretty' => '1', - 'X-SLUB-sort' => 'ASC', + 'X-SLUB-sort' => 'DESC', //'X-SLUB-count' => '10', //'X-SLUB-offset' => 0 ] From 3cd0ea2d94426751db7a09f96b1505920e0ba66f Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 11 Oct 2022 16:55:11 +0200 Subject: [PATCH 55/81] [TASK] Add pagination to load history --- Classes/Mvc/View/JsonView.php | 1 + Classes/Service/UserLoanHistoryService.php | 31 ++++++++++++++++--- .../Routes/UserLoanHistoryDetail.yaml | 4 ++- Configuration/TypoScript/constants.typoscript | 4 +++ Configuration/TypoScript/setup.typoscript | 1 + postman_collection.json | 6 ++-- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index aac1f7c..1d07da3 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -52,6 +52,7 @@ class JsonView extends ExtbaseJsonView ], 'userLoanHistoryDetail' => [ '_only' => [ + 'paginator', 'loanHistory' ] ], diff --git a/Classes/Service/UserLoanHistoryService.php b/Classes/Service/UserLoanHistoryService.php index 1017271..6110be9 100644 --- a/Classes/Service/UserLoanHistoryService.php +++ b/Classes/Service/UserLoanHistoryService.php @@ -14,12 +14,14 @@ use Slub\SlubProfileAccount\Domain\Model\Dto\ApiConfiguration; use Slub\SlubProfileAccount\Http\Request; use Slub\SlubProfileAccount\Utility\ApiUtility; +use Slub\SlubProfileAccount\Utility\SettingsUtility; class UserLoanHistoryService { protected ApiConfiguration $apiConfiguration; protected AccountService $accountService; protected Request $request; + protected int $itemsPerPage; /** * @param ApiConfiguration $apiConfiguration @@ -34,6 +36,7 @@ public function __construct( $this->apiConfiguration = $apiConfiguration; $this->accountService = $accountService; $this->request = $request; + $this->itemsPerPage = (int)SettingsUtility::getPluginSettings()['general']['itemsPerPage'] ?? 25; } /** @@ -43,13 +46,21 @@ public function __construct( */ public function getData(array $arguments): ?array { + $page = (int)($arguments['page'] ?? 1); $account = $this->accountService->getAccountByArguments($arguments); $accountId = $this->accountService->getAccountId(); if ($accountId > 0 && is_array($account)) { - $processed = $this->requestData($accountId)['history'] ?? []; + $processed = $this->requestData($accountId, $page); - return ['loanHistory' => $processed]; + return [ + 'paginator' => [ + 'countItems' => $processed['count'], + 'currentPage' => $page, + 'itemsPerPage' => $this->itemsPerPage + ], + 'loanHistory' => $processed['history'] + ]; } return []; @@ -57,10 +68,11 @@ public function getData(array $arguments): ?array /** * @param int $id + * @param int $page * @return array|null * @throws \JsonException */ - protected function requestData(int $id): ?array + protected function requestData(int $id, int $page): ?array { $uri = $this->apiConfiguration->getLoanHistoryUri(); $uri = ApiUtility::replaceUriPlaceholder([$id], $uri); @@ -70,9 +82,18 @@ protected function requestData(int $id): ?array 'X-SLUB-Standard' => 'paia_ext', 'X-SLUB-pretty' => '1', 'X-SLUB-sort' => 'DESC', - //'X-SLUB-count' => '10', - //'X-SLUB-offset' => 0 + 'X-SLUB-count' => $this->itemsPerPage, + 'X-SLUB-offset' => $this->getOffset($page) ] ]); } + + /** + * @param int $page + * @return int + */ + protected function getOffset(int $page): int + { + return (int)($page * $this->itemsPerPage) - $this->itemsPerPage; + } } diff --git a/Configuration/Routes/UserLoanHistoryDetail.yaml b/Configuration/Routes/UserLoanHistoryDetail.yaml index f539fdf..9c2cdd9 100644 --- a/Configuration/Routes/UserLoanHistoryDetail.yaml +++ b/Configuration/Routes/UserLoanHistoryDetail.yaml @@ -2,8 +2,10 @@ routeEnhancers: SlubAccountUserLoanHistoryDetail: type: Simple limitToPages: [31] - routePath: '/{user}' + routePath: '/{user}/page/{page}' requirements: user: '[0-9]{1,10}' + page: '[0-9]{1,10}' _arguments: user: 'tx_slubprofileaccount_userloanhistorydetail/user' + page: 'tx_slubprofileaccount_userloanhistorydetail/page' diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 3a8e941..74c7340 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -1,3 +1,4 @@ +# customsubcategory=76595001_General=General # customsubcategory=76595002_Api=API # customsubcategory=76595003_Cache=Cache @@ -20,5 +21,8 @@ plugin.tx_slubprofileaccount { # cat=plugin.tx_slubprofileaccount/76595003_Cache/100; type=int; label=Life time account cache in seconds cache.account.lifeTime = 3600 + + # cat=plugin.tx_slubprofileaccount/76595002_General/100; type=int; label=Items per page + general.itemsPerPage = 10 } } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 044bf38..b0c3d37 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -17,6 +17,7 @@ plugin.tx_slubprofileaccount { } cache.account.lifeTime = {$plugin.tx_slubprofileaccount.settings.cache.account.lifeTime} + general.itemsPerPage = {$plugin.tx_slubprofileaccount.settings.general.itemsPerPage} } } diff --git a/postman_collection.json b/postman_collection.json index 5f19f8c..fb514e8 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -217,14 +217,16 @@ "raw": "" }, "url": { - "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", + "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}/page/1", "host": [ "{{domain}}" ], "path": [ "benutzer", "ausleihhistorie", - "{{user}}" + "{{user}}", + "page", + "1" ] } }, From 966826766741fd110d7f8e4399e9b4980ac2076c Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 11 Oct 2022 17:23:40 +0200 Subject: [PATCH 56/81] [TASK] Refactor loan history --- ...nHistoryController.php => UserLoanController.php} | 12 ++++++------ Classes/Mvc/View/JsonView.php | 2 +- ...serLoanHistoryService.php => UserLoanService.php} | 8 ++++---- Configuration/Icons.php | 4 ++-- Configuration/Routes/Default.yaml | 2 +- .../{UserLoanHistoryDetail.yaml => UserLoan.yaml} | 6 +++--- Configuration/Services.yaml | 2 +- Configuration/TCA/Overrides/tt_content.php | 2 +- Configuration/TsConfig/Page/mod.tsconfig | 12 ++++++------ Resources/Private/Language/de.locallang_backend.xlf | 12 ++++++------ Resources/Private/Language/locallang_backend.xlf | 8 ++++---- ...loan-history-detail.svg => user-loan-history.svg} | 0 ext_localconf.php | 10 +++++----- 13 files changed, 40 insertions(+), 40 deletions(-) rename Classes/Controller/{UserLoanHistoryController.php => UserLoanController.php} (70%) rename Classes/Service/{UserLoanHistoryService.php => UserLoanService.php} (92%) rename Configuration/Routes/{UserLoanHistoryDetail.yaml => UserLoan.yaml} (52%) rename Resources/Public/Icons/Wizard/{user-loan-history-detail.svg => user-loan-history.svg} (100%) diff --git a/Classes/Controller/UserLoanHistoryController.php b/Classes/Controller/UserLoanController.php similarity index 70% rename from Classes/Controller/UserLoanHistoryController.php rename to Classes/Controller/UserLoanController.php index 0c20975..92baf18 100644 --- a/Classes/Controller/UserLoanHistoryController.php +++ b/Classes/Controller/UserLoanController.php @@ -14,10 +14,10 @@ use JsonException; use Psr\Http\Message\ResponseInterface; use Slub\SlubProfileAccount\Mvc\View\JsonView; -use Slub\SlubProfileAccount\Service\UserLoanHistoryService as UserService; +use Slub\SlubProfileAccount\Service\UserLoanService as UserService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -class UserLoanHistoryController extends ActionController +class UserLoanController extends ActionController { protected $view; protected $defaultViewObjectName = JsonView::class; @@ -35,14 +35,14 @@ public function __construct(UserService $userService) * @return ResponseInterface * @throws JsonException */ - public function detailAction(): ResponseInterface + public function historyAction(): ResponseInterface { - $loanHistory = $this->userService->getData( + $loanHistory = $this->userService->getHistory( $this->request->getArguments() ); - $this->view->setVariablesToRender(['userLoanHistoryDetail']); - $this->view->assign('userLoanHistoryDetail', $loanHistory); + $this->view->setVariablesToRender(['userLoanHistory']); + $this->view->assign('userLoanHistory', $loanHistory); return $this->jsonResponse(); } diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index 1d07da3..2fc981d 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -50,7 +50,7 @@ class JsonView extends ExtbaseJsonView 'dashboardWidgets' ] ], - 'userLoanHistoryDetail' => [ + 'userLoanHistory' => [ '_only' => [ 'paginator', 'loanHistory' diff --git a/Classes/Service/UserLoanHistoryService.php b/Classes/Service/UserLoanService.php similarity index 92% rename from Classes/Service/UserLoanHistoryService.php rename to Classes/Service/UserLoanService.php index 6110be9..84614c9 100644 --- a/Classes/Service/UserLoanHistoryService.php +++ b/Classes/Service/UserLoanService.php @@ -16,7 +16,7 @@ use Slub\SlubProfileAccount\Utility\ApiUtility; use Slub\SlubProfileAccount\Utility\SettingsUtility; -class UserLoanHistoryService +class UserLoanService { protected ApiConfiguration $apiConfiguration; protected AccountService $accountService; @@ -44,14 +44,14 @@ public function __construct( * @return array|null * @throws \JsonException */ - public function getData(array $arguments): ?array + public function getHistory(array $arguments): ?array { $page = (int)($arguments['page'] ?? 1); $account = $this->accountService->getAccountByArguments($arguments); $accountId = $this->accountService->getAccountId(); if ($accountId > 0 && is_array($account)) { - $processed = $this->requestData($accountId, $page); + $processed = $this->requestHistory($accountId, $page); return [ 'paginator' => [ @@ -72,7 +72,7 @@ public function getData(array $arguments): ?array * @return array|null * @throws \JsonException */ - protected function requestData(int $id, int $page): ?array + protected function requestHistory(int $id, int $page): ?array { $uri = $this->apiConfiguration->getLoanHistoryUri(); $uri = ApiUtility::replaceUriPlaceholder([$id], $uri); diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 3e632a6..da4d62d 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -35,9 +35,9 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-update.svg' ], - 'slubprofileaccount-wizard-userloanhistorydetail' => [ + 'slubprofileaccount-wizard-userloanhistory' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-loan-history-detail.svg' + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-loan-history.svg' ], 'slubprofileaccount-wizard-userpasswordupdate' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index 17bd2f1..86bdf01 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -5,7 +5,7 @@ imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserAccountUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardUpdate.yaml' - - resource: 'EXT:slub_profile_account/Configuration/Routes/UserLoanHistoryDetail.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserLoan.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPasswordUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPinUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryDetail.yaml' diff --git a/Configuration/Routes/UserLoanHistoryDetail.yaml b/Configuration/Routes/UserLoan.yaml similarity index 52% rename from Configuration/Routes/UserLoanHistoryDetail.yaml rename to Configuration/Routes/UserLoan.yaml index 9c2cdd9..a30d26b 100644 --- a/Configuration/Routes/UserLoanHistoryDetail.yaml +++ b/Configuration/Routes/UserLoan.yaml @@ -1,5 +1,5 @@ routeEnhancers: - SlubAccountUserLoanHistoryDetail: + SlubAccountUserLoanHistory: type: Simple limitToPages: [31] routePath: '/{user}/page/{page}' @@ -7,5 +7,5 @@ routeEnhancers: user: '[0-9]{1,10}' page: '[0-9]{1,10}' _arguments: - user: 'tx_slubprofileaccount_userloanhistorydetail/user' - page: 'tx_slubprofileaccount_userloanhistorydetail/page' + user: 'tx_slubprofileaccount_userloanhistory/user' + page: 'tx_slubprofileaccount_userloanhistory/page' diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 24ec46b..62d9058 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -29,7 +29,7 @@ services: Slub\SlubProfileAccount\Service\UserDashboardService: public: true - Slub\SlubProfileAccount\Service\UserLoanHistoryService: + Slub\SlubProfileAccount\Service\UserLoanService: public: true Slub\SlubProfileAccount\Service\UserPasswordService: diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 589e3ef..0ea8871 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -63,7 +63,7 @@ 'useraccountupdate', 'userdashboarddetail', 'userdashboardupdate', - 'userloanhistorydetail', + 'userloanhistory', 'userpinupdate', 'userpasswordupdate', 'usersearchquerydetail', diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index bbba6db..72e72b9 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -36,12 +36,12 @@ mod { tt_content_defValues.CType = slubprofileaccount_userdashboardupdate } - slubprofileaccount_userloanhistorydetail { - iconIdentifier = slubprofileaccount-wizard-userloanhistorydetail + slubprofileaccount_userloanhistory { + iconIdentifier = slubprofileaccount-wizard-userloanhistory iconOverlay = slubprofileaccount-overlay-extension - title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloanhistorydetail.title - description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloanhistorydetail.description - tt_content_defValues.CType = slubprofileaccount_userloanhistorydetail + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloanhistory.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloanhistory.description + tt_content_defValues.CType = slubprofileaccount_userloanhistory } slubprofileaccount_userpindupdate { @@ -81,7 +81,7 @@ mod { show := addToList(slubprofileaccount_useraccountupdate) show := addToList(slubprofileaccount_userdashboardupdate) show := addToList(slubprofileaccount_userdashboarddetail) - show := addToList(slubprofileaccount_userloanhistorydetail) + show := addToList(slubprofileaccount_userloanhistory) show := addToList(slubprofileaccount_userpasswordupdate) show := addToList(slubprofileaccount_userpindupdate) show := addToList(slubprofileaccount_usersearchqueryupdate) diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 256c9c2..23fd969 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -49,13 +49,13 @@ Daten der Dashboardeinstellung eines Benutzers aktualisieren. - - User detail (constraint: loan history) - Details eines Benutzers (Einschränkung: Ausleihhistorie) + + User loan history + Ausleihhistorie eines Benutzers - - Details of a specific user (loan history). Returns only the user constraint "loan history" data. - Details zu einem spezifischen Benutzer (Ausleihhistorie). Gibt nur die Daten des Benutzers mit der Einschränkung "Ausleihhistorie" zurück. + + Loan history of a specific user. Returns only the user constraint "loan history" data. + Ausleihhistorie zu einem spezifischen Benutzer. Gibt nur die Daten des Benutzers mit der Einschränkung "Ausleihhistorie" zurück. diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 2fef0ae..278c2d5 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -40,11 +40,11 @@ Update data of dashboard user. - - User detail (constraint: loan history) + + User loan history - - Details of a specific user (loan history). Returns only the user constraint "loan history" data. + + Loan history of a specific user. Returns only the user constraint "loan history" data. diff --git a/Resources/Public/Icons/Wizard/user-loan-history-detail.svg b/Resources/Public/Icons/Wizard/user-loan-history.svg similarity index 100% rename from Resources/Public/Icons/Wizard/user-loan-history-detail.svg rename to Resources/Public/Icons/Wizard/user-loan-history.svg diff --git a/ext_localconf.php b/ext_localconf.php index 7e62604..e5b9ba6 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,7 +2,7 @@ use Slub\SlubProfileAccount\Controller\UserAccountController; use Slub\SlubProfileAccount\Controller\UserDashboardController; -use Slub\SlubProfileAccount\Controller\UserLoanHistoryController; +use Slub\SlubProfileAccount\Controller\UserLoanController; use Slub\SlubProfileAccount\Controller\UserPasswordController; use Slub\SlubProfileAccount\Controller\UserPinController; use Slub\SlubProfileAccount\Controller\UserSearchQueryController; @@ -96,15 +96,15 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); -// Configure plugin - user search query detail +// Configure plugin - user loan history ExtensionUtility::configurePlugin( 'SlubProfileAccount', - 'UserLoanHistoryDetail', + 'UserLoanHistory', [ - UserLoanHistoryController::class => 'detail' + UserLoanController::class => 'history' ], [ - UserLoanHistoryController::class => 'detail' + UserLoanController::class => 'history' ], ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); From 29a0c30f99aebdc01865fcf8d4ac9b4687ede93e Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 11 Oct 2022 17:26:03 +0200 Subject: [PATCH 57/81] [TASK] Add documentation for pagination --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5edfcab..1f905c9 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,15 @@ Furthermore, have a look at postman and import the "postman_collection" file. Th ### 3.2 Typoscript -| Setup / Constant | Comment | -|-----------------------------------------------------------------|----------------------------------| -| plugin.tx_slubprofile_account.settings.api.path.user | Path to get user info / detail | -| plugin.tx_slubprofile_account.settings.api.path.login | Path to login | -| plugin.tx_slubprofile_account.settings.api.path.passwordUpdate | Path to change password | -| plugin.tx_slubprofile_account.settings.api.path.pinUpdate | Path to change pin | -| plugin.tx_slubprofile_account.settings.api.path.loanHistory | path tp loan history | -| plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data. | +| Setup / Constant | Comment | +|----------------------------------------------------------------|----------------------------------| +| plugin.tx_slubprofile_account.settings.api.path.user | Path to get user info / detail | +| plugin.tx_slubprofile_account.settings.api.path.login | Path to login | +| plugin.tx_slubprofile_account.settings.api.path.passwordUpdate | Path to change password | +| plugin.tx_slubprofile_account.settings.api.path.pinUpdate | Path to change pin | +| plugin.tx_slubprofile_account.settings.api.path.loanHistory | Path to loan history | +| plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | +| plugin.tx_slubprofile_account.settings.general.itemsPerPage | Items per page for pagination | ### 3.3 Update account data From 4ea27edd06d7308b7838ba01c0237a7c1475c51c Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 14 Oct 2022 16:16:16 +0200 Subject: [PATCH 58/81] [POSTMAN] Change loan history and add loan current --- postman_collection.json | 129 +++++++++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 34 deletions(-) diff --git a/postman_collection.json b/postman_collection.json index fb514e8..da77673 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -202,56 +202,117 @@ ] }, { - "name": "Loan History", + "name": "Loan", "item": [ { - "name": "Get - Default", - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [], - "body": { - "mode": "raw", - "raw": "" - }, - "url": { - "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}/page/1", - "host": [ - "{{domain}}" - ], - "path": [ - "benutzer", - "ausleihhistorie", - "{{user}}", - "page", - "1" + "name": "Current", + "item": [ + { + "name": "Get - Default", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{domain}}/benutzer/ausleihe/aktuell/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihe", + "aktuell", + "{{user}}" + ] + } + }, + "response": [ + { + "name": "Unknown user", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihhistorie", + "{{user}}" + ] + } + }, + "_postman_previewlanguage": "json", + "header": [], + "cookie": [], + "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" + } ] } - }, - "response": [ + ] + }, + { + "name": "History", + "item": [ { - "name": "Unknown user", - "originalRequest": { + "name": "Get - Default", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { "method": "GET", "header": [], + "body": { + "mode": "raw", + "raw": "" + }, "url": { - "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", + "raw": "{{domain}}/benutzer/ausleihe/historie/{{user}}/page/1", "host": [ "{{domain}}" ], "path": [ "benutzer", - "ausleihhistorie", - "{{user}}" + "ausleihe", + "historie", + "{{user}}", + "page", + "1" ] } }, - "_postman_previewlanguage": "json", - "header": [], - "cookie": [], - "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" + "response": [ + { + "name": "Unknown user", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihhistorie", + "{{user}}" + ] + } + }, + "_postman_previewlanguage": "json", + "header": [], + "cookie": [], + "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" + } + ] } ] } From 8103a8a11794bd9ee5d7f5b69fe8b1e3198fbc6d Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 14 Oct 2022 16:17:06 +0200 Subject: [PATCH 59/81] [TASK] Add loan current --- Classes/Controller/UserLoanController.php | 16 ++++++++ Classes/Domain/Model/Dto/ApiConfiguration.php | 18 +++++++++ Classes/Mvc/View/JsonView.php | 5 +++ Classes/Service/UserLoanService.php | 40 +++++++++++++++++++ Configuration/Icons.php | 4 ++ Configuration/Routes/UserLoan.yaml | 8 ++++ Configuration/TCA/Overrides/tt_content.php | 1 + Configuration/TsConfig/Page/mod.tsconfig | 9 +++++ Configuration/TypoScript/constants.typoscript | 4 +- Configuration/TypoScript/setup.typoscript | 1 + .../Private/Language/de.locallang_backend.xlf | 9 +++++ .../Private/Language/locallang_backend.xlf | 7 ++++ .../Public/Icons/Wizard/user-loan-current.svg | 10 +++++ ext_localconf.php | 13 ++++++ 14 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 Resources/Public/Icons/Wizard/user-loan-current.svg diff --git a/Classes/Controller/UserLoanController.php b/Classes/Controller/UserLoanController.php index 92baf18..b87cce1 100644 --- a/Classes/Controller/UserLoanController.php +++ b/Classes/Controller/UserLoanController.php @@ -31,6 +31,22 @@ public function __construct(UserService $userService) $this->userService = $userService; } + /** + * @return ResponseInterface + * @throws JsonException + */ + public function currentAction(): ResponseInterface + { + $loanCurrent = $this->userService->getCurrent( + $this->request->getArguments() + ); + + $this->view->setVariablesToRender(['userLoanCurrent']); + $this->view->assign('userLoanCurrent', $loanCurrent); + + return $this->jsonResponse(); + } + /** * @return ResponseInterface * @throws JsonException diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index 62fa1f2..a4663fb 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -19,6 +19,7 @@ class ApiConfiguration protected string $userUri = ''; protected string $passwordUpdateUri = ''; protected string $pinUpdateUri = ''; + protected string $loanCurrentUri = ''; protected string $loanHistoryUri = ''; public function __construct() @@ -29,6 +30,7 @@ public function __construct() $this->setUserUri($settings['api']['path']['user']); $this->setPasswordUpdateUri($settings['api']['path']['passwordUpdate']); $this->setPinUpdateUri($settings['api']['path']['pinUpdate']); + $this->setLoanCurrentUri($settings['api']['path']['loanCurrent']); $this->setLoanHistoryUri($settings['api']['path']['loanHistory']); } @@ -96,6 +98,22 @@ public function setPinUpdateUri(string $pinUpdateUri = ''): void $this->pinUpdateUri = $pinUpdateUri; } + /** + * @return string + */ + public function getLoanCurrentUri(): string + { + return $this->loanCurrentUri; + } + + /** + * @param string $loanCurrentUri + */ + public function setLoanCurrentUri(string $loanCurrentUri = ''): void + { + $this->loanCurrentUri = $loanCurrentUri; + } + /** * @return string */ diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index 2fc981d..fb039a2 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -50,6 +50,11 @@ class JsonView extends ExtbaseJsonView 'dashboardWidgets' ] ], + 'userLoanCurrent' => [ + '_only' => [ + 'loanCurrent' + ] + ], 'userLoanHistory' => [ '_only' => [ 'paginator', diff --git a/Classes/Service/UserLoanService.php b/Classes/Service/UserLoanService.php index 84614c9..f918a84 100644 --- a/Classes/Service/UserLoanService.php +++ b/Classes/Service/UserLoanService.php @@ -39,6 +39,27 @@ public function __construct( $this->itemsPerPage = (int)SettingsUtility::getPluginSettings()['general']['itemsPerPage'] ?? 25; } + /** + * @param array $arguments + * @return array|null + * @throws \JsonException + */ + public function getCurrent(array $arguments): ?array + { + $account = $this->accountService->getAccountByArguments($arguments); + $accountId = $this->accountService->getAccountId(); + + if ($accountId > 0 && is_array($account)) { + $processed = $this->requestCurrent($accountId); + + return [ + 'loanCurrent' => $processed['loan'] + ]; + } + + return []; + } + /** * @param array $arguments * @return array|null @@ -66,6 +87,25 @@ public function getHistory(array $arguments): ?array return []; } + /** + * @param int $id + * @return array|null + * @throws \JsonException + */ + protected function requestCurrent(int $id): ?array + { + $uri = $this->apiConfiguration->getLoanCurrentUri(); + $uri = ApiUtility::replaceUriPlaceholder([$id], $uri); + + return $this->request->process($uri, 'GET', [ + 'headers' => [ + 'X-SLUB-Standard' => 'paia_ext', + 'X-SLUB-pretty' => '1', + 'X-SLUB-sort' => 'DESC' + ] + ]); + } + /** * @param int $id * @param int $page diff --git a/Configuration/Icons.php b/Configuration/Icons.php index da4d62d..6f5f196 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -35,6 +35,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-update.svg' ], + 'slubprofileaccount-wizard-userloancurrent' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-loan-current.svg' + ], 'slubprofileaccount-wizard-userloanhistory' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-loan-history.svg' diff --git a/Configuration/Routes/UserLoan.yaml b/Configuration/Routes/UserLoan.yaml index a30d26b..1843655 100644 --- a/Configuration/Routes/UserLoan.yaml +++ b/Configuration/Routes/UserLoan.yaml @@ -1,4 +1,12 @@ routeEnhancers: + SlubAccountUserLoanCurrent: + type: Simple + limitToPages: [32] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userloancurrent/user' SlubAccountUserLoanHistory: type: Simple limitToPages: [31] diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 0ea8871..2b75176 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -63,6 +63,7 @@ 'useraccountupdate', 'userdashboarddetail', 'userdashboardupdate', + 'userloancurrent', 'userloanhistory', 'userpinupdate', 'userpasswordupdate', diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index 72e72b9..0e10373 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -36,6 +36,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_userdashboardupdate } + slubprofileaccount_userloancurrent { + iconIdentifier = slubprofileaccount-wizard-userloancurrent + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloancurrent.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloancurrent.description + tt_content_defValues.CType = slubprofileaccount_userloancurrent + } + slubprofileaccount_userloanhistory { iconIdentifier = slubprofileaccount-wizard-userloanhistory iconOverlay = slubprofileaccount-overlay-extension @@ -81,6 +89,7 @@ mod { show := addToList(slubprofileaccount_useraccountupdate) show := addToList(slubprofileaccount_userdashboardupdate) show := addToList(slubprofileaccount_userdashboarddetail) + show := addToList(slubprofileaccount_userloancurrent) show := addToList(slubprofileaccount_userloanhistory) show := addToList(slubprofileaccount_userpasswordupdate) show := addToList(slubprofileaccount_userpindupdate) diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 74c7340..8bbb6e2 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -15,7 +15,9 @@ plugin.tx_slubprofileaccount { passwordUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/change # cat=plugin.tx_slubprofileaccount/76595002_Api/115; type=string; label=Path to update pin pinUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/###USER_ID###/pin - # cat=plugin.tx_slubprofileaccount/76595002_Api/120; type=string; label=Path to loan history + # cat=plugin.tx_slubprofileaccount/76595002_Api/120; type=string; label=Path to loan current + loanCurrent = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/loan + # cat=plugin.tx_slubprofileaccount/76595002_Api/125; type=string; label=Path to loan history loanHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/history } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index b0c3d37..3fe555e 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -13,6 +13,7 @@ plugin.tx_slubprofileaccount { user = {$plugin.tx_slubprofileaccount.settings.api.path.user} passwordUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.passwordUpdate} pinUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.pinUpdate} + loanCurrent = {$plugin.tx_slubprofileaccount.settings.api.path.loanCurrent} loanHistory = {$plugin.tx_slubprofileaccount.settings.api.path.loanHistory} } diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 23fd969..d5c4a74 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -49,6 +49,15 @@ Daten der Dashboardeinstellung eines Benutzers aktualisieren. + + User current loan + Aktuelle Ausleihen eines Benutzers + + + Current loan of a specific user. Returns only the user constraint "current loan" data. + Aktuelle Ausleihen zu einem spezifischen Benutzer. Gibt nur die Daten des Benutzers mit der Einschränkung "Aktuelle Ausleihen" zurück. + + User loan history Ausleihhistorie eines Benutzers diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 278c2d5..7745930 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -40,6 +40,13 @@ Update data of dashboard user. + + User current loan + + + Current loan of a specific user. Returns only the user constraint "current loan" data. + + User loan history diff --git a/Resources/Public/Icons/Wizard/user-loan-current.svg b/Resources/Public/Icons/Wizard/user-loan-current.svg new file mode 100644 index 0000000..bb48eb6 --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-loan-current.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index e5b9ba6..48dee11 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -96,6 +96,19 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); +// Configure plugin - user loan current +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserLoanCurrent', + [ + UserLoanController::class => 'current' + ], + [ + UserLoanController::class => 'current' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user loan history ExtensionUtility::configurePlugin( 'SlubProfileAccount', From 83e6f54768c1df90ae95935d98c42fc5c3277354 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 14 Oct 2022 16:42:53 +0200 Subject: [PATCH 60/81] [TASK] Document typoscript loan current --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1f905c9..b64aebc 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,16 @@ Furthermore, have a look at postman and import the "postman_collection" file. Th ### 3.2 Typoscript -| Setup / Constant | Comment | -|----------------------------------------------------------------|----------------------------------| -| plugin.tx_slubprofile_account.settings.api.path.user | Path to get user info / detail | -| plugin.tx_slubprofile_account.settings.api.path.login | Path to login | -| plugin.tx_slubprofile_account.settings.api.path.passwordUpdate | Path to change password | -| plugin.tx_slubprofile_account.settings.api.path.pinUpdate | Path to change pin | -| plugin.tx_slubprofile_account.settings.api.path.loanHistory | Path to loan history | -| plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | -| plugin.tx_slubprofile_account.settings.general.itemsPerPage | Items per page for pagination | +| Setup / Constant | Comment | +|----------------------------------------------------------------|---------------------------------| +| plugin.tx_slubprofile_account.settings.api.path.user | Path to get user info / detail | +| plugin.tx_slubprofile_account.settings.api.path.login | Path to login | +| plugin.tx_slubprofile_account.settings.api.path.passwordUpdate | Path to change password | +| plugin.tx_slubprofile_account.settings.api.path.pinUpdate | Path to change pin | +| plugin.tx_slubprofile_account.settings.api.path.loanCurrent | Path to loan current | +| plugin.tx_slubprofile_account.settings.api.path.loanHistory | Path to loan history | +| plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | +| plugin.tx_slubprofile_account.settings.general.itemsPerPage | Items per page for pagination | ### 3.3 Update account data From 66d99139ea6f6b3bffcc6dacfe4412db3175c1d0 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 20 Oct 2022 10:02:36 +0200 Subject: [PATCH 61/81] [FEATURE] Add api for reserve current and reserve history --- Classes/Controller/UserReserveController.php | 65 ++++++++ Classes/Domain/Model/Dto/ApiConfiguration.php | 36 +++++ Classes/Mvc/View/JsonView.php | 11 ++ Classes/Service/UserReserveService.php | 139 ++++++++++++++++++ Configuration/Icons.php | 8 + Configuration/Routes/Default.yaml | 1 + Configuration/Routes/UserReserve.yaml | 19 +++ Configuration/Services.yaml | 3 + Configuration/TCA/Overrides/tt_content.php | 2 + Configuration/TsConfig/Page/mod.tsconfig | 18 +++ Configuration/TypoScript/constants.typoscript | 4 + Configuration/TypoScript/setup.typoscript | 2 + README.md | 2 + .../Private/Language/de.locallang_backend.xlf | 18 +++ .../Private/Language/locallang_backend.xlf | 14 ++ .../Icons/Wizard/user-reserve-current.svg | 10 ++ .../Icons/Wizard/user-reserve-history.svg | 10 ++ ext_localconf.php | 27 ++++ 18 files changed, 389 insertions(+) create mode 100644 Classes/Controller/UserReserveController.php create mode 100644 Classes/Service/UserReserveService.php create mode 100644 Configuration/Routes/UserReserve.yaml create mode 100644 Resources/Public/Icons/Wizard/user-reserve-current.svg create mode 100644 Resources/Public/Icons/Wizard/user-reserve-history.svg diff --git a/Classes/Controller/UserReserveController.php b/Classes/Controller/UserReserveController.php new file mode 100644 index 0000000..4cdb7f6 --- /dev/null +++ b/Classes/Controller/UserReserveController.php @@ -0,0 +1,65 @@ +userService = $userService; + } + + /** + * @return ResponseInterface + * @throws JsonException + */ + public function currentAction(): ResponseInterface + { + $reserveCurrent = $this->userService->getCurrent( + $this->request->getArguments() + ); + + $this->view->setVariablesToRender(['userReserveCurrent']); + $this->view->assign('userReserveCurrent', $reserveCurrent); + + return $this->jsonResponse(); + } + + /** + * @return ResponseInterface + * @throws JsonException + */ + public function historyAction(): ResponseInterface + { + $reserveHistory = $this->userService->getHistory( + $this->request->getArguments() + ); + + $this->view->setVariablesToRender(['userReserveHistory']); + $this->view->assign('userReserveHistory', $reserveHistory); + + return $this->jsonResponse(); + } +} diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index a4663fb..fb3aea0 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -21,6 +21,8 @@ class ApiConfiguration protected string $pinUpdateUri = ''; protected string $loanCurrentUri = ''; protected string $loanHistoryUri = ''; + protected string $reserveCurrentUri = ''; + protected string $reserveHistoryUri = ''; public function __construct() { @@ -32,6 +34,8 @@ public function __construct() $this->setPinUpdateUri($settings['api']['path']['pinUpdate']); $this->setLoanCurrentUri($settings['api']['path']['loanCurrent']); $this->setLoanHistoryUri($settings['api']['path']['loanHistory']); + $this->setReserveCurrentUri($settings['api']['path']['reserveCurrent']); + $this->setReserveHistoryUri($settings['api']['path']['reserveHistory']); } /** @@ -129,4 +133,36 @@ public function setLoanHistoryUri(string $loanHistoryUri = ''): void { $this->loanHistoryUri = $loanHistoryUri; } + + /** + * @return string + */ + public function getReserveCurrentUri(): string + { + return $this->reserveCurrentUri; + } + + /** + * @param string $reserveCurrentUri + */ + public function setReserveCurrentUri(string $reserveCurrentUri = ''): void + { + $this->reserveCurrentUri = $reserveCurrentUri; + } + + /** + * @return string + */ + public function getReserveHistoryUri(): string + { + return $this->reserveHistoryUri; + } + + /** + * @param string $reserveHistoryUri + */ + public function setReserveHistoryUri(string $reserveHistoryUri = ''): void + { + $this->reserveHistoryUri = $reserveHistoryUri; + } } diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index fb039a2..6ed2797 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -61,6 +61,17 @@ class JsonView extends ExtbaseJsonView 'loanHistory' ] ], + 'userReserveCurrent' => [ + '_only' => [ + 'reserveCurrent' + ] + ], + 'userReserveHistory' => [ + '_only' => [ + 'paginator', + 'reserveHistory' + ] + ], 'userSearchQueryDetail' => [ '_only' => [ 'searchQuery' diff --git a/Classes/Service/UserReserveService.php b/Classes/Service/UserReserveService.php new file mode 100644 index 0000000..1d44e1a --- /dev/null +++ b/Classes/Service/UserReserveService.php @@ -0,0 +1,139 @@ +apiConfiguration = $apiConfiguration; + $this->accountService = $accountService; + $this->request = $request; + $this->itemsPerPage = (int)SettingsUtility::getPluginSettings()['general']['itemsPerPage'] ?? 25; + } + + /** + * @param array $arguments + * @return array|null + * @throws \JsonException + */ + public function getCurrent(array $arguments): ?array + { + $account = $this->accountService->getAccountByArguments($arguments); + $accountId = $this->accountService->getAccountId(); + + if ($accountId > 0 && is_array($account)) { + $processed = $this->requestCurrent($accountId); + + return [ + 'reserveCurrent' => $processed['reserve'] + ]; + } + + return []; + } + + /** + * @param array $arguments + * @return array|null + * @throws \JsonException + */ + public function getHistory(array $arguments): ?array + { + $page = (int)($arguments['page'] ?? 1); + $account = $this->accountService->getAccountByArguments($arguments); + $accountId = $this->accountService->getAccountId(); + + if ($accountId > 0 && is_array($account)) { + $processed = $this->requestHistory($accountId, $page); + + return [ + 'paginator' => [ + 'countItems' => $processed['count'], + 'currentPage' => $page, + 'itemsPerPage' => $this->itemsPerPage + ], + 'reserveHistory' => $processed['history'] + ]; + } + + return []; + } + + /** + * @param int $id + * @return array|null + * @throws \JsonException + */ + protected function requestCurrent(int $id): ?array + { + $uri = $this->apiConfiguration->getReserveCurrentUri(); + $uri = ApiUtility::replaceUriPlaceholder([$id], $uri); + + return $this->request->process($uri, 'GET', [ + 'headers' => [ + 'X-SLUB-Standard' => 'paia_ext', + 'X-SLUB-pretty' => '1', + 'X-SLUB-sort' => 'DESC' + ] + ]); + } + + /** + * @param int $id + * @param int $page + * @return array|null + * @throws \JsonException + */ + protected function requestHistory(int $id, int $page): ?array + { + $uri = $this->apiConfiguration->getReserveHistoryUri(); + $uri = ApiUtility::replaceUriPlaceholder([$id], $uri); + + return $this->request->process($uri, 'GET', [ + 'headers' => [ + 'X-SLUB-Standard' => 'paia_ext', + 'X-SLUB-pretty' => '1', + 'X-SLUB-sort' => 'DESC', + 'X-SLUB-count' => $this->itemsPerPage, + 'X-SLUB-offset' => $this->getOffset($page) + ] + ]); + } + + /** + * @param int $page + * @return int + */ + protected function getOffset(int $page): int + { + return (int)($page * $this->itemsPerPage) - $this->itemsPerPage; + } +} diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 6f5f196..9675577 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -51,6 +51,14 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-pin-update.svg' ], + 'slubprofileaccount-wizard-userreservecurrent' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-reserve-current.svg' + ], + 'slubprofileaccount-wizard-userreservehistory' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-reserve-history.svg' + ], 'slubprofileaccount-wizard-usersearchquerydetail' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-search-query-detail.svg' diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index 86bdf01..ba5cb92 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -8,5 +8,6 @@ imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserLoan.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPasswordUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPinUpdate.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserReserve.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserSearchQueryUpdate.yaml' diff --git a/Configuration/Routes/UserReserve.yaml b/Configuration/Routes/UserReserve.yaml new file mode 100644 index 0000000..0f5399a --- /dev/null +++ b/Configuration/Routes/UserReserve.yaml @@ -0,0 +1,19 @@ +routeEnhancers: + SlubAccountUserReserveCurrent: + type: Simple + limitToPages: [35] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userreservecurrent/user' + SlubAccountUserReserveHistory: + type: Simple + limitToPages: [36] + routePath: '/{user}/page/{page}' + requirements: + user: '[0-9]{1,10}' + page: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userreservehistory/user' + page: 'tx_slubprofileaccount_userreservehistory/page' diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 62d9058..50aa6a5 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -38,6 +38,9 @@ services: Slub\SlubProfileAccount\Service\UserPinService: public: true + Slub\SlubProfileAccount\Service\UserReserveService: + public: true + Slub\SlubProfileAccount\Service\UserSearchQueryService: public: true diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 2b75176..c46fa54 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -67,6 +67,8 @@ 'userloanhistory', 'userpinupdate', 'userpasswordupdate', + 'userreservecurrent', + 'userreservehistory', 'usersearchquerydetail', 'usersearchqueryupdate' ] diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index 0e10373..3906a4f 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -68,6 +68,22 @@ mod { tt_content_defValues.CType = slubprofileaccount_userpasswordupdate } + slubprofileaccount_userreservecurrent { + iconIdentifier = slubprofileaccount-wizard-userreservecurrent + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userreservecurrent.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userreservecurrent.description + tt_content_defValues.CType = slubprofileaccount_userreservecurrent + } + + slubprofileaccount_userreservehistory { + iconIdentifier = slubprofileaccount-wizard-userreservehistory + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userreservehistory.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userreservehistory.description + tt_content_defValues.CType = slubprofileaccount_userreservehistory + } + slubprofileaccount_usersearchquerydetail { iconIdentifier = slubprofileaccount-wizard-usersearchquerydetail iconOverlay = slubprofileaccount-overlay-extension @@ -93,6 +109,8 @@ mod { show := addToList(slubprofileaccount_userloanhistory) show := addToList(slubprofileaccount_userpasswordupdate) show := addToList(slubprofileaccount_userpindupdate) + show := addToList(slubprofileaccount_userreservecurrent) + show := addToList(slubprofileaccount_userreservehistory) show := addToList(slubprofileaccount_usersearchqueryupdate) show := addToList(slubprofileaccount_usersearchquerydetail) } diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 8bbb6e2..c7b44fe 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -19,6 +19,10 @@ plugin.tx_slubprofileaccount { loanCurrent = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/loan # cat=plugin.tx_slubprofileaccount/76595002_Api/125; type=string; label=Path to loan history loanHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/history + # cat=plugin.tx_slubprofileaccount/76595002_Api/130; type=string; label=Path to reserve current + reserveCurrent = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/reserve + # cat=plugin.tx_slubprofileaccount/76595002_Api/135; type=string; label=Path to reserve history + reserveHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/historyres } # cat=plugin.tx_slubprofileaccount/76595003_Cache/100; type=int; label=Life time account cache in seconds diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 3fe555e..433f72f 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -15,6 +15,8 @@ plugin.tx_slubprofileaccount { pinUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.pinUpdate} loanCurrent = {$plugin.tx_slubprofileaccount.settings.api.path.loanCurrent} loanHistory = {$plugin.tx_slubprofileaccount.settings.api.path.loanHistory} + reserveCurrent = {$plugin.tx_slubprofileaccount.settings.api.path.reserveCurrent} + reserveHistory = {$plugin.tx_slubprofileaccount.settings.api.path.reserveHistory} } cache.account.lifeTime = {$plugin.tx_slubprofileaccount.settings.cache.account.lifeTime} diff --git a/README.md b/README.md index b64aebc..b3fd51d 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ Furthermore, have a look at postman and import the "postman_collection" file. Th | plugin.tx_slubprofile_account.settings.api.path.pinUpdate | Path to change pin | | plugin.tx_slubprofile_account.settings.api.path.loanCurrent | Path to loan current | | plugin.tx_slubprofile_account.settings.api.path.loanHistory | Path to loan history | +| plugin.tx_slubprofile_account.settings.api.path.reserveCurrent | Path to reserve current | +| plugin.tx_slubprofile_account.settings.api.path.reserveHistory | Path to reserve history | | plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | | plugin.tx_slubprofile_account.settings.general.itemsPerPage | Items per page for pagination | diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index d5c4a74..82ce839 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -67,6 +67,24 @@ Ausleihhistorie zu einem spezifischen Benutzer. Gibt nur die Daten des Benutzers mit der Einschränkung "Ausleihhistorie" zurück. + + User current reservation + Aktuelle Vormerkungen eines Benutzers + + + Current reservation of a specific user. Returns only the user constraint "current reservation" data. + Aktuelle Vormerkungen zu einem spezifischen Benutzer. Gibt nur die Daten des Benutzers mit der Einschränkung "Aktuelle Vormerkungen" zurück. + + + + User reservation history + Vormerkhistorie eines Benutzers + + + Reservation history of a specific user. Returns only the user constraint "reservation history" data. + Vormerkhistorie zu einem spezifischen Benutzer. Gibt nur die Daten des Benutzers mit der Einschränkung "Vormerkhistorie" zurück. + + Update password Passwort aktualisieren diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 7745930..eaeca80 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -54,6 +54,20 @@ Loan history of a specific user. Returns only the user constraint "loan history" data. + + User current reservation + + + Current reservation of a specific user. Returns only the user constraint "current reservation" data. + + + + User reservation history + + + Reservation history of a specific user. Returns only the user constraint "reservation history" data. + + Update password diff --git a/Resources/Public/Icons/Wizard/user-reserve-current.svg b/Resources/Public/Icons/Wizard/user-reserve-current.svg new file mode 100644 index 0000000..bb48eb6 --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-reserve-current.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Resources/Public/Icons/Wizard/user-reserve-history.svg b/Resources/Public/Icons/Wizard/user-reserve-history.svg new file mode 100644 index 0000000..bb48eb6 --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-reserve-history.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index 48dee11..fa36a3f 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -5,6 +5,7 @@ use Slub\SlubProfileAccount\Controller\UserLoanController; use Slub\SlubProfileAccount\Controller\UserPasswordController; use Slub\SlubProfileAccount\Controller\UserPinController; +use Slub\SlubProfileAccount\Controller\UserReserveController; use Slub\SlubProfileAccount\Controller\UserSearchQueryController; use Slub\SlubProfileAccount\Form\Element\AccountOverviewElement; use Slub\SlubProfileAccount\Form\Element\UserCategoryDescriptionElement; @@ -122,6 +123,32 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); +// Configure plugin - user reserve current +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserReserveCurrent', + [ + UserReserveController::class => 'current' + ], + [ + UserReserveController::class => 'current' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + +// Configure plugin - user reserve history +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserReserveHistory', + [ + UserReserveController::class => 'history' + ], + [ + UserReserveController::class => 'history' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user search query detail ExtensionUtility::configurePlugin( 'SlubProfileAccount', From de88ae17e47735a9ff24f1adcd26e70308dff200 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 20 Oct 2022 10:03:03 +0200 Subject: [PATCH 62/81] [POSTMAN] Add api for reserve current and reserve history --- postman_collection.json | 117 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/postman_collection.json b/postman_collection.json index da77673..219734d 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -318,6 +318,123 @@ } ] }, + { + "name": "Reserve", + "item": [ + { + "name": "Current", + "item": [ + { + "name": "Get - Default", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{domain}}/benutzer/ausleihe/aktuell/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihe", + "aktuell", + "{{user}}" + ] + } + }, + "response": [ + { + "name": "Unknown user", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihhistorie", + "{{user}}" + ] + } + }, + "_postman_previewlanguage": "json", + "header": [], + "cookie": [], + "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" + } + ] + } + ] + }, + { + "name": "History", + "item": [ + { + "name": "Get - Default", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{domain}}/benutzer/vormerkung/historie/{{user}}/page/1", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "vormerkung", + "historie", + "{{user}}", + "page", + "1" + ] + } + }, + "response": [ + { + "name": "Unknown user", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihhistorie", + "{{user}}" + ] + } + }, + "_postman_previewlanguage": "json", + "header": [], + "cookie": [], + "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" + } + ] + } + ] + } + ] + }, { "name": "Search query", "item": [ From 7bc4a6e81ff9c5e342a8ab967628bdd8a6b3f8ff Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 21 Oct 2022 10:30:26 +0200 Subject: [PATCH 63/81] [POSTMAN] Refresh api for reserve current and reserve history --- postman_collection.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postman_collection.json b/postman_collection.json index 219734d..f7eeb47 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -337,13 +337,13 @@ "raw": "" }, "url": { - "raw": "{{domain}}/benutzer/ausleihe/aktuell/{{user}}", + "raw": "{{domain}}/benutzer/vormerkung/aktuell/{{user}}", "host": [ "{{domain}}" ], "path": [ "benutzer", - "ausleihe", + "vormerkung", "aktuell", "{{user}}" ] From 610458e6d932023194276bf169e9d04b68c084bb Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 4 Nov 2022 16:32:50 +0100 Subject: [PATCH 64/81] [TASK] Change API-Paths and methode type to change pin --- Classes/Service/UserPinService.php | 3 ++- Classes/Validation/PinArgumentValidation.php | 10 +++++----- Configuration/TypoScript/constants.typoscript | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Classes/Service/UserPinService.php b/Classes/Service/UserPinService.php index 0d129c9..c75f16d 100644 --- a/Classes/Service/UserPinService.php +++ b/Classes/Service/UserPinService.php @@ -17,6 +17,7 @@ use Slub\SlubProfileAccount\Utility\ApiUtility; use Slub\SlubProfileAccount\Utility\FileUtility; use Slub\SlubProfileAccount\Validation\PinArgumentValidation; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; class UserPinService { @@ -62,7 +63,7 @@ public function update(User $user): array $uri = $this->apiConfiguration->getPinUpdateUri(); $uri = ApiUtility::replaceUriPlaceholder([$accountId], $uri); - $processed = $this->request->process($uri, 'POST', [ + $processed = $this->request->process($uri, 'PATCH', [ 'body' => json_encode([ 'SelfCheckPin' => $data['pin'] ]) diff --git a/Classes/Validation/PinArgumentValidation.php b/Classes/Validation/PinArgumentValidation.php index 98e2229..8131389 100644 --- a/Classes/Validation/PinArgumentValidation.php +++ b/Classes/Validation/PinArgumentValidation.php @@ -98,13 +98,13 @@ private function validatePassword(string $username, string $password): array ]) ]); - if ($processed['code'] !== 200) { - return [ - 'password' => ApiUtility::VALIDATION['isInvalidLogin'] - ]; + if ($processed['status'] === 1) { + return []; } - return []; + return [ + 'password' => ApiUtility::VALIDATION['isInvalidLogin'] + ]; } /** diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index c7b44fe..bb1483f 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -8,13 +8,13 @@ plugin.tx_slubprofileaccount { settings { api.path { # cat=plugin.tx_slubprofileaccount/76595002_Api/100; type=string; label=Path for login - login = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/auth/login + login = https://liberoproxy.staging.katalogbeta.slub-dresden.de/auth/login # cat=plugin.tx_slubprofileaccount/76595002_Api/105; type=string; label=Path for user user = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID### # cat=plugin.tx_slubprofileaccount/76595002_Api/110; type=string; label=Path to update password passwordUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/change # cat=plugin.tx_slubprofileaccount/76595002_Api/115; type=string; label=Path to update pin - pinUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/###USER_ID###/pin + pinUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/auth/###USER_ID###/pin # cat=plugin.tx_slubprofileaccount/76595002_Api/120; type=string; label=Path to loan current loanCurrent = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/loan # cat=plugin.tx_slubprofileaccount/76595002_Api/125; type=string; label=Path to loan history From 39267b8bc9297e7222bd2fda6ca378bd275da551 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 4 Nov 2022 16:33:48 +0100 Subject: [PATCH 65/81] [TASK] Code quality --- Classes/Service/UserPinService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Classes/Service/UserPinService.php b/Classes/Service/UserPinService.php index c75f16d..ea2b6f1 100644 --- a/Classes/Service/UserPinService.php +++ b/Classes/Service/UserPinService.php @@ -17,7 +17,6 @@ use Slub\SlubProfileAccount\Utility\ApiUtility; use Slub\SlubProfileAccount\Utility\FileUtility; use Slub\SlubProfileAccount\Validation\PinArgumentValidation; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; class UserPinService { From a77a7830c6b6edd0017eb90da1e0036be000573b Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 4 Nov 2022 16:45:46 +0100 Subject: [PATCH 66/81] [TASK] Change api to change password --- Configuration/TypoScript/constants.typoscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index bb1483f..a8401d6 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -12,7 +12,7 @@ plugin.tx_slubprofileaccount { # cat=plugin.tx_slubprofileaccount/76595002_Api/105; type=string; label=Path for user user = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID### # cat=plugin.tx_slubprofileaccount/76595002_Api/110; type=string; label=Path to update password - passwordUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/auth/change + passwordUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/auth/change # cat=plugin.tx_slubprofileaccount/76595002_Api/115; type=string; label=Path to update pin pinUpdate = https://liberoproxy.staging.katalogbeta.slub-dresden.de/auth/###USER_ID###/pin # cat=plugin.tx_slubprofileaccount/76595002_Api/120; type=string; label=Path to loan current From 18fbe51da827afa0b222678ea589dc8f08c8b000 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 15 Nov 2022 10:39:10 +0100 Subject: [PATCH 67/81] [POSTMAN] Change properties for password update api --- postman_collection.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postman_collection.json b/postman_collection.json index f7eeb47..127e402 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -527,7 +527,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"password\": {\r\n \"newPassword\": \"test\",\r\n \"patron\": \"4998866\"\r\n }\r\n}", + "raw": "{\r\n \"password\": {\r\n \"password\": \"test\",\r\n \"newPassword\": \"test\"\r\n }\r\n}", "options": { "raw": { "language": "json" From 561d59673e261d13d3a88f092f69817052877f82 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 15 Nov 2022 10:39:45 +0100 Subject: [PATCH 68/81] [TASK] Add password validation when update password --- Classes/Service/UserPasswordService.php | 11 ++ .../Validation/PasswordArgumentValidation.php | 102 ++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 Classes/Validation/PasswordArgumentValidation.php diff --git a/Classes/Service/UserPasswordService.php b/Classes/Service/UserPasswordService.php index 87ba5ab..b5752c2 100644 --- a/Classes/Service/UserPasswordService.php +++ b/Classes/Service/UserPasswordService.php @@ -16,21 +16,26 @@ use Slub\SlubProfileAccount\Http\Request; use Slub\SlubProfileAccount\Utility\ApiUtility; use Slub\SlubProfileAccount\Utility\FileUtility; +use Slub\SlubProfileAccount\Validation\PasswordArgumentValidation; class UserPasswordService { protected ApiConfiguration $apiConfiguration; + protected PasswordArgumentValidation $passwordArgumentValidation; protected Request $request; /** * @param ApiConfiguration $apiConfiguration + * @param PasswordArgumentValidation $passwordArgumentValidation * @param Request $request */ public function __construct( ApiConfiguration $apiConfiguration, + PasswordArgumentValidation $passwordArgumentValidation, Request $request ) { $this->apiConfiguration = $apiConfiguration; + $this->passwordArgumentValidation = $passwordArgumentValidation; $this->request = $request; } @@ -48,6 +53,12 @@ public function update(User $user): array return ApiUtility::STATUS[400]; } + $validated = $this->passwordArgumentValidation->validateUpdateArguments($data, $accountId); + + if ($validated['code'] === 400) { + return $validated; + } + $uri = $this->apiConfiguration->getPasswordUpdateUri(); $uri = ApiUtility::replaceUriPlaceholder([$accountId], $uri); diff --git a/Classes/Validation/PasswordArgumentValidation.php b/Classes/Validation/PasswordArgumentValidation.php new file mode 100644 index 0000000..5a46134 --- /dev/null +++ b/Classes/Validation/PasswordArgumentValidation.php @@ -0,0 +1,102 @@ +isEmpty($arguments) ?? []; + + if (isset($arguments['password'])) { + $error = array_merge($error, $this->validatePassword((string)$accountId, $arguments['password'])); + } + + if (count($error) > 0) { + $status = ApiUtility::STATUS[400]; + $status['error'] = $error; + + return $status; + } + + return []; + } + + /** + * @param string $username + * @param string $password + * @return array + * @throws \JsonException + */ + private function validatePassword(string $username, string $password): array + { + $uri = GeneralUtility::makeInstance(ApiConfiguration::class) + ->getLoginUri(); + + $processed = GeneralUtility::makeInstance(Request::class) + ->process($uri, 'POST', [ + 'body' => json_encode([ + 'username' => $username, + 'password' => $password + ]) + ]); + + if ($processed['status'] === 1) { + return []; + } + + return [ + 'password' => ApiUtility::VALIDATION['isInvalidLogin'] + ]; + } + + /** + * @param array $arguments + * @return array + */ + private function isEmpty(array $arguments): array + { + if (count($arguments) === 0) { + return []; + } + + $error = []; + + foreach ($arguments as $key => $value) { + if (in_array($key, self::REQUIRED_ARGUMENTS) && empty($value)) { + $error[$key] = ApiUtility::VALIDATION['isEmpty']; + } + } + + return $error; + } +} From 89e276307ccba6c81979b8d37e14d09c7def4abd Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 16 Nov 2022 16:55:23 +0100 Subject: [PATCH 69/81] [POSTMAN] Add load renewal api --- postman_collection.json | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/postman_collection.json b/postman_collection.json index 127e402..c77c084 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -315,6 +315,35 @@ ] } ] + }, + { + "name": "Renewal", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"renew\": [\r\n 34778448,\r\n 30688558,\r\n 34779972\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{domain}}/benutzer/ausleihe/erneuern/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "ausleihe", + "erneuern", + "{{user}}" + ] + } + }, + "response": [] } ] }, From fcd8d25caf01618002f2b551eabdf62cd3857bbe Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 16 Nov 2022 16:55:45 +0100 Subject: [PATCH 70/81] [TASK] Add load renewal api --- Classes/Controller/UserLoanController.php | 17 +++ Classes/Domain/Model/Dto/ApiConfiguration.php | 18 +++ Classes/Service/UserLoanService.php | 117 +++++++++++++++--- Classes/Utility/ApiUtility.php | 11 +- Classes/Validation/LoanArgumentValidation.php | 56 +++++++++ Configuration/Icons.php | 4 + Configuration/Routes/UserLoan.yaml | 8 ++ Configuration/TCA/Overrides/tt_content.php | 3 + Configuration/TsConfig/Page/mod.tsconfig | 9 ++ Configuration/TypoScript/constants.typoscript | 6 +- Configuration/TypoScript/setup.typoscript | 1 + README.md | 1 + .../Private/Language/de.locallang_backend.xlf | 9 ++ .../Private/Language/locallang_backend.xlf | 7 ++ .../Public/Icons/Wizard/user-loan-renewal.svg | 7 ++ ext_localconf.php | 14 +++ 16 files changed, 265 insertions(+), 23 deletions(-) create mode 100644 Classes/Validation/LoanArgumentValidation.php create mode 100644 Resources/Public/Icons/Wizard/user-loan-renewal.svg diff --git a/Classes/Controller/UserLoanController.php b/Classes/Controller/UserLoanController.php index b87cce1..5b5f16f 100644 --- a/Classes/Controller/UserLoanController.php +++ b/Classes/Controller/UserLoanController.php @@ -16,6 +16,7 @@ use Slub\SlubProfileAccount\Mvc\View\JsonView; use Slub\SlubProfileAccount\Service\UserLoanService as UserService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; class UserLoanController extends ActionController { @@ -62,4 +63,20 @@ public function historyAction(): ResponseInterface return $this->jsonResponse(); } + + /** + * @return ResponseInterface + * @throws JsonException + */ + public function renewalAction(): ResponseInterface + { + $status = $this->userService->getRenewal( + $this->request->getArguments() + ); + + $this->view->setVariablesToRender(['status']); + $this->view->assign('status', $status); + + return $this->jsonResponse(); + } } diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index fb3aea0..242614f 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -21,6 +21,7 @@ class ApiConfiguration protected string $pinUpdateUri = ''; protected string $loanCurrentUri = ''; protected string $loanHistoryUri = ''; + protected string $loanRenewalUri = ''; protected string $reserveCurrentUri = ''; protected string $reserveHistoryUri = ''; @@ -34,6 +35,7 @@ public function __construct() $this->setPinUpdateUri($settings['api']['path']['pinUpdate']); $this->setLoanCurrentUri($settings['api']['path']['loanCurrent']); $this->setLoanHistoryUri($settings['api']['path']['loanHistory']); + $this->setLoanRenewalUri($settings['api']['path']['loanRenewal']); $this->setReserveCurrentUri($settings['api']['path']['reserveCurrent']); $this->setReserveHistoryUri($settings['api']['path']['reserveHistory']); } @@ -134,6 +136,22 @@ public function setLoanHistoryUri(string $loanHistoryUri = ''): void $this->loanHistoryUri = $loanHistoryUri; } + /** + * @return string + */ + public function getLoanRenewalUri(): string + { + return $this->loanRenewalUri; + } + + /** + * @param string $loanRenewalUri + */ + public function setLoanRenewalUri(string $loanRenewalUri = ''): void + { + $this->loanRenewalUri = $loanRenewalUri; + } + /** * @return string */ diff --git a/Classes/Service/UserLoanService.php b/Classes/Service/UserLoanService.php index f918a84..e9b7cc0 100644 --- a/Classes/Service/UserLoanService.php +++ b/Classes/Service/UserLoanService.php @@ -14,27 +14,33 @@ use Slub\SlubProfileAccount\Domain\Model\Dto\ApiConfiguration; use Slub\SlubProfileAccount\Http\Request; use Slub\SlubProfileAccount\Utility\ApiUtility; +use Slub\SlubProfileAccount\Utility\FileUtility; use Slub\SlubProfileAccount\Utility\SettingsUtility; +use Slub\SlubProfileAccount\Validation\LoanArgumentValidation; class UserLoanService { protected ApiConfiguration $apiConfiguration; protected AccountService $accountService; + protected LoanArgumentValidation $loanArgumentValidation; protected Request $request; protected int $itemsPerPage; /** * @param ApiConfiguration $apiConfiguration * @param AccountService $accountService + * @param LoanArgumentValidation $loanArgumentValidation * @param Request $request */ public function __construct( ApiConfiguration $apiConfiguration, AccountService $accountService, + LoanArgumentValidation $loanArgumentValidation, Request $request ) { $this->apiConfiguration = $apiConfiguration; $this->accountService = $accountService; + $this->loanArgumentValidation = $loanArgumentValidation; $this->request = $request; $this->itemsPerPage = (int)SettingsUtility::getPluginSettings()['general']['itemsPerPage'] ?? 25; } @@ -46,18 +52,17 @@ public function __construct( */ public function getCurrent(array $arguments): ?array { - $account = $this->accountService->getAccountByArguments($arguments); - $accountId = $this->accountService->getAccountId(); - - if ($accountId > 0 && is_array($account)) { - $processed = $this->requestCurrent($accountId); + $accountId = $this->getAccountId($arguments); - return [ - 'loanCurrent' => $processed['loan'] - ]; + if ($accountId === null) { + return []; } - return []; + $processed = $this->requestCurrent($accountId); + + return [ + 'loanCurrent' => $processed['loan'] + ]; } /** @@ -67,24 +72,80 @@ public function getCurrent(array $arguments): ?array */ public function getHistory(array $arguments): ?array { + $accountId = $this->getAccountId($arguments); + + if ($accountId === null) { + return []; + } + $page = (int)($arguments['page'] ?? 1); - $account = $this->accountService->getAccountByArguments($arguments); - $accountId = $this->accountService->getAccountId(); + $processed = $this->requestHistory($accountId, $page); + + return [ + 'paginator' => [ + 'countItems' => $processed['count'], + 'currentPage' => $page, + 'itemsPerPage' => $this->itemsPerPage + ], + 'loanHistory' => $processed['history'] + ]; + } - if ($accountId > 0 && is_array($account)) { - $processed = $this->requestHistory($accountId, $page); + /** + * @param array $arguments + * @return array|null + * @throws \JsonException + */ + public function getRenewal(array $arguments): ?array + { + $current = $this->getCurrent($arguments); + + if (count($current) === 0) { + return []; + } + + $data = FileUtility::getContent()['renew']; + + if ($data === null) { + return ApiUtility::STATUS[400]; + } + + $validArguments = $this->loanArgumentValidation->validateRenewalArguments($data, $current['loanCurrent']); + $accountId = $this->getAccountId($arguments); + + return $this->requestRenewal($validArguments['barcodes'], $accountId); + } + /** + * @param array $barcodes + * @param int $accountId + * @return array + * @throws \JsonException + */ + protected function requestRenewal(array $barcodes, int $accountId): array + { + if (count($barcodes) === 0) { return [ - 'paginator' => [ - 'countItems' => $processed['count'], - 'currentPage' => $page, - 'itemsPerPage' => $this->itemsPerPage - ], - 'loanHistory' => $processed['history'] + 0 => ApiUtility::STATUS[405] ]; } - return []; + $uri = $this->apiConfiguration->getLoanRenewalUri(); + $results = []; + + foreach ($barcodes as $barcode) { + $barCodeUri = ApiUtility::replaceUriPlaceholder([$accountId, $barcode], $uri); + $processed = $this->request->process($barCodeUri, 'POST'); + + if ($processed['status'] === 1) { + $results[$barcode] = ApiUtility::STATUS[200]; + } else { + $results[$barcode] = ApiUtility::STATUS[410]; + $results[$barcode]['error'] = $processed['message']; + } + } + + return $results; } /** @@ -136,4 +197,20 @@ protected function getOffset(int $page): int { return (int)($page * $this->itemsPerPage) - $this->itemsPerPage; } + + /** + * @param array $arguments + * @return int|null + */ + protected function getAccountId(array $arguments): ?int + { + $account = $this->accountService->getAccountByArguments($arguments); + $accountId = $this->accountService->getAccountId(); + + if ($accountId > 0 && is_array($account)) { + return $accountId; + } + + return null; + } } diff --git a/Classes/Utility/ApiUtility.php b/Classes/Utility/ApiUtility.php index 3de47c1..f7d1696 100644 --- a/Classes/Utility/ApiUtility.php +++ b/Classes/Utility/ApiUtility.php @@ -22,6 +22,14 @@ class ApiUtility 'code' => 400, 'message' => 'Bad Request', ], + 405 => [ + 'code' => 405, + 'message' => 'Bad Request. No renewable data given.', + ], + 410 => [ + 'code' => 410, + 'message' => 'Bad Request. Renewal not possible.', + ], 500 => [ 'code' => 500, 'message' => 'Internal Server Error' @@ -53,7 +61,8 @@ class ApiUtility ]; public const URI_PLACEHOLDER = [ - '###USER_ID###' + '###USER_ID###', + '###BARCODE###' ]; /** diff --git a/Classes/Validation/LoanArgumentValidation.php b/Classes/Validation/LoanArgumentValidation.php new file mode 100644 index 0000000..9526d91 --- /dev/null +++ b/Classes/Validation/LoanArgumentValidation.php @@ -0,0 +1,56 @@ +validateBarcode((int)$argument, $loans); + } + + return [ + 'barcodes' => $this->validBarcodes + ]; + } + + /** + * Check that given barcode is a real barcode of mine and + * it is renewable. + * + * @param int $barcode + * @param array $loans + * @return void + */ + private function validateBarcode(int $barcode, array $loans): void + { + foreach ($loans as $loan) { + if ((int)$loan['X_barcode'] === $barcode && + (bool)$loan['X_is_renewable'] === true + ) { + $this->validBarcodes[] = $barcode; + } + } + } +} diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 9675577..a278e68 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -43,6 +43,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-loan-history.svg' ], + 'slubprofileaccount-wizard-userloanrenewal' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-loan-renewal.svg' + ], 'slubprofileaccount-wizard-userpasswordupdate' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-password-update.svg' diff --git a/Configuration/Routes/UserLoan.yaml b/Configuration/Routes/UserLoan.yaml index 1843655..8f13276 100644 --- a/Configuration/Routes/UserLoan.yaml +++ b/Configuration/Routes/UserLoan.yaml @@ -17,3 +17,11 @@ routeEnhancers: _arguments: user: 'tx_slubprofileaccount_userloanhistory/user' page: 'tx_slubprofileaccount_userloanhistory/page' + SlubAccountUserLoanRenewal: + type: Simple + limitToPages: [37] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userloanrenewal/user' diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index c46fa54..313eb42 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -58,6 +58,8 @@ } })( 'slub_profile_account', + // All the content elements have the same structure. Keep them in one file + // instead of making each separate. [ 'useraccountdetail', 'useraccountupdate', @@ -65,6 +67,7 @@ 'userdashboardupdate', 'userloancurrent', 'userloanhistory', + 'userloanrenewal', 'userpinupdate', 'userpasswordupdate', 'userreservecurrent', diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index 3906a4f..ff12ccf 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -52,6 +52,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_userloanhistory } + slubprofileaccount_userloanrenewal { + iconIdentifier = slubprofileaccount-wizard-userloanrenewal + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloanrenewal.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userloanrenewal.description + tt_content_defValues.CType = slubprofileaccount_userloanrenewal + } + slubprofileaccount_userpindupdate { iconIdentifier = slubprofileaccount-wizard-userpinupdate iconOverlay = slubprofileaccount-overlay-extension @@ -107,6 +115,7 @@ mod { show := addToList(slubprofileaccount_userdashboarddetail) show := addToList(slubprofileaccount_userloancurrent) show := addToList(slubprofileaccount_userloanhistory) + show := addToList(slubprofileaccount_userloanrenewal) show := addToList(slubprofileaccount_userpasswordupdate) show := addToList(slubprofileaccount_userpindupdate) show := addToList(slubprofileaccount_userreservecurrent) diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index a8401d6..6560357 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -19,9 +19,11 @@ plugin.tx_slubprofileaccount { loanCurrent = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/loan # cat=plugin.tx_slubprofileaccount/76595002_Api/125; type=string; label=Path to loan history loanHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/history - # cat=plugin.tx_slubprofileaccount/76595002_Api/130; type=string; label=Path to reserve current + # cat=plugin.tx_slubprofileaccount/76595002_Api/130; type=string; label=Path to loan renewal + loanRenewal = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/renew/###BARCODE### + # cat=plugin.tx_slubprofileaccount/76595002_Api/135; type=string; label=Path to reserve current reserveCurrent = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/reserve - # cat=plugin.tx_slubprofileaccount/76595002_Api/135; type=string; label=Path to reserve history + # cat=plugin.tx_slubprofileaccount/76595002_Api/140; type=string; label=Path to reserve history reserveHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/historyres } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 433f72f..de3cbab 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -15,6 +15,7 @@ plugin.tx_slubprofileaccount { pinUpdate = {$plugin.tx_slubprofileaccount.settings.api.path.pinUpdate} loanCurrent = {$plugin.tx_slubprofileaccount.settings.api.path.loanCurrent} loanHistory = {$plugin.tx_slubprofileaccount.settings.api.path.loanHistory} + loanRenewal = {$plugin.tx_slubprofileaccount.settings.api.path.loanRenewal} reserveCurrent = {$plugin.tx_slubprofileaccount.settings.api.path.reserveCurrent} reserveHistory = {$plugin.tx_slubprofileaccount.settings.api.path.reserveHistory} } diff --git a/README.md b/README.md index b3fd51d..f93e5df 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Furthermore, have a look at postman and import the "postman_collection" file. Th | plugin.tx_slubprofile_account.settings.api.path.pinUpdate | Path to change pin | | plugin.tx_slubprofile_account.settings.api.path.loanCurrent | Path to loan current | | plugin.tx_slubprofile_account.settings.api.path.loanHistory | Path to loan history | +| plugin.tx_slubprofile_account.settings.api.path.loanRenewal | Path to loan loanRenewal | | plugin.tx_slubprofile_account.settings.api.path.reserveCurrent | Path to reserve current | | plugin.tx_slubprofile_account.settings.api.path.reserveHistory | Path to reserve history | | plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 82ce839..d3fd10f 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -67,6 +67,15 @@ Ausleihhistorie zu einem spezifischen Benutzer. Gibt nur die Daten des Benutzers mit der Einschränkung "Ausleihhistorie" zurück. + + User loan renew medium + Ausleihe eines Mediums verlängern + + + Renew a loan medium from a specific user. + Ausleihe eines Mediums zu einem spezifischen Benutzer verlängern. + + User current reservation Aktuelle Vormerkungen eines Benutzers diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index eaeca80..4aa5c31 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -54,6 +54,13 @@ Loan history of a specific user. Returns only the user constraint "loan history" data. + + User loan renew medium + + + Renew a loan medium from a specific user. + + User current reservation diff --git a/Resources/Public/Icons/Wizard/user-loan-renewal.svg b/Resources/Public/Icons/Wizard/user-loan-renewal.svg new file mode 100644 index 0000000..d4b3535 --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-loan-renewal.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index fa36a3f..40c37c4 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -123,6 +123,20 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); + +// Configure plugin - user loan history +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserLoanRenewal', + [ + UserLoanController::class => 'renewal' + ], + [ + UserLoanController::class => 'renewal' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user reserve current ExtensionUtility::configurePlugin( 'SlubProfileAccount', From 7b01cb37cc78315231297e99f57014ed9cbd360c Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 17 Nov 2022 11:08:32 +0100 Subject: [PATCH 71/81] [TASK] Improve code quality --- Classes/Controller/UserLoanController.php | 1 - Classes/Validation/LoanArgumentValidation.php | 1 - ext_localconf.php | 1 - 3 files changed, 3 deletions(-) diff --git a/Classes/Controller/UserLoanController.php b/Classes/Controller/UserLoanController.php index 5b5f16f..b594b51 100644 --- a/Classes/Controller/UserLoanController.php +++ b/Classes/Controller/UserLoanController.php @@ -16,7 +16,6 @@ use Slub\SlubProfileAccount\Mvc\View\JsonView; use Slub\SlubProfileAccount\Service\UserLoanService as UserService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -use TYPO3\CMS\Extbase\Utility\DebuggerUtility; class UserLoanController extends ActionController { diff --git a/Classes/Validation/LoanArgumentValidation.php b/Classes/Validation/LoanArgumentValidation.php index 9526d91..fc7e787 100644 --- a/Classes/Validation/LoanArgumentValidation.php +++ b/Classes/Validation/LoanArgumentValidation.php @@ -41,7 +41,6 @@ public function validateRenewalArguments(array $arguments, array $loans): array * * @param int $barcode * @param array $loans - * @return void */ private function validateBarcode(int $barcode, array $loans): void { diff --git a/ext_localconf.php b/ext_localconf.php index 40c37c4..bdb4272 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -123,7 +123,6 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); - // Configure plugin - user loan history ExtensionUtility::configurePlugin( 'SlubProfileAccount', From 5c18d43fd0848f018925fcdddbd64a2f4a2cb331 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 23 Nov 2022 16:48:48 +0100 Subject: [PATCH 72/81] [POSTMAN] Add api to delete reservation --- postman_collection.json | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/postman_collection.json b/postman_collection.json index c77c084..0f04bfa 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -461,6 +461,35 @@ ] } ] + }, + { + "name": "Delete", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"delete\": [\r\n 30490690,\r\n 1234567890\r\n ]\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{domain}}/benutzer/vormerkung/loeschen/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "vormerkung", + "loeschen", + "{{user}}" + ] + } + }, + "response": [] } ] }, From 0af0873d8149e234080bf2eb9707d177aada3f80 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 23 Nov 2022 16:49:05 +0100 Subject: [PATCH 73/81] [TASK] Add api to delete reservation --- Classes/Controller/UserReserveController.php | 16 ++++ Classes/Domain/Model/Dto/ApiConfiguration.php | 18 ++++ Classes/Service/UserLoanService.php | 4 +- Classes/Service/UserReserveService.php | 88 +++++++++++++++++++ Classes/Utility/ApiUtility.php | 12 ++- .../Validation/ReserveArgumentValidation.php | 53 +++++++++++ Configuration/Icons.php | 4 + Configuration/Routes/UserReserve.yaml | 8 ++ Configuration/TCA/Overrides/tt_content.php | 1 + Configuration/TsConfig/Page/mod.tsconfig | 9 ++ Configuration/TypoScript/constants.typoscript | 4 +- Configuration/TypoScript/setup.typoscript | 1 + README.md | 1 + .../Private/Language/de.locallang_backend.xlf | 9 ++ .../Private/Language/locallang_backend.xlf | 7 ++ .../Icons/Wizard/user-reserve-delete.svg | 6 ++ ext_localconf.php | 13 +++ 17 files changed, 250 insertions(+), 4 deletions(-) create mode 100644 Classes/Validation/ReserveArgumentValidation.php create mode 100644 Resources/Public/Icons/Wizard/user-reserve-delete.svg diff --git a/Classes/Controller/UserReserveController.php b/Classes/Controller/UserReserveController.php index 4cdb7f6..0b1ee9c 100644 --- a/Classes/Controller/UserReserveController.php +++ b/Classes/Controller/UserReserveController.php @@ -62,4 +62,20 @@ public function historyAction(): ResponseInterface return $this->jsonResponse(); } + + /** + * @return ResponseInterface + * @throws JsonException + */ + public function deleteAction(): ResponseInterface + { + $status = $this->userService->getDelete( + $this->request->getArguments() + ); + + $this->view->setVariablesToRender(['status']); + $this->view->assign('status', $status); + + return $this->jsonResponse(); + } } diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index 242614f..78c8969 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -23,6 +23,7 @@ class ApiConfiguration protected string $loanHistoryUri = ''; protected string $loanRenewalUri = ''; protected string $reserveCurrentUri = ''; + protected string $reserveDeleteUri = ''; protected string $reserveHistoryUri = ''; public function __construct() @@ -37,6 +38,7 @@ public function __construct() $this->setLoanHistoryUri($settings['api']['path']['loanHistory']); $this->setLoanRenewalUri($settings['api']['path']['loanRenewal']); $this->setReserveCurrentUri($settings['api']['path']['reserveCurrent']); + $this->setReserveDeleteUri($settings['api']['path']['reserveDelete']); $this->setReserveHistoryUri($settings['api']['path']['reserveHistory']); } @@ -168,6 +170,22 @@ public function setReserveCurrentUri(string $reserveCurrentUri = ''): void $this->reserveCurrentUri = $reserveCurrentUri; } + /** + * @return string + */ + public function getReserveDeleteUri(): string + { + return $this->reserveDeleteUri; + } + + /** + * @param string $reserveDeleteUri + */ + public function setReserveDeleteUri(string $reserveDeleteUri = ''): void + { + $this->reserveDeleteUri = $reserveDeleteUri; + } + /** * @return string */ diff --git a/Classes/Service/UserLoanService.php b/Classes/Service/UserLoanService.php index e9b7cc0..3b0d5f7 100644 --- a/Classes/Service/UserLoanService.php +++ b/Classes/Service/UserLoanService.php @@ -134,8 +134,8 @@ protected function requestRenewal(array $barcodes, int $accountId): array $results = []; foreach ($barcodes as $barcode) { - $barCodeUri = ApiUtility::replaceUriPlaceholder([$accountId, $barcode], $uri); - $processed = $this->request->process($barCodeUri, 'POST'); + $renewalUri = ApiUtility::replaceUriPlaceholder([$accountId, $barcode], $uri); + $processed = $this->request->process($renewalUri, 'POST'); if ($processed['status'] === 1) { $results[$barcode] = ApiUtility::STATUS[200]; diff --git a/Classes/Service/UserReserveService.php b/Classes/Service/UserReserveService.php index 1d44e1a..8a351c9 100644 --- a/Classes/Service/UserReserveService.php +++ b/Classes/Service/UserReserveService.php @@ -14,27 +14,33 @@ use Slub\SlubProfileAccount\Domain\Model\Dto\ApiConfiguration; use Slub\SlubProfileAccount\Http\Request; use Slub\SlubProfileAccount\Utility\ApiUtility; +use Slub\SlubProfileAccount\Utility\FileUtility; use Slub\SlubProfileAccount\Utility\SettingsUtility; +use Slub\SlubProfileAccount\Validation\ReserveArgumentValidation; class UserReserveService { protected ApiConfiguration $apiConfiguration; protected AccountService $accountService; + protected ReserveArgumentValidation $reserveArgumentValidation; protected Request $request; protected int $itemsPerPage; /** * @param ApiConfiguration $apiConfiguration * @param AccountService $accountService + * @param ReserveArgumentValidation $reserveArgumentValidation * @param Request $request */ public function __construct( ApiConfiguration $apiConfiguration, AccountService $accountService, + ReserveArgumentValidation $reserveArgumentValidation, Request $request ) { $this->apiConfiguration = $apiConfiguration; $this->accountService = $accountService; + $this->reserveArgumentValidation = $reserveArgumentValidation; $this->request = $request; $this->itemsPerPage = (int)SettingsUtility::getPluginSettings()['general']['itemsPerPage'] ?? 25; } @@ -87,6 +93,31 @@ public function getHistory(array $arguments): ?array return []; } + /** + * @param array $arguments + * @return array|null + * @throws \JsonException + */ + public function getDelete(array $arguments): ?array + { + $current = $this->getCurrent($arguments); + + if (count($current) === 0) { + return []; + } + + $data = FileUtility::getContent()['delete']; + + if ($data === null) { + return ApiUtility::STATUS[400]; + } + + $validArguments = $this->reserveArgumentValidation->validateDeleteArguments($data, $current['reserveCurrent']); + $accountId = $this->getAccountId($arguments); + + return $this->requestDelete($validArguments, $accountId); + } + /** * @param int $id * @return array|null @@ -106,6 +137,47 @@ protected function requestCurrent(int $id): ?array ]); } + /** + * @param array $data + * @param int $accountId + * @return array + * @throws \JsonException + */ + protected function requestDelete(array $data, int $accountId): array + { + if (count($data) === 0) { + return [ + 0 => ApiUtility::STATUS[415] + ]; + } + + $uri = $this->apiConfiguration->getReserveDeleteUri(); + $results = []; + + foreach ($data as $item) { + $label = $item['label']; + $deleteUri = ApiUtility::replaceUriPlaceholder( + [ + $accountId, + '', + $label, + $item['queueNumber'] + ], + $uri + ); + $processed = $this->request->process($deleteUri, 'POST'); + + if ($processed['status'] === 1) { + $results[$label] = ApiUtility::STATUS[200]; + } else { + $results[$label] = ApiUtility::STATUS[420]; + $results[$label]['error'] = $processed['message']; + } + } + + return $results; + } + /** * @param int $id * @param int $page @@ -136,4 +208,20 @@ protected function getOffset(int $page): int { return (int)($page * $this->itemsPerPage) - $this->itemsPerPage; } + + /** + * @param array $arguments + * @return int|null + */ + protected function getAccountId(array $arguments): ?int + { + $account = $this->accountService->getAccountByArguments($arguments); + $accountId = $this->accountService->getAccountId(); + + if ($accountId > 0 && is_array($account)) { + return $accountId; + } + + return null; + } } diff --git a/Classes/Utility/ApiUtility.php b/Classes/Utility/ApiUtility.php index f7d1696..fa11591 100644 --- a/Classes/Utility/ApiUtility.php +++ b/Classes/Utility/ApiUtility.php @@ -30,6 +30,14 @@ class ApiUtility 'code' => 410, 'message' => 'Bad Request. Renewal not possible.', ], + 415 => [ + 'code' => 415, + 'message' => 'Bad Request. No deletable data given.', + ], + 420 => [ + 'code' => 420, + 'message' => 'Bad Request. Deletable not possible.', + ], 500 => [ 'code' => 500, 'message' => 'Internal Server Error' @@ -62,7 +70,9 @@ class ApiUtility public const URI_PLACEHOLDER = [ '###USER_ID###', - '###BARCODE###' + '###BARCODE###', + '###LABEL###', + '###QUEUE_NUMBER###' ]; /** diff --git a/Classes/Validation/ReserveArgumentValidation.php b/Classes/Validation/ReserveArgumentValidation.php new file mode 100644 index 0000000..6a5a889 --- /dev/null +++ b/Classes/Validation/ReserveArgumentValidation.php @@ -0,0 +1,53 @@ +validateLabel((int)$argument, $reserve); + } + + return $this->validLabels; + } + + /** + * Check that given label is a real label of mine. + * + * @param int $label + * @param array $reserve + */ + private function validateLabel(int $label, array $reserve): void + { + foreach ($reserve as $reserveItem) { + if ((int)$reserveItem['label'] === $label) { + $this->validLabels[] = [ + 'label' => $label, + 'queueNumber' => $reserveItem['X_queue_number'], + ]; + } + } + } +} diff --git a/Configuration/Icons.php b/Configuration/Icons.php index a278e68..6ffdbb5 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -59,6 +59,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-reserve-current.svg' ], + 'slubprofileaccount-wizard-userreservedelete' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-reserve-delete.svg' + ], 'slubprofileaccount-wizard-userreservehistory' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-reserve-history.svg' diff --git a/Configuration/Routes/UserReserve.yaml b/Configuration/Routes/UserReserve.yaml index 0f5399a..c1d9f64 100644 --- a/Configuration/Routes/UserReserve.yaml +++ b/Configuration/Routes/UserReserve.yaml @@ -7,6 +7,14 @@ routeEnhancers: user: '[0-9]{1,10}' _arguments: user: 'tx_slubprofileaccount_userreservecurrent/user' + SlubAccountUserReserveDelete: + type: Simple + limitToPages: [38] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userreservedelete/user' SlubAccountUserReserveHistory: type: Simple limitToPages: [36] diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 313eb42..e6d3443 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -71,6 +71,7 @@ 'userpinupdate', 'userpasswordupdate', 'userreservecurrent', + 'userreservedelete', 'userreservehistory', 'usersearchquerydetail', 'usersearchqueryupdate' diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index ff12ccf..9106529 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -84,6 +84,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_userreservecurrent } + slubprofileaccount_userreservedelete { + iconIdentifier = slubprofileaccount-wizard-userreservedelete + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userreservedelete.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userreservedelete.description + tt_content_defValues.CType = slubprofileaccount_userreservedelete + } + slubprofileaccount_userreservehistory { iconIdentifier = slubprofileaccount-wizard-userreservehistory iconOverlay = slubprofileaccount-overlay-extension @@ -119,6 +127,7 @@ mod { show := addToList(slubprofileaccount_userpasswordupdate) show := addToList(slubprofileaccount_userpindupdate) show := addToList(slubprofileaccount_userreservecurrent) + show := addToList(slubprofileaccount_userreservedelete) show := addToList(slubprofileaccount_userreservehistory) show := addToList(slubprofileaccount_usersearchqueryupdate) show := addToList(slubprofileaccount_usersearchquerydetail) diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 6560357..9fe95d1 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -23,7 +23,9 @@ plugin.tx_slubprofileaccount { loanRenewal = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/renew/###BARCODE### # cat=plugin.tx_slubprofileaccount/76595002_Api/135; type=string; label=Path to reserve current reserveCurrent = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/reserve - # cat=plugin.tx_slubprofileaccount/76595002_Api/140; type=string; label=Path to reserve history + # cat=plugin.tx_slubprofileaccount/76595002_Api/140; type=string; label=Path to delete reservation + reserveDelete = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/cancel/###LABEL###/###QUEUE_NUMBER### + # cat=plugin.tx_slubprofileaccount/76595002_Api/145; type=string; label=Path to reserve history reserveHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/historyres } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index de3cbab..abc05fd 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -17,6 +17,7 @@ plugin.tx_slubprofileaccount { loanHistory = {$plugin.tx_slubprofileaccount.settings.api.path.loanHistory} loanRenewal = {$plugin.tx_slubprofileaccount.settings.api.path.loanRenewal} reserveCurrent = {$plugin.tx_slubprofileaccount.settings.api.path.reserveCurrent} + reserveDelete = {$plugin.tx_slubprofileaccount.settings.api.path.reserveDelete} reserveHistory = {$plugin.tx_slubprofileaccount.settings.api.path.reserveHistory} } diff --git a/README.md b/README.md index f93e5df..b1b98f7 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ Furthermore, have a look at postman and import the "postman_collection" file. Th | plugin.tx_slubprofile_account.settings.api.path.loanHistory | Path to loan history | | plugin.tx_slubprofile_account.settings.api.path.loanRenewal | Path to loan loanRenewal | | plugin.tx_slubprofile_account.settings.api.path.reserveCurrent | Path to reserve current | +| plugin.tx_slubprofile_account.settings.api.path.reserveDelete | Path to delete reservation | | plugin.tx_slubprofile_account.settings.api.path.reserveHistory | Path to reserve history | | plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | | plugin.tx_slubprofile_account.settings.general.itemsPerPage | Items per page for pagination | diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index d3fd10f..be3b23d 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -85,6 +85,15 @@ Aktuelle Vormerkungen zu einem spezifischen Benutzer. Gibt nur die Daten des Benutzers mit der Einschränkung "Aktuelle Vormerkungen" zurück. + + User reservation delete + Vormerkungen löschen + + + Delete entry from user reservation. + Eintrag aus den Vormerkungen eines bestimmten Benutzers löschen. + + User reservation history Vormerkhistorie eines Benutzers diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 4aa5c31..bcd9bfc 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -68,6 +68,13 @@ Current reservation of a specific user. Returns only the user constraint "current reservation" data. + + User reservation delete + + + Delete entry from user reservation. + + User reservation history diff --git a/Resources/Public/Icons/Wizard/user-reserve-delete.svg b/Resources/Public/Icons/Wizard/user-reserve-delete.svg new file mode 100644 index 0000000..bd56d1b --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-reserve-delete.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index bdb4272..752fc71 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -149,6 +149,19 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); +// Configure plugin - user reserve delete +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserReserveDelete', + [ + UserReserveController::class => 'delete' + ], + [ + UserReserveController::class => 'delete' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user reserve history ExtensionUtility::configurePlugin( 'SlubProfileAccount', From 7f7c21056b853a0ef9649b6083e75952f1845416 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 1 Feb 2023 16:57:53 +0100 Subject: [PATCH 74/81] [TASK] Do not overwrite other custom render types --- ext_localconf.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/ext_localconf.php b/ext_localconf.php index 752fc71..bcedc07 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -202,17 +202,16 @@ ); // Register new renderTypes -$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'] = [ - 'accountOverview' => [ - 'nodeName' => 'accountOverview', - 'priority' => 40, - 'class' => AccountOverviewElement::class, - ], - 'userCategoryDescription' => [ - 'nodeName' => 'userCategoryDescription', - 'priority' => 45, - 'class' => UserCategoryDescriptionElement::class, - ] +$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1675154443] = [ + 'nodeName' => 'accountOverview', + 'priority' => 40, + 'class' => AccountOverviewElement::class, +]; + +$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1675154444] = [ + 'nodeName' => 'userCategoryDescription', + 'priority' => 45, + 'class' => UserCategoryDescriptionElement::class, ]; // Custom cache to save user account From 737cd0de35f3cbdc3b0ef1bccc32193f201a7364 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 26 Apr 2023 17:37:33 +0200 Subject: [PATCH 75/81] [TASK] Hide overview columns from "show column" collector --- Configuration/TCA/tx_slubprofileaccount_domain_model_user.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php index 1e8e5a0..bb16e19 100644 --- a/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php +++ b/Configuration/TCA/tx_slubprofileaccount_domain_model_user.php @@ -188,7 +188,7 @@ 'account_overview' => [ 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user.account_overview', 'config' => [ - 'type' => 'user', + 'type' => 'none', 'renderType' => 'accountOverview', ], ], @@ -206,7 +206,7 @@ 'user_category_description' => [ 'label' => $ll['slubProfileAccount']['db'] . ':tx_slubprofileaccount_domain_model_user.user_category_description', 'config' => [ - 'type' => 'user', + 'type' => 'none', 'renderType' => 'userCategoryDescription', ], ], From c0ee672432dff194f5995a0b0ae53aa5e8a7e18c Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 5 Jan 2024 13:50:25 +0100 Subject: [PATCH 76/81] [TASK] Add download api --- Classes/Controller/UserDataController.php | 52 ++++++++ Classes/Domain/Model/Dto/ApiConfiguration.php | 18 +++ Classes/Mvc/View/JsonView.php | 2 + Classes/Service/UserDataService.php | 116 ++++++++++++++++++ Classes/Utility/ApiUtility.php | 3 +- Classes/Validation/DataArgumentValidation.php | 42 +++++++ Configuration/Icons.php | 4 + Configuration/Routes/Default.yaml | 1 + Configuration/Routes/UserDataDownload.yaml | 9 ++ Configuration/Services.yaml | 3 + Configuration/TCA/Overrides/tt_content.php | 1 + Configuration/TsConfig/Page/mod.tsconfig | 9 ++ Configuration/TypoScript/constants.typoscript | 2 + Configuration/TypoScript/setup.typoscript | 1 + README.md | 1 + .../Private/Language/de.locallang_backend.xlf | 9 ++ .../Private/Language/locallang_backend.xlf | 7 ++ .../Icons/Wizard/user-data-download.svg | 7 ++ ext_localconf.php | 14 +++ postman_collection.json | 64 ++++++++++ 20 files changed, 364 insertions(+), 1 deletion(-) create mode 100644 Classes/Controller/UserDataController.php create mode 100644 Classes/Service/UserDataService.php create mode 100644 Classes/Validation/DataArgumentValidation.php create mode 100644 Configuration/Routes/UserDataDownload.yaml create mode 100644 Resources/Public/Icons/Wizard/user-data-download.svg diff --git a/Classes/Controller/UserDataController.php b/Classes/Controller/UserDataController.php new file mode 100644 index 0000000..24455e4 --- /dev/null +++ b/Classes/Controller/UserDataController.php @@ -0,0 +1,52 @@ +userService = $userService; + } + + /** + * @return ResponseInterface + * @throws \JsonException + */ + public function downloadAction(): ResponseInterface + { + $dataDownload = $this->userService->getDownload( + $this->request->getArguments() + ); + + $this->view->setVariablesToRender(['userDataDownload']); + $this->view->assign('userDataDownload', $dataDownload); + + return $this->jsonResponse(); + } +} diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index 78c8969..7e371cc 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -25,6 +25,7 @@ class ApiConfiguration protected string $reserveCurrentUri = ''; protected string $reserveDeleteUri = ''; protected string $reserveHistoryUri = ''; + protected string $dataDownloadUri = ''; public function __construct() { @@ -40,6 +41,7 @@ public function __construct() $this->setReserveCurrentUri($settings['api']['path']['reserveCurrent']); $this->setReserveDeleteUri($settings['api']['path']['reserveDelete']); $this->setReserveHistoryUri($settings['api']['path']['reserveHistory']); + $this->setDataDownloadUri($settings['api']['path']['dataDownload']); } /** @@ -201,4 +203,20 @@ public function setReserveHistoryUri(string $reserveHistoryUri = ''): void { $this->reserveHistoryUri = $reserveHistoryUri; } + + /** + * @return string + */ + public function getDataDownloadUri(): string + { + return $this->dataDownloadUri; + } + + /** + * @param string $dataDownloadUri + */ + public function setDataDownloadUri(string $dataDownloadUri = ''): void + { + $this->dataDownloadUri = $dataDownloadUri; + } } diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index 6ed2797..70ec61c 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -72,6 +72,8 @@ class JsonView extends ExtbaseJsonView 'reserveHistory' ] ], + 'userDataDownload' => [ + ], 'userSearchQueryDetail' => [ '_only' => [ 'searchQuery' diff --git a/Classes/Service/UserDataService.php b/Classes/Service/UserDataService.php new file mode 100644 index 0000000..96068a9 --- /dev/null +++ b/Classes/Service/UserDataService.php @@ -0,0 +1,116 @@ +apiConfiguration = $apiConfiguration; + $this->accountService = $accountService; + $this->dataArgumentValidation = $dataArgumentValidation; + $this->request = $request; + } + + /** + * @param array $arguments + * @return array|null + * @throws \JsonException + */ + public function getDownload(array $arguments): ?array + { + $accountId = $this->getAccountId($arguments); + $fileFormat = $this->dataArgumentValidation->validateDownloadArguments($arguments); + + if ($accountId === null) { + return []; + } + + if ($fileFormat === null) { + $status = ApiUtility::STATUS[400]; + $status['message'] = 'Invalid file type. Only ' . implode(', ', $this->dataArgumentValidation::FILE_FORMATS) . '.'; + + return $status; + } + + $download = $this->requestDownload($accountId, $fileFormat); + + if ($download === null) { + return ApiUtility::STATUS[500]; + } + + return $download; + } + + /** + * @param int $accountId + * @param string $fileFormat + * @return array|null + * @throws \JsonException + */ + protected function requestDownload(int $accountId, string $fileFormat): ?array + { + $uri = $this->apiConfiguration->getDataDownloadUri(); + $uri = ApiUtility::replaceUriPlaceholder([$accountId, '', '', '', $fileFormat], $uri); + + return $this->request->process($uri, 'GET', [ + 'headers' => [ + 'Pragma' => 'public', + 'Expires' => 0, + 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', + 'Content-Description' => 'File Transfer', + 'Content-Type' => 'charset=UTF-8, text/' . $fileFormat . ';', + 'Content-Disposition' => 'attachment; filename="' . self::FILE_NAME . '"', + 'Content-Transfer-Encoding' => 'binary', + ] + ]); + } + + /** + * @param array $arguments + * @return int|null + */ + protected function getAccountId(array $arguments): ?int + { + $account = $this->accountService->getAccountByArguments($arguments); + $accountId = $this->accountService->getAccountId(); + + if ($accountId > 0 && is_array($account)) { + return $accountId; + } + + return null; + } +} diff --git a/Classes/Utility/ApiUtility.php b/Classes/Utility/ApiUtility.php index fa11591..3f1a568 100644 --- a/Classes/Utility/ApiUtility.php +++ b/Classes/Utility/ApiUtility.php @@ -72,7 +72,8 @@ class ApiUtility '###USER_ID###', '###BARCODE###', '###LABEL###', - '###QUEUE_NUMBER###' + '###QUEUE_NUMBER###', + '###FILE_FORMAT###', ]; /** diff --git a/Classes/Validation/DataArgumentValidation.php b/Classes/Validation/DataArgumentValidation.php new file mode 100644 index 0000000..71f5d1a --- /dev/null +++ b/Classes/Validation/DataArgumentValidation.php @@ -0,0 +1,42 @@ + \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-dashboard-update.svg' ], + 'slubprofileaccount-wizard-userdatadownload' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-data-download.svg' + ], 'slubprofileaccount-wizard-userloancurrent' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-loan-current.svg' diff --git a/Configuration/Routes/Default.yaml b/Configuration/Routes/Default.yaml index ba5cb92..dedd497 100644 --- a/Configuration/Routes/Default.yaml +++ b/Configuration/Routes/Default.yaml @@ -5,6 +5,7 @@ imports: - resource: 'EXT:slub_profile_account/Configuration/Routes/UserAccountUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardDetail.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDashboardUpdate.yaml' + - resource: 'EXT:slub_profile_account/Configuration/Routes/UserDataDownload.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserLoan.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPasswordUpdate.yaml' - resource: 'EXT:slub_profile_account/Configuration/Routes/UserPinUpdate.yaml' diff --git a/Configuration/Routes/UserDataDownload.yaml b/Configuration/Routes/UserDataDownload.yaml new file mode 100644 index 0000000..ae7faed --- /dev/null +++ b/Configuration/Routes/UserDataDownload.yaml @@ -0,0 +1,9 @@ +routeEnhancers: + SlubAccountUserDataDownload: + type: Simple + limitToPages: [39] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userdatadownload/user' diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 50aa6a5..e3aca6e 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -23,6 +23,9 @@ services: Slub\SlubProfileAccount\Service\DashboardService: public: true + Slub\SlubProfileAccount\Service\DataService: + public: true + Slub\SlubProfileAccount\Service\UserAccountService: public: true diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index e6d3443..bdd11d6 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -65,6 +65,7 @@ 'useraccountupdate', 'userdashboarddetail', 'userdashboardupdate', + 'userdatadownload', 'userloancurrent', 'userloanhistory', 'userloanrenewal', diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index 9106529..4a55cbf 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -36,6 +36,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_userdashboardupdate } + slubprofileaccount_userdatadownload { + iconIdentifier = slubprofileaccount-wizard-userdatadownload + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userdatadownload.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userdatadownload.description + tt_content_defValues.CType = slubprofileaccount_userdatadownload + } + slubprofileaccount_userloancurrent { iconIdentifier = slubprofileaccount-wizard-userloancurrent iconOverlay = slubprofileaccount-overlay-extension @@ -121,6 +129,7 @@ mod { show := addToList(slubprofileaccount_useraccountupdate) show := addToList(slubprofileaccount_userdashboardupdate) show := addToList(slubprofileaccount_userdashboarddetail) + show := addToList(slubprofileaccount_userdatadownload) show := addToList(slubprofileaccount_userloancurrent) show := addToList(slubprofileaccount_userloanhistory) show := addToList(slubprofileaccount_userloanrenewal) diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 9fe95d1..75dfdaa 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -27,6 +27,8 @@ plugin.tx_slubprofileaccount { reserveDelete = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/cancel/###LABEL###/###QUEUE_NUMBER### # cat=plugin.tx_slubprofileaccount/76595002_Api/145; type=string; label=Path to reserve history reserveHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/historyres + # cat=plugin.tx_slubprofileaccount/76595002_Api/150; type=string; label=Path to data download + dataDownload = https://libero.slub-dresden.de/csp/user/dsgvo01.csp?patronid=###USER_ID###&format=###FILE_FORMAT### } # cat=plugin.tx_slubprofileaccount/76595003_Cache/100; type=int; label=Life time account cache in seconds diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index abc05fd..d54bad0 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -19,6 +19,7 @@ plugin.tx_slubprofileaccount { reserveCurrent = {$plugin.tx_slubprofileaccount.settings.api.path.reserveCurrent} reserveDelete = {$plugin.tx_slubprofileaccount.settings.api.path.reserveDelete} reserveHistory = {$plugin.tx_slubprofileaccount.settings.api.path.reserveHistory} + dataDownload = {$plugin.tx_slubprofileaccount.settings.api.path.dataDownload} } cache.account.lifeTime = {$plugin.tx_slubprofileaccount.settings.cache.account.lifeTime} diff --git a/README.md b/README.md index b1b98f7..8e9e545 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Furthermore, have a look at postman and import the "postman_collection" file. Th | plugin.tx_slubprofile_account.settings.api.path.reserveCurrent | Path to reserve current | | plugin.tx_slubprofile_account.settings.api.path.reserveDelete | Path to delete reservation | | plugin.tx_slubprofile_account.settings.api.path.reserveHistory | Path to reserve history | +| plugin.tx_slubprofile_account.settings.api.path.dataDownload | Path to data download | | plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | | plugin.tx_slubprofile_account.settings.general.itemsPerPage | Items per page for pagination | diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index be3b23d..24c5c6c 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -49,6 +49,15 @@ Daten der Dashboardeinstellung eines Benutzers aktualisieren. + + Download data + Download der Daten + + + Download all data a user has accumulated. + Download aller Daten, die ein Benutzer angesammelt hat. + + User current loan Aktuelle Ausleihen eines Benutzers diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index bcd9bfc..86d759d 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -40,6 +40,13 @@ Update data of dashboard user. + + Download data + + + Download all data a user has accumulated. + + User current loan diff --git a/Resources/Public/Icons/Wizard/user-data-download.svg b/Resources/Public/Icons/Wizard/user-data-download.svg new file mode 100644 index 0000000..439bcab --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-data-download.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index bcedc07..a36a43e 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,6 +2,7 @@ use Slub\SlubProfileAccount\Controller\UserAccountController; use Slub\SlubProfileAccount\Controller\UserDashboardController; +use Slub\SlubProfileAccount\Controller\UserDataController; use Slub\SlubProfileAccount\Controller\UserLoanController; use Slub\SlubProfileAccount\Controller\UserPasswordController; use Slub\SlubProfileAccount\Controller\UserPinController; @@ -97,6 +98,19 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); +// Configure plugin - user data download +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserDataDownload', + [ + UserDataController::class => 'download' + ], + [ + UserDataController::class => 'download' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user loan current ExtensionUtility::configurePlugin( 'SlubProfileAccount', diff --git a/postman_collection.json b/postman_collection.json index 0f04bfa..ef438c6 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -642,6 +642,70 @@ "response": [] } ] + }, + { + "name": "Data", + "item": [ + { + "name": "Download", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{domain}}/benutzer/download/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "download", + "{{user}}" + ] + } + }, + "response": [] + }, + { + "name": "Download with file type", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{domain}}/benutzer/download/{{user}}?tx_slubprofileaccount_userdatadownload[fileFormat]=htmlx", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "download", + "{{user}}" + ], + "query": [ + { + "key": "tx_slubprofileaccount_userdatadownload[fileFormat]", + "value": "htmlx", + "description": "html, csv or json" + } + ] + } + }, + "response": [] + } + ] } ], "event": [ From 5a94bb625f22d54b54b1af60040bee7bc6285db5 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Mon, 8 Apr 2024 13:52:36 +0200 Subject: [PATCH 77/81] [TASK] Add data download api --- Classes/Controller/UserDataController.php | 2 -- Classes/Http/Request.php | 25 +++++++++---- Classes/Mvc/View/JsonView.php | 5 +++ Classes/Service/UserDataService.php | 35 +++++++++++-------- Classes/Validation/DataArgumentValidation.php | 2 +- Configuration/TypoScript/constants.typoscript | 2 +- 6 files changed, 46 insertions(+), 25 deletions(-) diff --git a/Classes/Controller/UserDataController.php b/Classes/Controller/UserDataController.php index 24455e4..57abb8c 100644 --- a/Classes/Controller/UserDataController.php +++ b/Classes/Controller/UserDataController.php @@ -11,13 +11,11 @@ namespace Slub\SlubProfileAccount\Controller; -use Exception; use Psr\Http\Message\ResponseInterface; use Slub\SlubProfileAccount\Domain\Model\User\Account as User; use Slub\SlubProfileAccount\Mvc\View\JsonView; use Slub\SlubProfileAccount\Service\UserDataService as UserService; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; -use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; class UserDataController extends ActionController { diff --git a/Classes/Http/Request.php b/Classes/Http/Request.php index 4d50bf3..93135df 100644 --- a/Classes/Http/Request.php +++ b/Classes/Http/Request.php @@ -44,16 +44,21 @@ public function __construct(RequestFactory $requestFactory) * @param string $uri * @param string $method * @param array $options + * @param string $contentType * @return array|null * @throws JsonException */ - public function process(string $uri = '', string $method = 'GET', array $options = []): ?array - { + public function process( + string $uri = '', + string $method = 'GET', + array $options = [], + string $contentType = 'application/json' + ): ?array { try { $options = $this->mergeOptions($this->options, $options); $response = $this->requestFactory->request($uri, $method, $options); - return $this->getContent($response, $uri); + return $this->getContent($response, $contentType, $uri); } catch (RequestException $e) { /** @extensionScannerIgnoreLine */ $this->logger->error($e->getMessage()); @@ -78,16 +83,20 @@ protected function mergeOptions(array $default, array $new): array /** * @param ResponseInterface $response + * @param string $contentType * @param string $uri * @return array|null * @throws JsonException */ - protected function getContent(ResponseInterface $response, string $uri = ''): ?array + protected function getContent(ResponseInterface $response, string $contentType, string $uri = ''): ?array { $content = ''; - if ($response->getStatusCode() === 200 && strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { - $content = (array)json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); + if ( + $response->getStatusCode() === 200 && + strpos($response->getHeaderLine('Content-Type'), $contentType) === 0 + ) { + $content = $response->getBody()->getContents(); } if (empty($content)) { @@ -103,6 +112,8 @@ protected function getContent(ResponseInterface $response, string $uri = ''): ?a return null; } - return $content; + return $contentType === 'application/json' + ? (array)json_decode($content, true, 512, JSON_THROW_ON_ERROR) + : ['data' => $content]; } } diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index 70ec61c..b631a9c 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -73,6 +73,11 @@ class JsonView extends ExtbaseJsonView ] ], 'userDataDownload' => [ + '_only' => [ + 'contentType', + 'data', + 'error' + ] ], 'userSearchQueryDetail' => [ '_only' => [ diff --git a/Classes/Service/UserDataService.php b/Classes/Service/UserDataService.php index 96068a9..97b1a05 100644 --- a/Classes/Service/UserDataService.php +++ b/Classes/Service/UserDataService.php @@ -15,7 +15,6 @@ use Slub\SlubProfileAccount\Http\Request; use Slub\SlubProfileAccount\Utility\ApiUtility; use Slub\SlubProfileAccount\Validation\DataArgumentValidation; -use TYPO3\CMS\Core\Utility\GeneralUtility; class UserDataService { @@ -60,7 +59,7 @@ public function getDownload(array $arguments): ?array if ($fileFormat === null) { $status = ApiUtility::STATUS[400]; - $status['message'] = 'Invalid file type. Only ' . implode(', ', $this->dataArgumentValidation::FILE_FORMATS) . '.'; + $status['error'] = 'Invalid file type. Only ' . implode(', ', $this->dataArgumentValidation::FILE_FORMATS) . '.'; return $status; } @@ -71,7 +70,10 @@ public function getDownload(array $arguments): ?array return ApiUtility::STATUS[500]; } - return $download; + return [ + 'contentType' => 'text/' . $fileFormat, + 'data' => $download['data'], + ]; } /** @@ -85,17 +87,22 @@ protected function requestDownload(int $accountId, string $fileFormat): ?array $uri = $this->apiConfiguration->getDataDownloadUri(); $uri = ApiUtility::replaceUriPlaceholder([$accountId, '', '', '', $fileFormat], $uri); - return $this->request->process($uri, 'GET', [ - 'headers' => [ - 'Pragma' => 'public', - 'Expires' => 0, - 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', - 'Content-Description' => 'File Transfer', - 'Content-Type' => 'charset=UTF-8, text/' . $fileFormat . ';', - 'Content-Disposition' => 'attachment; filename="' . self::FILE_NAME . '"', - 'Content-Transfer-Encoding' => 'binary', - ] - ]); + return $this->request->process( + $uri, + 'GET', + [ + 'headers' => [ + 'Pragma' => 'public', + 'Expires' => 0, + 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', + 'Content-Description' => 'File Transfer', + 'Content-Type' => 'charset=UTF-8, text/' . $fileFormat . ';', + 'Content-Disposition' => 'attachment; filename="' . self::FILE_NAME . '"', + 'Content-Transfer-Encoding' => 'binary', + ] + ], + $fileFormat === 'csv' ? 'text/text' : 'text/' . $fileFormat + ); } /** diff --git a/Classes/Validation/DataArgumentValidation.php b/Classes/Validation/DataArgumentValidation.php index 71f5d1a..a0ff58e 100644 --- a/Classes/Validation/DataArgumentValidation.php +++ b/Classes/Validation/DataArgumentValidation.php @@ -25,7 +25,7 @@ class DataArgumentValidation * User is checked somewhere else. * * @param array $arguments - * @return string + * @return string|null */ public function validateDownloadArguments(array $arguments): ?string { diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 75dfdaa..44896a6 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -28,7 +28,7 @@ plugin.tx_slubprofileaccount { # cat=plugin.tx_slubprofileaccount/76595002_Api/145; type=string; label=Path to reserve history reserveHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/historyres # cat=plugin.tx_slubprofileaccount/76595002_Api/150; type=string; label=Path to data download - dataDownload = https://libero.slub-dresden.de/csp/user/dsgvo01.csp?patronid=###USER_ID###&format=###FILE_FORMAT### + dataDownload = https://liberoproxy.staging.katalogbeta.slub-dresden.de/csp/user/dsgvo01.csp?patronid=###USER_ID###&format=###FILE_FORMAT### } # cat=plugin.tx_slubprofileaccount/76595003_Cache/100; type=int; label=Life time account cache in seconds From eccbe2693075bee5313b3b3ff461aedddcf5c55a Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Tue, 23 Apr 2024 15:35:38 +0200 Subject: [PATCH 78/81] [TASK] Refresh api collection --- postman_collection.json | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/postman_collection.json b/postman_collection.json index ef438c6..77b3e31 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -1,8 +1,9 @@ { "info": { - "_postman_id": "8b8facb3-ab8d-4f06-980d-531159a5714b", + "_postman_id": "233a4a8e-6509-4ff3-9178-68876237ce3f", "name": "SLUB - Profile Service - Account (slub_profile_account)", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "32157282" }, "item": [ { @@ -685,7 +686,7 @@ "raw": "" }, "url": { - "raw": "{{domain}}/benutzer/download/{{user}}?tx_slubprofileaccount_userdatadownload[fileFormat]=htmlx", + "raw": "{{domain}}/benutzer/download/{{user}}?tx_slubprofileaccount_userdatadownload[fileFormat]=csv", "host": [ "{{domain}}" ], @@ -697,7 +698,7 @@ "query": [ { "key": "tx_slubprofileaccount_userdatadownload[fileFormat]", - "value": "htmlx", + "value": "csv", "description": "html, csv or json" } ] @@ -738,6 +739,16 @@ "key": "domain", "value": "https://ddev-slub-profile-service.ddev.site/", "type": "default" + }, + { + "key": "domainCatalogue", + "value": "https://katalog.ddev.site/", + "type": "string" + }, + { + "key": "appKey", + "value": "6627b6fab58c1", + "type": "string" } ] } \ No newline at end of file From 0394143f31d888bfc284d0bfa219d8acc645a88f Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Thu, 25 Apr 2024 17:10:27 +0200 Subject: [PATCH 79/81] [TASK] Add reserve hold api --- Classes/Controller/UserReserveController.php | 16 ++++ Classes/Domain/Model/Dto/ApiConfiguration.php | 18 +++++ Classes/Mvc/View/JsonView.php | 5 ++ Classes/Service/UserReserveService.php | 40 ++++++++++ Configuration/Icons.php | 4 + Configuration/Routes/UserReserve.yaml | 8 ++ Configuration/TCA/Overrides/tt_content.php | 1 + Configuration/TsConfig/Page/mod.tsconfig | 9 +++ Configuration/TypoScript/constants.typoscript | 2 + Configuration/TypoScript/setup.typoscript | 1 + README.md | 1 + .../Private/Language/de.locallang_backend.xlf | 9 +++ .../Private/Language/locallang_backend.xlf | 7 ++ .../Public/Icons/Wizard/user-reserve-hold.svg | 10 +++ ext_localconf.php | 13 +++ postman_collection.json | 80 ++++++++----------- 16 files changed, 177 insertions(+), 47 deletions(-) create mode 100644 Resources/Public/Icons/Wizard/user-reserve-hold.svg diff --git a/Classes/Controller/UserReserveController.php b/Classes/Controller/UserReserveController.php index 0b1ee9c..3377370 100644 --- a/Classes/Controller/UserReserveController.php +++ b/Classes/Controller/UserReserveController.php @@ -63,6 +63,22 @@ public function historyAction(): ResponseInterface return $this->jsonResponse(); } + /** + * @return ResponseInterface + * @throws JsonException + */ + public function holdAction(): ResponseInterface + { + $reserveHold = $this->userService->getHold( + $this->request->getArguments() + ); + + $this->view->setVariablesToRender(['userReserveHold']); + $this->view->assign('userReserveHold', $reserveHold); + + return $this->jsonResponse(); + } + /** * @return ResponseInterface * @throws JsonException diff --git a/Classes/Domain/Model/Dto/ApiConfiguration.php b/Classes/Domain/Model/Dto/ApiConfiguration.php index 7e371cc..80482e3 100644 --- a/Classes/Domain/Model/Dto/ApiConfiguration.php +++ b/Classes/Domain/Model/Dto/ApiConfiguration.php @@ -25,6 +25,7 @@ class ApiConfiguration protected string $reserveCurrentUri = ''; protected string $reserveDeleteUri = ''; protected string $reserveHistoryUri = ''; + protected string $reserveHoldUri = ''; protected string $dataDownloadUri = ''; public function __construct() @@ -41,6 +42,7 @@ public function __construct() $this->setReserveCurrentUri($settings['api']['path']['reserveCurrent']); $this->setReserveDeleteUri($settings['api']['path']['reserveDelete']); $this->setReserveHistoryUri($settings['api']['path']['reserveHistory']); + $this->setReserveHoldUri($settings['api']['path']['reserveHold']); $this->setDataDownloadUri($settings['api']['path']['dataDownload']); } @@ -204,6 +206,22 @@ public function setReserveHistoryUri(string $reserveHistoryUri = ''): void $this->reserveHistoryUri = $reserveHistoryUri; } + /** + * @return string + */ + public function getReserveHoldUri(): string + { + return $this->reserveHoldUri; + } + + /** + * @param string $reserveHoldUri + */ + public function setReserveHoldUri(string $reserveHoldUri = ''): void + { + $this->reserveHoldUri = $reserveHoldUri; + } + /** * @return string */ diff --git a/Classes/Mvc/View/JsonView.php b/Classes/Mvc/View/JsonView.php index b631a9c..9b77a57 100644 --- a/Classes/Mvc/View/JsonView.php +++ b/Classes/Mvc/View/JsonView.php @@ -72,6 +72,11 @@ class JsonView extends ExtbaseJsonView 'reserveHistory' ] ], + 'userReserveHold' => [ + '_only' => [ + 'reserveHold' + ] + ], 'userDataDownload' => [ '_only' => [ 'contentType', diff --git a/Classes/Service/UserReserveService.php b/Classes/Service/UserReserveService.php index 8a351c9..02aaee9 100644 --- a/Classes/Service/UserReserveService.php +++ b/Classes/Service/UserReserveService.php @@ -93,6 +93,27 @@ public function getHistory(array $arguments): ?array return []; } + /** + * @param array $arguments + * @return array|null + * @throws \JsonException + */ + public function getHold(array $arguments): ?array + { + $account = $this->accountService->getAccountByArguments($arguments); + $accountId = $this->accountService->getAccountId(); + + if ($accountId > 0 && is_array($account)) { + $processed = $this->requestHold($accountId); + + return [ + 'reserveHold' => $processed['hold'] + ]; + } + + return []; + } + /** * @param array $arguments * @return array|null @@ -137,6 +158,25 @@ protected function requestCurrent(int $id): ?array ]); } + /** + * @param int $id + * @return array|null + * @throws \JsonException + */ + protected function requestHold(int $id): ?array + { + $uri = $this->apiConfiguration->getReserveHoldUri(); + $uri = ApiUtility::replaceUriPlaceholder([$id], $uri); + + return $this->request->process($uri, 'GET', [ + 'headers' => [ + 'X-SLUB-Standard' => 'paia_ext', + 'X-SLUB-pretty' => '1', + 'X-SLUB-sort' => 'DESC' + ] + ]); + } + /** * @param array $data * @param int $accountId diff --git a/Configuration/Icons.php b/Configuration/Icons.php index dbd2643..7dfa719 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -71,6 +71,10 @@ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-reserve-history.svg' ], + 'slubprofileaccount-wizard-userreservehold' => [ + 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-reserve-hold.svg' + ], 'slubprofileaccount-wizard-usersearchquerydetail' => [ 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, 'source' => 'EXT:slub_profile_account/Resources/Public/Icons/Wizard/user-search-query-detail.svg' diff --git a/Configuration/Routes/UserReserve.yaml b/Configuration/Routes/UserReserve.yaml index c1d9f64..753bbd7 100644 --- a/Configuration/Routes/UserReserve.yaml +++ b/Configuration/Routes/UserReserve.yaml @@ -1,4 +1,12 @@ routeEnhancers: + SlubAccountUserReserveHold: + type: Simple + limitToPages: [40] + routePath: '/{user}' + requirements: + user: '[0-9]{1,10}' + _arguments: + user: 'tx_slubprofileaccount_userreservehold/user' SlubAccountUserReserveCurrent: type: Simple limitToPages: [35] diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index bdd11d6..2a443ec 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -74,6 +74,7 @@ 'userreservecurrent', 'userreservedelete', 'userreservehistory', + 'userreservehold', 'usersearchquerydetail', 'usersearchqueryupdate' ] diff --git a/Configuration/TsConfig/Page/mod.tsconfig b/Configuration/TsConfig/Page/mod.tsconfig index 4a55cbf..f1e125f 100644 --- a/Configuration/TsConfig/Page/mod.tsconfig +++ b/Configuration/TsConfig/Page/mod.tsconfig @@ -108,6 +108,14 @@ mod { tt_content_defValues.CType = slubprofileaccount_userreservehistory } + slubprofileaccount_userreservehold { + iconIdentifier = slubprofileaccount-wizard-userreservehold + iconOverlay = slubprofileaccount-overlay-extension + title = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userreservehold.title + description = LLL:EXT:slub_profile_account/Resources/Private/Language/locallang_backend.xlf:plugin.userreservehold.description + tt_content_defValues.CType = slubprofileaccount_userreservehold + } + slubprofileaccount_usersearchquerydetail { iconIdentifier = slubprofileaccount-wizard-usersearchquerydetail iconOverlay = slubprofileaccount-overlay-extension @@ -138,6 +146,7 @@ mod { show := addToList(slubprofileaccount_userreservecurrent) show := addToList(slubprofileaccount_userreservedelete) show := addToList(slubprofileaccount_userreservehistory) + show := addToList(slubprofileaccount_userreservehold) show := addToList(slubprofileaccount_usersearchqueryupdate) show := addToList(slubprofileaccount_usersearchquerydetail) } diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 44896a6..ee21247 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -27,6 +27,8 @@ plugin.tx_slubprofileaccount { reserveDelete = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/cancel/###LABEL###/###QUEUE_NUMBER### # cat=plugin.tx_slubprofileaccount/76595002_Api/145; type=string; label=Path to reserve history reserveHistory = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/historyres + # cat=plugin.tx_slubprofileaccount/76595002_Api/145; type=string; label=Path to reserve hold + reserveHold = https://liberoproxy.staging.katalogbeta.slub-dresden.de/core/###USER_ID###/items/hold # cat=plugin.tx_slubprofileaccount/76595002_Api/150; type=string; label=Path to data download dataDownload = https://liberoproxy.staging.katalogbeta.slub-dresden.de/csp/user/dsgvo01.csp?patronid=###USER_ID###&format=###FILE_FORMAT### } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index d54bad0..198fa18 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -19,6 +19,7 @@ plugin.tx_slubprofileaccount { reserveCurrent = {$plugin.tx_slubprofileaccount.settings.api.path.reserveCurrent} reserveDelete = {$plugin.tx_slubprofileaccount.settings.api.path.reserveDelete} reserveHistory = {$plugin.tx_slubprofileaccount.settings.api.path.reserveHistory} + reserveHold = {$plugin.tx_slubprofileaccount.settings.api.path.reserveHold} dataDownload = {$plugin.tx_slubprofileaccount.settings.api.path.dataDownload} } diff --git a/README.md b/README.md index 8e9e545..8771f06 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Furthermore, have a look at postman and import the "postman_collection" file. Th | plugin.tx_slubprofile_account.settings.api.path.reserveCurrent | Path to reserve current | | plugin.tx_slubprofile_account.settings.api.path.reserveDelete | Path to delete reservation | | plugin.tx_slubprofile_account.settings.api.path.reserveHistory | Path to reserve history | +| plugin.tx_slubprofile_account.settings.api.path.reserveHold | Path to reserve hold | | plugin.tx_slubprofile_account.settings.api.path.dataDownload | Path to data download | | plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | | plugin.tx_slubprofile_account.settings.general.itemsPerPage | Items per page for pagination | diff --git a/Resources/Private/Language/de.locallang_backend.xlf b/Resources/Private/Language/de.locallang_backend.xlf index 24c5c6c..db6e04d 100644 --- a/Resources/Private/Language/de.locallang_backend.xlf +++ b/Resources/Private/Language/de.locallang_backend.xlf @@ -112,6 +112,15 @@ Vormerkhistorie zu einem spezifischen Benutzer. Gibt nur die Daten des Benutzers mit der Einschränkung "Vormerkhistorie" zurück. + + Hold user reservation + Abholbereite Vormerkungen eines Benutzers + + + Hold reservation of a specific user. + Abholbereite Vormerkungen zu einem spezifischen Benutzer. + + Update password Passwort aktualisieren diff --git a/Resources/Private/Language/locallang_backend.xlf b/Resources/Private/Language/locallang_backend.xlf index 86d759d..cb8448a 100644 --- a/Resources/Private/Language/locallang_backend.xlf +++ b/Resources/Private/Language/locallang_backend.xlf @@ -89,6 +89,13 @@ Reservation history of a specific user. Returns only the user constraint "reservation history" data. + + Hold user reservation + + + Hold reservation of a specific user. + + Update password diff --git a/Resources/Public/Icons/Wizard/user-reserve-hold.svg b/Resources/Public/Icons/Wizard/user-reserve-hold.svg new file mode 100644 index 0000000..bb48eb6 --- /dev/null +++ b/Resources/Public/Icons/Wizard/user-reserve-hold.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ext_localconf.php b/ext_localconf.php index a36a43e..e382b75 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -189,6 +189,19 @@ ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT ); +// Configure plugin - user reserve hold +ExtensionUtility::configurePlugin( + 'SlubProfileAccount', + 'UserReserveHold', + [ + UserReserveController::class => 'hold' + ], + [ + UserReserveController::class => 'hold' + ], + ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT +); + // Configure plugin - user search query detail ExtensionUtility::configurePlugin( 'SlubProfileAccount', diff --git a/postman_collection.json b/postman_collection.json index 77b3e31..803b7fb 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -379,30 +379,7 @@ ] } }, - "response": [ - { - "name": "Unknown user", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", - "host": [ - "{{domain}}" - ], - "path": [ - "benutzer", - "ausleihhistorie", - "{{user}}" - ] - } - }, - "_postman_previewlanguage": "json", - "header": [], - "cookie": [], - "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" - } - ] + "response": [] } ] }, @@ -436,30 +413,39 @@ ] } }, - "response": [ - { - "name": "Unknown user", - "originalRequest": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}/benutzer/ausleihhistorie/{{user}}", - "host": [ - "{{domain}}" - ], - "path": [ - "benutzer", - "ausleihhistorie", - "{{user}}" - ] - } - }, - "_postman_previewlanguage": "json", - "header": [], - "cookie": [], - "body": "{\n \"account\": {\n \"code\": 404,\n \"error\": \"not_found\",\n \"X_message\": \"patronid not found\"\n }\n}" + "response": [] + } + ] + }, + { + "name": "Hold", + "item": [ + { + "name": "Get - Default", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{domain}}/benutzer/vormerkung/abholbereit/{{user}}", + "host": [ + "{{domain}}" + ], + "path": [ + "benutzer", + "vormerkung", + "abholbereit", + "{{user}}" + ] } - ] + }, + "response": [] } ] }, From 4bebb71872eb28b6b46f6c078890729ae955f287 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Fri, 3 May 2024 10:48:42 +0200 Subject: [PATCH 80/81] [TASK] Update api documentation --- postman_collection.json | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/postman_collection.json b/postman_collection.json index 803b7fb..41a343b 100644 --- a/postman_collection.json +++ b/postman_collection.json @@ -709,6 +709,7 @@ "listen": "test", "script": { "type": "text/javascript", + "packages": {}, "exec": [ "" ] @@ -725,16 +726,6 @@ "key": "domain", "value": "https://ddev-slub-profile-service.ddev.site/", "type": "default" - }, - { - "key": "domainCatalogue", - "value": "https://katalog.ddev.site/", - "type": "string" - }, - { - "key": "appKey", - "value": "6627b6fab58c1", - "type": "string" } ] } \ No newline at end of file From 368f21a00375b8f82d8369d24576182d6e141f47 Mon Sep 17 00:00:00 2001 From: Andreas Pfeiffer Date: Wed, 18 Dec 2024 10:32:01 +0100 Subject: [PATCH 81/81] [TASK] Remove versioning from documentation --- README.md | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 8771f06..795016b 100644 --- a/README.md +++ b/README.md @@ -16,23 +16,14 @@ Run the following command within your Composer based TYPO3 project: composer require slub/slub-profile-account ``` -## 2 Administration corner +## 2 Api -### 2.1 Release Management - -News uses [semantic versioning][2], which means, that -* **bugfix updates** (e.g. 1.0.0 => 1.0.1) just includes small bugfixes or security relevant stuff without breaking changes, -* **minor updates** (e.g. 1.0.0 => 1.1.0) includes new features and smaller tasks without breaking changes, -* **major updates** (e.g. 1.0.0 => 2.0.0) breaking changes which can be refactorings, features or bugfixes. - -## 3 Api - -### 3.1 Routes +### 2.1 Routes Please check the routes' configuration. You have to set the matching page (limitToPages). If not the routes will not work properly. Furthermore, have a look at postman and import the "postman_collection" file. This explains the possible APIs very well. -### 3.2 Typoscript +### 2.2 Typoscript | Setup / Constant | Comment | |----------------------------------------------------------------|---------------------------------| @@ -51,7 +42,7 @@ Furthermore, have a look at postman and import the "postman_collection" file. Th | plugin.tx_slubprofile_account.settings.cache.account.lifeTime | Life time to cache account data | | plugin.tx_slubprofile_account.settings.general.itemsPerPage | Items per page for pagination | -### 3.3 Update account data +### 2.3 Update account data To update data via external form you have to send an array called "account" via post with the following fields: @@ -69,7 +60,7 @@ To update data via external form you have to send an array called "account" via | ResAddressPostCode | | | ResAddressCountry | | -### 3.4 Update pin +### 2.4 Update pin To update pin via external form you have to send an array called "pin" via post with the following fields: @@ -79,7 +70,7 @@ To update pin via external form you have to send an array called "pin" via post | pinRepeat | Obligation | | password | Obligation | -### 3.5 Update password +### 2.5 Update password To update password via external form you have to send a string called "password" via post with the following fields: @@ -88,5 +79,4 @@ To update password via external form you have to send a string called "password" | password | Obligation | [1]: https://getcomposer.org/ -[2]: https://semver.org/