server/apps/calendar/ajax/import/dropimport.php

26 lines
1 KiB
PHP
Raw Normal View History

2012-05-13 13:05:57 +00:00
<?php
2012-06-30 13:17:29 +00:00
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
2012-05-13 13:05:57 +00:00
$data = $_POST['data'];
$data = explode(',', $data);
$data = end($data);
$data = base64_decode($data);
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
2012-06-30 13:17:29 +00:00
$import = new OC_Calendar_Import($data);
2012-06-30 20:08:30 +00:00
$import->setUserID(OCP\User::getUser());
2012-06-30 13:17:29 +00:00
$import->setTimeZone(OC_Calendar_App::$tz);
$import->disableProgressCache();
if(!$import->isValid()){
OCP\JSON::error();
exit;
2012-05-13 13:05:57 +00:00
}
2012-06-30 20:26:29 +00:00
$newcalendarname = strip_tags($import->createCalendarName());
$newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(),$newcalendarname,'VEVENT,VTODO,VJOURNAL',null,0,$import->createCalendarColor());
2012-06-30 13:17:29 +00:00
$import->setCalendarID($newid);
$import->import();
2012-06-30 20:26:29 +00:00
OCP\JSON::success(array('newcalendarname'=>$newcalendarname, 'count'=>$import->getCount(), 'newcalendarid'=>$newid, 'eventSource'=>OC_Calendar_Calendar::getEventSourceInfo(OC_Calendar_Calendar::find($newid))));