+ // handle changing password
+ $pwdForm = $this->createForm(ChangePasswordType::class, null, array('action' => $this->generateUrl('config').'#set4'));
+ $pwdForm->handleRequest($request);
+
+ if ($pwdForm->isValid()) {
+ $user->setPlainPassword($pwdForm->get('new_password')->getData());
+ $userManager->updateUser($user, true);
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Password updated'
+ );
+
+ return $this->redirect($this->generateUrl('config').'#set4');
+ }
+
+ // handle changing user information
+ $userForm = $this->createForm(UserInformationType::class, $user, array(
+ 'validation_groups' => array('Profile'),
+ 'action' => $this->generateUrl('config').'#set3',
+ ));
+ $userForm->handleRequest($request);
+
+ if ($userForm->isValid()) {
+ $userManager->updateUser($user, true);
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Information updated'
+ );
+
+ return $this->redirect($this->generateUrl('config').'#set3');
+ }
+
+ // handle rss information
+ $rssForm = $this->createForm(RssType::class, $config, array('action' => $this->generateUrl('config').'#set2'));
+ $rssForm->handleRequest($request);
+
+ if ($rssForm->isValid()) {
+ $em->persist($config);
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'RSS information updated'
+ );
+
+ return $this->redirect($this->generateUrl('config').'#set2');
+ }
+
+ // handle tagging rule
+ $taggingRule = new TaggingRule();
+ $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, array('action' => $this->generateUrl('config').'#set5'));
+ $newTaggingRule->handleRequest($request);
+
+ if ($newTaggingRule->isValid()) {
+ $taggingRule->setConfig($config);
+ $em->persist($taggingRule);
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ 'Tagging rules updated'
+ );
+
+ return $this->redirect($this->generateUrl('config').'#set5');
+ }
+
+ // handle adding new user
+ $newUser = $userManager->createUser();
+ // enable created user by default
+ $newUser->setEnabled(true);
+ $newUserForm = $this->createForm(NewUserType::class, $newUser, array(
+ 'validation_groups' => array('Profile'),
+ 'action' => $this->generateUrl('config').'#set6',
+ ));
+ $newUserForm->handleRequest($request);
+
+ if ($newUserForm->isValid() && $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) {
+ $userManager->updateUser($newUser, true);
+
+ $config = new Config($newUser);
+ $config->setTheme($this->getParameter('wallabag_core.theme'));
+ $config->setItemsPerPage($this->getParameter('wallabag_core.items_on_page'));
+ $config->setRssLimit($this->getParameter('wallabag_core.rss_limit'));
+ $config->setLanguage($this->getParameter('wallabag_core.language'));
+
+ $em->persist($config);
+
+ $em->flush();
+
+ $this->get('session')->getFlashBag()->add(
+ 'notice',
+ sprintf('User "%s" added', $newUser->getUsername())
+ );
+
+ return $this->redirect($this->generateUrl('config').'#set6');
+ }
+