/**
  * @param Application $app
  * @param string $type courses|sessions|mycoursecategories
  * @param string $filter for the userportal courses page. Only works when setting 'history'
  * @param int $page
  *
  * @return Response|void
  */
 public function indexAction(Application $app, $type = 'courses', $filter = 'current', $page = 1)
 {
     // @todo Use filters like "after/before|finish" to manage user access
     api_block_anonymous_users();
     // Abort request because the user is not allowed here - @todo use filters
     if ($app['allowed'] == false) {
         return $app->abort(403, 'Not allowed');
     }
     // Main courses and session list
     $items = null;
     $type = str_replace('/', '', $type);
     /** @var \PageController $pageController */
     $pageController = $app['page_controller'];
     switch ($type) {
         case 'sessions':
             $items = $pageController->returnSessions(api_get_user_id(), $filter, $page);
             break;
         case 'sessioncategories':
             $items = $pageController->returnSessionsCategories(api_get_user_id(), $filter, $page);
             break;
         case 'courses':
             $items = $pageController->returnCourses(api_get_user_id(), $filter, $page);
             break;
         case 'mycoursecategories':
             $items = $pageController->returnMyCourseCategories(api_get_user_id(), $filter, $page);
             break;
         case 'specialcourses':
             $items = $pageController->returnSpecialCourses(api_get_user_id(), $filter, $page);
             break;
     }
     //Show the chamilo mascot
     if (empty($items) && empty($filter)) {
         $pageController->return_welcome_to_course_block($app['template']);
     }
     /*
             $app['my_main_menu'] = function($app) {
                 $menu = $app['knp_menu.factory']->createItem('root');
                 $menu->addChild('Home', array('route' => api_get_path(WEB_CODE_PATH)));
                 return $menu;
             };
             $app['knp_menu.menus'] = array('main' => 'my_main_menu');*/
     $app['template']->assign('content', $items);
     $pageController->setCourseSessionMenu();
     $pageController->setProfileBlock();
     $pageController->setUserImageBlock();
     $pageController->setCourseBlock($filter);
     $pageController->setSessionBlock();
     $pageController->return_reservation_block();
     $pageController->returnNavigationLinks($app['template']->getNavigationLinks());
     $app['template']->assign('search_block', $pageController->return_search_block());
     $app['template']->assign('classes_block', $pageController->return_classes_block());
     $pageController->returnSkillsLinks();
     // Deleting the session_id.
     Session::erase('session_id');
     $response = $app['template']->render_template('userportal/index.tpl');
     return new Response($response, 200, array());
 }
 /**
  *
  * @Route("/")
  * @Method({"GET"})
  */
 public function indexAction()
 {
     // @todo Use filters like "after/before|finish" to manage user access
     api_block_anonymous_users();
     // Abort request because the user is not allowed here - @todo use filters
     if ($app['allowed'] == false) {
         return $app->abort(403, 'Not allowed');
     }
     $breadcrumbs = array(array('name' => get_lang('Curriculum'), 'url' => array()));
     $this->setBreadcrumb($breadcrumbs);
     $userId = $this->getUser()->getUserId();
     $qb = $this->getManager()->createQueryBuilder()->select('node, i, u')->from('Chamilo\\CoreBundle\\Entity\\CurriculumCategory', 'node')->innerJoin('node.course', 'c')->leftJoin('node.items', 'i')->leftJoin('i.userItems', 'u', 'WITH', 'u.userId = :userId OR u.userId IS NULL')->setParameter('userId', $userId)->orderBy('node.root, node.lft, node.title', 'ASC');
     $this->setCourseParameters($qb, 'node');
     $query = $qb->getQuery();
     $categories = $query->getResult();
     $formList = array();
     /** @var \Chamilo\CoreBundle\Entity\CurriculumCategory $category */
     foreach ($categories as $category) {
         /** @var \Chamilo\CoreBundle\Entity\CurriculumItem $item */
         foreach ($category->getItems() as $item) {
             $formType = new CurriculumItemRelUserCollectionType($item->getId());
             $count = count($item->getUserItems());
             // If there are no items for the user, then create a new one!
             if ($count == 0) {
                 $userItem = new CurriculumItemRelUser();
                 $userItem->setItemId($item->getId());
                 $userItemList = array($userItem);
                 $item->setUserItems($userItemList);
             }
             $form = $this->get('form.factory')->create($formType, $item);
             $formList[$item->getId()] = $form->createView();
         }
     }
     if (api_is_allowed_to_edit()) {
         $this->get('template')->assign('teacher_links', $categories);
     }
     $this->get('template')->assign('categories', $categories);
     $this->get('template')->assign('links', $this->generateLinks());
     $this->get('template')->assign('form_list', $formList);
     $this->get('template')->assign('isAllowed', api_is_allowed_to_edit(true, true, true));
     $response = $this->get('template')->render_template($this->getTemplatePath() . 'list.tpl');
     return new Response($response, 200, array());
 }
Esempio n. 3
0
    $this_section = SECTION_COURSES;
} else {
    $_SESSION['gradebook_dest'] = 'gradebook.php';
    $this_section = SECTION_MYGRADEBOOK;
    unset($_GET['course']);
}
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {
	for (i=0;i<$(".actions").length;i++) {
		if ($(".actions:eq("+i+")").html()=="<table border=\\"0\\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) {
			$(".actions:eq("+i+")").hide();
		}
	}
 } );
 </script>';
api_block_anonymous_users();
$htmlHeadXtra[] = '<script type="text/javascript">
function confirmation ()
{
	if (confirm("' . get_lang('DeleteAll') . '?")) {
	    return true;
	} else {
	    return false;
	}
}
</script>';
$filter_confirm_msg = true;
$filter_warning_msg = true;
// ACTIONS
//this is called when there is no data for the course admin
if (isset($_GET['createallcategories'])) {
Esempio n. 4
0
 */

use \ChamiloSession as Session;
$language_file = array('courses', 'index', 'admin', 'userInfo');
/* Flag forcing the 'current course' reset, as we're not inside a course anymore */
$cidReset = true;

// For HTML editor repository.
if (isset($_SESSION['this_section']))
	unset($_SESSION['this_section']);

/* Included libraries */
require_once './main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'userportal.lib.php';

api_block_anonymous_users(); // Only users who are logged in can proceed.

$user_id = api_get_user_id();

/* Constants and CONFIGURATION parameters */
$load_dirs = api_get_setting('show_documents_preview');

// Check if a user is enrolled only in one course for going directly to the course after the login.
if (api_get_setting('go_to_course_after_login') == 'true') {

	// Get the courses list
	$personal_course_list = UserManager::get_personal_session_course_list($user_id);

	$my_session_list = array();
	$count_of_courses_no_sessions = 0;
	$count_of_courses_with_sessions = 0;