public function update_event() { if (!isset($_POST['save'])) { Flash::set('error', __('Could not update this event!')); } else { use_helper('Kses'); /* Prepare the data */ $data = $_POST['event']; if (isset($data['id'])) { $data['id'] = kses(trim($data['id']), array()); } $event = new CalendarEvent(); if (isset($data['id'])) { $event->id = $data['id']; $event->created_by_id = $data['created_by_id']; } $event->title = $data['title']; $event->date_from = $data['date_from']; $event->date_to = $data['date_to']; $event->description = $data['description']; /* Check data and, if correct, save to DB */ if ($event->checkData() && $event->save()) { if (isset($data['id'])) { Flash::set('success', __('The event has been updated.')); } else { Flash::set('success', __('A new event has been created.')); } redirect(get_url('plugin/calendar/events')); } else { Flash::setNow('error', __('There are errors in the form.')); $this->display(CALENDAR_VIEWS . '/update', array('event' => $event)); } } }