From 98a68f47c55098eafd75807768d578cb712d7fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D?= Date: Sat, 20 Jul 2019 21:44:04 +0200 Subject: [PATCH] * [FIX] Client custom fields were not created/saved. Thanks to @ZUNbado and @sf32738 for the notice. Closes #1375 * [MOD] Minor code tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rubén D --- .../Controllers/AccessManagerController.php | 8 ++--- .../web/Controllers/AccountController.php | 22 ++++++------ .../Controllers/AccountFavoriteController.php | 8 +++++ .../web/Controllers/AccountFileController.php | 7 ++-- .../AccountHistoryManagerController.php | 4 ++- .../Controllers/AccountManagerController.php | 4 ++- .../web/Controllers/AuthTokenController.php | 8 ++--- .../web/Controllers/CategoryController.php | 16 ++++----- .../web/Controllers/ClientController.php | 14 +++++--- .../Controllers/ConfigAccountController.php | 2 ++ .../Controllers/ConfigBackupController.php | 3 ++ .../Controllers/ConfigDokuWikiController.php | 2 ++ .../ConfigEncryptionController.php | 2 ++ .../Controllers/ConfigGeneralController.php | 2 ++ .../Controllers/ConfigImportController.php | 2 ++ .../Controllers/ConfigManagerController.php | 6 ++-- .../web/Controllers/ConfigWikiController.php | 2 ++ .../web/Controllers/CustomFieldController.php | 8 ++--- .../web/Controllers/EventlogController.php | 4 ++- .../web/Controllers/ItemManagerController.php | 8 ++--- .../web/Controllers/ItemPresetController.php | 8 ++--- .../web/Controllers/ItemsController.php | 3 ++ .../Controllers/NotificationController.php | 4 ++- .../web/Controllers/PluginController.php | 8 ++--- .../web/Controllers/PublicLinkController.php | 7 ++-- .../Controllers/SecurityManagerController.php | 8 ++--- app/modules/web/Controllers/TagController.php | 8 ++--- .../web/Controllers/TrackController.php | 4 ++- .../web/Controllers/UserController.php | 19 ++++++----- .../web/Controllers/UserGroupController.php | 30 ++++++++-------- .../web/Controllers/UserProfileController.php | 34 ++++++++++--------- .../UserSettingsGeneralController.php | 2 ++ 32 files changed, 160 insertions(+), 107 deletions(-) diff --git a/app/modules/web/Controllers/AccessManagerController.php b/app/modules/web/Controllers/AccessManagerController.php index 88e26f7f..1111eb47 100644 --- a/app/modules/web/Controllers/AccessManagerController.php +++ b/app/modules/web/Controllers/AccessManagerController.php @@ -26,12 +26,11 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\DataModel\ItemSearchData; use SP\Html\DataGrid\DataGridTab; use SP\Modules\Web\Controllers\Helpers\Grid\AuthTokenGrid; @@ -205,9 +204,10 @@ final class AccessManagerController extends ControllerBase } /** - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/AccountController.php b/app/modules/web/Controllers/AccountController.php index c617481e..a86e08d3 100644 --- a/app/modules/web/Controllers/AccountController.php +++ b/app/modules/web/Controllers/AccountController.php @@ -833,8 +833,6 @@ final class AccountController extends ControllerBase implements CrudControllerIn $accountId = $this->accountService->create($form->getItemData()); - $this->addCustomFieldsForItem(Acl::ACCOUNT, $accountId, $this->request); - $accountDetails = $this->accountService->getById($accountId)->getAccountVData(); $this->eventDispatcher->notifyEvent('create.account', @@ -844,6 +842,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn ->addDetail(__u('Client'), $accountDetails->getClientName())) ); + $this->addCustomFieldsForItem(Acl::ACCOUNT, $accountId, $this->request); + return $this->returnJsonResponseData( [ 'itemId' => $accountId, @@ -882,8 +882,6 @@ final class AccountController extends ControllerBase implements CrudControllerIn $this->accountService->update($itemData); - $this->updateCustomFieldsForItem(Acl::ACCOUNT, $id, $this->request); - $accountDetails = $this->accountService->getById($id)->getAccountVData(); $this->eventDispatcher->notifyEvent('edit.account', @@ -893,6 +891,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn ->addDetail(__u('Client'), $accountDetails->getClientName())) ); + $this->updateCustomFieldsForItem(Acl::ACCOUNT, $id, $this->request); + return $this->returnJsonResponseData( [ 'itemId' => $id, @@ -1013,12 +1013,14 @@ final class AccountController extends ControllerBase implements CrudControllerIn if ($id === null) { $this->accountService->deleteByIdBatch($this->getItemsIdFromRequest($this->request)); - $this->deleteCustomFieldsForItem(Acl::ACCOUNT, $id); - - $this->eventDispatcher->notifyEvent('delete.account.selection', - new Event($this, EventMessage::factory()->addDescription(__u('Accounts removed'))) + $this->eventDispatcher->notifyEvent( + 'delete.account.selection', + new Event($this, EventMessage::factory() + ->addDescription(__u('Accounts removed'))) ); + $this->deleteCustomFieldsForItem(Acl::ACCOUNT, $id); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Accounts removed')); } @@ -1026,8 +1028,6 @@ final class AccountController extends ControllerBase implements CrudControllerIn $this->accountService->delete($id); - $this->deleteCustomFieldsForItem(Acl::ACCOUNT, $id); - $this->eventDispatcher->notifyEvent('delete.account', new Event($this, EventMessage::factory() ->addDescription(__u('Account removed')) @@ -1035,6 +1035,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn ->addDetail(__u('Client'), $accountDetails->getClientName())) ); + $this->deleteCustomFieldsForItem(Acl::ACCOUNT, $id); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Account removed')); } catch (Exception $e) { processException($e); diff --git a/app/modules/web/Controllers/AccountFavoriteController.php b/app/modules/web/Controllers/AccountFavoriteController.php index 9d36aa4c..6f7c52e3 100644 --- a/app/modules/web/Controllers/AccountFavoriteController.php +++ b/app/modules/web/Controllers/AccountFavoriteController.php @@ -24,8 +24,11 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; use Exception; use SP\Core\Events\Event; +use SP\Core\Exceptions\SessionTimeout; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Services\Account\AccountToFavoriteService; @@ -84,6 +87,11 @@ final class AccountFavoriteController extends SimpleControllerBase } } + /** + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout + */ protected function initialize() { $this->checks(); diff --git a/app/modules/web/Controllers/AccountFileController.php b/app/modules/web/Controllers/AccountFileController.php index ea819fea..8c65f5a9 100644 --- a/app/modules/web/Controllers/AccountFileController.php +++ b/app/modules/web/Controllers/AccountFileController.php @@ -28,13 +28,13 @@ use DI\DependencyException; use DI\NotFoundException; use Exception; use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use RuntimeException; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\DataModel\FileData; use SP\Html\Html; @@ -467,9 +467,10 @@ final class AccountFileController extends ControllerBase implements CrudControll /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/AccountHistoryManagerController.php b/app/modules/web/Controllers/AccountHistoryManagerController.php index 96c7b23e..940f0a23 100644 --- a/app/modules/web/Controllers/AccountHistoryManagerController.php +++ b/app/modules/web/Controllers/AccountHistoryManagerController.php @@ -32,6 +32,7 @@ use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\AccountHistoryGrid; @@ -180,9 +181,10 @@ final class AccountHistoryManagerController extends ControllerBase /** * Initialize class * + * @throws AuthException * @throws DependencyException * @throws NotFoundException - * @throws AuthException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/AccountManagerController.php b/app/modules/web/Controllers/AccountManagerController.php index 07f87050..e21d5270 100644 --- a/app/modules/web/Controllers/AccountManagerController.php +++ b/app/modules/web/Controllers/AccountManagerController.php @@ -32,6 +32,7 @@ use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\AccountGrid; @@ -272,9 +273,10 @@ final class AccountManagerController extends ControllerBase /** * Initialize class * + * @throws AuthException * @throws DependencyException * @throws NotFoundException - * @throws AuthException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/AuthTokenController.php b/app/modules/web/Controllers/AuthTokenController.php index 84a5c961..35764482 100644 --- a/app/modules/web/Controllers/AuthTokenController.php +++ b/app/modules/web/Controllers/AuthTokenController.php @@ -27,13 +27,12 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\AuthTokenData; @@ -389,9 +388,10 @@ final class AuthTokenController extends ControllerBase implements CrudController /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/CategoryController.php b/app/modules/web/Controllers/CategoryController.php index d68efe35..1b9ad6d0 100644 --- a/app/modules/web/Controllers/CategoryController.php +++ b/app/modules/web/Controllers/CategoryController.php @@ -27,13 +27,12 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\CategoryData; @@ -272,8 +271,6 @@ final class CategoryController extends ControllerBase implements CrudControllerI $id = $this->categoryService->create($itemData); - $this->addCustomFieldsForItem(Acl::CATEGORY, $id, $this->request); - $this->eventDispatcher->notifyEvent('create.category', new Event($this, EventMessage::factory() @@ -281,6 +278,8 @@ final class CategoryController extends ControllerBase implements CrudControllerI ->addDetail(__u('Category'), $itemData->getName())) ); + $this->addCustomFieldsForItem(Acl::CATEGORY, $id, $this->request); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Category added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); @@ -316,8 +315,6 @@ final class CategoryController extends ControllerBase implements CrudControllerI $this->categoryService->update($itemData); - $this->updateCustomFieldsForItem(Acl::CATEGORY, $id, $this->request); - $this->eventDispatcher->notifyEvent('edit.category', new Event($this, EventMessage::factory() @@ -325,6 +322,8 @@ final class CategoryController extends ControllerBase implements CrudControllerI ->addDetail(__u('Category'), $itemData->getName())) ); + $this->updateCustomFieldsForItem(Acl::CATEGORY, $id, $this->request); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Category updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); @@ -373,9 +372,10 @@ final class CategoryController extends ControllerBase implements CrudControllerI /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ClientController.php b/app/modules/web/Controllers/ClientController.php index 856de315..057f12a9 100644 --- a/app/modules/web/Controllers/ClientController.php +++ b/app/modules/web/Controllers/ClientController.php @@ -28,13 +28,12 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\ClientData; @@ -267,7 +266,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt $itemData = $form->getItemData(); - $this->clientService->create($itemData); + $id = $this->clientService->create($itemData); $this->eventDispatcher->notifyEvent('create.client', new Event($this, @@ -276,6 +275,8 @@ final class ClientController extends ControllerBase implements CrudControllerInt ->addDetail(__u('Client'), $itemData->getName())) ); + $this->addCustomFieldsForItem(Acl::CLIENT, $id, $this->request); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Client added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); @@ -316,6 +317,8 @@ final class ClientController extends ControllerBase implements CrudControllerInt ->addDetail(__u('Client'), $id)) ); + $this->updateCustomFieldsForItem(Acl::CLIENT, $id, $this->request); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Client updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); @@ -364,9 +367,10 @@ final class ClientController extends ControllerBase implements CrudControllerInt /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigAccountController.php b/app/modules/web/Controllers/ConfigAccountController.php index 2c6746eb..090549a1 100644 --- a/app/modules/web/Controllers/ConfigAccountController.php +++ b/app/modules/web/Controllers/ConfigAccountController.php @@ -28,6 +28,7 @@ use SP\Core\Acl\ActionsInterface; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; @@ -120,6 +121,7 @@ final class ConfigAccountController extends SimpleControllerBase /** * @return bool + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigBackupController.php b/app/modules/web/Controllers/ConfigBackupController.php index fe50d5c0..144cd266 100644 --- a/app/modules/web/Controllers/ConfigBackupController.php +++ b/app/modules/web/Controllers/ConfigBackupController.php @@ -30,6 +30,7 @@ use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Context\SessionContext; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; @@ -279,6 +280,8 @@ final class ConfigBackupController extends SimpleControllerBase /** * initialize + * + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigDokuWikiController.php b/app/modules/web/Controllers/ConfigDokuWikiController.php index fa6349a2..ed0bb7de 100644 --- a/app/modules/web/Controllers/ConfigDokuWikiController.php +++ b/app/modules/web/Controllers/ConfigDokuWikiController.php @@ -28,6 +28,7 @@ use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; @@ -90,6 +91,7 @@ final class ConfigDokuWikiController extends SimpleControllerBase /** * @return bool + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigEncryptionController.php b/app/modules/web/Controllers/ConfigEncryptionController.php index 6864c71f..8eeb36f1 100644 --- a/app/modules/web/Controllers/ConfigEncryptionController.php +++ b/app/modules/web/Controllers/ConfigEncryptionController.php @@ -33,6 +33,7 @@ use SP\Core\Crypt\Hash; use SP\Core\Crypt\Session as CryptSession; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; @@ -264,6 +265,7 @@ final class ConfigEncryptionController extends SimpleControllerBase /** * @return bool + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigGeneralController.php b/app/modules/web/Controllers/ConfigGeneralController.php index 8ba65eab..8bada48d 100644 --- a/app/modules/web/Controllers/ConfigGeneralController.php +++ b/app/modules/web/Controllers/ConfigGeneralController.php @@ -32,6 +32,7 @@ use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Context\SessionContext; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; @@ -287,6 +288,7 @@ final class ConfigGeneralController extends SimpleControllerBase /** * @return bool + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigImportController.php b/app/modules/web/Controllers/ConfigImportController.php index 5be9531c..62a9825a 100644 --- a/app/modules/web/Controllers/ConfigImportController.php +++ b/app/modules/web/Controllers/ConfigImportController.php @@ -32,6 +32,7 @@ use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Context\SessionContext; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; @@ -104,6 +105,7 @@ final class ConfigImportController extends SimpleControllerBase /** * @return bool + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigManagerController.php b/app/modules/web/Controllers/ConfigManagerController.php index b5386f3a..94aa8f53 100644 --- a/app/modules/web/Controllers/ConfigManagerController.php +++ b/app/modules/web/Controllers/ConfigManagerController.php @@ -35,6 +35,7 @@ use SP\Core\Events\Event; use SP\Core\Exceptions\CheckException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Language; use SP\Core\MimeTypes; @@ -417,9 +418,10 @@ final class ConfigManagerController extends ControllerBase } /** - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigWikiController.php b/app/modules/web/Controllers/ConfigWikiController.php index d399e944..772d9d59 100644 --- a/app/modules/web/Controllers/ConfigWikiController.php +++ b/app/modules/web/Controllers/ConfigWikiController.php @@ -28,6 +28,7 @@ use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; @@ -86,6 +87,7 @@ final class ConfigWikiController extends SimpleControllerBase /** * @return bool + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/CustomFieldController.php b/app/modules/web/Controllers/CustomFieldController.php index 0cdd0517..8287c255 100644 --- a/app/modules/web/Controllers/CustomFieldController.php +++ b/app/modules/web/Controllers/CustomFieldController.php @@ -27,13 +27,12 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\CustomFieldDefinitionData; @@ -354,9 +353,10 @@ final class CustomFieldController extends ControllerBase implements CrudControll /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/EventlogController.php b/app/modules/web/Controllers/EventlogController.php index 151f907f..03b906e7 100644 --- a/app/modules/web/Controllers/EventlogController.php +++ b/app/modules/web/Controllers/EventlogController.php @@ -32,6 +32,7 @@ use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\EventlogGrid; @@ -143,9 +144,10 @@ final class EventlogController extends ControllerBase } /** + * @throws AuthException * @throws DependencyException * @throws NotFoundException - * @throws AuthException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ItemManagerController.php b/app/modules/web/Controllers/ItemManagerController.php index 5300a3e9..f17a3d45 100644 --- a/app/modules/web/Controllers/ItemManagerController.php +++ b/app/modules/web/Controllers/ItemManagerController.php @@ -26,12 +26,11 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\DataModel\ItemSearchData; use SP\Html\DataGrid\DataGridTab; use SP\Modules\Web\Controllers\Helpers\Grid\AccountGrid; @@ -271,9 +270,10 @@ final class ItemManagerController extends ControllerBase } /** - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ItemPresetController.php b/app/modules/web/Controllers/ItemPresetController.php index 885958a4..a76bcdb6 100644 --- a/app/modules/web/Controllers/ItemPresetController.php +++ b/app/modules/web/Controllers/ItemPresetController.php @@ -27,8 +27,6 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; @@ -36,6 +34,7 @@ use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\InvalidArgumentException; use SP\Core\Exceptions\NoSuchPropertyException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\ItemPresetData; @@ -402,9 +401,10 @@ final class ItemPresetController extends ControllerBase implements CrudControlle /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/ItemsController.php b/app/modules/web/Controllers/ItemsController.php index e8975763..a949eb3b 100644 --- a/app/modules/web/Controllers/ItemsController.php +++ b/app/modules/web/Controllers/ItemsController.php @@ -28,6 +28,7 @@ use DI\DependencyException; use DI\NotFoundException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\DataModel\DataModelInterface; use SP\DataModel\NotificationData; @@ -166,6 +167,8 @@ final class ItemsController extends SimpleControllerBase /** * ItemsController constructor. + * + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/NotificationController.php b/app/modules/web/Controllers/NotificationController.php index f90377b4..4135bc15 100644 --- a/app/modules/web/Controllers/NotificationController.php +++ b/app/modules/web/Controllers/NotificationController.php @@ -32,6 +32,7 @@ use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\DataModel\NotificationData; use SP\Http\JsonResponse; @@ -410,9 +411,10 @@ final class NotificationController extends ControllerBase implements CrudControl } /** + * @throws AuthException * @throws DependencyException * @throws NotFoundException - * @throws AuthException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/PluginController.php b/app/modules/web/Controllers/PluginController.php index 9af21d6f..887e783f 100644 --- a/app/modules/web/Controllers/PluginController.php +++ b/app/modules/web/Controllers/PluginController.php @@ -27,13 +27,12 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\PluginGrid; @@ -322,9 +321,10 @@ final class PluginController extends ControllerBase } /** - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/PublicLinkController.php b/app/modules/web/Controllers/PublicLinkController.php index 8456fc6c..34ec126c 100644 --- a/app/modules/web/Controllers/PublicLinkController.php +++ b/app/modules/web/Controllers/PublicLinkController.php @@ -28,7 +28,6 @@ use DI\DependencyException; use DI\NotFoundException; use Exception; use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use RuntimeException; use SP\Bootstrap; use SP\Core\Acl\Acl; @@ -36,6 +35,7 @@ use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\PublicLinkData; @@ -398,9 +398,10 @@ final class PublicLinkController extends ControllerBase implements CrudControlle /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/SecurityManagerController.php b/app/modules/web/Controllers/SecurityManagerController.php index 3dcaa536..13774a64 100644 --- a/app/modules/web/Controllers/SecurityManagerController.php +++ b/app/modules/web/Controllers/SecurityManagerController.php @@ -26,12 +26,11 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\DataModel\ItemSearchData; use SP\Html\DataGrid\DataGridTab; use SP\Modules\Web\Controllers\Helpers\Grid\EventlogGrid; @@ -141,9 +140,10 @@ final class SecurityManagerController extends ControllerBase } /** - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/TagController.php b/app/modules/web/Controllers/TagController.php index 4deb2ae3..8e1d2066 100644 --- a/app/modules/web/Controllers/TagController.php +++ b/app/modules/web/Controllers/TagController.php @@ -27,12 +27,11 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\TagData; @@ -339,9 +338,10 @@ final class TagController extends ControllerBase implements CrudControllerInterf /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/TrackController.php b/app/modules/web/Controllers/TrackController.php index 1a0fc34f..d4a5517d 100644 --- a/app/modules/web/Controllers/TrackController.php +++ b/app/modules/web/Controllers/TrackController.php @@ -32,6 +32,7 @@ use SP\Core\Acl\UnauthorizedActionException; use SP\Core\Events\Event; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\TrackGrid; @@ -157,9 +158,10 @@ final class TrackController extends ControllerBase } /** + * @throws AuthException * @throws DependencyException * @throws NotFoundException - * @throws AuthException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserController.php b/app/modules/web/Controllers/UserController.php index b1ab1588..5814c110 100644 --- a/app/modules/web/Controllers/UserController.php +++ b/app/modules/web/Controllers/UserController.php @@ -29,12 +29,12 @@ use DI\DependencyException; use DI\NotFoundException; use Exception; use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\UserData; @@ -286,8 +286,6 @@ final class UserController extends ControllerBase implements CrudControllerInter if ($id === null) { $this->userService->deleteByIdBatch($this->getItemsIdFromRequest($this->request)); - $this->deleteCustomFieldsForItem(Acl::USER, $id); - $this->eventDispatcher->notifyEvent( 'delete.user.selection', new Event($this, EventMessage::factory() @@ -295,6 +293,8 @@ final class UserController extends ControllerBase implements CrudControllerInter ->setExtra('userId', $this->getItemsIdFromRequest($this->request))) ); + $this->deleteCustomFieldsForItem(Acl::USER, $id); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Users deleted')); } else { $this->userService->delete($id); @@ -338,14 +338,14 @@ final class UserController extends ControllerBase implements CrudControllerInter $id = $this->userService->create($itemData); - $this->addCustomFieldsForItem(Acl::USER, $id, $this->request); - $this->eventDispatcher->notifyEvent('create.user', new Event($this, EventMessage::factory() ->addDescription(__u('User added')) ->addDetail(__u('User'), $itemData->getName())) ); + $this->addCustomFieldsForItem(Acl::USER, $id, $this->request); + $this->checkChangeUserPass($id, $itemData); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('User added')); @@ -405,8 +405,6 @@ final class UserController extends ControllerBase implements CrudControllerInter $this->userService->update($itemData); - $this->updateCustomFieldsForItem(Acl::USER, $id, $this->request); - $this->eventDispatcher->notifyEvent('edit.user', new Event($this, EventMessage::factory() ->addDescription(__u('User updated')) @@ -414,6 +412,8 @@ final class UserController extends ControllerBase implements CrudControllerInter ->addExtra('userId', $id)) ); + $this->updateCustomFieldsForItem(Acl::USER, $id, $this->request); + $this->checkChangeUserPass($id, $itemData); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('User updated')); @@ -503,9 +503,10 @@ final class UserController extends ControllerBase implements CrudControllerInter } /** - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserGroupController.php b/app/modules/web/Controllers/UserGroupController.php index cd81986c..29023ed1 100644 --- a/app/modules/web/Controllers/UserGroupController.php +++ b/app/modules/web/Controllers/UserGroupController.php @@ -27,13 +27,12 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\UserGroupData; @@ -234,18 +233,18 @@ final class UserGroupController extends ControllerBase implements CrudController if ($id === null) { $this->userGroupService->deleteByIdBatch($this->getItemsIdFromRequest($this->request)); - $this->deleteCustomFieldsForItem(Acl::GROUP, $id); - - $this->eventDispatcher->notifyEvent('delete.userGroup.selection', - new Event($this, EventMessage::factory()->addDescription(__u('Groups deleted'))) + $this->eventDispatcher->notifyEvent( + 'delete.userGroup.selection', + new Event($this, EventMessage::factory() + ->addDescription(__u('Groups deleted'))) ); + $this->deleteCustomFieldsForItem(Acl::GROUP, $id); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Groups deleted')); } else { $this->userGroupService->delete($id); - $this->deleteCustomFieldsForItem(Acl::GROUP, $id); - $this->eventDispatcher->notifyEvent('delete.userGroup', new Event($this, EventMessage::factory() ->addDescription(__u('Group deleted')) @@ -253,6 +252,8 @@ final class UserGroupController extends ControllerBase implements CrudController ->addExtra('userGroupId', $id)) ); + $this->deleteCustomFieldsForItem(Acl::GROUP, $id); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Group deleted')); } } catch (Exception $e) { @@ -283,14 +284,14 @@ final class UserGroupController extends ControllerBase implements CrudController $id = $this->userGroupService->create($groupData); - $this->addCustomFieldsForItem(Acl::GROUP, $id, $this->request); - $this->eventDispatcher->notifyEvent('create.userGroup', new Event($this, EventMessage::factory() ->addDescription(__u('Group added')) ->addDetail(__u('Name'), $groupData->getName())) ); + $this->addCustomFieldsForItem(Acl::GROUP, $id, $this->request); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Group added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); @@ -326,8 +327,6 @@ final class UserGroupController extends ControllerBase implements CrudController $this->userGroupService->update($groupData); - $this->updateCustomFieldsForItem(Acl::GROUP, $id, $this->request); - $this->eventDispatcher->notifyEvent('edit.userGroup', new Event($this, EventMessage::factory() ->addDescription(__u('Group updated')) @@ -335,6 +334,8 @@ final class UserGroupController extends ControllerBase implements CrudController ->addExtra('userGroupId', $id)) ); + $this->updateCustomFieldsForItem(Acl::GROUP, $id, $this->request); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Group updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); @@ -383,9 +384,10 @@ final class UserGroupController extends ControllerBase implements CrudController /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserProfileController.php b/app/modules/web/Controllers/UserProfileController.php index c8f8aa87..dca41c7f 100644 --- a/app/modules/web/Controllers/UserProfileController.php +++ b/app/modules/web/Controllers/UserProfileController.php @@ -27,13 +27,12 @@ namespace SP\Modules\Web\Controllers; use DI\DependencyException; use DI\NotFoundException; use Exception; -use Psr\Container\ContainerExceptionInterface; -use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\ProfileData; @@ -224,26 +223,30 @@ final class UserProfileController extends ControllerBase implements CrudControll if ($id === null) { $this->userProfileService->deleteByIdBatch($this->getItemsIdFromRequest($this->request)); - $this->deleteCustomFieldsForItem(Acl::PROFILE, $id); - - $this->eventDispatcher->notifyEvent('delete.userProfile.selection', - new Event($this, EventMessage::factory()->addDescription(__u('Profiles deleted'))) + $this->eventDispatcher->notifyEvent( + 'delete.userProfile.selection', + new Event($this, EventMessage::factory() + ->addDescription(__u('Profiles deleted'))) ); + $this->deleteCustomFieldsForItem(Acl::PROFILE, $id); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Profiles deleted')); } $this->userProfileService->delete($id); - $this->deleteCustomFieldsForItem(Acl::PROFILE, $id); - $this->eventDispatcher->notifyEvent('delete.userProfile', + $this->eventDispatcher->notifyEvent( + 'delete.userProfile', new Event($this, EventMessage::factory() ->addDescription(__u('Profile deleted')) ->addDetail(__u('Profile'), $id) ->addExtra('userProfileId', $id)) ); + $this->deleteCustomFieldsForItem(Acl::PROFILE, $id); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Profile deleted')); } catch (Exception $e) { processException($e); @@ -273,16 +276,14 @@ final class UserProfileController extends ControllerBase implements CrudControll $id = $this->userProfileService->create($profileData); - $this->addCustomFieldsForItem(Acl::PROFILE, $id, $this->request); - - $this->eventDispatcher->notifyEvent('create.userProfile', new Event($this)); - $this->eventDispatcher->notifyEvent('create.userProfile', new Event($this, EventMessage::factory() ->addDescription(__u('Profile added')) ->addDetail(__u('Name'), $profileData->getName())) ); + $this->addCustomFieldsForItem(Acl::PROFILE, $id, $this->request); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Profile added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); @@ -318,8 +319,6 @@ final class UserProfileController extends ControllerBase implements CrudControll $this->userProfileService->update($profileData); - $this->updateCustomFieldsForItem(Acl::PROFILE, $id, $this->request); - $this->eventDispatcher->notifyEvent('edit.userProfile', new Event($this, EventMessage::factory() ->addDescription(__u('Profile updated')) @@ -327,6 +326,8 @@ final class UserProfileController extends ControllerBase implements CrudControll ->addExtra('userProfileId', $id)) ); + $this->updateCustomFieldsForItem(Acl::PROFILE, $id, $this->request); + return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Profile updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); @@ -375,9 +376,10 @@ final class UserProfileController extends ControllerBase implements CrudControll /** * Initialize class * - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface * @throws AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserSettingsGeneralController.php b/app/modules/web/Controllers/UserSettingsGeneralController.php index ae4c99e7..b7e4c762 100644 --- a/app/modules/web/Controllers/UserSettingsGeneralController.php +++ b/app/modules/web/Controllers/UserSettingsGeneralController.php @@ -28,6 +28,7 @@ use DI\DependencyException; use DI\NotFoundException; use Exception; use SP\Core\Events\Event; +use SP\Core\Exceptions\SessionTimeout; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Services\User\UserService; @@ -90,6 +91,7 @@ final class UserSettingsGeneralController extends SimpleControllerBase * * @throws DependencyException * @throws NotFoundException + * @throws SessionTimeout */ protected function initialize() {