Register suggested values

@param  Request $request The current request
@param  integer $bas_id  The collection base_id
@return Response
481549
public function submitSuggestedValues(Request $request, $bas_id)
    {
        $success = false;

        $collection = \collection::getByBaseId($this->app, $bas_id);
        $prefs = $request->request->get('str');

        try {
            if ('' !== trim($prefs)) {
                $domdoc = new \DOMDocument();
                if (true === @$domdoc->loadXML($prefs)) {
                    $collection->set_prefs($domdoc);
                    $success = true;
                }
            }
        } catch (\Exception $e) {

        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $success ? $this->app->trans('Successful update') : $this->app->trans('An error occured'),
                'bas_id'  => $collection->get_base_id(),
            ]);
        }

        return $this->app->redirectPath('admin_collection_display_suggested_values', [
            'bas_id'      => $collection->get_sbas_id(),
            'success'     => (int) $success,
        ]);
    }
102705
public function registerFromSocialLogin(LoginRequest $request)
    {
        $email = $request->getEmails()[0];
        $user  = $this->userService->registerWithoutPassword(array(
            'email' => $email
        ));

        $socialLoginEntity = new SocialLoginEntity;
        $socialLoginEntity->setUserId($user->getId())
            ->setProvider($request->getProvider())
            ->setProviderUserId($request->getProviderUserId())
            ->setAccessToken($request->getAccessToken())
            ->setAccessTokenExpires($request->getAccessTokenExpires())
            ->setRefreshToken($request->getRefreshToken());

        $entity = $this->socialLoginMapper->persist($socialLoginEntity);
        return array(
            'user'         => $user,
            'social_login' => $entity
        );
    }
1258040
public function registerAction(Request $request)
    {
        /** @var UserManager $userManager */
        $userManager = $this->get('sik_industries.user_manager');
        $user = $userManager->createUser();
        $form = $this->createForm(new UserRegistrationForm(), $user);
        $form->submit($request);

        if ($form->isValid()) {
            /** @var EQM $eqm */
            $userManager->insert($user);

            $response = $this->redirect($this->generateUrl('dashboard'));
        } else {
            $response = ['form' => $form->createView()];
        }

        return $response;
    }
1218410
public function putAction(Request $request, $id)
    {
        try {
            $this->checkArguments($request);
            $locale = $this->getRequestParameter($request, 'locale', true);
            $user = $this->getUserManager()->save($request->request->all(), $locale, $id);
            $view = $this->view($user, 200);
        } catch (EntityNotFoundException $exc) {
            $view = $this->view($exc->toArray(), 404);
        } catch (UsernameNotUniqueException $exc) {
            $view = $this->view($exc->toArray(), 409);
        } catch (EmailNotUniqueException $exc) {
            $view = $this->view($exc->toArray(), 409);
        } catch (RestException $exc) {
            $view = $this->view($exc->toArray(), 400);
        }

        $this->addSerializationGroups($view);

        return $this->handleView($view);
    }
364069
public function register(Request $request)
    {
        $user = new User();
        $form = $this
            ->createForm(new UserRegistrationType(), $user)
            ->handleRequest($request)
        ;

        //@TODO: Check if username and email are unique

        if($form->isSubmitted() && $form->isValid()) {
            $helper = new UserHelper($this->container);
            $helper->setPassword($user, $user->getPassword());

            $user->setRegistrationToken(hash("sha1",rand()));
            $user->setRegistrationTime(new \DateTime());

            $groupRepository = $this->getDoctrine()->getRepository('FOMUserBundle:Group');
            foreach($this->container->getParameter('fom_user.self_registration_groups') as $groupTitle) {
                $group = $groupRepository->findOneByTitle($groupTitle);
                if($group) {
                    $user->addGroups($group);
                } else {
                    $msg = sprintf('Self-registration group "%s" not found for user "%s"',
                        $groupTitle,
                        $user->getUsername());
                    $this->get('logger')->err($msg);
                }

            }

            $this->sendEmail($user);

            $em = $this->getDoctrine()->getManager();
            $em->persist($user);
            $em->flush();

            $helper->giveOwnRights($user);

            return $this->redirect($this->generateUrl('fom_user_registration_send'));
        }

        return array(
            'user' => $user,
            'form' => $form->createView(),
            'form_name' => $form->getName());
    }
301697
protected function registerDirectly($request, $callback, $registerUrL, $vo = null, $group = null)
    {
        $params = array();
        if (!is_null($vo)) {
            $params['vo'] = $vo->getShortName();
            if (!is_null($group)) {
                $params['group'] = $group->getName();
            }
        }
        $params[self::TARGET_NEW] = $callback;
        $params[self::TARGET_EXISTING] = $callback;
        $params[self::TARGET_EXTENDED] = $callback;

        $id = State::saveState($request, 'perun:PerunIdentity');

        if (in_array($this->spEntityId, $this->listOfSpsWithoutInfoAboutRedirection)) {
            HTTP::redirectTrustedURL($registerUrL, $params);
        }

        $url = Module::getModuleURL('perun/unauthorized_access_go_to_registration.php');
        HTTP::redirectTrustedURL(
            $url,
            array(
                'StateId' => $id,
                'SPMetadata' => $request['SPMetadata'],
                'registerUrL' => $registerUrL,
                'params' => $params
            )
        );
    }
831044
public function rename(Request $request, $bas_id)
    {
        if (trim($name = $request->request->get('name')) === '') {
            $this->app->abort(400, $this->app->trans('Missing name parameter'));
        }

        $success = false;

        $collection = \collection::getByBaseId($this->app, $bas_id);

        try {
            $collection->set_name($name);
            $success = true;
        } catch (\Exception $e) {

        }

        if ('json' === $this->app['request']->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $success ? $this->app->trans('Successful update') : $this->app->trans('An error occured'),
            ]);
        }

        return $this->app->redirectPath('admin_display_collection', [
            'bas_id'      => $collection->get_base_id(),
            'success'     => (int) $success,
            'reload-tree' => 1,
        ]);
    }
1293957
public function delete(Request $request, $bas_id)
    {
        $success = false;
        $msg = $this->app->trans('An error occured');

        $collection = \collection::getByBaseId($this->app, $bas_id);

        try {
            if ($collection->get_record_amount() > 0) {
                $msg = $this->app->trans('Empty the collection before removing');
            } else {
                $collection->unmount();
                $collection->delete();
                $success = true;
                $msg = $this->app->trans('Successful removal');
            }
        } catch (\Exception $e) {
        }

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success' => $success,
                'msg'     => $msg
            ]);
        }

        if ($collection->get_record_amount() > 0) {
            return $this->app->redirectPath('admin_display_collection', [
                'bas_id'  => $collection->get_sbas_id(),
                'success' => 0,
                'error'   => 'collection-not-empty',
            ]);
        }

        if ($success) {
            return $this->app->redirectPath('admin_display_collection', [
                'bas_id'      => $collection->get_sbas_id(),
                'success'     => 1,
                'reload-tree' => 1,
            ]);
        }

        return $this->app->redirectPath('admin_display_collection', [
            'bas_id'  => $collection->get_sbas_id(),
            'success' => 0,
        ]);
    }
238796
public function addAction(Request $request, $id) 
    {
        $em = $this->getDoctrine()->getManager();
        $actor = $em->getRepository($this->get('core_manager')->getActorBundleName().':Actor')->findOneById($id);
        
        $trans = $this->get('translator');
        $form = $this->container->get('form.factory')->create('CoreBundle\Form\ActorRoleType');
        $form->handleRequest($request);
           
        if ($form->isSubmitted()) {
            $em = $this->getDoctrine()->getManager();
            $data = $request->request->get($form->getName());
            $role = $em->getRepository('CoreBundle:Role')->find($data['roles']);
            $actor->addRole($role);
            try {
                $em->persist($actor);
                $em->flush($actor);
                return new JsonResponse(array('status' => 'success', 'id'=> $actor->getId(), 'message'=> $trans->trans('role.created')));
            } catch (\Exception $exc) {
                return new JsonResponse(array('status' => 'error', 'message'=> $trans->trans('role.duplicate')));
            }
        }
        return new JsonResponse(array('status' => 'error', 'message'=> $trans->trans('role.form.notsubmit')));
    }
499543
public function register(Request $request): Response
    {
        $contentTypeIdentifier = $this->getConfigResolver()->getParameter('user.content_type_identifier', 'ngsite');
        $contentType = $this->getRepository()->getContentTypeService()->loadContentTypeByIdentifier($contentTypeIdentifier);
        $languages = $this->getConfigResolver()->getParameter('languages');
        $userCreateStruct = $this->userService->newUserCreateStruct(
            null,
            null,
            null,
            $languages[0],
            $contentType
        );

        $userCreateStruct->enabled = (bool) $this->getConfigResolver()->getParameter('user.auto_enable', 'ngsite');
        $userCreateStruct->alwaysAvailable = (bool) $contentType->defaultAlwaysAvailable;

        $data = new DataWrapper($userCreateStruct, $userCreateStruct->contentType);

        $formBuilder = $this->formFactory->createBuilder(
            CreateUserType::class,
            $data,
            [
                'translation_domain' => 'ngsite_user',
            ]
        );

        $form = $formBuilder->getForm();
        $form->handleRequest($request);

        if (!$form->isValid()) {
            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.register', 'ngsite'),
                [
                    'form' => $form->createView(),
                ]
            );
        }

        $users = $this->userService->loadUsersByEmail($form->getData()->payload->email);

        if (!empty($users)) {
            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.register', 'ngsite'),
                [
                    'form' => $form->createView(),
                    'error' => 'email_in_use',
                ]
            );
        }

        try {
            $this->userService->loadUserByLogin($form->getData()->payload->login);

            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.register', 'ngsite'),
                [
                    'form' => $form->createView(),
                    'error' => 'username_taken',
                ]
            );
        } catch (NotFoundException $e) {
            // do nothing
        }

        $userGroupId = $this->getConfigResolver()->getParameter('user.user_group_content_id', 'ngsite');

        $preUserRegisterEvent = new UserEvents\PreRegisterEvent($data->payload);
        $this->eventDispatcher->dispatch(SiteEvents::USER_PRE_REGISTER, $preUserRegisterEvent);
        $data->payload = $preUserRegisterEvent->getUserCreateStruct();

        /** @var \eZ\Publish\API\Repository\Values\User\User $newUser */
        $newUser = $this->getRepository()->sudo(
            static function (Repository $repository) use ($data, $userGroupId): User {
                $userGroup = $repository->getUserService()->loadUserGroup($userGroupId);

                return $repository->getUserService()->createUser(
                    $data->payload,
                    [$userGroup]
                );
            }
        );

        $userRegisterEvent = new UserEvents\PostRegisterEvent($newUser);
        $this->eventDispatcher->dispatch(SiteEvents::USER_POST_REGISTER, $userRegisterEvent);

        if ($newUser->enabled) {
            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.register_success', 'ngsite')
            );
        }

        if ($this->getConfigResolver()->getParameter('user.require_admin_activation', 'ngsite')) {
            return $this->render(
                $this->getConfigResolver()->getParameter('template.user.activate_admin_activation_pending', 'ngsite')
            );
        }

        return $this->render(
            $this->getConfigResolver()->getParameter('template.user.activate_sent', 'ngsite')
        );
    }
656882
public function register(Request $request)
    {
        // Preventing spamer registration
        if ($request->input('account_intent')) {
            return redirect()->route('home');
        }

        $this->validator->setData($request->all());
        $input = $this->validator->validate('register');
        $user  = dispatch_now(new CreateUser($input));
        event(new Registered($user));

        $this->guard()->login($user);

        dispatch(new SendWelcomeEmail($user));
        session()->put('showWelcomePage', true);

        return redirect(routeMl('account.welcome', $this->getEffectiveLocale()));
    }
1116936
public function putAction(Request $request, $id)
    {
        $language = $this->getLanguage($request);
        $action = $request->get('action');

        $this->checkActionParameterSecurity($action, $language, $id);

        $document = $this->getDocumentManager()->find(
            $id,
            $language,
            [
                'load_ghost_content' => false,
                'load_shadow_content' => false,
            ]
        );

        $formType = $this->getMetadataFactory()->getMetadataForClass(get_class($document))->getFormType();

        $this->get('sulu_hash.request_hash_checker')->checkHash($request, $document, $document->getUuid());

        $this->persistDocument($request, $formType, $document, $language);
        $this->handleActionParameter($action, $document, $language);
        $this->getDocumentManager()->flush();

        $context = new Context();
        $context->setGroups(['defaultPage']);

        return $this->handleView($this->view($document)->setContext($context));
    }
718394
public function register(Request $request)
    {
        $attributes = request()->validate(User::$rules);

        // create new user
        $user = User::create([
            'firstname'          => $attributes['firstname'],
            'lastname'           => $attributes['lastname'],
            'email'              => $attributes['email'],
            'password'           => bcrypt($attributes['password']),
            'confirmation_token' => 'confirmation_token', // will generate a new unique token
        ]);

        // add user roles
        // send email
        // log activity
        event(new UserRegistered($user, input('token')));

        alert()->success('Thank you,',
            'your account has been created, please check your inbox for further instructions.');

        log_activity('Register', $user->fullname . ' registered.');

        return redirect(route('login'));
    }
1199675
public function registerPage(ServerRequestInterface $request): ResponseInterface
    {
        $this->checkRegistrationAllowed();

        $comments = $request->get('comments', '');
        $email    = $request->get('email', '');
        $realname = $request->get('realname', '');
        $username = $request->get('username', '');

        $show_caution = Site::getPreference('SHOW_REGISTER_CAUTION') === '1';

        $title = I18N::translate('Request a new user account');

        return $this->viewResponse('register-page', [
            'comments'     => $comments,
            'email'        => $email,
            'realname'     => $realname,
            'show_caution' => $show_caution,
            'title'        => $title,
            'username'     => $username,
        ]);
    }
210959
public function index(Request $request)
    {
        $this->validate($request, ['category_id' => ['required']]);

        $threads = $this->model()
            ->withRequestScopes($request)
            ->where('category_id', $request->input('category_id'))
            ->get();

        return $this->response($threads);
    }
842243
public function activate(Request $request): JsonResponse
    {
        $this->connection->beginTransaction();

        try {
            $user = $this->activationService->activateUser(
                $request->input('token')
            );

            $token = $user->createToken('Personal Access Token');

            $this->connection->commit();
        } catch (\Throwable $exception) {
            $this->connection->rollback();

            report($exception);

            return $this->response->error($exception->getMessage());
        }

        return $this->response->success('OK', (new HCAuthorizeDTO($user, $token))->toArray());
    }
636856
public function sendOrder(Request $request, $order_id)
    {
        $elementIds = $request->request->get('elements', []);
        $acceptor = $this->getAuthenticatedUser();

        $basketElements = $this->doAcceptElements($order_id, $elementIds, $acceptor);

        $success = !empty($basketElements);

        if ('json' === $request->getRequestFormat()) {
            return $this->app->json([
                'success'  => $success,
                'msg'      => $success
                    ? $this->app->trans('Order has been sent')
                    : $this->app->trans('An error occured while sending, please retry  or contact an admin if problem persists'),
                'order_id' => $order_id,
            ]);
        }

        return $this->app->redirectPath('prod_orders', [
            'success' => (int) $success,
            'action'  => 'send',
        ]);
    }