Пример #1
0
 /**
  * @param \Silex\Application $app
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Application $app)
 {
     $template = $this->getTemplate();
     /*$user = $this->getManager()->getRepository('Entity\User')->find(1);
       foreach($user->getPortals() as $portal) {
           var_dump($portal->getUrl());
       }*/
     /*
             $token = $app['security']->getToken();
             if (null !== $token) {
                 $user = $token->getUser();
             }*/
     /*\ChamiloSession::write('name', 'clara');
       var_dump(\ChamiloSession::read('name'));
       var_dump($_SESSION['name']);*/
     //var_dump(\ChamiloSession::read('aaa'));
     /*\ChamiloSession::write('name', 'clar');
       echo \ChamiloSession::read('name');
       $app['session']->set('name', 'julio');
       echo $app['session']->get('name');*/
     /*
             $token = $app['security']->getToken();
             if (null !== $token) {
                 $user = $token->getUser();
                 var_dump($user );
             }
             if ($app['security']->isGranted('ROLE_ADMIN')) {
             }*/
     /** @var \Entity\User $user */
     /*$em = $app['orm.ems']['db_write'];
       $user = $em->getRepository('Entity\User')->find(6);
       $role = $em->getRepository('Entity\Role')->findOneByRole('ROLE_STUDENT');
       $user->getRolesObj()->add($role);
       $em->persist($user);
       $em->flush();*/
     //$user->roles->add($status);
     /*$roles = $user->getRolesObj();
       foreach ($roles as $role) {
       }*/
     // $countries = Intl::getRegionBundle()->getCountryNames('es');
     //var_dump($countries);
     /*$formatter = new \IntlDateFormatter(\Locale::getDefault(), \IntlDateFormatter::NONE, \IntlDateFormatter::NONE);
       //http://userguide.icu-project.org/formatparse/datetime for date formats
       $formatter->setPattern("EEEE d MMMM Y");
       echo $formatter->format(time());*/
     //@todo improve this JS includes should be added using twig
     $extra = array(api_get_jquery_libraries_js(array('bxslider')), '<script>
         $(document).ready(function(){
             $("#slider").bxSlider({
                 infiniteLoop	: true,
                 auto			: true,
                 pager			: true,
                 autoHover		: true,
             pause			: 10000
             });
         });
         </script>');
     if (api_get_setting('use_virtual_keyboard') == 'true') {
         $extra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH) . 'javascript/keyboard/keyboard.css');
         $extra[] = api_get_js('keyboard/jquery.keyboard.js');
     }
     $app['extraJS'] = $extra;
     $app['this_section'] = SECTION_CAMPUS;
     $request = $app['request'];
     if (api_get_setting('allow_terms_conditions') == 'true') {
         unset($_SESSION['term_and_condition']);
     }
     // If we are not logged in and custompages activated
     if (!api_get_user_id() && \CustomPages::enabled()) {
         $loggedOut = $request->get('loggedout');
         if ($loggedOut) {
             \CustomPages::display(\CustomPages::LOGGED_OUT);
         } else {
             \CustomPages::display(\CustomPages::INDEX_UNLOGGED);
         }
     }
     /** @var \PageController $pageController */
     $pageController = $app['page_controller'];
     if (api_get_setting('display_categories_on_homepage') == 'true') {
         $template->assign('course_category_block', $pageController->return_courses_in_categories());
     }
     // @todo Custom Facebook connection lib could be replaced with opauth
     // Facebook connection, if activated
     if (api_is_facebook_auth_activated() && !api_get_user_id()) {
         facebook_connect();
     }
     $this->setLoginForm($app);
     if (!api_is_anonymous()) {
         $pageController->setProfileBlock();
         $pageController->setUserImageBlock();
         if (api_is_platform_admin()) {
             $pageController->setCourseBlock();
         } else {
             $pageController->return_teacher_link();
         }
     }
     // Hot courses & announcements
     $hotCourses = null;
     $announcementsBlock = null;
     // When loading a chamilo page do not include the hot courses and news
     if (!isset($_REQUEST['include'])) {
         if (api_get_setting('show_hot_courses') == 'true') {
             $hotCourses = $pageController->returnHotCourses();
         }
         $announcementsBlock = $pageController->return_announcements();
     }
     $template->assign('hot_courses', $hotCourses);
     $template->assign('announcements_block', $announcementsBlock);
     // Homepage
     $template->assign('home_page_block', $pageController->returnHomePage());
     // Navigation links
     $pageController->returnNavigationLinks($template->getNavigationLinks());
     $pageController->returnNotice();
     $pageController->returnHelp();
     if (api_is_platform_admin() || api_is_drh()) {
         $pageController->returnSkillsLinks();
     }
     $response = $template->renderLayout('layout_2_col.tpl');
     return new Response($response, 200, array());
 }
Пример #2
0
            // decode all open event informations and fill the track_c_* tables
            include api_get_path(LIBRARY_PATH) . 'stats.lib.inc.php';
            decodeOpenInfos();
        }
    }
    // End login -- if ($_POST['submitAuth'])
} else {
    // Only if login form was not sent because if the form is sent the user was already on the page.
    event_open();
}
if (api_get_setting('display_categories_on_homepage') == 'true') {
    $controller->tpl->assign('course_category_block', $controller->return_courses_in_categories());
}
// Facebook connexion, if activated
if (api_is_facebook_auth_activated() && !api_get_user_id()) {
    facebook_connect();
}
$controller->set_login_form();
//@todo move this inside the IndexManager
if (!api_is_anonymous()) {
    $controller->tpl->assign('profile_block', $controller->return_profile_block());
    $controller->tpl->assign('user_image_block', $controller->return_user_image_block());
    if (api_is_platform_admin()) {
        $controller->tpl->assign('course_block', $controller->return_course_block());
    } else {
        $controller->tpl->assign('teacher_block', $controller->return_teacher_link());
    }
}
$hot_courses = null;
$announcements_block = null;
// Display the Site Use Cookie Warning Validation