planification.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
  4. $cidReset = true;
  5. require_once __DIR__.'/../inc/global.inc.php';
  6. api_block_anonymous_users();
  7. $current_course_tool = TOOL_CALENDAR_EVENT;
  8. $this_section = SECTION_MYAGENDA;
  9. $timezone = new DateTimeZone(api_get_timezone());
  10. $now = new DateTime('now', $timezone);
  11. $currentYear = (int) $now->format('Y');
  12. $searchYear = isset($_GET['year']) ? (int) $_GET['year'] : $currentYear;
  13. $userInfo = api_get_user_info();
  14. $userId = $userInfo['id'];
  15. $sessions = [];
  16. if (api_is_drh()) {
  17. $count = SessionManager::get_sessions_followed_by_drh($userId, null, null, true);
  18. } else {
  19. $count = UserManager::get_sessions_by_category($userId, false, true, true, true);
  20. }
  21. $sessionsList = UserManager::getSubscribedSessionsByYear($userInfo, $searchYear);
  22. if ($count > 50) {
  23. $message = Display::return_message('TooMuchSessionsInPlanification', 'warning');
  24. api_not_allowed(true, $message);
  25. }
  26. $sessions = UserManager::getSessionsCalendarByYear($sessionsList, $searchYear);
  27. $colors = ChamiloApi::getColorPalette(false, true, count($sessions));
  28. $agenda = new Agenda('personal');
  29. $actions = $agenda->displayActions('list', $userId);
  30. $toolName = get_lang('Sessions plan calendar');
  31. $interbreadcrumb[] = [
  32. 'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal',
  33. 'name' => get_lang('Agenda'),
  34. ];
  35. $template = new Template($toolName);
  36. $template->assign('toolbar', $actions);
  37. $template->assign('student_id', $userId);
  38. $template->assign('search_year', $searchYear);
  39. $template->assign('colors', $colors);
  40. $template->assign('sessions', $sessions);
  41. $layout = $template->get_template('agenda/planification.tpl');
  42. $template->display($layout);