agenda_js.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.calendar
  5. */
  6. /**
  7. * INIT SECTION
  8. */
  9. // name of the language file that needs to be included
  10. $language_file = array('agenda','group');
  11. // use anonymous mode when accessing this course tool
  12. $use_anonymous = true;
  13. require_once '../inc/global.inc.php';
  14. require_once 'agenda.lib.php';
  15. $htmlHeadXtra[] = api_get_jquery_ui_js();
  16. $htmlHeadXtra[] = api_get_js('qtip2/jquery.qtip.min.js');
  17. $htmlHeadXtra[] = api_get_js('fullcalendar/fullcalendar.min.js');
  18. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/fullcalendar/fullcalendar.css');
  19. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/qtip2/jquery.qtip.min.css');
  20. $type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
  21. if (api_is_platform_admin() && $type == 'admin') {
  22. $type = 'admin';
  23. }
  24. //if (api_get_course_id() != -1 && $type == 'course') {
  25. if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) {
  26. $type = 'course';
  27. }
  28. switch($type) {
  29. case 'admin':
  30. $this_section = SECTION_PLATFORM_ADMIN;
  31. break;
  32. case 'course':
  33. $this_section = SECTION_COURSES;
  34. break;
  35. case 'personal':
  36. $this_section = SECTION_MYAGENDA;
  37. break;
  38. }
  39. $tpl = new Template(get_lang('Agenda'));
  40. $can_add_events = 0;
  41. if (api_is_platform_admin() && $type == 'admin') {
  42. $can_add_events = 1;
  43. }
  44. if (api_is_allowed_to_edit() && $type == 'course') {
  45. $can_add_events = 1;
  46. }
  47. if (!api_is_anonymous() && $type == 'personal') {
  48. $can_add_events = 1;
  49. }
  50. //Setting translations
  51. $day_short = api_get_week_days_short();
  52. $days = api_get_week_days_long();
  53. $months = api_get_months_long();
  54. $months_short = api_get_months_short();
  55. //Setting calendar translations
  56. $tpl->assign('month_names', json_encode($months));
  57. $tpl->assign('month_names_short', json_encode($months_short));
  58. $tpl->assign('day_names', json_encode($days));
  59. $tpl->assign('day_names_short', json_encode($day_short));
  60. $tpl->assign('button_text', json_encode(array( 'today' => get_lang('Today'),
  61. 'month' => get_lang('Month'),
  62. 'week' => get_lang('Week'),
  63. 'day' => get_lang('Day'))));
  64. //Calendar Type : course, admin, personal
  65. $tpl->assign('type', $type);
  66. //Calendar type label
  67. $tpl->assign('type_label', get_lang($type.'Calendar'));
  68. //Current user can add event?
  69. $tpl->assign('can_add_events', $can_add_events);
  70. //Setting AJAX caller
  71. $agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type.'&';
  72. $tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);
  73. $course_code = api_get_course_id();
  74. if (api_is_allowed_to_edit() && $course_code != '-1') {
  75. $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id());
  76. $group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id());
  77. $agenda = new Agenda();
  78. $select = $agenda->construct_not_selected_select_form($group_list, $user_list, 'everyone');
  79. $tpl->assign('visible_to', $select);
  80. }
  81. //Loading Agenda template
  82. $content = $tpl->fetch('default/agenda/month.tpl');
  83. $tpl->assign('content', $content);
  84. //Loading main Chamilo 1 col template
  85. $tpl->display_one_col_template();