/** * This is the function that updates an agenda item. It does 3 things * 1. storethe start_date, end_date, title and message in the calendar_event table * 2. store the groups/users who this message is meant for in the item_property table * 3. modify the attachments (if needed) * @author Patrick Cool <*****@*****.**>, Ghent University * @author Julio Montoya Adding UTC support */ function store_edited_agenda_item($event_id, $id_attach, $file_comment) { // STEP 1: editing the calendar_event table // 1.a. some filtering of the input data $id = $event_id; $title = strip_tags(trim($_POST['title'])); // no html allowed in the title $content = trim($_POST['content']); $start_date = (int) $_POST['fyear'] . "-" . (int) $_POST['fmonth'] . "-" . (int) $_POST['fday'] . " " . (int) $_POST['fhour'] . ":" . (int) $_POST['fminute'] . ":00"; $end_date = (int) $_POST['end_fyear'] . "-" . (int) $_POST['end_fmonth'] . "-" . (int) $_POST['end_fday'] . " " . (int) $_POST['end_fhour'] . ":" . (int) $_POST['end_fminute'] . ":00"; $to = $_POST['selectedform']; if ($_POST['empty_end_date'] == 'on') { $end_date = "0000-00-00 00:00:00"; } $course_info = api_get_course_info(); $agendaObj = new Agenda(); if (empty($course_info)) { $agendaObj->type = 'personal'; } else { $agendaObj->set_course($course_info); $agendaObj->type = 'course'; if (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $event_id)) { return false; } if (!api_is_allowed_to_edit(null, true)) { return false; } } $all_day = isset($_REQUEST['all_day']) && !empty($_REQUEST['all_day']) ? 1 : 0; $agendaObj->edit_event($id, $start_date, $end_date, $all_day, $title, $content); if (empty($id_attach)) { add_agenda_attachment_file($file_comment, $id); } else { edit_agenda_attachment_file($file_comment, $id, $id_attach); } // step 3: update the attachments (=delete all and add those in the session update_added_resources("Agenda", $id); // return the message; Display::display_confirmation_message(get_lang("EditSuccess")); }
/** * This is the function that updates an agenda item. It does 3 things * 1. storethe start_date, end_date, title and message in the calendar_event table * 2. store the groups/users who this message is meant for in the item_property table * 3. modify the attachments (if needed) * @author Patrick Cool <*****@*****.**>, Ghent University * @author Julio Montoya Adding UTC support */ function store_edited_agenda_item($event_id, $id_attach, $file_comment) { // STEP 1: editing the calendar_event table // 1.a. some filtering of the input data $id = $event_id; $title = strip_tags(trim($_POST['title'])); // no html allowed in the title $content = trim($_POST['content']); $start_date = (int) $_POST['fyear'] . "-" . (int) $_POST['fmonth'] . "-" . (int) $_POST['fday'] . " " . (int) $_POST['fhour'] . ":" . (int) $_POST['fminute'] . ":00"; $end_date = (int) $_POST['end_fyear'] . "-" . (int) $_POST['end_fmonth'] . "-" . (int) $_POST['end_fday'] . " " . (int) $_POST['end_fhour'] . ":" . (int) $_POST['end_fminute'] . ":00"; $to = $_POST['selectedform']; if ($_POST['empty_end_date'] == 'on') { $end_date = "0000-00-00 00:00:00"; } $course_info = api_get_course_info(); $agendaObj = new Agenda(); if (empty($course_info)) { $agendaObj->type = 'personal'; } else { $agendaObj->set_course($course_info); $agendaObj->type = 'course'; if (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $event_id)) { return false; } if (!api_is_allowed_to_edit(null, true)) { return false; } } $all_day = isset($_REQUEST['all_day']) && !empty($_REQUEST['all_day']) ? 1 : 0; $agendaObj->edit_event($id, $start_date, $end_date, $all_day, null, $title, $content); if (empty($id_attach)) { add_agenda_attachment_file($file_comment, $id); } else { edit_agenda_attachment_file($file_comment, $id, $id_attach); } // step 2: editing the item_property table (=delete all and add the new destination users/groups) /*if ($edit_result = true) { // 2.a. delete everything for the users $sql_delete = "DELETE FROM ".$TABLE_ITEM_PROPERTY." WHERE c_id = $course_id AND ref='$id' AND tool='".TOOL_CALENDAR_EVENT."'"; $result = Database::query($sql_delete) or die(Database::error()); // 2.b. storing the new users/groups if (!is_null($to)) { // !is_null($to): when no user is selected we send it to everyone $send_to = separate_users_groups($to); // storing the selected groups if (is_array($send_to['groups'])) { foreach ($send_to['groups'] as $group) { api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), $group, '', $start_date, $end_date); } } // storing the selected users if (is_array($send_to['users'])) { foreach ($send_to['users'] as $user) { api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), '', $user, $start_date, $end_date); } } } else { // the message is sent to everyone, so we set the group to 0 api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), '', '', $start_date, $end_date); } }*/ // step 3: update the attachments (=delete all and add those in the session update_added_resources("Agenda", $id); // return the message; Display::display_confirmation_message(get_lang("EditSuccess")); }