2011-10-04 00:50:10 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once ('../../lib/base.php');
|
2011-10-04 00:52:13 +04:00
|
|
|
OC_JSON::checkLoggedIn();
|
2011-10-04 00:50:10 +04:00
|
|
|
OC_Util::checkAppEnabled('calendar');
|
|
|
|
|
|
|
|
if($_GET["import"] == "existing"){
|
|
|
|
$calid = $_GET["calid"];
|
2011-12-19 01:58:20 +04:00
|
|
|
$calendar = OC_Calendar_App::getCalendar($calid);
|
2011-10-04 00:50:10 +04:00
|
|
|
if($_GET["path"] != ""){
|
|
|
|
$filename = $_GET["path"] . "/" . $_GET["file"];
|
|
|
|
}else{
|
|
|
|
$filename = "/" . $_GET["file"];
|
|
|
|
}
|
|
|
|
}else{
|
2011-10-08 15:28:01 +04:00
|
|
|
$id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname']);
|
2011-10-04 00:50:10 +04:00
|
|
|
OC_Calendar_Calendar::setCalendarActive($id, 1);
|
|
|
|
$calid = $id;
|
|
|
|
if($_POST["path"] != ""){
|
|
|
|
$filename = $_POST["path"] . "/" . $_POST["file"];
|
|
|
|
}else{
|
|
|
|
$filename = "/" . $_POST["file"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$vcalendar = OC_Filesystem::file_get_contents($filename);
|
|
|
|
$vcalendar = explode("BEGIN:VEVENT", $vcalendar);
|
|
|
|
for($i = 1;$i < count($vcalendar);$i++){
|
|
|
|
$vcalendar[$i] = "BEGIN:VEVENT" . $vcalendar[$i];
|
|
|
|
}
|
|
|
|
for($i = 1;$i < count($vcalendar) - 1;$i++){
|
|
|
|
$vcalendar[$i] = $vcalendar[$i] . "END:VCALENDAR";
|
|
|
|
}
|
|
|
|
for($i = 1;$i < count($vcalendar);$i++){
|
|
|
|
$vcalendar[$i] = $vcalendar[0] . $vcalendar[$i];
|
|
|
|
}
|
|
|
|
for($i = 1;$i < count($vcalendar);$i++){
|
|
|
|
OC_Calendar_Object::add($calid, $vcalendar[$i]);
|
|
|
|
}
|
|
|
|
OC_JSON::success();
|
2011-12-19 01:58:20 +04:00
|
|
|
?>
|