/** * this function is store the modified resources * first we delete all the added resources in the database, * then we add all the resources from the session object. */ function update_added_resources($type, $id) { $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); $course_id = api_get_course_int_id(); $id = intval($id); $type = Database::escape_string($type); // delete all the added resources for this item in the database; $sql="DELETE FROM $TABLERESOURCE WHERE c_id = $course_id AND source_type='$type' AND source_id='$id'"; //echo $sql; Database::query($sql); // store the resources from the session into the database store_resources($type, $id); //delete_added_resource_($type, $id); unset_session_resources(); }
/** * this function is store the modified resources * first we delete all the added resources in the database, * then we add all the resources from the session object. */ function update_added_resources($type, $id) { global $_course; $course_id = api_get_course_int_id(); $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES); // delete all the added resources for this item in the database; $sql = "DELETE FROM {$TABLERESOURCE} WHERE c_id = {$course_id} AND source_type='{$type}' AND source_id='{$id}'"; //echo $sql; Database::query($sql); // Store the resources from the session into the database. store_resources($type, $id); //delete_added_resource_($type, $id); unset_session_resources(); }
/** * 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(); }