agenda_list.php 2.3 KB

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