/** * @NoAdminRequired */ public function newEvent() { $postRequestAll = $this->getParams(); $pStart = $this->params('viewstart'); $pEnd = $this->params('viewend'); // \OCP\Util::writeLog($this->appName,'foundDESCR '.$pStart.':'.$Start, \OCP\Util::DEBUG); $calId = $this->params('calendar'); $errarr = Object::validateRequest($postRequestAll); if ($errarr) { $errarr['status'] = 'error'; $response = new JSONResponse($errarr); return $response; } else { $vcalendar = Object::createVCalendarFromRequest($postRequestAll); $id = Object::add($calId, $vcalendar->serialize()); $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 = CalendarApp::generateEventOutput($editedEvent, $start, $end); $params = ['status' => 'success', 'data' => ['id' => $id, 'events' => $events]]; $response = new JSONResponse($params); return $response; } }
/** * @NoAdminRequired */ public function newEvent() { $postRequestAll = $this->getParams(); $pStart = $this->params('viewstart'); $pEnd = $this->params('viewend'); $calId = $this->params('calendar'); $errarr = Object::validateRequest($postRequestAll); if ($errarr) { $errarr['status'] = 'error'; $response = new JSONResponse($errarr); return $response; } else { $vcalendar = Object::createVCalendarFromRequest($postRequestAll); $id = Object::add($calId, $vcalendar->serialize()); $editedEvent = CalendarApp::getEventObject($id, false, false); $start = new \DateTime($pStart); $end = new \DateTime($pEnd); $events = CalendarApp::generateEventOutput($editedEvent, $start, $end); $params = ['status' => 'success', 'data' => ['id' => $id, 'events' => $events]]; $response = new JSONResponse($params); return $response; } }