* [FIX] Client custom fields were not created/saved. Thanks to @ZUNbado and @sf32738 for the notice. Closes #1375

* [MOD] Minor code tweaks

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2019-07-20 21:44:04 +02:00
parent b5559b52eb
commit 98a68f47c5
32 changed files with 160 additions and 107 deletions

View File

@@ -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()
{