if (empty($_GET['id'])) { api_not_allowed(); } $id = explode('_', $_GET['id']); $type = $id[0]; $id = $id[1]; $agenda = new Agenda(); $agenda->type = $type; //course,admin or personal if (isset($_GET['course_id'])) { $course_info = api_get_course_info_by_id($_GET['course_id']); if (!empty($course_info)) { $agenda->set_course($course_info); } } $event = $agenda->get_event($id); if (!empty($event)) { define('ICAL_LANG', api_get_language_isocode()); $ical = new vcalendar(); $ical->setConfig('unique_id', api_get_path(WEB_PATH)); $ical->setProperty('method', 'PUBLISH'); $ical->setConfig('url', api_get_path(WEB_PATH)); $vevent = new vevent(); switch ($_GET['class']) { case 'public': $vevent->setClass('PUBLIC'); break; case 'private': $vevent->setClass('PRIVATE'); break; case 'confidential':
/** * Show the form for adding a new agenda item. This is the same function that is used whenever we are editing an * agenda item. When the id parameter is empty (default behaviour), then we show an empty form, else we are editing and * we have to retrieve the information that is in the database and use this information in the forms. * @author Patrick Cool <*****@*****.**>, Ghent University * @param integer id, the id of the agenda item we are editing. By default this is empty which means that we are adding an * agenda item. * @deprecated */ function show_add_form($id = '', $type = null) { $htmlHeadXtra[] = to_javascript(); $course_info = null; $agendaObj = new Agenda(); // if the id is set then we are editing an agenda item if (!empty($id)) { $course_info = api_get_course_info(); if (!empty($course_info)) { $agendaObj->set_course($course_info); $agendaObj->type = 'course'; } else { if (api_is_platform_admin() && $type == 'platform') { $agendaObj->type = 'admin'; } else { $agendaObj->type = 'personal'; } } $agendaItem = $agendaObj->get_event($id); $title = $agendaItem['title']; $content = $agendaItem['description']; // start date if ($agendaItem['start_date'] != '0000-00-00 00:00:00') { $agendaItem['start_date'] = api_get_local_time($agendaItem['start_date']); list($datepart, $timepart) = explode(" ", $agendaItem['start_date']); list($year, $month, $day) = explode("-", $datepart); list($hours, $minutes, $seconds) = explode(":", $timepart); } // end date if (!empty($agendaItem['end_date']) && $agendaItem['end_date'] != '0000-00-00 00:00:00') { $agendaItem['end_date'] = api_get_local_time($agendaItem['end_date']); list($datepart, $timepart) = explode(" ", $agendaItem['end_date']); list($end_year, $end_month, $end_day) = explode("-", $datepart); list($end_hours, $end_minutes, $end_seconds) = explode(":", $timepart); } else { if ($agendaItem['all_day']) { $end_year = $year; $end_month = $month; $end_day = $day; $end_hours = $hours; $end_minutes = $minutes; $end_seconds = $seconds; } } // attachments //edit_added_resources("Agenda", $id); //$to = $item_2_edit['to']; } else { $to = load_edit_users(TOOL_CALENDAR_EVENT, $id); } // we start a completely new item, we do not come from the resource linker if (isset($_GET['originalresource']) && $_GET['originalresource'] !== "no" and $_GET['action'] == "add") { $_SESSION["formelements"] = null; unset_session_resources(); } $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null; $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null; $idAttach = isset($_GET['id_attach']) ? Security::remove_XSS($_GET['id_attach']) : null; $course_url = empty($course_info) ? null : api_get_cidreq(); $id = isset($id) ? intval($id) : null; $url = api_get_self() . '?type=' . Security::remove_XSS($type) . '&origin=' . $origin . '&' . $course_url . '&sort=asc&toolgroup=' . api_get_group_id() . '&action=' . Security::remove_XSS($_GET['action']); $form = new FormValidator('new_calendar_item', 'post', $url, null, array('enctype' => 'multipart/form-data')); $form->addElement('hidden', 'id', $id); $form->addElement('hidden', 'action', $action); $form->addElement('hidden', 'id_attach', $idAttach); $form->addElement('hidden', 'sort', 'asc'); $form->addElement('hidden', 'submit_event', 'ok'); // The form title if (isset($id) and $id != '') { $form_title = get_lang('ModifyCalendarItem'); } else { $form_title = get_lang('AddCalendarItem'); } $form->addElement('header', $form_title); $form->addElement('text', 'title', get_lang('ItemTitle')); // selecting the users / groups $group_id = api_get_group_id(); if (empty($id)) { if (isset($group_id) && !empty($group_id)) { $form->addElement('hidden', 'selected_form[0]', "GROUP:'.{$group_id}.'"); $form->addElement('hidden', 'To', 'true'); //$form .= '<input type="hidden" name="selected_form[0]" value="GROUP:'.$group_id.'"/>'; //$form .= '<input type="hidden" name="To" value="true"/>'; } else { $agendaObj->show_to_form($form, $to); } } // start date and time $form->addElement('text', 'start_date', get_lang('StartDate')); $form->addElement('text', 'end_date', get_lang('EndDate')); // Repeating the calendar item if (empty($id)) { $form->addElement('label', null, '<a href="javascript://" onclick="return plus_repeated_event();"><span id="plus2"> <img style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> ' . get_lang('RepeatEvent') . '</span> </a>'); $form->addElement('html', '<div id="options2" style="display: none;">'); $form->addElement('checkbox', 'repeat', get_lang('RepeatEvent')); $form->addElement('select', 'repeat_type', get_lang('RepeatType'), $agendaObj->getRepeatTypes()); $form->addElement('text', 'repeat_end_day', get_lang('RepeatEnd')); $form->addElement('html', '</div>'); } if (isset($agendaItem['all_day'])) { $checked = null; if ($agendaItem['all_day']) { $checked = 'checked'; } $form->addElement('checkbox', 'all_day', get_lang('AllDay')); } $form->addElement('html_editor', 'content', get_lang('Description')); $form->addElement('checkbox', 'add_announcement', get_lang('AddAnnouncement') . ' (' . get_lang('SendMail') . ')'); if ($agendaObj->type == 'course') { // File attachment $form->addElement('file', 'user_upload', get_lang('AddAnAttachment')); $form->addElement('textarea', 'file_comment', get_lang('Comment')); $form->add_progress_bar(); } if (isset($_GET['id'])) { $text = get_lang('ModifyEvent'); } else { $text = get_lang('AgendaAdd'); } $form->addElement('button', 'submit', $text); return $form->return_form(); }
$endDate = substr($values['repeat_end_day'], 0, 10) . ' 23:59:59'; $agenda->addRepeatedItem($eventId, $values['repeat_type'], $endDate, $values['users_to_send']); } Display::return_message(get_lang('AddSuccess'), 'confirmation'); if ($sendEmail) { Display::return_message(get_lang('AdditionalMailWasSentToSelectedUsers'), 'confirmation'); } header("Location: {$agendaUrl}"); exit; } else { $content = $form->return_form(); } break; case 'edit': $actionName = get_lang('Edit'); $event = $agenda->get_event($eventId); if (empty($event)) { api_not_allowed(true); } $event['action'] = 'edit'; $event['id'] = $eventId; $form = $agenda->getForm($event); if ($form->validate()) { $values = $form->getSubmitValues(); $allDay = isset($values['all_day']) ? 'true' : 'false'; $startDate = $values['date_range_start']; $endDate = $values['date_range_end']; $sendAttachment = isset($_FILES['user_upload']) ? true : false; $attachment = $sendAttachment ? $_FILES['user_upload'] : null; $attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null; $comment = isset($values['comment']) ? $values['comment'] : null;
/** * Show the form for adding a new agenda item. This is the same function that is used whenever we are editing an * agenda item. When the id parameter is empty (default behaviour), then we show an empty form, else we are editing and * we have to retrieve the information that is in the database and use this information in the forms. * @author Patrick Cool <*****@*****.**>, Ghent University * @param integer id, the id of the agenda item we are editing. By default this is empty which means that we are adding an * agenda item. */ function show_add_form($id = '', $type = null) { $showImg = Display::return_icon('div_show.gif'); $hideImg = Display::return_icon('div_hide.gif'); $MonthsLong = api_get_months_long(); $htmlHeadXtra[] = to_javascript(); // the default values for the forms if (!isset($_GET['originalresource'])) { $day = date('d'); $month = date('m'); $year = date('Y'); $hours = 9; $minutes = '00'; $title = null; $content = null; $repeat = false; } else { // we are coming from the resource linker so there might already have been some information in the form. // When we clicked on the button to add resources we stored every form information into a session and now we // are doing the opposite thing: getting the information out of the session and putting it into variables to // display it in the forms. $title = $form_elements['title']; $content = $form_elements['content']; $id = $form_elements['id']; $to = $form_elements['to']; $repeat = $form_elements['repeat']; } // switching the send to all/send to groups/send to users if (isset($_POST['To']) && $_POST['To']) { $day = $_POST['fday']; $month = $_POST['fmonth']; $year = $_POST['fyear']; $hours = $_POST['fhour']; $minutes = $_POST['fminute']; $end_day = $_POST['end_fday']; $end_month = $_POST['end_fmonth']; $end_year = $_POST['end_fyear']; $end_hours = $_POST['end_fhour']; $end_minutes = $_POST['end_fminute']; $title = $_POST['title']; $content = $_POST['content']; // the invisible fields $action = $_POST['action']; $id = $_POST['id']; $repeat = !empty($_POST['repeat']) ? true : false; } $default_no_empty_end_date = 0; $course_info = null; // if the id is set then we are editing an agenda item if (!empty($id)) { $course_info = api_get_course_info(); $agendaObj = new Agenda(); if (!empty($course_info)) { $agendaObj->set_course($course_info); $agendaObj->type = 'course'; } else { if (api_is_platform_admin() && $type == 'platform') { $agendaObj->type = 'admin'; } else { $agendaObj->type = 'personal'; } } $agendaItem = $agendaObj->get_event($id); $title = $agendaItem['title']; $content = $agendaItem['description']; // start date if ($agendaItem['start_date'] != '0000-00-00 00:00:00') { $agendaItem['start_date'] = api_get_local_time($agendaItem['start_date']); list($datepart, $timepart) = explode(" ", $agendaItem['start_date']); list($year, $month, $day) = explode("-", $datepart); list($hours, $minutes, $seconds) = explode(":", $timepart); } // end date if (!empty($agendaItem['end_date']) && $agendaItem['end_date'] != '0000-00-00 00:00:00') { $agendaItem['end_date'] = api_get_local_time($agendaItem['end_date']); list($datepart, $timepart) = explode(" ", $agendaItem['end_date']); list($end_year, $end_month, $end_day) = explode("-", $datepart); list($end_hours, $end_minutes, $end_seconds) = explode(":", $timepart); } } else { $to = load_edit_users(TOOL_CALENDAR_EVENT, $id); } $content = stripslashes($content); $title = stripslashes($title); $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null; $course_url = empty($course_info) ? null : api_get_cidreq(); // The form title if (isset($id) and $id != '') { $form_title = get_lang('ModifyCalendarItem'); } else { $form_title = get_lang('AddCalendarItem'); } $url = api_get_self() . '?type=' . Security::remove_XSS($type) . '&origin=' . $origin . '&' . $course_url . "&sort=asc&toolgroup=" . api_get_group_id() . '&action=' . Security::remove_XSS($_GET['action']); $idAttach = isset($_REQUEST['id_attach']) ? intval($_REQUEST['id_attach']) : null; $form = new FormValidator('new_calendar_item', 'post', $url, array('enctype' => 'multipart/form-data')); $form->addElement('header', $form_title); $form->addElement('hidden', 'id', $id); $form->addElement('hidden', 'action', Security::remove_XSS($_GET['action'])); $form->addElement('hidden', 'id_attach', $idAttach); $form->addElement('hidden', 'sort', 'asc'); $form->addElement('hidden', 'submit_event', 'ok'); $form->addElement('text', 'title', get_lang('ItemTitle')); // selecting the users / groups $group_id = api_get_group_id(); if (empty($id)) { CourseManager::addUserGroupMultiSelect($form, array()); } $form->addElement('datepicker', 'start_date', get_lang('StartDate'), array('form_name' => $form->getAttribute('name'))); $form->addElement('datepicker', 'end_date', get_lang('EndDate'), array('form_name' => $form->getAttribute('name'))); // Repeating the calendar item if (empty($id)) { $form->addElement('label', null, ' <a href="javascript://" onclick="return plus_repeated_event();"> <span id="plus2"> ' . $showImg . ' ' . get_lang('RepeatEvent') . ' </span></a>'); $form->addElement('html', '<div id="options2" style="display:none">'); $form->addElement('checkbox', 'repeat', null, get_lang('RepeatEvent')); $options = array('daily' => get_lang('RepeatDaily'), 'weekly' => get_lang('RepeatWeekly'), 'monthlyByDate' => get_lang('RepeatMonthlyByDate'), 'yearly' => get_lang('RepeatYearly')); $form->addElement('select', 'repeat_type', get_lang('RepeatType'), $options); $form->addElement('datepicker', 'repeat_end_day', get_lang('RepeatEnd')); $form->addElement('html', '</div>'); if (isset($agendaItem['all_day'])) { $checked = null; if ($agendaItem['all_day']) { $checked = 'checked'; } $form->addElement('checkbox', 'all_day', null, get_lang('AllDay')); } $form->addElement('html_editor', 'content', get_lang('Description')); if (isset($agendaObj) && $agendaObj->type == 'course') { $form->addElement('file', 'user_upload', null, get_lang('AddAnAttachment')); $form->addElement('text', 'file_comment', null, get_lang('Comment')); } if (isset($_GET['id'])) { $class = 'save'; $text = get_lang('ModifyEvent'); } else { $class = 'add'; $text = get_lang('AgendaAdd'); } $form->addElement('button', 'submit', $text); $form->display(); } }