if (!api_is_allowed_to_edit(null, true) && $type == 'course') { break; } $day_delta = $_REQUEST['day_delta']; $minute_delta = $_REQUEST['minute_delta']; $id = explode('_', $_REQUEST['id']); $id = $id[1]; $agenda->move_event($id, $day_delta, $minute_delta); break; case 'get_events': $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null; if (substr($user_id, 0, 1) == 'G') { $length = strlen($user_id); $group_id = substr($user_id, 2, $length - 1); } $events = $agenda->get_events($_REQUEST['start'], $_REQUEST['end'], api_get_course_int_id(), $group_id, $user_id); echo $events; break; case 'get_user_agenda': //Used in the admin user list api_protect_admin_script(); if (api_is_allowed_to_edit(null, true)) { //@todo move this in the agenda class $DaysShort = api_get_week_days_short(); $MonthsLong = api_get_months_long(); $user_id = intval($_REQUEST['user_id']); $my_course_list = CourseManager::get_courses_list_by_user_id($user_id, true); if (!is_array($my_course_list)) { // this is for the special case if the user has no courses (otherwise you get an error) $my_course_list = array(); }
<?php /* For licensing terms, see /license.txt */ /** * @package chamilo.calendar */ // name of the language file that needs to be included $language_file = array('agenda', 'group', 'announcements'); require_once '../inc/global.inc.php'; require_once 'agenda.lib.php'; require_once 'agenda.inc.php'; $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . "calendar/agenda_js.php", 'name' => get_lang('Agenda')); $agenda = new Agenda(); $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null; $agenda->setType($type); $events = $agenda->get_events(null, null, api_get_course_int_id(), api_get_group_id(), null, 'array'); $this_section = SECTION_MYAGENDA; if (!empty($GLOBALS['_cid']) && $GLOBALS['_cid'] != -1) { // Agenda is inside a course tool // Little hack to sort the events by start date in personal agenda (Agenda events List view - See #8014) usort($events, function ($a, $b) { $t1 = strtotime($a['start']); $t2 = strtotime($b['start']); return $t1 - $t2; }); $url = false; foreach ($events as &$event) { $event['url'] = api_get_self() . '?cid=' . $event['course_id'] . '&type=' . $event['type']; } $url = api_get_self() . '?' . api_get_cidreq(); $this_section = SECTION_COURSES;
break; } $day_delta = $_REQUEST['day_delta']; $minute_delta = $_REQUEST['minute_delta']; $id = explode('_', $_REQUEST['id']); $id = $id[1]; $agenda->move_event($id, $day_delta, $minute_delta); break; case 'get_events': $filter = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : null; $result = $agenda->parseAgendaFilter($filter); $groupId = current($result['groups']); $userId = current($result['users']); $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : null; $end = isset($_REQUEST['end']) ? $_REQUEST['end'] : null; $events = $agenda->get_events($start, $end, api_get_course_int_id(), $groupId, $userId); echo $events; break; case 'get_user_agenda': //Used in the admin user list api_protect_admin_script(); if (api_is_allowed_to_edit(null, true)) { //@todo move this in the agenda class $DaysShort = api_get_week_days_short(); $MonthsLong = api_get_months_long(); $user_id = intval($_REQUEST['user_id']); $my_course_list = CourseManager::get_courses_list_by_user_id($user_id, true); if (!is_array($my_course_list)) { // this is for the special case if the user has no courses (otherwise you get an error) $my_course_list = array(); }