From a869edf5c8ae8c1a3556897e6b8d2cb7f8faf258 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 30 May 2014 16:04:39 +0200 Subject: [PATCH] Removing unused controllers/listeners. --- .../Component/Auth/LoginListener.php | 29 - .../Component/Auth/LoginSuccessHandler.php | 119 ---- .../Component/Auth/LogoutSuccessHandler.php | 47 -- .../CoreBundle/Controller/CrudController.php | 530 ------------------ .../Controller/CrudControllerInterface.php | 37 -- .../Controller/SecurityController.php | 34 -- .../CoreBundle/Listener/LegacyListener.php | 100 ---- .../Listener/LoginSuccessHandler.php | 139 ----- .../Listener/LogoutSuccessHandler.php | 49 -- src/ChamiloLMS/CoreBundle/Menu/Builder.php | 101 ---- 10 files changed, 1185 deletions(-) delete mode 100644 src/ChamiloLMS/CoreBundle/Component/Auth/LoginListener.php delete mode 100644 src/ChamiloLMS/CoreBundle/Component/Auth/LoginSuccessHandler.php delete mode 100644 src/ChamiloLMS/CoreBundle/Component/Auth/LogoutSuccessHandler.php delete mode 100644 src/ChamiloLMS/CoreBundle/Controller/CrudController.php delete mode 100644 src/ChamiloLMS/CoreBundle/Controller/CrudControllerInterface.php delete mode 100644 src/ChamiloLMS/CoreBundle/Controller/SecurityController.php delete mode 100644 src/ChamiloLMS/CoreBundle/Listener/LegacyListener.php delete mode 100644 src/ChamiloLMS/CoreBundle/Listener/LoginSuccessHandler.php delete mode 100644 src/ChamiloLMS/CoreBundle/Listener/LogoutSuccessHandler.php delete mode 100644 src/ChamiloLMS/CoreBundle/Menu/Builder.php diff --git a/src/ChamiloLMS/CoreBundle/Component/Auth/LoginListener.php b/src/ChamiloLMS/CoreBundle/Component/Auth/LoginListener.php deleted file mode 100644 index 4103a1c61c..0000000000 --- a/src/ChamiloLMS/CoreBundle/Component/Auth/LoginListener.php +++ /dev/null @@ -1,29 +0,0 @@ -getTargetUser(); - /*var_dump($user ); - var_dump($event->getRequest()->getUser()); - */ - - $request = $event->getRequest(); - $session = $request->getSession(); - \ChamiloSession::setSession($session); - - $session = $event->getRequest()->getSession(); - //$session->remove('partThatShouldNotCarryOver'); - } -} diff --git a/src/ChamiloLMS/CoreBundle/Component/Auth/LoginSuccessHandler.php b/src/ChamiloLMS/CoreBundle/Component/Auth/LoginSuccessHandler.php deleted file mode 100644 index f3f4734b0b..0000000000 --- a/src/ChamiloLMS/CoreBundle/Component/Auth/LoginSuccessHandler.php +++ /dev/null @@ -1,119 +0,0 @@ -router = $urlGenerator; - $this->security = $security; - } - - /** - * @param Request $request - * @param TokenInterface $token - * @return null|RedirectResponse|\Symfony\Component\Security\Http\Authentication\Response - */ - public function onAuthenticationSuccess(Request $request, TokenInterface $token) - { - /** @var User $user */ - $user = $token->getUser(); - $userId = $user->getUserId(); - $session = $request->getSession(); - - \ChamiloSession::setSession($session); - - event_login($user); - - // Setting last login datetime - $session->set('user_last_login_datetime', api_get_utc_datetime()); - - $response = null; - /* Possible values: index.php, user_portal.php, main/auth/courses.php */ - $pageAfterLogin = api_get_setting('page_after_login'); - - $url = null; - if ($this->security->isGranted('ROLE_STUDENT') && !empty($pageAfterLogin)) { - switch ($pageAfterLogin) { - case 'index.php': - $url = $this->router->generate('index'); - break; - case 'user_portal.php': - $url = $this->router->generate('userportal'); - break; - case 'main/auth/courses.php': - $url = api_get_path(WEB_PUBLIC_PATH).$pageAfterLogin; - break; - } - } - - // Redirecting to a course or a session - - if (api_get_setting('go_to_course_after_login') == 'true') { - - // Get the courses list - $personal_course_list = \UserManager::get_personal_session_course_list($userId); - - $my_session_list = array(); - $count_of_courses_no_sessions = 0; - $count_of_courses_with_sessions = 0; - - foreach ($personal_course_list as $course) { - if (!empty($course['session_id'])) { - $my_session_list[$course['session_id']] = true; - $count_of_courses_with_sessions++; - } else { - $count_of_courses_no_sessions++; - } - } - - $count_of_sessions = count($my_session_list); - - if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) { - $key = array_keys($personal_course_list); - $course_info = $personal_course_list[$key[0]]['course_info']; - $id_session = isset($course_info['session_id']) ? $course_info['session_id'] : 0; - - $url = api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/index.php?id_session='.$id_session; - } - - if ($count_of_sessions == 0 && $count_of_courses_no_sessions == 1) { - $key = array_keys($personal_course_list); - $course_info = $personal_course_list[$key[0]]['course_info']; - $url = api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/index.php?id_session=0'; - } - } - - if (!empty($url)) { - $response = new RedirectResponse($url); - } - - // Redirect the user to where they were before the login process begun. - if (empty($response)) { - $refererUrl = $request->headers->get('referer'); - $response = new RedirectResponse($refererUrl); - } - - return $response; - } -} diff --git a/src/ChamiloLMS/CoreBundle/Component/Auth/LogoutSuccessHandler.php b/src/ChamiloLMS/CoreBundle/Component/Auth/LogoutSuccessHandler.php deleted file mode 100644 index a48dfe4ea1..0000000000 --- a/src/ChamiloLMS/CoreBundle/Component/Auth/LogoutSuccessHandler.php +++ /dev/null @@ -1,47 +0,0 @@ -router = $urlGenerator; - $this->security = $security; - } - - /** - * @param Request $request - * @return null|RedirectResponse - */ - public function onLogoutSuccess(Request $request) - { - $session = $request->getSession(); - \ChamiloSession::setSession($session); - - // Chamilo logout - $userId = api_get_user_id(); - \Online::logout($userId, false); - - $login = $this->router->generate('index'); - $response = new RedirectResponse($login); - return $response; - } -} diff --git a/src/ChamiloLMS/CoreBundle/Controller/CrudController.php b/src/ChamiloLMS/CoreBundle/Controller/CrudController.php deleted file mode 100644 index 782959a50e..0000000000 --- a/src/ChamiloLMS/CoreBundle/Controller/CrudController.php +++ /dev/null @@ -1,530 +0,0 @@ -get('orm.em')->getRepository($this->getClass()); - } - - /** - * Returns a new entity instance to be used for the "create/edit" actions. - * - * @return stdClass - */ - public function getNewEntity() - { - $class = $this->getClass(); - - return new $class; - } - - /** - * Returns a new Form Type - * @return \Symfony\Component\Form\AbstractType - */ - public function getFormType() - { - $class = $this->getType(); - - return new $class; - } - - /** - * - * @Route("/") - * @Method({"GET"}) - */ - public function indexAction() - { - $breadcrumbs = array( - array( - 'name' => get_lang('Curriculum'), - 'url' => array( - 'route' => 'curriculum_user.controller:indexAction', - 'routeParameters' => array( - //'course' => $this->getCourse()->getCode() - ) - ) - ), - array( - 'name' => get_lang('Categories') - ) - ); - //$this->setBreadcrumb(array()); - - return $this->listingAction(); - } - - /** - * @Route("/") - * @Method({"GET"}) - */ - public function listingAction() - { - $template = $this->getTemplate(); - - // Getting query - $qb = $this->getRepository()->createQueryBuilder('e'); - $query = $qb->getQuery(); - - // Process query in a pagination mode. - $adapter = new DoctrineORMAdapter($query); - $pager = new Pagerfanta($adapter); - - $page = $this->getRequest()->get('page'); - - if (empty($page)) { - $page = 1; - } - - $routeGenerator = function ($page) { - return $this->generateControllerUrl('listingAction', array('page' => $page)); - }; - - $pager->setMaxPerPage($this->maxPerPage); - $pager->setCurrentPage($page); - - $view = new TwitterBootstrap3View(); - $pagination = $view->render($pager, $routeGenerator, array( - 'proximity' => 3, - )); - - $template->assign('items', $pager); - $template->assign('grid_pagination', $pagination); - $template->assign('links', $this->generateLinks()); - $response = $this->renderTemplate('list.tpl'); - - return new Response($response, 200, array()); - } - - /** - * {@inheritdoc} - */ - protected function generateLinks() - { - return $this->generateDefaultCrudRoutes(); - } - - protected function generateDefaultCrudRoutes() - { - $className = $this->getControllerAlias(); - - return - array( - 'create_link' => $className.':addAction', - 'read_link' => $className.':readAction', - 'update_link' => $className.':editAction', - 'delete_link' => $className.':deleteAction', - 'list_link' => $className.':indexAction' - ); - } - - public function getLink($action) - { - - } - - /** - * @Route("/add") - * @Method({"GET"}) - */ - public function addAction() - { - $request = $this->getRequest(); - $form = $this->createForm($this->getFormType(), $this->getNewEntity()); - - $form->handleRequest($request); - - if ($form->isValid()) { - $item = $form->getData(); - $this->createAction($item); - $this->addMessage('Added', 'success'); - $url = $this->generateControllerUrl('listingAction'); - - return $this->redirect($url); - } - - $template = $this->getTemplate(); - $template->assign('links', $this->generateLinks()); - $template->assign('form', $form->createView()); - $response = $this->renderTemplate('add.tpl'); - - return new Response($response, 200, array()); - } - - /** - * - * @Route("/{id}", requirements={"id" = "\d+"}) - * @Method({"GET"}) - */ - public function readAction($id) - { - $template = $this->getTemplate(); - $template->assign('links', $this->generateLinks()); - return $this->readEntity($id); - } - - /** - * @Route("/{id}/edit", requirements={"id" = "\d+"}) - * @Method({"GET"}) - */ - public function editAction($id) - { - $repo = $this->getRepository(); - $request = $this->getRequest(); - $item = $repo->findOneById($id); - - if ($item) { - $form = $this->createForm($this->getFormType(), $item); - - $form->handleRequest($request); - - if ($form->isValid()) { - $data = $form->getData(); - $this->updateAction($data); - $this->addMessage('Updated', 'success'); - $url = $this->generateControllerUrl('listingAction'); - - return $this->redirect($url); - } - - $template = $this->getTemplate(); - $template->assign('item', $item); - $template->assign('form', $form->createView()); - $template->assign('links', $this->generateLinks()); - $response = $this->renderTemplate('edit.tpl'); - - return new Response($response, 200, array()); - } else { - return $this->createNotFoundException(); - } - } - - /** - * @Route("/{id}/delete", requirements={"id" = "\d+"}) - * @Method({"GET"}) - */ - public function deleteAction($id) - { - $result = $this->removeEntity($id); - if ($result) { - $url = $this->generateControllerUrl('listingAction'); - $this->addMessage('Deleted', 'success'); - - return $this->redirect($url); - } - } - - /** - * @Route("/export/{format}") - * @Method({"GET"}) - */ - public function exportAction($format = 'csv') - { - $qb = $this->getRepository()->createQueryBuilder('e'); - $query = $qb->getQuery(); - - $source = new \Exporter\Source\DoctrineORMQuerySourceIterator($query, array('id')); - - // Prepare the writer - $writer = new \Exporter\Writer\CsvWriter('data2.csv'); - - $filename = sprintf('export_%s_%s.%s', - strtolower(substr($this->getClassNameLabel(), strripos($this->getClassNameLabel(), '\\') + 1)), - date('Y_m_d_H_i_s', strtotime('now')), - $format - ); - - - return $this->get('exporter')->getResponse( - $format, - $filename, - $this->getDataSourceIterator() - ); - } - - public function getDataSourceIterator() - { - - } - - /** - * Base "read" action. - * - * @param int $id - * @return JsonResponse|NotFoundHttpException - */ - protected function readEntity($id) - { - $entityInstance = $this->getEntityForJson($id); - if (false === $entityInstance) { - return $this->createNotFoundException(); - } - - return new JsonResponse($entityInstance); - } - - /** - * Base "delete" action. - * @param int id - * @return JsonResponse|NotFoundHttpException - */ - protected function removeEntity($id) - { - $object = $this->getEntity($id); - if (false === $object) { - return $this->createNotFoundException(); - } - $em = $this->getManager(); - $em->remove($object); - $em->flush(); - - return new JsonResponse(array()); - } - - /** - * Base "list" action. - * @param string format - * @return JsonResponse - */ - protected function listAction($format = 'json') - { - return $this->getList($format); - } - - - /** - * @param string $format - * @return JsonResponse - */ - protected function getList($format = 'json') - { - $qb = $this->getRepository()->createQueryBuilder('e'); - $list = $qb->getQuery()->getResult(Query::HYDRATE_ARRAY); - - switch ($format) { - case 'json': - return new JsonResponse($list); - break; - default: - return $list; - break; - } - } - - /** - * Base "read" action. - * - * @param int $id - * @param string format - * - * @return JsonResponse|NotFoundHttpException - */ - protected function readActionByFormat($id, $format = 'array') - { - $entityInstance = $this->getEntityForJson($id); - if (false === $entityInstance) { - return $this->createNotFoundException(); - } - switch($format) { - case 'json': - return new JsonResponse($entityInstance); - case 'array': - return $entityInstance; - } - - return $entityInstance; - } - - /** - * Base "create" action. - * @param stdClass $object - * - * @throws \Exception - */ - protected function createAction($object) - { - if (false === $object) { - throw new \Exception('Unable to create the entity'); - } - - $em = $this->getManager(); - $em->persist($object); - $em->flush(); - } - - /** - * Base "upload" action. - * @param int id - * @return JsonResponse|NotFoundHttpException - */ - protected function updateAction($object) - { - if (false === $object) { - return $this->createNotFoundException(); - } - $this->getManager()->flush($object); - } - - /** - * Returns an entity from its ID, or FALSE in case of error. - * - * @param int $id - * @return Object|boolean - */ - protected function getEntity($id) - { - try { - return $this->getRepository()->find($id); - } catch (NoResultException $ex) { - return false; - } - - return false; - } - - // json actions - - /** - * Base "create" action. - * - * @return JsonResponse|NotFoundHttpException - */ - protected function createJsonAction() - { - $json = $this->getJsonDataFromRequest(); - - if (false === $json) { - throw new \Exception('Invalid JSON'); - } - - $object = $this->updateEntity($this->getNewEntity(), $json); - - if (false === $object) { - throw new \Exception('Unable to create the entity'); - } - $em = $this->getManager(); - $em->persist($object); - $em->flush(); - - return new JsonResponse($this->getEntityForJson($object->getId())); - } - - /** - * Returns an entity from its ID as an associative array, false in error. - * - * @param int $id - * @return array|boolean - */ - protected function getEntityForJson($id) - { - try { - return $this->getRepository()->createQueryBuilder('e') - ->where('e.id = :id') - ->setParameter('id', $id) - ->getQuery() - ->getSingleResult(Query::HYDRATE_ARRAY); - } catch (NoResultException $ex) { - return false; - } - - return false; - } - - /** - * Returns the request's JSON content, or FALSE in case of error. - * - * @return string|boolean - */ - protected function getJsonDataFromRequest() - { - $data = $this->getRequest()->getContent(); - if (!$data) { - return false; - } - - return $data; - } - - /** - * Base "upload" action. - * @param int id - * @return JsonResponse|NotFoundHttpException - */ - protected function updateJsonAction($id, $data) - { - $object = $this->getEntity($id); - if (false === $object) { - return $this->createNotFoundException(); - } - - $json = $this->getJsonDataFromRequest(); - - if (false === $json) { - throw new \Exception('Invalid JSON'); - } - if (false === $this->updateEntity($object, $json)) { - throw new \Exception('Unable to update the entity'); - } - $this->getManager()->flush($object); - - return new JsonResponse($this->getEntityForJson($object->getId())); - } - - /** - * Updates an entity with data from a JSON string. - * Returns the entity, or FALSE in case of error. - * - * @param Object $entity - * @param string $data - * @return Object|boolean - */ - protected function updateEntity($entity, $data) - { - $data = json_decode($data, true); - - if ($data == null) { - return false; - } - - foreach ($data as $name => $value) { - if ($name != 'id') { - $setter = 'set'.ucfirst($name); - if (method_exists($entity, $setter)) { - call_user_func_array(array($entity, $setter), array($value)); - } - } - } - - return $entity; - } -} diff --git a/src/ChamiloLMS/CoreBundle/Controller/CrudControllerInterface.php b/src/ChamiloLMS/CoreBundle/Controller/CrudControllerInterface.php deleted file mode 100644 index 68d09bb6a3..0000000000 --- a/src/ChamiloLMS/CoreBundle/Controller/CrudControllerInterface.php +++ /dev/null @@ -1,37 +0,0 @@ -getSession(); - - // get the login error if there is one - if ($request->attributes->has(SecurityContextInterface::AUTHENTICATION_ERROR)) { - $error = $request->attributes->get( - SecurityContextInterface::AUTHENTICATION_ERROR - ); - } else { - $error = $session->get(SecurityContextInterface::AUTHENTICATION_ERROR); - $session->remove(SecurityContextInterface::AUTHENTICATION_ERROR); - } - - return $this->render( - 'ChamiloLMSCoreBundle:Security:login.html.twig', - array( - // last username entered by the user - 'last_username' => $session->get(SecurityContextInterface::LAST_USERNAME), - 'error' => $error, - ) - ); - } -} diff --git a/src/ChamiloLMS/CoreBundle/Listener/LegacyListener.php b/src/ChamiloLMS/CoreBundle/Listener/LegacyListener.php deleted file mode 100644 index a1d7455125..0000000000 --- a/src/ChamiloLMS/CoreBundle/Listener/LegacyListener.php +++ /dev/null @@ -1,100 +0,0 @@ -container = $container; - } - - public function onKernelRequest(GetResponseEvent $event) - { - $kernel = $event->getKernel(); - $request = $event->getRequest(); - $container = $this->container; - - // Loading legacy variables - Session::setSession($request->getSession()); - $dbConnection = $this->container->get('database_connection'); - $database = new \Database($dbConnection, array()); - \Database::setManager($this->container->get('doctrine')->getManager()); - Session::$urlGenerator = $this->container->get('router'); - Session::$security = $this->container->get('security.context'); - Session::$translator = $this->container->get('translator'); - Session::$rootDir = $this->container->get('kernel')->getRealRootDir(); - Session::$logDir = $this->container->get('kernel')->getLogDir(); - Session::$dataDir = $this->container->get('kernel')->getDataDir(); - Session::$tempDir = $this->container->get('kernel')->getCacheDir(); - Session::$courseDir = $this->container->get('kernel')->getDataDir(); - Session::$configDir = $this->container->get('kernel')->getConfigDir(); - - - - // Injecting course in twig - - $courseCode = $request->get('code'); - - if (empty($courseCode)) { - $courseCodeFromRequest = $request->get('cidReq'); - $courseCode = $courseCodeFromRequest; - } - - if (!empty($courseCode)) { - $em = $this->container->get('doctrine')->getManager(); - $course = $em->getRepository('ChamiloLMSCoreBundle:Course')->findOneByCode($courseCode); - $this->container->get('twig')->addGlobal('course', $course); - $request->getSession()->set('_real_cid', $course->getId()); - $request->getSession()->set('_cid', $course->getCode()); - $courseInfo = api_get_course_info($course->getCode()); - $request->getSession()->set('_course', $courseInfo); - } - - // Loading portal settings from DB. - $settingsRefreshInfo = api_get_settings_params_simple(array('variable = ?' => 'settings_latest_update')); - $settingsLatestUpdate = $settingsRefreshInfo ? $settingsRefreshInfo['selected_value'] : null; - - $settings = Session::read('_setting'); - - if (empty($settings)) { - api_set_settings_and_plugins(); - } else { - if (isset($settings['settings_latest_update']) && $settings['settings_latest_update'] != $settingsLatestUpdate) { - api_set_settings_and_plugins(); - } - } - } - - public function onKernelResponse(FilterResponseEvent $event) - { - $response = $event->getResponse(); - $request = $event->getRequest(); - $kernel = $event->getKernel(); - $container = $this->container; - - /*switch ($request->query->get('option')) { - case 2: - $response->setContent('Blah'); - break; - - case 3: - $response->headers->setCookie(new Cookie('test', 1)); - break; - }*/ - } - - public function onKernelController(FilterControllerEvent $event) - { - - } -} diff --git a/src/ChamiloLMS/CoreBundle/Listener/LoginSuccessHandler.php b/src/ChamiloLMS/CoreBundle/Listener/LoginSuccessHandler.php deleted file mode 100644 index 36b7a3adc0..0000000000 --- a/src/ChamiloLMS/CoreBundle/Listener/LoginSuccessHandler.php +++ /dev/null @@ -1,139 +0,0 @@ -container->get('database_connection'); - $database = new \Database($dbConnection, array()); - - $this->router = $urlGenerator; - $this->security = $security; - } - - /** - * @param Request $request - * @param TokenInterface $token - * @return null|RedirectResponse|\Symfony\Component\Security\Http\Authentication\Response - */ - public function onAuthenticationSuccess(Request $request, TokenInterface $token) - { - /** @var User $user */ - $user = $token->getUser(); - $userId = $user->getUserId(); - $session = $request->getSession(); - - \ChamiloSession::setSession($session); - \ChamiloSession::$urlGenerator = $this->router; - - event_login($user); - - $userInfo = api_get_user_info($user->getUserId()); - $userInfo['is_anonymous'] = false; - - $request->getSession()->set('_user', $userInfo); - - // Setting admin permissions. - if ($this->security->isGranted('ROLE_ADMIN')) { - $request->getSession()->set('is_platformAdmin', true); - } - - // Setting teachers permissions. - if ($this->security->isGranted('ROLE_TEACHER')) { - $request->getSession()->set('is_allowedCreateCourse', true); - } - - // Setting last login datetime - $session->set('user_last_login_datetime', api_get_utc_datetime()); - - $response = null; - /* Possible values: index.php, user_portal.php, main/auth/courses.php */ - $pageAfterLogin = api_get_setting('page_after_login'); - - $url = null; - if ($this->security->isGranted('ROLE_STUDENT') && !empty($pageAfterLogin)) { - switch ($pageAfterLogin) { - case 'index.php': - $url = $this->router->generate('index'); - break; - case 'user_portal.php': - $url = $this->router->generate('userportal'); - break; - case 'main/auth/courses.php': - $url = api_get_path(WEB_PUBLIC_PATH).$pageAfterLogin; - break; - } - } - - // Redirecting to a course or a session - - if (api_get_setting('go_to_course_after_login') == 'true') { - - // Get the courses list - $personal_course_list = \UserManager::get_personal_session_course_list($userId); - - $my_session_list = array(); - $count_of_courses_no_sessions = 0; - $count_of_courses_with_sessions = 0; - - foreach ($personal_course_list as $course) { - if (!empty($course['session_id'])) { - $my_session_list[$course['session_id']] = true; - $count_of_courses_with_sessions++; - } else { - $count_of_courses_no_sessions++; - } - } - - $count_of_sessions = count($my_session_list); - - if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) { - $key = array_keys($personal_course_list); - $course_info = $personal_course_list[$key[0]]['course_info']; - $id_session = isset($course_info['session_id']) ? $course_info['session_id'] : 0; - - $url = api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/index.php?id_session='.$id_session; - } - - if ($count_of_sessions == 0 && $count_of_courses_no_sessions == 1) { - $key = array_keys($personal_course_list); - $course_info = $personal_course_list[$key[0]]['course_info']; - $url = api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/index.php?id_session=0'; - } - } - - if (!empty($url)) { - $response = new RedirectResponse($url); - } - - // Redirect the user to where they were before the login process begun. - if (empty($response)) { - $refererUrl = $request->headers->get('referer'); - $response = new RedirectResponse($refererUrl); - } - - return $response; - } -} diff --git a/src/ChamiloLMS/CoreBundle/Listener/LogoutSuccessHandler.php b/src/ChamiloLMS/CoreBundle/Listener/LogoutSuccessHandler.php deleted file mode 100644 index c8f630dfb4..0000000000 --- a/src/ChamiloLMS/CoreBundle/Listener/LogoutSuccessHandler.php +++ /dev/null @@ -1,49 +0,0 @@ -router = $urlGenerator; - $this->security = $security; - } - - /** - * @param Request $request - * @return null|RedirectResponse - */ - public function onLogoutSuccess(Request $request) - { - $session = $request->getSession(); - \ChamiloSession::setSession($session); - - // Chamilo logout - $userId = api_get_user_id(); - //\Online::logout($userId, false); - - $login = $this->router->generate('index'); - $response = new RedirectResponse($login); - return $response; - } -} diff --git a/src/ChamiloLMS/CoreBundle/Menu/Builder.php b/src/ChamiloLMS/CoreBundle/Menu/Builder.php deleted file mode 100644 index 1cbfbccbb1..0000000000 --- a/src/ChamiloLMS/CoreBundle/Menu/Builder.php +++ /dev/null @@ -1,101 +0,0 @@ -createItem('root'); - $menu->setChildrenAttribute('class', 'nav navbar-nav'); - - $menu->addChild($this->container->get('translator')->trans('Home'), array('route' => 'root')); - $menu->addChild('Administration', array( - 'route' => 'administration' - //'routeParameters' => array('id' => 42) - )); - // ... add more children - - return $menu; - } - - /** - * Top menu right - * @param FactoryInterface $factory - * @param array $options - * @return \Knp\Menu\ItemInterface - */ - public function rightMenu(FactoryInterface $factory, array $options) - { - $menu = $factory->createItem('root'); - $menu->setChildrenAttribute('class', 'nav navbar-nav navbar-right'); - - $menu->addChild('User'); - - /* {% if is_granted('IS_AUTHENTICATED_FULLY') == true %} -
  • - - - -
  • - {% endif %} - */ - if ($this->container->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) { - $logoutLink = $menu->addChild('Logout', array('route' => 'logout')); - $logoutLink - ->setLinkAttributes(array( - 'id' => 'logout_button', - 'class' => 'fa fa-power-off' - )) - ->setAttributes(array( - /*'id' => 'signin', - 'class' => 'dropdown'*/ - )) - ; - //$logoutLink->addChild($this->templating->render('ApplicationSonataUserBundle:Security:login_options.html.twig')); - - } - - return $menu; - } - - public function profileMenu(FactoryInterface $factory, array $options) - { - $menu = $factory->createItem('root'); - $security = $this->container->get('security.context'); - if ($security->isGranted('IS_AUTHENTICATED_FULLY')) { - $menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); - - $menu->addChild('Inbox', array('route' => 'logout')); - $menu->addChild('Compose', array('route' => 'logout')); - $menu->addChild('Edit', array('route' => 'logout')); - } - - return $menu; - } - - public function courseMenu(FactoryInterface $factory, array $options) - { - $security = $this->container->get('security.context'); - $menu = $factory->createItem('root'); - if ($security->isGranted('IS_AUTHENTICATED_FULLY')) { - - $menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); - - $menu->addChild('Create course', array('route' => 'logout')); - $menu->addChild('Catalog', array('route' => 'logout')); - $menu->addChild('History', array('route' => 'logout')); - } - return $menu; - } - -}