/** * It's used for editing attendace, * render to attendance_edit or attendance_list view * @param int attendance id */ public function attendance_edit($attendance_id) { $attendance = new Attendance(); $data = array(); $attendance_id = intval($attendance_id); if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { if (!empty($_POST['title'])) { $check = Security::check_token(); if ($check) { $attendance->set_name($_POST['title']); $attendance->set_description($_POST['description']); $attendance->set_attendance_qualify_title($_POST['attendance_qualify_title']); $attendance->set_attendance_weight($_POST['attendance_weight']); $attendance->category_id = $_POST['category_id']; $link_to_gradebook = false; if (isset($_POST['attendance_qualify_gradebook']) && $_POST['attendance_qualify_gradebook'] == 1) { $link_to_gradebook = true; } $last_id = $attendance->attendance_edit($attendance_id, $link_to_gradebook); Security::clear_token(); $param_gradebook = ''; if (isset($_SESSION['gradebook'])) { $param_gradebook = '&gradebook=' . Security::remove_XSS($_SESSION['gradebook']); } header('location:index.php?action=attendance_list&' . api_get_cidreq() . $param_gradebook); exit; } } else { $data['attendance_id'] = $_POST['attendance_id']; $data['error'] = true; $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('attendance_edit'); $this->view->render(); } } else { // default values $attendance_data = $attendance->get_attendance_by_id($attendance_id); $data['attendance_id'] = $attendance_data['id']; $data['title'] = $attendance_data['name']; $data['description'] = $attendance_data['description']; $data['attendance_qualify_title'] = $attendance_data['attendance_qualify_title']; $data['attendance_weight'] = $attendance_data['attendance_weight']; $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('attendance_edit'); $this->view->render(); } }