X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FController%2FConfigController.php;h=68f30f6e65e07dd6cc040136b72e0bb32a303e9a;hb=1093e979ff49f9072c30d1d576c6adf1f8e76bdf;hp=e2484064a3e85c1d7b90c5ffe6a634d996994f8e;hpb=f71e55ac886a26813ca1171c0aca4921aa8f00ad;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index e2484064..68f30f6e 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -39,6 +39,8 @@ class ConfigController extends Controller $em->persist($config); $em->flush(); + $request->getSession()->set('_locale', $config->getLanguage()); + // switch active theme $activeTheme = $this->get('liip_theme.active_theme'); $activeTheme->setName($config->getTheme()); @@ -149,6 +151,7 @@ class ConfigController extends Controller 'token' => $config->getRssToken(), ], 'twofactor_auth' => $this->getParameter('twofactor_auth'), + 'wallabag_url' => $this->get('craue_config')->get('wallabag_url'), 'enabled_users' => $this->getDoctrine() ->getRepository('WallabagUserBundle:User') ->getSumEnabledUsers(), @@ -233,8 +236,6 @@ class ConfigController extends Controller */ public function resetAction($type) { - $em = $this->getDoctrine()->getManager(); - switch ($type) { case 'annotations': $this->getDoctrine() @@ -253,7 +254,7 @@ class ConfigController extends Controller $this->getDoctrine()->getRepository('WallabagAnnotationBundle:Annotation')->removeAllByUserId($this->getUser()->getId()); } - // manually remove tags first to avoid orphan tag + // manually remove tags to avoid orphan tag $this->removeAllTagsByUserId($this->getUser()->getId()); $this->getDoctrine() @@ -270,9 +271,9 @@ class ConfigController extends Controller } /** - * Remove all tags for a given user and cleanup orphan tags + * Remove all tags for a given user and cleanup orphan tags. * - * @param int $userId + * @param int $userId */ private function removeAllTagsByUserId($userId) { @@ -286,6 +287,7 @@ class ConfigController extends Controller ->getRepository('WallabagCoreBundle:Entry') ->removeTags($userId, $tags); + // cleanup orphan tags $em = $this->getDoctrine()->getManager(); foreach ($tags as $tag) { @@ -361,4 +363,25 @@ class ConfigController extends Controller return $this->redirect($this->generateUrl('fos_user_security_login')); } + + /** + * Switch view mode for current user. + * + * @Route("/config/view-mode", name="switch_view_mode") + * + * @param Request $request + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function changeViewModeAction(Request $request) + { + $user = $this->getUser(); + $user->getConfig()->setListMode(!$user->getConfig()->getListMode()); + + $em = $this->getDoctrine()->getManager(); + $em->persist($user); + $em->flush(); + + return $this->redirect($request->headers->get('referer')); + } }