X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FConfigController.php;h=779be2689897a3344a279f4b667acbc03b0cffbe;hb=4204a06b7726597dc84fe34b39c53f1534a86140;hp=e7fb5ad0fcc985c725d02ad060565535772ace2a;hpb=55da765e11608e852bf197a01c164e442e635f2e;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index e7fb5ad0..779be268 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -5,6 +5,7 @@ namespace Wallabag\CoreBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\TaggingRule; @@ -15,7 +16,6 @@ use Wallabag\CoreBundle\Form\Type\RssType; use Wallabag\CoreBundle\Form\Type\TaggingRuleType; use Wallabag\CoreBundle\Form\Type\UserInformationType; use Wallabag\CoreBundle\Tools\Utils; -use Wallabag\UserBundle\Entity\User; class ConfigController extends Controller { @@ -45,7 +45,7 @@ class ConfigController extends Controller $this->get('session')->getFlashBag()->add( 'notice', - 'Config saved. Some parameters will be considered after disconnection.' + 'flashes.config.notice.config_saved' ); return $this->redirect($this->generateUrl('config')); @@ -56,13 +56,16 @@ class ConfigController extends Controller $pwdForm->handleRequest($request); if ($pwdForm->isValid()) { - $user->setPlainPassword($pwdForm->get('new_password')->getData()); - $userManager->updateUser($user, true); + if ($this->get('craue_config')->get('demo_mode_enabled') && $this->get('craue_config')->get('demo_mode_username') === $user->getUsername()) { + $message = 'flashes.config.notice.password_not_updated_demo'; + } else { + $message = 'flashes.config.notice.password_updated'; - $this->get('session')->getFlashBag()->add( - 'notice', - 'Password updated' - ); + $user->setPlainPassword($pwdForm->get('new_password')->getData()); + $userManager->updateUser($user, true); + } + + $this->get('session')->getFlashBag()->add('notice', $message); return $this->redirect($this->generateUrl('config').'#set4'); } @@ -79,7 +82,7 @@ class ConfigController extends Controller $this->get('session')->getFlashBag()->add( 'notice', - 'Information updated' + 'flashes.config.notice.user_updated' ); return $this->redirect($this->generateUrl('config').'#set3'); @@ -95,7 +98,7 @@ class ConfigController extends Controller $this->get('session')->getFlashBag()->add( 'notice', - 'RSS information updated' + 'flashes.config.notice.rss_updated' ); return $this->redirect($this->generateUrl('config').'#set2'); @@ -113,7 +116,7 @@ class ConfigController extends Controller $this->get('session')->getFlashBag()->add( 'notice', - 'Tagging rules updated' + 'flashes.config.notice.tagging_rules_updated' ); return $this->redirect($this->generateUrl('config').'#set5'); @@ -144,7 +147,7 @@ class ConfigController extends Controller $this->get('session')->getFlashBag()->add( 'notice', - $this->get('translator')->trans('User "%username%" added', array('%username%' => $newUser->getUsername())) + $this->get('translator')->trans('flashes.config.notice.user_added', array('%username%' => $newUser->getUsername())) ); return $this->redirect($this->generateUrl('config').'#set6'); @@ -172,7 +175,7 @@ class ConfigController extends Controller * * @Route("/generate-token", name="generate_token") * - * @return JsonResponse + * @return RedirectResponse|JsonResponse */ public function generateTokenAction(Request $request) { @@ -189,7 +192,7 @@ class ConfigController extends Controller $this->get('session')->getFlashBag()->add( 'notice', - 'RSS token updated' + 'flashes.config.notice.rss_token_updated' ); return $this->redirect($this->generateUrl('config').'#set2'); @@ -202,12 +205,12 @@ class ConfigController extends Controller * * @Route("/tagging-rule/delete/{id}", requirements={"id" = "\d+"}, name="delete_tagging_rule") * - * @return \Symfony\Component\HttpFoundation\RedirectResponse + * @return RedirectResponse */ public function deleteTaggingRuleAction(TaggingRule $rule) { if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { - throw $this->createAccessDeniedException('You can not access this tagging ryle.'); + throw $this->createAccessDeniedException('You can not access this tagging rule.'); } $em = $this->getDoctrine()->getManager(); @@ -216,7 +219,7 @@ class ConfigController extends Controller $this->get('session')->getFlashBag()->add( 'notice', - 'Tagging rule deleted' + 'flashes.config.notice.tagging_rules_deleted' ); return $this->redirect($this->generateUrl('config').'#set5');