agenda_js.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. $htmlHeadXtra[] = api_get_jquery_ui_js();
  15. $htmlHeadXtra[] = api_get_js('qtip2/jquery.qtip.min.js');
  16. $htmlHeadXtra[] = api_get_js('fullcalendar/fullcalendar.min.js');
  17. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/fullcalendar/fullcalendar.css');
  18. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/qtip2/jquery.qtip.min.css');
  19. $type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
  20. if (api_is_platform_admin() && $type == 'admin') {
  21. $type = 'admin';
  22. }
  23. //if (api_get_course_id() != -1 && $type == 'course') {
  24. if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) {
  25. $type = 'course';
  26. }
  27. switch($type) {
  28. case 'admin':
  29. $this_section = SECTION_PLATFORM_ADMIN;
  30. break;
  31. case 'course':
  32. $this_section = SECTION_COURSES;
  33. break;
  34. case 'personal':
  35. $this_section = SECTION_MYAGENDA;
  36. break;
  37. }
  38. $tpl = new Template(get_lang('Agenda'));
  39. $can_add_events = 0;
  40. if (api_is_platform_admin() && $type == 'admin') {
  41. $can_add_events = 1;
  42. }
  43. if (api_is_allowed_to_edit() && $type == 'course') {
  44. $can_add_events = 1;
  45. }
  46. if (!api_is_anonymous() && $type == 'personal') {
  47. $can_add_events = 1;
  48. }
  49. //Setting translations
  50. $day_short = api_get_week_days_short();
  51. $days = api_get_week_days_long();
  52. $months = api_get_months_long();
  53. $months_short = api_get_months_short();
  54. //Setting calendar translations
  55. $tpl->assign('month_names', json_encode($months));
  56. $tpl->assign('month_names_short', json_encode($months_short));
  57. $tpl->assign('day_names', json_encode($days));
  58. $tpl->assign('day_names_short', json_encode($day_short));
  59. $tpl->assign('button_text', json_encode(array( 'today' => get_lang('Today'),
  60. 'month' => get_lang('Month'),
  61. 'week' => get_lang('Week'),
  62. 'day' => get_lang('Day'))));
  63. //Calendar Type : course, admin, personal
  64. $tpl->assign('type', $type);
  65. //Calendar type label
  66. $tpl->assign('type_label', get_lang($type.'Calendar'));
  67. //Current user can add event?
  68. $tpl->assign('can_add_events', $can_add_events);
  69. //Setting AJAX caller
  70. $agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type.'&';
  71. $tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);
  72. //Loading Agenda template
  73. $content = $tpl->fetch('default/agenda/month.tpl');
  74. $tpl->assign('content', $content);
  75. //Loading main Chamilo 1 col template
  76. $template_file = $tpl->get_template('layout/layout_1_col.tpl');
  77. $tpl->display($template_file);