From 30fd39213b7b7be61be44b7d62947361a142f991 Mon Sep 17 00:00:00 2001 From: Jorge Oscar Gianotti Date: Fri, 20 May 2016 11:27:16 -0300 Subject: [PATCH] =?UTF-8?q?Se=20agreg=C3=B3=20control=20de=20instancia=20a?= =?UTF-8?q?dministrada=20temporal,=20desde=20el=20selector=20de=20instanci?= =?UTF-8?q?a=20secundaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/SuperadminInstanceController.php | 2 ++ src/Celsius3/CoreBundle/Controller/UserController.php | 7 +++++-- .../Resources/views/Layout/_instances_panel.html.twig | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Celsius3/CoreBundle/Controller/SuperadminInstanceController.php b/src/Celsius3/CoreBundle/Controller/SuperadminInstanceController.php index b6abb58c0..cb04debde 100644 --- a/src/Celsius3/CoreBundle/Controller/SuperadminInstanceController.php +++ b/src/Celsius3/CoreBundle/Controller/SuperadminInstanceController.php @@ -287,6 +287,8 @@ public function adminAction($id) $this->get('session')->set('instance_url', $entity->getUrl()); $this->get('session')->set('instance_host', $entity->getHost()); + $this->get('session')->set('admin_instance', $this->get('celsius3_core.instance_helper')->getSessionOrUrlInstance()); + return $this->redirect($this->generateUrl('administration')); } diff --git a/src/Celsius3/CoreBundle/Controller/UserController.php b/src/Celsius3/CoreBundle/Controller/UserController.php index 21b0508fe..18eecff49 100755 --- a/src/Celsius3/CoreBundle/Controller/UserController.php +++ b/src/Celsius3/CoreBundle/Controller/UserController.php @@ -98,9 +98,12 @@ public function changeContextAction($id) $this->get('session')->set('instance_url', $instance->getUrl()); $this->get('session')->set('instance_host', $instance->getHost()); - if ($user->getSecondaryInstances()){ - $user->setRoles($user->getSecondaryInstances()[$id]); + if ($this->get('session')->get('admin_instance')) { + $this->get('session')->remove('admin_instance'); + } + if ($user->getSecondaryInstances()) { + $user->setRoles($user->getSecondaryInstances()[$id]); } $token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken( diff --git a/src/Celsius3/CoreBundle/Resources/views/Layout/_instances_panel.html.twig b/src/Celsius3/CoreBundle/Resources/views/Layout/_instances_panel.html.twig index 223539eb6..b4efaf2d7 100644 --- a/src/Celsius3/CoreBundle/Resources/views/Layout/_instances_panel.html.twig +++ b/src/Celsius3/CoreBundle/Resources/views/Layout/_instances_panel.html.twig @@ -1,3 +1,11 @@ +{% if app.session.get('admin_instance') is not empty %} + {{ app.user.addSecondaryInstance(app.session.get('admin_instance'), ['ROLE_ADMIN']) }} + {{ app.session.set('temp_instance', app.session.get('admin_instance')) }} +{% elseif app.session.get('temp_instance') is not empty %} + {{ app.user.removeSecondaryInstance(app.session.get('temp_instance')) }} + {{ app.session.remove('temp_instance') }} +{% endif %} + {% set secondaryInstances = app.user ? app.user.getSecondaryInstances() : null %} {% if secondaryInstances is not empty %}