diff --git a/app/AppKernel.php b/app/AppKernel.php index 83402350a6..fbf6799233 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -52,6 +52,7 @@ class AppKernel extends Kernel new Sonata\DatagridBundle\SonataDatagridBundle(), new Sonata\MediaBundle\SonataMediaBundle(), new Sonata\PageBundle\SonataPageBundle(), + new Theodo\Evolution\Bundle\SessionBundle\TheodoEvolutionSessionBundle(), new Spy\TimelineBundle\SpyTimelineBundle(), new Sonata\TimelineBundle\SonataTimelineBundle(), diff --git a/app/config/config.yml b/app/config/config.yml index f770931d3f..da73f1e5f8 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -67,10 +67,18 @@ framework: trusted_proxies: ~ session: # handler_id set to null will use default session handler from php.ini - handler_id: ~ + handler_id: ~ + name: ch_sid + fragments: ~ http_method_override: true + +theodo_evolution_session: + bag_manager: + class: Theodo\Evolution\Bundle\SessionBundle\Manager\Symfony1\BagManager + configuration_class: Theodo\Evolution\Bundle\SessionBundle\Manager\Symfony1\BagConfiguration + # Twig Configuration twig: debug: "%kernel.debug%" diff --git a/app/config/routing.yml b/app/config/routing.yml index c4bf462d35..4355a4aef3 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -1,6 +1,10 @@ home: path: / + +userportal: + path: ../../user_portal.php + #index: # path: / diff --git a/composer.json b/composer.json index bfa5a05c27..20eec6fdfc 100755 --- a/composer.json +++ b/composer.json @@ -141,7 +141,8 @@ "jeroendesloovere/vcard": "^1.2", "a2lix/translation-form-bundle": "~2.0", "knplabs/doctrine-behaviors": "~1.1", - "lunetics/locale-bundle": "^2.4" + "lunetics/locale-bundle": "^2.4", + "theodo-evolution/session-bundle": "1.0.*" }, "require-dev": { "behat/behat": "@stable", diff --git a/main/admin/index.php b/main/admin/index.php index 86984aa6c7..45be92dabb 100644 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -540,5 +540,3 @@ $content = $tpl->fetch($admin_template); $tpl->assign('content', $content); $tpl->assign('message', $message); $tpl->display_one_col_template(); - -// Note: version checking mechanism has now been moved to main/inc/ajax/admin.ajax.php diff --git a/main/inc/lib/chamilo_session.class.php b/main/inc/lib/chamilo_session.class.php index 8eb1fd3853..dc973d5fdd 100755 --- a/main/inc/lib/chamilo_session.class.php +++ b/main/inc/lib/chamilo_session.class.php @@ -1,5 +1,8 @@ container = $container; + $this->tokenStorage = $tokenStorage; + } + + /** + * @param GetResponseEvent $event + */ + public function onKernelRequest(GetResponseEvent $event) + { + $request = $event->getRequest(); + + if (!$request->hasPreviousSession()) { + + return; + } + $token = $this->tokenStorage->getToken(); + if ($token) { + $isGranted = $this->container->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY'); + if (!$isGranted) { + if (isset($_SESSION) && isset($_SESSION['_user'])) { + if ($_SESSION['_user']['active'] == 1) { + + $userManager = $this->container->get('fos_user.user_manager'); + $username = $_SESSION['_user']['username']; + /** @var User $user */ + $user = $userManager->findUserByUsername($username); + if ($user) { + + $token = new UsernamePasswordToken($user, null, "main", $user->getRoles()); + + $this->tokenStorage->setToken($token); //now the user is logged in + + //now dispatch the login event + $event = new InteractiveLoginEvent($request, $token); + $this->container->get("event_dispatcher")->dispatch("security.interactive_login", $event); + } + } + } + } + } + } + + /** + * @return array + */ + public static function getSubscribedEvents() + { + return array( + // must be registered before the default Locale listener + KernelEvents::REQUEST => array(array('onKernelRequest', 17)), + ); + } +} diff --git a/src/Chamilo/CoreBundle/Menu/NavBuilder.php b/src/Chamilo/CoreBundle/Menu/NavBuilder.php index b3f3010af8..27de25fffa 100644 --- a/src/Chamilo/CoreBundle/Menu/NavBuilder.php +++ b/src/Chamilo/CoreBundle/Menu/NavBuilder.php @@ -65,11 +65,11 @@ class NavBuilder extends ContainerAware if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) { - /*$menu->addChild( + $menu->addChild( $translator->trans('MyCourses'), array('route' => 'userportal') ); - + /* $menu->addChild( $translator->trans('Calendar'), array( diff --git a/src/Chamilo/CoreBundle/Resources/config/services.yml b/src/Chamilo/CoreBundle/Resources/config/services.yml index 0e0e970c89..234b87857d 100644 --- a/src/Chamilo/CoreBundle/Resources/config/services.yml +++ b/src/Chamilo/CoreBundle/Resources/config/services.yml @@ -132,12 +132,12 @@ services: # - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse } # - { name: kernel.event_listener, event: kernel.controller, method: onKernelController } - # Setting locale -# chamilo_core.listener.locale: -# class: Chamilo\CoreBundle\EventListener\LocaleListener -# arguments: ["%kernel.default_locale%", "@service_container"] -# tags: -# - { name: kernel.event_subscriber } + #Setting locale + chamilo_core.listener.legacy_login_listener: + class: Chamilo\CoreBundle\EventListener\LegacyLoginListener + arguments: ["@service_container", '@security.token_storage'] + tags: + - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } # Setting user and platform locale # chamilo_core.listener.user_locale_listener: diff --git a/src/Chamilo/FaqBundle/Resources/views/Faq/index.html.twig b/src/Chamilo/FaqBundle/Resources/views/Faq/index.html.twig index 57825b3ace..bfaa7e2144 100644 --- a/src/Chamilo/FaqBundle/Resources/views/Faq/index.html.twig +++ b/src/Chamilo/FaqBundle/Resources/views/Faq/index.html.twig @@ -12,7 +12,9 @@ {% else %}
{{ question.headline|e }}
{{ question.body }}
{% endfor %} diff --git a/src/Chamilo/UserBundle/Resources/views/Security/base_login.html.twig b/src/Chamilo/UserBundle/Resources/views/Security/base_login.html.twig index c0342c1a65..9545c5d589 100644 --- a/src/Chamilo/UserBundle/Resources/views/Security/base_login.html.twig +++ b/src/Chamilo/UserBundle/Resources/views/Security/base_login.html.twig @@ -27,7 +27,8 @@