agenda_js.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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', 'announcements');
  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. require_once 'agenda.inc.php';
  16. $htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui','jquery-ui-i18n'));
  17. $htmlHeadXtra[] = api_get_js('qtip2/jquery.qtip.min.js');
  18. $htmlHeadXtra[] = api_get_js('fullcalendar/fullcalendar.min.js');
  19. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/fullcalendar/fullcalendar.css');
  20. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/qtip2/jquery.qtip.min.css');
  21. $type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
  22. if (api_is_platform_admin() && $type == 'admin') {
  23. $type = 'admin';
  24. }
  25. //if (api_get_course_id() != -1 && $type == 'course') {
  26. if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) {
  27. $type = 'course';
  28. }
  29. switch($type) {
  30. case 'admin':
  31. $this_section = SECTION_PLATFORM_ADMIN;
  32. break;
  33. case 'course':
  34. $this_section = SECTION_COURSES;
  35. break;
  36. case 'personal':
  37. $this_section = SECTION_MYAGENDA;
  38. break;
  39. }
  40. $tpl = new Template(get_lang('Agenda'));
  41. $can_add_events = 0;
  42. if (api_is_platform_admin() && $type == 'admin') {
  43. $can_add_events = 1;
  44. }
  45. if (api_is_allowed_to_edit() && $type == 'course') {
  46. $can_add_events = 1;
  47. }
  48. if (!api_is_anonymous() && $type == 'personal') {
  49. $can_add_events = 1;
  50. }
  51. //Setting translations
  52. $day_short = api_get_week_days_short();
  53. $days = api_get_week_days_long();
  54. $months = api_get_months_long();
  55. $months_short = api_get_months_short();
  56. //Setting calendar translations
  57. $tpl->assign('month_names', json_encode($months));
  58. $tpl->assign('month_names_short', json_encode($months_short));
  59. $tpl->assign('day_names', json_encode($days));
  60. $tpl->assign('day_names_short', json_encode($day_short));
  61. $tpl->assign('button_text', json_encode(array( 'today' => get_lang('Today'),
  62. 'month' => get_lang('Month'),
  63. 'week' => get_lang('Week'),
  64. 'day' => get_lang('Day'))));
  65. //see http://docs.jquery.com/UI/Datepicker/$.datepicker.formatDate
  66. $tpl->assign('js_format_date', 'D d M yy');
  67. $region_value = api_get_language_isocode();
  68. if ($region_value == 'en') {
  69. $region_value = 'en-GB';
  70. }
  71. $tpl->assign('region_value', $region_value);
  72. if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && api_is_allowed_to_session_edit(false,true)) {
  73. if ($type == 'course') {
  74. $actions = display_courseadmin_links();
  75. }
  76. $tpl->assign('actions', $actions);
  77. }
  78. //Calendar Type : course, admin, personal
  79. $tpl->assign('type', $type);
  80. //Calendar type label
  81. $tpl->assign('type_label', get_lang(ucfirst($type).'Calendar'));
  82. //Current user can add event?
  83. $tpl->assign('can_add_events', $can_add_events);
  84. //Setting AJAX caller
  85. $agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type;
  86. $tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);
  87. $course_code = api_get_course_id();
  88. if (api_is_allowed_to_edit() && $course_code != '-1' && $type == 'course') {
  89. $order = 'lastname';
  90. if (api_is_western_name_order) {
  91. $order = 'firstname';
  92. }
  93. $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order);
  94. $group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id());
  95. $agenda = new Agenda();
  96. $select = $agenda->construct_not_selected_select_form($group_list, $user_list);
  97. $tpl->assign('visible_to', $select);
  98. }
  99. //Loading Agenda template
  100. $content = $tpl->fetch('default/agenda/month.tpl');
  101. $tpl->assign('content', $content);
  102. //Loading main Chamilo 1 col template
  103. $tpl->display_one_col_template();