/** * @NoAdminRequired */ public function editEvent() { $id = (int) $this->params('id'); $pStart = $this->params('viewstart'); $pEnd = $this->params('viewend'); $postRequestAll = $this->getParams(); $calId = (int) $this->params('calendar'); $lastmodified = $this->params('lastmodified'); if (!array_key_exists('calendar', $postRequestAll)) { $calId = (int) Object::getCalendarid($id); } $errarr = $this->objectParser->validateRequest($postRequestAll); if ($errarr) { $errarr['status'] = 'error'; $response = new JSONResponse($errarr); return $response; } else { $data = CalendarApp::getEventObject($id, false, false); $vcalendar = VObject::parse($data['calendardata']); CalendarApp::isNotModified($vcalendar->VEVENT, $lastmodified); $this->objectParser->updateVCalendarFromRequest($postRequestAll, $vcalendar); Object::edit($id, $vcalendar->serialize()); if ((int) $data['calendarid'] !== $calId) { Object::moveToCalendar($id, $calId); } $editedEvent = CalendarApp::getEventObject($id, false, false); if (stristr($pStart, '(')) { $temp = explode('(', $pStart); $pStart = $temp[0]; } if (stristr($pEnd, '(')) { $temp = explode('(', $pEnd); $pEnd = $temp[0]; } $start = new \DateTime($pStart); $end = new \DateTime($pEnd); $events = $this->generateEventOutput($editedEvent, $start, $end); $params = ['status' => 'success', 'data' => ['id' => $id, 'events' => $events]]; $response = new JSONResponse($params); return $response; } }