agenda_js.php 4.6 KB

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