agenda_list.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.calendar
  5. */
  6. // name of the language file that needs to be included
  7. $language_file = array('agenda', 'group', 'announcements');
  8. require_once '../inc/global.inc.php';
  9. require_once 'agenda.inc.php';
  10. $interbreadcrumb[] = array(
  11. 'url' => api_get_path(WEB_CODE_PATH) . "calendar/agenda_js.php",
  12. 'name' => get_lang('Agenda')
  13. );
  14. $agenda = new Agenda();
  15. $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
  16. $agenda->setType($type);
  17. $events = $agenda->get_events(
  18. null,
  19. null,
  20. api_get_course_int_id(),
  21. api_get_group_id(),
  22. null,
  23. 'array'
  24. );
  25. $this_section = SECTION_MYAGENDA;
  26. if (!empty($GLOBALS['_cid']) && $GLOBALS['_cid'] != -1) {
  27. // Agenda is inside a course tool
  28. $url = api_get_self() . '?' . api_get_cidreq();
  29. $this_section = SECTION_COURSES;
  30. } else {
  31. // Agenda is out of the course tool (e.g personal agenda)
  32. $url = false;
  33. foreach ($events as &$event) {
  34. $event['url'] = api_get_self() . '?cid=' . $event['course_id'] .
  35. '&type=' . $event['type'];
  36. }
  37. }
  38. $tpl = new Template(get_lang('Events'));
  39. $tpl->assign('agenda_events', $events);
  40. $actions = $agenda->displayActions('list');
  41. $tpl->assign('url', $url);
  42. $tpl->assign('actions', $actions);
  43. $tpl->assign('is_allowed_to_edit', api_is_allowed_to_edit());
  44. if (api_is_allowed_to_edit()) {
  45. if (isset($_GET['action']) && $_GET['action'] == 'change_visibility') {
  46. $courseInfo = api_get_course_info();
  47. if (empty($courseInfo)) {
  48. // This happens when list agenda is not inside a course
  49. if (
  50. ($type == 'course' || $type == 'session') &&
  51. isset($_GET['cid']) &&
  52. intval($_GET['cid']) !== 0
  53. ) {
  54. // For course and session event types
  55. // Just needs course ID
  56. $courseInfo = array('real_id' => intval($_GET['cid']));
  57. $agenda->changeVisibility($_GET['id'], $_GET['visibility'], $courseInfo);
  58. } else {
  59. // personal and admin do not have visibility property
  60. }
  61. }
  62. header('Location: '. api_get_self());
  63. exit;
  64. }
  65. }
  66. // Loading Agenda template
  67. $content = $tpl->fetch('default/agenda/event_list.tpl');
  68. $tpl->assign('content', $content);
  69. // Loading main Chamilo 1 col template
  70. $tpl->display_one_col_template();