<?php /** * Copyright (c) 2012 Georg Ehrke <*****@*****.**> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ $data = $_POST['data']; $data = explode(',', $data); $data = end($data); $data = base64_decode($data); OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); $import = new OC_Calendar_Import($data); $import->setUserID(OCP\User::getUser()); $import->setTimeZone(OC_Calendar_App::$tz); $import->disableProgressCache(); if (!$import->isValid()) { OCP\JSON::error(); exit; } $newcalendarname = strip_tags($import->createCalendarName()); $newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(), $newcalendarname, 'VEVENT,VTODO,VJOURNAL', null, 0, $import->createCalendarColor()); $import->setCalendarID($newid); $import->import(); $count = $import->getCount(); if ($count == 0) { OC_Calendar_Calendar::deleteCalendar($newid); OCP\JSON::error(array('message' => OC_Calendar_App::$l10n->t('The file contained either no events or all events are already saved in your calendar.'))); } else {
* See the COPYING-README file. */ OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); OCP\JSON::callCheck(); session_write_close(); if (isset($_POST['progresskey']) && isset($_POST['getprogress'])) { echo OCP\JSON::success(array('percent' => OC_Cache::get($_POST['progresskey']))); exit; } $file = \OC\Files\Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); if (!$file) { OCP\JSON::error(array('error' => '404')); } $file = Sabre\VObject\StringUtil::convertToUTF8($file); $import = new OC_Calendar_Import($file); $import->setUserID(OCP\User::getUser()); $import->setTimeZone(OC_Calendar_App::$tz); $import->enableProgressCache(); $import->setProgresskey($_POST['progresskey']); if (!$import->isValid()) { OCP\JSON::error(array('error' => 'notvalid')); exit; } $newcal = false; if ($_POST['method'] == 'new') { $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser()); foreach ($calendars as $calendar) { if ($calendar['displayname'] == $_POST['calname']) { $id = $calendar['id']; $newcal = false;
$path = (string) $argv[1]; $userid = (string) $argv[2]; $calendarid = (int) $argv[3]; $tz = (string) $argv[4]; } //it's not necessary to load all apps $RUNTIME_NOAPPS = true; require_once OCROOT . '/lib/base.php'; //set userid OC_User::setUserId($userid); //get content of calendar file $ics = file_get_contents($path); //check if calendar app is enabled and load calendar scripts OC_Util::checkAppEnabled('calendar'); OC_App::loadApp('calendar'); //delete all old calendar entries $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*clndr_objects` WHERE `calendarid` = ?'); $stmt->execute(array($calendarid)); //initialize a new import object $import = new OC_Calendar_Import($ics); $import->setCalendarID($calendarid); $import->setProgresskey(false); $import->setTimeZone($tz); //import calendar try { $import->import(); $count = $import->getCount(); echo "imported " . $count . " objects in calendar\n"; } catch (Exception $e) { echo "import failed: " . $e; }
<?php //Prerendering for iCalendar file $file = \OC\Files\Filesystem::file_get_contents($_['path'] . '/' . $_['filename']); if (!$file) { OCP\JSON::error(array('error' => '404')); } $import = new OC_Calendar_Import($file); $import->setUserID(OCP\User::getUser()); $newcalendarname = OCP\Util::sanitizeHTML($import->createCalendarName()); $guessedcalendarname = OCP\Util::sanitizeHTML($import->guessCalendarName()); $calendarcolor = OCP\Util::sanitizeHTML($import->createCalendarColor()); //loading calendars for select box $calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); $calendar_options[] = array('id' => 'newcal', 'displayname' => $l->t('create a new calendar')); $defaultcolors = OC_Calendar_Calendar::getCalendarColorOptions(); ?> <div id="calendar_import_dialog" title="<?php p($l->t("Import a calendar file")); ?> "> <div id="calendar_import_form"> <form> <input type="hidden" id="calendar_import_filename" value="<?php p($_['filename']); ?> "> <input type="hidden" id="calendar_import_path" value="<?php p($_['path']); ?> ">
<?php //Prerendering for iCalendar file $file = OC_Filesystem::file_get_contents($_['path'] . '/' . $_['filename']); if (!$file) { OCP\JSON::error(array('error' => '404')); } $import = new OC_Calendar_Import($file); $import->setUserID(OCP\User::getUser()); $newcalendarname = strip_tags($import->createCalendarName()); $guessedcalendarname = strip_tags($import->guessCalendarName()); $calendarcolor = strip_tags($import->createCalendarColor()); //loading calendars for select box $calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser()); $calendar_options[] = array('id' => 'newcal', 'displayname' => $l->t('create a new calendar')); $defaultcolors = OC_Calendar_Calendar::getCalendarColorOptions(); ?> <div id="calendar_import_dialog" title="<?php echo $l->t("Import a calendar file"); ?> "> <div id="calendar_import_form"> <form> <input type="hidden" id="calendar_import_filename" value="<?php echo $_['filename']; ?> "> <input type="hidden" id="calendar_import_path" value="<?php echo $_['path']; ?> ">