@EXT\Route(
"/platform/list",
name="apiv2_log_connect_platform_list"
)
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})

@param User    $user
@param Request $request

@return JsonResponse
329391
public function logConnectPlatformListAction(User $user, Request $request)
    {
        $this->checkAdminToolAccess();
        $isAdmin = $this->authorization->isGranted('ROLE_ADMIN');
        $hiddenFilters = $isAdmin ?
            [] :
            ['hiddenFilters' => [
                'organizations' => array_map(function (Organization $organization) {
                    return $organization->getUuid();
                }, $user->getAdministratedOrganizations()->toArray()),
            ]];

        return new JsonResponse(
            $this->finder->search(LogConnectPlatform::class, array_merge(
                $request->query->all(),
                $hiddenFilters
            ))
        );
    }
130291
public function postAuthProcess(Request $request, User $user)
    {
        $date = new \DateTime('+' . (int) $this->getConf()->get(['registry', 'actions', 'validation-reminder-days']) . ' days');
        $manager = $this->getEntityManager();

        foreach ($this->getValidationParticipantRepository()->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) {
            $validationSession = $participant->getSession();
            $basket = $validationSession->getBasket();

            if (null === $token = $this->getTokenRepository()->findValidationToken($basket, $participant->getUser())) {
                continue;
            }

            $url = $this->app->url('lightbox_validation', ['basket' => $basket->getId(), 'LOG' => $token->getValue()]);
            $this->dispatch(PhraseaEvents::VALIDATION_REMINDER, new ValidationEvent($participant, $basket, $url));

            $participant->setReminded(new \DateTime('now'));
            $manager->persist($participant);
        }

        $manager->flush();

        $session = $this->getAuthenticator()->openAccount($user);

        if ($user->getLocale() != $this->app['locale']) {
            $user->setLocale($this->app['locale']);
        }

        $width = $height = null;
        if ($request->cookies->has('screen')) {
            $data = array_filter((explode('x', $request->cookies->get('screen', ''))));
            if (count($data) === 2) {
                $width = $data[0];
                $height = $data[1];
            }
        }
        $session->setIpAddress($request->getClientIp())
            ->setScreenHeight($height)
            ->setScreenWidth($width);

        $manager->persist($session);
        $manager->flush();

        return $session;
    }
239442
public function getListAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        Auth::checkComponentAccess($this, 'list', $tree, $user);
      
        $listController = new PlaceHierarchyController(app(Statistics::class));
        return $listController->show($request, $tree, app(SearchService::class));
    }
416766
public function getListAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        Auth::checkComponentAccess($this, 'list', $tree, $user);
      
        $listController = new ListController(app(IndividualListService::class), app(LocalizationService::class));
        return $listController->individualList($request, $tree, $user, $this);
    }
603902
public function getPageAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        Auth::checkComponentAccess($this, 'list', $tree, $user);
      
        $listController = new BranchesController(app(ModuleService::class));
        return $listController->page($request);
    }
954263
public function createJsonAuthResponse(BaseUser $user)
    {
        $responseModel = $this->createResponseAuthModel($user);

        $response = new JsonResponse($responseModel->getBody(), Response::HTTP_CREATED);

        return $this->setCookieForResponse($response, $responseModel);
    }
1338005
public function familyList(ServerRequestInterface $request, Tree $tree, UserInterface $user, ?ModuleListInterface $moduleListInterface): ResponseInterface
    {
        return $this->individualOrFamilyList($request, $tree, $user, true, $moduleListInterface);
    }
471940
public function listPoliciesForUser(Request $request)
    {
        return new Values\PolicyList(
            $this->roleService->loadPoliciesByUserId(
                $request->query->get('userId')
            ),
            $request->getPathInfo()
        );
    }
675559
public function getOAuthCallbackAction(Request $request)
    {
        $this->initSessionBag();

        if ($request->query->get("state") != $this->sessionBag->get("hash")) {
            throw new UserException("Invalid session verification hash");
        }

        $guzzle = new GuzzleClient();
        try {
            $response = $guzzle->post($this->getTokenUrl(), array("body" => array(
                "client_id" => $this->getClientId(),
                "client_secret" => $this->getClientSecret(),
                "grant_type" => $this->grantType,
                "redirect_uri" => $this->getCallbackUrl($request),
                "code" => $request->query->get("code")
            )));
        } catch (ClientException $e) {
            $errCode = $e->getResponse()->getStatusCode();
            if ($errCode == 400) {
                $desc = jsonDecode($e->getResponse()->getBody(true), true);
                $code = empty($desc["code"]) ? 0 : $desc["code"];
                $message = empty($desc["error_message"]) ? "Unknown error from API." : $desc["error_message"];

                throw new UserException(
                    "OAuth authentication failed[{$code}]: {$message}",
                    null,
                    [
                        'response' => $e->getResponse()->getBody()
                    ]
                );
            } else {
                throw $e;
            }
        }

        $responseData = jsonDecode($response->getBody(true));

        $this->storeOAuthData($responseData);
        return $this->returnResult($responseData);
    }
86585
public function get(UserInterface $user, $platform)
    {
        $request = $this->initHttpRequest(
            $this->account->getApiToken(Token::API_SSO),
            $this->account->getName()
        );
        $request->setPath(ApiRequest::PATH_SSO_AUTH);
        $request->setContentType(self::CONTENT_TYPE_APPLICATION_JSON);
        $request->setReplaceParams(array('{platform}' => $platform));
        $response = $request->post($user);
        if ($response->getCode() !== 200) {
            throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response);
        }

        return $response->getJsonResult()->login_url;
    }
68792
public function noteAction(Request $request, $resourceId, User $user)
    {
        $text = $request->get('social_media_note_text');
        $jsonResponse = new JsonResponse(true);
        if ($text !== null) {
            $note = new NoteAction();
            $note->setUser($user);
            $note->setText($text);
            $this->getNoteActionManager()->createNote($resourceId, $note);
            $jsonResponse = new JsonResponse(true);
        } else {
            $jsonResponse->setStatusCode(Response::HTTP_BAD_REQUEST);
        }

        return $jsonResponse;
    }
610844
public function save(Request $request, UserInterface $user)
    {
        $eid = $request->get('eid');
        $language = $request->get('language');
        $tid = $request->get('tid');
        $teaserId = $request->get('teaser_id');
        $isPublish = $request->get('isPublish');
        $values = $request->get('values');
        $publishComment = $request->get('publishComment');

        if ($values) {
            $values = json_decode($values, true);
        }

        $element = $this->elementService->findElement($eid);
        $elementtype = $this->elementService->findElementtype($element);
        $elementtypeStructure = $elementtype->getStructure();

        $oldElementVersion = $this->elementService->findLatestElementVersion($element);
        $oldElementStructure = $this->elementService->findElementStructure($oldElementVersion, 'de');
        $oldVersion = $oldElementVersion->getVersion();
        $isMaster = $element->getMasterLanguage() === $language;

        $tree = $this->treeManager->getByNodeId($tid);
        $node = $tree->get($tid);

        $teaser = null;
        if ($teaserId) {
            $teaser = $this->teaserManager->find($teaserId);
        }

        $comment = null;
        if ($request->get('comment')) {
            $comment = $request->get('comment');
        }

        if ($language === $element->getMasterLanguage()) {
            $elementStructure = new ElementStructure();
            if ($oldElementStructure->getDataId()) {
                $elementStructure
                    ->setDataId($oldElementStructure->getDataId())
                    ->setDsId($oldElementStructure->getDsId())
                    ->setType('root')
                    ->setName($oldElementStructure->getName());
            } else {
                $elementStructure
                    ->setDataId(UuidUtil::generate())
                    ->setDsId($elementtypeStructure->getRootDsId())
                    ->setType('root')
                    ->setName($elementtypeStructure->getRootNode()->getName());
            }
            $map = $this->applyStructure($elementStructure, $elementtypeStructure, $values, $language, $oldElementStructure);
            $this->applyOldValues($elementStructure, $oldElementStructure, $elementtypeStructure, $language);
            $this->applyValues($elementStructure, $elementtypeStructure, $values, $language, $map, null);
        } else {
            $elementStructure = clone $oldElementStructure;
            $this->applyValues($elementStructure, $elementtypeStructure, $values, $language, null, $element->getMasterLanguage());
        }

        $elementStructure->setId(null);

        $rii = new \RecursiveIteratorIterator($elementStructure->getIterator(), \RecursiveIteratorIterator::SELF_FIRST);
        foreach ($rii as $structure) {
            /* @var $structure ElementStructure */
            $structure->setId(null);
        }

        $elementVersion = $this->elementService->createElementVersion($element, $elementStructure, $language, $user->getId(), $comment);

        if ($teaser) {
            $this->saveTeaserData($teaser, $language, $request);
        } else {
            $this->saveNodeData($node, $language, $request);
        }

        // TODO: available languages
        $this->saveMeta($elementVersion, $language, $isMaster, ['de'], $request);

        $event = new SaveElementEvent($element, $language, $oldVersion);
        $this->eventDispatcher->dispatch(ElementEvents::SAVE_ELEMENT, $event);

        $publishSlaves = [];
        if ($isPublish) {
            $publishSlaves = $this->checkPublishSlaves($elementVersion, $node, $teaser, $language);
            if ($teaser) {
                $this->publishTeaser($elementVersion, $teaser, $language, $user->getId(), $publishComment, $publishSlaves);
            } else {
                $this->publishTreeNode($elementVersion, $node, $language, $user->getId(), $publishComment, $publishSlaves);
            }
        }

        $status = '';
        if ($teaser) {
            if ($this->teaserManager->isPublished($teaser, $language)) {
                $status = $this->teaserManager->isAsync($teaser, $language) ? 'async' : 'online';
            }
        } else {
            if ($tree->isPublished($node, $language)) {
                $status = $tree->isAsync($node, $language) ? 'async' : 'online';
            }
        }

        return [$elementVersion, $node, $teaser, $publishSlaves, $status];
    }
105240
public function shareAction(Request $request, User $user = null)
    {
        $share = new ShareAction();
        $share->setUser($user);
        $network = $request->get('network');
        $options = $this->getShareActionManager()->createShare($request, $share);
        $this->dispatchShareEvent($share);

        $response = array();
        if ($network !== null) {
            $socialShare = new SocialShare();
            $shareLink = $socialShare->getNetwork($network)->getShareLink($options['url'], array($options['title']));
            $response = new RedirectResponse($shareLink);
        }

        return $response;
    }
528126
public function messageAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        $body    = $request->get('body', '');
        $subject = $request->get('subject', '');
        $to      = $request->get('to', '');
        $url     = $request->get('url', '');

        $to_user = $this->user_service->findByUserName($to);
        $ip      = $request->getClientIp() ?? '127.0.0.1';

        if ($to_user === null || $to_user->getPreference('contactmethod') === 'none') {
            throw new AccessDeniedHttpException('Invalid contact user id');
        }

        if ($body === '' || $subject === '') {
            return redirect(route('message', [
                'body'    => $body,
                'subject' => $subject,
                'to'      => $to,
                'tree'    => $tree,
                'url'     => $url,
            ]));
        }

        if ($this->deliverMessage($tree, $user, $to_user, $subject, $body, $url, $ip)) {
            FlashMessages::addMessage(I18N::translate('The message was successfully sent to %s.', e($to_user->realName())), 'success');

            $url = $url ?: route('tree-page', ['ged' => $tree->name()]);

            return redirect($url);
        }

        FlashMessages::addMessage(I18N::translate('The message was not sent.'), 'danger');

        $redirect_url = route('contact', [
            'body'    => $body,
            'subject' => $subject,
            'to'      => $to,
            'url'     => $url,
        ]);

        return redirect($redirect_url);
    }
832492
public function getAction(Request $request, User $loggedUser, $type, $action)
    {
        $this->checkPortfolioToolAccess();

        $data = [];

        if ('form' === $action) {
            $data['form'] = $this->getWidgetsManager()->getFormView($type);
        } else {
            $widget = $this->getWidgetsManager()->getNewDataWidget($type, $loggedUser);
            $data = $this->getWidgetsManager()->getWidgetData($widget);
        }

        $response = new JsonResponse();
        $response->setData($data);

        return $response;
    }
691124
public function getChartAction(ServerRequestInterface $request, Tree $tree, UserInterface $user): ResponseInterface
    {
        $xref = $request->get('xref', '');

        $individual = Individual::getInstance($xref, $tree);

        Auth::checkIndividualAccess($individual);
        Auth::checkComponentAccess($this, 'chart', $tree, $user);

        $tv = new TreeView('tv');

        [$html, $js] = $tv->drawViewport($individual, 4);

        return $this->viewResponse('interactive-tree-page', [
            'html'       => $html,
            'individual' => $individual,
            'js'         => $js,
            'title'      => $this->chartTitle($individual),
            'tree'       => $tree,
        ]);
    }
585335
public function resendAction(Request $request, User $user = null)
    {
        $currentUser = $this->getUser();

        if (null === $user) {
            $user = $currentUser;
            if (!is_object($user) || !$user instanceof UserInterface) {
                throw new AccessDeniedException(
                    'This user does not have access to this section.'
                );
            }
        } else if (!$this->isGranted('ROLE_SUPER_ADMIN')) {
            throw new AccessDeniedException(
                'You cannot resend the confirmation for another user.'
            );
        }

        $isCurrentUser = $user->getId() === $currentUser->getId();

        // get the referer, if none redirect to the login
        // which should go to the default page after login
        $redirect = $request->headers->get(
            'referer',
            $this->generateUrl('fos_user_security_login')
        );

        if ($user->isEnabled()) {
            if ($isCurrentUser) {
                $this->addFlash('warning', 'Your account is already enabled.');
            } else {
                $this->addFlash('warning', 'The user is already enabled.');
            }

            return $this->redirect($redirect);
        }

        if (null === $user->getConfirmationToken()) {
            $user->setConfirmationToken(
                $this->get('fos_user.util.token_generator')
                    ->generateToken()
            );
            $this->get('fos_user.user_manager')->updateUser($user);
        }

        $this->get('fos_user.mailer')->sendConfirmationEmailMessage($user);

        if ($isCurrentUser) {
            $this->addFlash(
                'success',
                'Your account activation email has been resent.'
            );
        } else {
            $this->addFlash(
                'success',
                'The account activation email has been resent.'
            );
        }

        return $this->redirect($redirect);
    }