<?php
namespace Claromentis\People\Controller\Rest;

$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] = (@$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] ?: array()) + array("_795cf2d94dc58d02d01c23e25295b" . "2ad" => base64_decode("d2lkd" . "Gg="), "_9eb134425ed37f1" . "4f1e04097ed2ef46" . "0" => base64_decode("U29tZXRoaW5nIHdlbnQgd3" . "Jvbmc="), "_f9696953938d5eb0c93b1" . "562b60ba3a6" => base64_decode("eA=" . "="), "_7f628626dd1d55c71b1fc0932ffd" . "1d2c" => base64_decode("aXNfYXJyYX" . "k="), "_62d701c" . "3c53404f" . "06345eb3" . "5720a47b" . "4" => base64_decode("aXNfbnVtZXJp" . "Yw=="), "_e0637eee905e" . "be3938c5da50e" . "3db10d7" => base64_decode("cGF" . "zc3" . "dvc" . "mQ="), "_b1871640a171314067" . "a68a2389e3477c" => base64_decode("cmVhc3" . "NpZ25f" . "dXNlcl" . "9pZA=="), "_5159b3572969eca46acd1b2e" . "1418459c" => base64_decode("aW1wb" . "G9kZQ" . "=="), "_a4a1018258adabb74e7" . "b04836d8d7e3b" => base64_decode("Tm90I" . "EZvdW" . "5k"), "_e3a4c46d182fe6e780904aa33e7ea" . "6a1" => base64_decode("Y3JlYXRlX" . "3RlbXBfcG" . "F0aA=="), "_b324f64f5346fe6cd20483e20" . "8d94430" => base64_decode("bWFuYWdlcl9pZA=" . "="), "_c894747360c6ec5bd8169530eaf9c4" . "73" => base64_decode("QmFkIFJlcXVlc" . "3Q="), "_15f5f162efaff2443798e5cfc813" . "b02b" => base64_decode("Tm9" . "0IG" . "Zvd" . "W5k"), "_3efc5ba7b" . "f51ca70907" . "f5e65ab602" . "ec1" => base64_decode("SW50ZXJuY" . "WwgU2Vydm" . "VyIEVycm9" . "y"), "_fb2afe3aa58eabd" . "86bcae0f70e5ec64" . "4" => base64_decode("dGVtcG5hbQ=" . "="), "_79bd87060993ff622ef212c1e8b6" . "a79a" => base64_decode("Rm9yYmlkZ" . "GVu"), "user" . "_id" => base64_decode("dXNlcl9pZA=" . "="), "_11cad0367c939d76c4f877581c151a1" . "0" => base64_decode("eQ=" . "="), "_105dce3af" . "144472e061" . "0b7a16a85b" . "256" => base64_decode("dXN" . "yX3" . "Bob" . "3Rv"), "_aa0a228263feed9718881955" . "2013bc5a" => base64_decode("QW4gdW5leHBlY3RlZCBlcnJvciBvY2N1cnJlZCB3aGlsZSBkZWxldGluZyB0aG" . "UgVXNlcg=="), "_17247f55ce15f647f57c3ef8bb" . "3a474a" => base64_decode("dXNlcl9pZHM" . "="), "_eb2e75e8d8d7406e77661966ab9b" . "2d7a" => base64_decode("Tm8gbWFuYWdlciBJRCBzdX" . "BwbGllZA=="), "_3d73a8df5" . "b503f421ad" . "84ec4c4eea" . "fe9" => base64_decode("QmFkIHJlcX" . "Vlc3Q="), "_01f117db67aa749d3ec8da7e" . "b478730c" => base64_decode("L" . "C" . "A" . "="));
use Analogue\ORM\EntityCollection;
use Analogue\ORM\Exceptions\MappingException;
use Claromentis\Core\Http\JsonPrettyResponse;
use Claromentis\Core\Http\RequestData;
use Claromentis\Core\Http\RequestDataException;
use Claromentis\Core\Http\StatusCode;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Security\Exception\AccessDeniedException;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Exception\NotFoundException;
use Claromentis\People\Exception\NotUniqueException;
use Claromentis\People\Exception\PermissionException;
use Claromentis\People\Exception\ValidationException;
use Claromentis\People\Filter\GroupFilter;
use Claromentis\People\Filter\RoleFilter;
use Claromentis\People\Filter\UserFilter;
use Claromentis\People\PasswordChangeException;
use Claromentis\People\PeopleAcl;
use Claromentis\People\RestFormatter;
use Claromentis\People\UseCase\CreateUser;
use Claromentis\People\UseCase\DeleteUserPhoto;
use Claromentis\People\UseCase\DeleteUser;
use Claromentis\People\UseCase\GetCurrentUser;
use Claromentis\People\UseCase\GetGroups;
use Claromentis\People\UseCase\GetRoles;
use Claromentis\People\UseCase\GetUser;
use Claromentis\People\UseCase\GetUsers;
use Claromentis\People\UseCase\SetManager;
use Claromentis\People\UseCase\SetSubordinates;
use Claromentis\People\UseCase\SetUserGroups;
use Claromentis\People\UseCase\SetUserPassword;
use Claromentis\People\UseCase\SetUserPhoto;
use Claromentis\People\UseCase\SetUserRoles;
use Claromentis\People\UseCase\UpdateCurrentUser;
use Claromentis\People\UseCase\UpdateUser;
use Claromentis\People\Validator\ProfilePhotoValidator;
use InvalidArgumentException;
use Psr\Http\Message\ServerRequestInterface;
use RestExAuth;
use RestExBadRequest;
use RestExError;
use RestExForbidden;
use RestExNotFound;
use UnexpectedValueException;






class UserController extends AbstractController
{
    const E_NOT_UNIQUE = 'people.error.field_not_unique';
    const E_BAD_REQUEST_DATA = 'people.error.request_data';
    const E_USER_NOT_FOUND = 'people.error.no_user_with_id';
    const E_NO_SUBORDINATES = 'people.error.no_subordinates';
    const E_NO_PASSWORD = 'people.error.no_password';
    const S_USER_CREATED = 'people.success.user_created';
    const S_USER_UPDATED = 'people.success.user_updated';
    const S_USER_DELETED = 'people.success.user_deleted';
    const S_PHOTO_UPDATED = 'people.success.photo_updated';
    const S_PHOTO_DELETED = 'people.success.photo_deleted';
    const S_MANAGER_UPDATED = 'people.success.manager_update';
    const S_SUBORDINATES_UPDATED = 'people.error.subordinates_saved';
    const S_PASSWORD_UPDATED = 'people.success.password_updated';
    
    
    
    
    protected $formatter;
    
    
    
    
    protected $acl;
    
    
    
    
    protected $lmsg;
    
    
    
    
    
    
    public function __construct(RestFormatter $formatter, PeopleAcl $acl, Lmsg $lmsg)
    {
        $this->formatter = $formatter;
        $this->acl = $acl;
        $this->lmsg = $lmsg;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    public function GetOne(int $user_id, GetUser $get_user, SecurityContext $context, ServerRequestInterface $request)
    {
        try {
            $_03e9164d0a343b742df4793268b80767 = new UserFilter($context);
            $_03e9164d0a343b742df4793268b80767->Fill($this->formatter->GetRequestParams($request, $_03e9164d0a343b742df4793268b80767->GetDefaults()));
            $_24e0e36600d6af77406a44bb618a6253 = $get_user->Get($context, $user_id, $_03e9164d0a343b742df4793268b80767);
            return new JsonPrettyResponse($this->formatter->FormatUser($_24e0e36600d6af77406a44bb618a6253, $_03e9164d0a343b742df4793268b80767));
        } catch (InvalidArgumentException $exception) {
            throw new RestExBadRequest($exception->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_c894747360c6ec5bd8169530eaf9c" . "473"], $exception);
        } catch (NotFoundException $exception) {
            throw new RestExNotFound($exception->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_a4a1018258adabb74e7b04836d" . "8d7e3b"], $exception);
        } catch (AccessDeniedException $exception) {
            throw $this->GetAuthException($context, $exception);
        }
    }
    
    
    
    
    
    
    
    
    public function GetList(ServerRequestInterface $request, SecurityContext $context, GetUsers $get_users)
    {
        try {
            $_03e9164d0a343b742df4793268b80767 = new UserFilter($context);
            $_03e9164d0a343b742df4793268b80767->Fill($this->formatter->GetRequestParams($request, $_03e9164d0a343b742df4793268b80767->GetDefaults()));
            
            
            [$_e4543e131c67c631b14751cc849d1310, $total] = $get_users->GetUsers($_03e9164d0a343b742df4793268b80767);
            return new JsonPrettyResponse($this->formatter->Paginate($request, $this->formatter->FormatUsers($_e4543e131c67c631b14751cc849d1310, $_03e9164d0a343b742df4793268b80767), $_03e9164d0a343b742df4793268b80767->GetChanged(), $total));
        } catch (InvalidArgumentException|UnexpectedValueException $exception) {
            throw new RestExBadRequest($exception->getMessage(), $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_c894747360c6ec5b" . "d8169530eaf9c473"], $exception);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    public function GetGroups(ServerRequestInterface $request, SecurityContext $context, GetUser $get_user, GetGroups $get_groups)
    {
        try {
            $user_id = $this->formatter->GetRequestParam($request, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["use" . "r_i" . "d"]);
            $_7945aa6526b98d01ea0f6f6f7037bd6e = new UserFilter($context);
            $_24e0e36600d6af77406a44bb618a6253 = $get_user->Get($context, $user_id, $_7945aa6526b98d01ea0f6f6f7037bd6e);
            $_eea5f8bfe99a09bd4d06764e8020a0b8 = new GroupFilter($context);
            $_eea5f8bfe99a09bd4d06764e8020a0b8->Fill($this->formatter->GetRequestParams($request, $_eea5f8bfe99a09bd4d06764e8020a0b8->GetDefaults()));
            $_eea5f8bfe99a09bd4d06764e8020a0b8->SetUserIds($_24e0e36600d6af77406a44bb618a6253->id);
            [$_14e7d5dee412ccf516939d1e99c87733, $total] = $get_groups->GetGroups($_eea5f8bfe99a09bd4d06764e8020a0b8);
            return new JsonPrettyResponse($this->formatter->Paginate($request, $this->formatter->FormatGroups($_14e7d5dee412ccf516939d1e99c87733, $_eea5f8bfe99a09bd4d06764e8020a0b8), $_eea5f8bfe99a09bd4d06764e8020a0b8->GetChangedWithout([$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_17247f5" . "5ce15f64" . "7f57c3ef" . "8bb3a474" . "a"]]), $total));
        } catch (NotFoundException $exception) {
            throw new RestExNotFound($exception->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_a4a1018258adabb7" . "4e7b04836d8d7e3b"], $exception);
        } catch (AccessDeniedException $exception) {
            throw new RestExForbidden($exception->getMessage(), $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_79bd87060993ff622ef212c1e8b6a7" . "9a"], $exception);
        } catch (InvalidArgumentException|UnexpectedValueException $exception) {
            throw new RestExBadRequest($exception->getMessage(), $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_c894747360c6ec5b" . "d8169530eaf9c473"], $exception);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    public function PutGroups(ServerRequestInterface $request, SecurityContext $context, SetUserGroups $set_user_groups)
    {
        try {
            $_14e7d5dee412ccf516939d1e99c87733 = $set_user_groups->SetUserGroups($context, $this->formatter->GetRequestParam($request, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["us" . "er" . "_i" . "d"]), $this->formatter->PluckRequestIds($request));
            return new JsonPrettyResponse($this->formatter->FormatGroups($_14e7d5dee412ccf516939d1e99c87733));
        } catch (NotFoundException $exception) {
            throw new RestExNotFound($exception->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_a4a1018258adabb74e7b04836d8" . "d7e3b"], $exception);
        } catch (NotUniqueException $exception) {
            throw new RestExBadRequest($exception->getMessage(), $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_c894747360c6ec5bd8169530eaf9c4" . "73"], $exception);
        } catch (MappingException $exception) {
            throw new RestExError($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_3efc5ba7b" . "f51ca70907" . "f5e65ab602" . "ec1"], 500, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_3efc5ba7bf51ca70907f5e65ab6" . "02ec1"], $exception);
        } catch (ValidationException $exception) {
            return $this->formatter->FormatValidationException($exception);
        } catch (PermissionException $exception) {
            return $this->formatter->FormatPermissionException($exception);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    public function GetRoles(ServerRequestInterface $request, SecurityContext $context, GetUser $get_user, GetRoles $get_roles)
    {
        try {
            $user_id = $this->formatter->GetRequestParam($request, $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["user_" . "id"]);
            $_7945aa6526b98d01ea0f6f6f7037bd6e = new UserFilter($context);
            $_24e0e36600d6af77406a44bb618a6253 = $get_user->Get($context, $user_id, $_7945aa6526b98d01ea0f6f6f7037bd6e);
            $_c4506b641d332e9e2e9f9c875f91063a = new RoleFilter($context);
            $_c4506b641d332e9e2e9f9c875f91063a->Fill($this->formatter->GetRequestParams($request, $_c4506b641d332e9e2e9f9c875f91063a->GetDefaults()));
            $_c4506b641d332e9e2e9f9c875f91063a->SetUserIds($_24e0e36600d6af77406a44bb618a6253->id);
            [$_23ab4dd81b6c619f47099ef7c2485a12, $total] = $get_roles->GetRoles($_c4506b641d332e9e2e9f9c875f91063a);
            return new JsonPrettyResponse($this->formatter->Paginate($request, $this->formatter->FormatRoles($_23ab4dd81b6c619f47099ef7c2485a12, $_c4506b641d332e9e2e9f9c875f91063a), $_c4506b641d332e9e2e9f9c875f91063a->GetChangedWithout([$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_17247f55ce15f647f57c3ef8bb3a4" . "74a"]]), $total));
        } catch (NotFoundException $exception) {
            throw new RestExNotFound($exception->getMessage(), $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_a4a1018258adabb74" . "e7b04836d8d7e3b"], $exception);
        } catch (AccessDeniedException $exception) {
            throw new RestExForbidden($exception->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_79bd87060993ff622e" . "f212c1e8b6a79a"], $exception);
        } catch (InvalidArgumentException|UnexpectedValueException $exception) {
            throw new RestExBadRequest($exception->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_c894747360c6e" . "c5bd8169530eaf" . "9c473"], $exception);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    public function PutRoles(ServerRequestInterface $request, SecurityContext $context, SetUserRoles $set_user_roles)
    {
        try {
            $_23ab4dd81b6c619f47099ef7c2485a12 = $set_user_roles->SetUserRoles($context, $this->formatter->GetRequestParam($request, $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["us" . "er" . "_i" . "d"]), $this->formatter->PluckRequestIds($request));
            return new JsonPrettyResponse($this->formatter->FormatRoles($_23ab4dd81b6c619f47099ef7c2485a12));
        } catch (NotFoundException $exception) {
            throw new RestExNotFound($exception->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_a4a101825" . "8adabb74e7" . "b04836d8d7" . "e3b"], $exception);
        } catch (NotUniqueException $exception) {
            throw new RestExBadRequest($exception->getMessage(), $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_c894747360c6ec5bd8169530eaf" . "9c473"], $exception);
        } catch (MappingException $exception) {
            throw new RestExError($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_3efc5ba7bf51ca70907f5e65ab" . "602ec1"], 500, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_3efc5ba7bf51ca70907f5e65a" . "b602ec1"], $exception);
        } catch (ValidationException $exception) {
            return $this->formatter->FormatValidationException($exception);
        } catch (PermissionException $exception) {
            return $this->formatter->FormatPermissionException($exception);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    public function Post(ServerRequestInterface $request, CreateUser $create_user, SecurityContext $context)
    {
        try {
            $data = $this->formatter->GetJson($request);
            if (!$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_7f628626dd" . "1d55c71b1fc" . "0932ffd1d2c"]($data)) {
                $data = [];
            }
            $_24e0e36600d6af77406a44bb618a6253 = $create_user->Create($context, $data);
            return new JsonPrettyResponse($this->formatter->FormatUser($_24e0e36600d6af77406a44bb618a6253), StatusCode::CREATED);
        } catch (PermissionException $e) {
            throw $this->GetAuthException($context, $e);
        } catch (ValidationException $e) {
            return $this->formatter->FormatValidationException($e);
        } catch (NotUniqueException $e) {
            $fields = $e->getFields();
            throw new RestExBadRequest(($this->lmsg)(self::E_NOT_UNIQUE, $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_5159b35729" . "69eca46acd1" . "b2e1418459c"]($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_01f117db67aa749d3ec8da7eb4" . "78730c"], $fields)), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_3d73a8df5b50" . "3f421ad84ec4c" . "4eeafe9"], $e);
        } catch (MappingException $e) {
            throw new RestExError($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_9eb134425ed" . "37f14f1e0409" . "7ed2ef460"], StatusCode::INTERNAL_SERVER_ERROR, $e);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function Put(ServerRequestInterface $request, UpdateUser $update_user, int $user_id, SecurityContext $context)
    {
        try {
            $data = $this->formatter->GetJson($request);
            if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_7f628626dd1d55c71b1fc09" . "32ffd1d2c"]($data)) {
                $data = [];
            }
            $_24e0e36600d6af77406a44bb618a6253 = $update_user->Update($context, $user_id, $data);
            return new JsonPrettyResponse($this->formatter->FormatUser($_24e0e36600d6af77406a44bb618a6253));
        } catch (NotFoundException $e) {
            throw new RestExNotFound($e->getMessage(), $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_15f5f162" . "efaff2443" . "798e5cfc8" . "13b02b"], $e);
        } catch (ValidationException $e) {
            return $this->formatter->FormatValidationException($e);
        } catch (AccessDeniedException $e) {
            throw $this->GetAuthException($context, $e);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function Delete(ServerRequestInterface $request, SecurityContext $context, DeleteUser $delete_user, int $user_id)
    {
        try {
            $_b1871640a171314067a68a2389e3477c = $this->formatter->GetRequestParam($request, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_b1871640a171314067a68a2389e3477" . "c"]);
            $_b1871640a171314067a68a2389e3477c = $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_62d701c3c53404f06345eb35720a47" . "b4"]($_b1871640a171314067a68a2389e3477c) ? (int) $_b1871640a171314067a68a2389e3477c : null;
            $delete_user->Delete($context, $user_id, $_b1871640a171314067a68a2389e3477c);
            return new JsonPrettyResponse(null, 204);
        } catch (ValidationException $e) {
            throw new RestExBadRequest($e->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_3d73a8df5b503f421ad8" . "4ec4c4eeafe9"], $e);
        } catch (AccessDeniedException $e) {
            throw $this->GetAuthException($context, $e);
        } catch (NotFoundException $e) {
            throw new RestExNotFound($e->getMessage(), $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_15f5f162efaff2443798e5" . "cfc813b02b"], $e);
        } catch (MappingException $e) {
            throw new RestExError($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_aa0a228263feed9718881955" . "2013bc5a"], 500, $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_3efc5ba7bf51ca70907f5e65ab" . "602ec1"], $e);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function PutPhoto(RequestData $request_data, SecurityContext $context, int $user_id, ProfilePhotoValidator $photo_validator, SetUserPhoto $user_photo)
    {
        try {
            $_64cc3f0af0aeb2b004e7318ec5357113 = $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_e3a4c46d" . "182fe6e78" . "0904aa33e" . "7ea6a1"]();
            $filename = $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_fb2afe3aa58eabd86bcae0f70e5" . "ec644"]($_64cc3f0af0aeb2b004e7318ec5357113, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_105dce3af144472e061" . "0b7a16a85b256"]);
            $photo_validator->ValidateUpload($request_data, $filename);
            $user_photo->setPhoto($context, $user_id, $filename, (int) $request_data->Get($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_f9696953" . "938d5eb0c" . "93b1562b6" . "0ba3a6"]), (int) $request_data->Get($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_11cad0367c939" . "d76c4f877581c1" . "51a10"]), (int) $request_data->Get($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_795cf2d94dc58d02d01" . "c23e25295b2ad"]));
            return new JsonPrettyResponse(null, 204);
        } catch (RequestDataException $e) {
            throw new RestExBadRequest(($this->lmsg)(self::E_BAD_REQUEST_DATA), $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_c894747360c6ec" . "5bd8169530eaf9c" . "473"], $e);
        } catch (AccessDeniedException $e) {
            throw $this->GetAuthException($context, $e);
        } catch (NotFoundException $e) {
            throw new RestExNotFound(($this->lmsg)(self::E_USER_NOT_FOUND, $user_id), $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_a4a1018258adabb74e7b04836" . "d8d7e3b"], $e);
        }
    }
    
    
    
    
    
    
    
    
    
    
    public function DeletePhoto(int $user_id, SecurityContext $context, DeleteUserPhoto $delete_photo)
    {
        try {
            $delete_photo->DeletePhoto($context, $user_id);
        } catch (AccessDeniedException $e) {
            throw $this->GetAuthException($context, $e);
        } catch (NotFoundException $e) {
            throw new RestExNotFound($e->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_15f5f162efaf" . "f2443798e5cfc" . "813b02b"], $e);
        }
        return new JsonPrettyResponse(null, 204);
    }
    
    
    
    
    
    
    
    
    
    
    
    public function PutManager(ServerRequestInterface $request, SecurityContext $context, int $user_id, SetManager $set_manager)
    {
        $_ed5f03d686c37933b5943f295c6b4a43 = $this->formatter->GetJson($request);
        $_b324f64f5346fe6cd20483e208d94430 = $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_b324f64f5346fe6cd20483e208d9443" . "0"]] ?? null;
        if (!$_b324f64f5346fe6cd20483e208d94430) {
            throw new RestExBadRequest($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_eb2e75e" . "8d8d7406" . "e7766196" . "6ab9b2d7" . "a"]);
        }
        try {
            $_24e0e36600d6af77406a44bb618a6253 = $set_manager->SetManager($context, $user_id, $_b324f64f5346fe6cd20483e208d94430);
            return new JsonPrettyResponse($this->formatter->FormatUser($_24e0e36600d6af77406a44bb618a6253));
        } catch (ValidationException $e) {
            throw new RestExBadRequest($e->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_3d73a8df5b503f421ad84ec4c4eeafe" . "9"], $e);
        } catch (AccessDeniedException $e) {
            throw $this->GetAuthException($context, $e);
        }
    }
    
    
    
    
    
    
    
    
    
    public function GetSubordinates(int $user_id, SecurityContext $context, ServerRequestInterface $request, GetUsers $get_users)
    {
        try {
            $_03e9164d0a343b742df4793268b80767 = new UserFilter($context);
            $_03e9164d0a343b742df4793268b80767->Fill($this->formatter->GetRequestParams($request, $_03e9164d0a343b742df4793268b80767->GetDefaults()));
            $_03e9164d0a343b742df4793268b80767->SetManagerId($user_id);
            
            
            [$_e4543e131c67c631b14751cc849d1310, $total] = $get_users->GetUsers($_03e9164d0a343b742df4793268b80767);
            return new JsonPrettyResponse($this->formatter->Paginate($request, $this->formatter->FormatUsers($_e4543e131c67c631b14751cc849d1310, $_03e9164d0a343b742df4793268b80767), $_03e9164d0a343b742df4793268b80767->GetChanged(), $total));
        } catch (InvalidArgumentException|UnexpectedValueException $exception) {
            throw new RestExBadRequest($exception->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_c894747360c6ec" . "5bd8169530eaf9c" . "473"], $exception);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function PutSubordinates(SecurityContext $context, ServerRequestInterface $request, SetSubordinates $set_subordinates, GetUsers $get_users, int $user_id)
    {
        try {
            $_02ea59b60fd989f4aa27981354472f33 = $this->formatter->PluckRequestIds($request);
            $set_subordinates->SetSubordinates($context, $user_id, $_02ea59b60fd989f4aa27981354472f33);
            $_03e9164d0a343b742df4793268b80767 = new UserFilter($context);
            $_03e9164d0a343b742df4793268b80767->SetManagerId($user_id);
            
            
            [$_e4543e131c67c631b14751cc849d1310] = $get_users->GetUsers($_03e9164d0a343b742df4793268b80767);
            return new JsonPrettyResponse($this->formatter->FormatUsers($_e4543e131c67c631b14751cc849d1310, $_03e9164d0a343b742df4793268b80767));
        } catch (NotFoundException $e) {
            throw new RestExNotFound($e->getMessage(), $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_a4a1018258adabb74e7b04836d8d7" . "e3b"], $e);
        } catch (ValidationException $e) {
            throw new RestExBadRequest($e->getMessage(), $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_c89474736" . "0c6ec5bd81" . "69530eaf9c" . "473"], $e);
        } catch (AccessDeniedException $e) {
            throw $this->GetAuthException($context, $e);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function PutPassword(SetUserPassword $set_user_password, SecurityContext $context, ServerRequestInterface $request, int $user_id)
    {
        $_24e0e36600d6af77406a44bb618a6253 = new \User($user_id);
        if (!$_24e0e36600d6af77406a44bb618a6253->Load()) {
            throw new RestExNotFound(($this->lmsg)(self::E_USER_NOT_FOUND, $user_id));
        }
        $_ed5f03d686c37933b5943f295c6b4a43 = $this->formatter->GetJson($request);
        if (!isset($_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_e0637eee905ebe3938c5da50e" . "3db10d7"]])) {
            throw new RestExBadRequest(($this->lmsg)(self::E_NO_PASSWORD));
        }
        try {
            $set_user_password->SetPassword($_24e0e36600d6af77406a44bb618a6253, $_ed5f03d686c37933b5943f295c6b4a43[$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_e0637eee905ebe3938c5" . "da50e3db10d7"]], null, null, $context);
        } catch (PermissionException $e) {
            throw $this->GetAuthException($context, $e);
        } catch (PasswordChangeException $e) {
            $message = ($this->lmsg)($e->getLocalizationKey(), ...$e->getLocalizationArguments());
            throw new RestExBadRequest($message, $e->getCode(), $e);
        }
        if (!$_24e0e36600d6af77406a44bb618a6253->Save()) {
            throw new RestExError($_24e0e36600d6af77406a44bb618a6253->GetErrMsg());
        }
        return new JsonPrettyResponse(null, 204);
    }
    
    
    
    
    
    
    
    
    
    
    public function GetCurrentUser(SecurityContext $context, GetCurrentUser $current_user, ServerRequestInterface $request)
    {
        try {
            $_03e9164d0a343b742df4793268b80767 = new UserFilter($context);
            $_03e9164d0a343b742df4793268b80767->Fill($this->formatter->GetRequestParams($request, $_03e9164d0a343b742df4793268b80767->GetDefaults()));
            $_24e0e36600d6af77406a44bb618a6253 = $current_user->Get($context, $_03e9164d0a343b742df4793268b80767);
            return new JsonPrettyResponse($this->formatter->FormatUser($_24e0e36600d6af77406a44bb618a6253, $_03e9164d0a343b742df4793268b80767));
        } catch (NotFoundException $e) {
            throw new RestExNotFound($e->getMessage(), $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_15f5f162efaff2443798e5cfc81" . "3b02b"], $e);
        } catch (AccessDeniedException $e) {
            throw $this->GetAuthException($context, $e);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    public function PutCurrentUser(ServerRequestInterface $request, UpdateCurrentUser $update_user, SecurityContext $context)
    {
        try {
            $data = $this->formatter->GetJson($request);
            if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_7f628626dd1d55c71b1fc0" . "932ffd1d2c"]($data)) {
                $data = [];
            }
            $_24e0e36600d6af77406a44bb618a6253 = $update_user->Update($context, $data);
            return new JsonPrettyResponse($this->formatter->FormatUser($_24e0e36600d6af77406a44bb618a6253));
        } catch (ValidationException $e) {
            $e = new RestExBadRequest($e->getMessage(), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_3d73a8df5b503f421ad84" . "ec4c4eeafe9"], $e);
            throw $e;
        } catch (AccessDeniedException $e) {
            throw $this->GetAuthException($context, $e);
        } catch (NotFoundException $e) {
            throw new RestExNotFound($e->getMessage(), $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_15f5f16" . "2efaff24" . "43798e5c" . "fc813b02" . "b"], $e);
        }
    }
}