/** * @NoAdminRequired */ public function deleteCalendar() { $calId = (int) $this->params('calendarid'); $del = CalendarCalendar::deleteCalendar($calId); if ($del === true) { $calendars = CalendarCalendar::allCalendars($this->userId, false, false, false); $bNewId = null; //\OCP\Util::writeLog($this->appName, 'DEL COUNT-> '.count($calendars).$calendars[0]['id'], \OCP\Util::DEBUG); if (\OCP\USER::isLoggedIn() && count($calendars) === 0) { $bNewId = CalendarCalendar::addDefaultCalendars($this->userId); } $params = ['status' => 'success', 'newid' => $bNewId]; } else { $params = ['status' => 'error']; } $response = new JSONResponse($params); return $response; }
/** * @NoAdminRequired */ public function importEventsPerDrop() { $pCalid = $this->params('calid'); $pAddCal = $this->params('addCal'); $pAddCalCol = $this->params('addCalCol'); $data = $this->params('data'); $data = explode(',', $data); $data = end($data); $data = base64_decode($data); $import = new Import($data); $import->setUserID($this->userId); $import->setTimeZone(CalendarApp::$tz); $import->disableProgressCache(); if (!$import->isValid()) { $params = ['status' => 'error', 'error' => 'notvalid']; $response = new JSONResponse($params); return $response; } if ($pCalid == 'newCal' && $pAddCal != '') { $calendars = CalendarCalendar::allCalendars($this->userId); foreach ($calendars as $calendar) { if ($calendar['displayname'] == $pAddCal) { $id = $calendar['id']; $newcal = false; break; } $newcal = true; } if ($newcal) { $id = CalendarCalendar::addCalendar($this->userId, strip_tags($pAddCal), 'VEVENT,VTODO,VJOURNAL', null, 0, strip_tags($pAddCalCol)); CalendarCalendar::setCalendarActive($id, 1); } } else { $id = $pCalid; $calendar = CalendarApp::getCalendar($id); if ($calendar['userid'] != $this->userId) { $params = ['status' => 'error', 'error' => 'missingcalendarrights']; $response = new JSONResponse($params); return $response; } } $import->setOverwrite(false); $import->setCalendarID($id); $import->import(); $count = $import->getCount(); if ($count == 0) { CalendarCalendar::deleteCalendar($id); $params = ['status' => 'error', 'message' => $this->l10n->t('The file contained either no events or all events are already saved in your calendar.')]; $response = new JSONResponse($params); return $response; } else { $newcalendarname = strip_tags($pAddCal); if ($pAddCal != '') { $params = ['status' => 'success', 'message' => $count . ' ' . $this->l10n->t('events has been saved in the new calendar') . ' ' . $newcalendarname, 'eventSource' => CalendarCalendar::getEventSourceInfo(CalendarCalendar::find($id))]; $response = new JSONResponse($params); return $response; } else { $params = ['status' => 'success', 'message' => $count . ' ' . $this->l10n->t('events has been saved in the calendar') . ' ' . $calendar['displayname'], 'eventSource' => '']; $response = new JSONResponse($params); return $response; } } }
/** * @NoAdminRequired */ public function deleteCalendar() { $calId = (int) $this->params('calendarid'); $del = CalendarCalendar::deleteCalendar($calId); if ($del === true) { $params = ['status' => 'success']; } else { $params = ['status' => 'error']; } $response = new JSONResponse($params); return $response; }
/** * Delete a calendar and all it's objects * * @param string $calendarId * @return void */ public function deleteCalendar($calendarId) { if (preg_match('=iCal/[1-4]?.*Mac OS X/10.[1-6](.[0-9])?=', $_SERVER['HTTP_USER_AGENT'])) { //throw new \Sabre\DAV\Exception\Forbidden("Action is not possible with OSX 10.6.x", 403); } //\OCP\Util::writeLog('calendar', 'DEL ID-> '.$calendarId, \OCP\Util::DEBUG); CalendarCalendar::deleteCalendar($calendarId); return true; }