/**
  * @Route("/userportal", name="userportal")
  * @Method({"GET"})
  * @Security("has_role('ROLE_USER')")
  *
  * @param string $type courses|sessions|mycoursecategories
  * @param string $filter for the userportal courses page. Only works when setting 'history'
  * @param int $page
  *
  * @return Response
  */
 public function userPortalAction($type = 'courses', $filter = 'current', $coursePage = 1, Request $request)
 {
     /** @var \Application\Sonata\PageBundle\Entity\Site $site */
     $site = $this->get('sonata.page.site.selector')->retrieve();
     $site->getId();
     $settingsManager = $this->get('chamilo.settings.manager');
     $setting = $settingsManager->getSetting('platform.institution');
     $settingsManagerCourse = $this->get('chamilo_course.settings.manager');
     $course = $this->getDoctrine()->getRepository('ChamiloCoreBundle:Course')->find(1);
     if ($course) {
         $settingsManagerCourse->setCourse($course);
         $agenda = $settingsManagerCourse->getSetting('calendar_event.enabled');
     }
     $user = $this->getUser();
     $pageController = new \Chamilo\CoreBundle\Framework\PageController();
     $items = null;
     $page = $coursePage;
     if (!empty($user)) {
         $userId = $user->getId();
         // Main courses and session list
         $type = str_replace('/', '', $type);
         switch ($type) {
             case 'sessions':
                 $items = $pageController->returnSessions($userId, $filter, $page);
                 break;
             case 'sessioncategories':
                 $items = $pageController->returnSessionsCategories($userId, $filter, $page);
                 break;
             case 'courses':
                 $items = $pageController->returnCourses($userId, $filter, $page);
                 break;
             case 'mycoursecategories':
                 $items = $pageController->returnMyCourseCategories($userId, $filter, $page);
                 break;
             case 'specialcourses':
                 $items = $pageController->returnSpecialCourses($userId, $filter, $page);
                 break;
         }
     }
     $template = $this->getTemplate();
     // Show the chamilo mascot
     if (empty($items) && empty($filter)) {
         $pageController->return_welcome_to_course_block($template);
     }
     /** @var \Chamilo\SettingsBundle\Manager\SettingsManager $settingManager */
     $settingManager = $this->get('chamilo.settings.manager');
     /*var_dump($settingManager->getSetting('platform.institution'));
       $settings = $settingManager->loadSettings('platform');
       var_dump($settings->get('institution'));
       var_dump(api_get_setting('platform.institution'));*/
     $pageController->returnSkillsLinks();
     // Deleting the session_id.
     $request->getSession()->remove('session_id');
     return $this->render('ChamiloCoreBundle:Index:userportal.html.twig', array('content' => $items, 'page_title' => 'dsqd'));
 }
 /**
  * @Route("/", name="home")
  * @Method({"GET"})
  *
  * @param string $type courses|sessions|mycoursecategories
  * @param string $filter for the userportal courses page. Only works when setting 'history'
  * @param int $page
  *
  * @return Response
  */
 public function indexAction(Request $request)
 {
     /** @var \PageController $pageController */
     //$pageController = $this->get('page_controller');
     $pageController = new PageController();
     /*
             if (api_get_setting('display_categories_on_homepage') == 'true') {
                 //$template->assign('course_category_block', $pageController->return_courses_in_categories());
             }
     
             if (!api_is_anonymous()) {
                 if (api_is_platform_admin()) {
                     $pageController->setCourseBlock();
                 } else {
                     $pageController->return_teacher_link();
                 }
             }
     
             // Hot courses & announcements
             $hotCourses         = null;
             $announcementsBlock = null;
     
             // Navigation links
             //$pageController->returnNavigationLinks($template->getNavigationLinks());
             $pageController->returnNotice();
             $pageController->returnHelp();
     
             if (api_is_platform_admin() || api_is_drh()) {
                 $pageController->returnSkillsLinks();
             }*/
     $sessionHandler = $request->getSession();
     $sessionHandler->remove('coursesAlreadyVisited');
     $announcementsBlock = $pageController->getAnnouncements();
     $this->get('session')->remove('id_session');
     return $this->render('@ChamiloCore/Index/index.html.twig', array('content' => '', 'announcements_block' => $announcementsBlock));
 }
 /**
  * @Route("/{type}/{filter}", name="userportal")
  * @Method({"GET"})
  * @Security("has_role('ROLE_USER')")
  *
  * @param string $type courses|sessions|mycoursecategories
  * @param string $filter history|current for the userportal courses page
  * @param int $page
  *
  * @return Response
  */
 public function indexAction($type = 'courses', $filter = 'current', $coursePage = 1, Request $request)
 {
     //$settingsManager = $this->get('chamilo.settings.manager');
     //$setting = $settingsManager->getSetting('platform.institution');
     /*$settingsManagerCourse = $this->get('chamilo_course.settings.manager');
       $course = $this->getDoctrine()->getRepository('ChamiloCoreBundle:Course')->find(1);
       if ($course) {
           $settingsManagerCourse->setCourse($course);
           $agenda = $settingsManagerCourse->getSetting(
               'calendar_event.enabled'
           );
       }*/
     $user = $this->getUser();
     $pageController = new \Chamilo\CoreBundle\Framework\PageController();
     $items = null;
     $page = $coursePage;
     if (!empty($user)) {
         $userId = $user->getId();
         // Main courses and session list
         $type = str_replace('/', '', $type);
         switch ($type) {
             case 'sessions':
                 $items = $pageController->returnSessions($userId, $filter, $page);
                 break;
             case 'sessioncategories':
                 $items = $pageController->returnSessionsCategories($userId, $filter, $page);
                 break;
             case 'courses':
                 $items = $pageController->returnCourses($userId, $filter, $page);
                 break;
             case 'mycoursecategories':
                 $items = $pageController->returnMyCourseCategories($userId, $filter, $page);
                 break;
             case 'specialcourses':
                 $items = $pageController->returnSpecialCourses($userId, $filter, $page);
                 break;
         }
     }
     /** @var \Chamilo\SettingsBundle\Manager\SettingsManager $settingManager */
     $settingManager = $this->get('chamilo.settings.manager');
     /*var_dump($settingManager->getSetting('platform.institution'));
       $settings = $settingManager->loadSettings('platform');
       var_dump($settings->get('institution'));
       var_dump(api_get_setting('platform.institution'));*/
     $pageController->returnSkillsLinks();
     // Deleting the session_id.
     $request->getSession()->remove('session_id');
     $countCourses = \CourseManager::count_courses();
     return $this->render('ChamiloCoreBundle:Index:userportal.html.twig', array('content' => $items, 'count_courses' => $countCourses));
 }
 /**
  * @Route("/", name="home")
  * @Method({"GET"})
  *
  * @param string $type courses|sessions|mycoursecategories
  * @param string $filter for the userportal courses page. Only works when setting 'history'
  * @param int $page
  *
  * @return Response
  */
 public function indexAction(Request $request)
 {
     /** @var \PageController $pageController */
     //$pageController = $this->get('page_controller');
     $pageController = new PageController();
     /*
             if (api_get_setting('display_categories_on_homepage') == 'true') {
                 //$template->assign('course_category_block', $pageController->return_courses_in_categories());
             }
     
             if (!api_is_anonymous()) {
                 if (api_is_platform_admin()) {
                     $pageController->setCourseBlock();
                 } else {
                     $pageController->return_teacher_link();
                 }
             }
     
             // Hot courses & announcements
             $hotCourses         = null;
             $announcementsBlock = null;
     
             // Navigation links
             //$pageController->returnNavigationLinks($template->getNavigationLinks());
             $pageController->returnNotice();
             $pageController->returnHelp();
     
             if (api_is_platform_admin() || api_is_drh()) {
                 $pageController->returnSkillsLinks();
             }*/
     $sessionHandler = $request->getSession();
     $sessionHandler->remove('coursesAlreadyVisited');
     $announcementsBlock = $pageController->getAnnouncements();
     /** @var User $user */
     $userManager = $this->container->get('fos_user.user_manager');
     $user = $userManager->find(1);
     //$attribute = $this->container->get('doctrine')->getRepository('ChamiloCoreBundle:ExtraField')->find(1);
     /*
             $attribute = new ExtraField();
             $attribute->setName('size');
             $attribute->setVariable('size');
             $attribute->setType(TextAttributeType::TYPE);
             $attribute->setStorageType(AttributeValueInterface::STORAGE_TEXT);
             $this->getDoctrine()->getManager()->persist($attribute);
             $this->getDoctrine()->getManager()->flush();
     
             $attributeColor = new ExtraField();
             $attributeColor->setName('color');
             $attributeColor->setVariable('color');
             $attributeColor->setType(TextAttributeType::TYPE);
             $attributeColor->setStorageType(AttributeValueInterface::STORAGE_TEXT);
             $this->getDoctrine()->getManager()->persist($attributeColor);
             $this->getDoctrine()->getManager()->flush();
     
             $color = new ExtraFieldValues();
             $color->setComment('lol');
             $color->setAttribute($attributeColor);
             $color->setValue('blue');
     
             $user->addAttribute($color);
     
             $smallSize = new ExtraFieldValues();
             $smallSize->setComment('lol');
             $smallSize->setAttribute($attribute);
             $smallSize->setValue('S');
     
             $user->addAttribute($smallSize);
             $userManager->updateUser($user);
     */
     $this->get('session')->remove('id_session');
     return $this->render('@ChamiloCore/Index/index.html.twig', array('content' => '', 'announcements_block' => $announcementsBlock));
 }