diff --git a/apps/calendar/ajax/importdialog.php b/apps/calendar/ajax/importdialog.php
new file mode 100644
index 00000000000..232b4ba5807
--- /dev/null
+++ b/apps/calendar/ajax/importdialog.php
@@ -0,0 +1,20 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+require_once('../../../lib/base.php');
+
+$l10n = new OC_L10N('calendar');
+
+if(!OC_USER::isLoggedIn()) {
+ die("");
+}
+OC_JSON::checkAppEnabled('calendar');
+
+$tmpl = new OC_Template('calendar', 'part.import');
+$tmpl->printpage();
+?>
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 837c6d6b124..2dc01eab0f6 100644
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -6,6 +6,8 @@ OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php';
OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'deleteUser');
+OC_Util::addScript('calendar','loader');
+
OC_App::register( array(
'order' => 10,
'id' => 'calendar',
diff --git a/apps/calendar/import.php b/apps/calendar/import.php
new file mode 100644
index 00000000000..e31d8bbdc6f
--- /dev/null
+++ b/apps/calendar/import.php
@@ -0,0 +1,50 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+require_once ('../../lib/base.php');
+//OC_JSON::checkLoggedIn();
+OC_Util::checkAppEnabled('calendar');
+
+if($_GET["import"] == "existing"){
+ $calid = $_GET["calid"];
+ $calendar = OC_Calendar_Calendar::findCalendar($calid);
+ if($calendar['userid'] != OC_User::getUser()){
+ OC_JSON::error();
+ exit;
+ }
+ if($_GET["path"] != ""){
+ $filename = $_GET["path"] . "/" . $_GET["file"];
+ }else{
+ $filename = "/" . $_GET["file"];
+ }
+}else{
+ $id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname'], $_POST['description']);
+ 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();
+?>
\ No newline at end of file
diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js
new file mode 100644
index 00000000000..6eafec8b10d
--- /dev/null
+++ b/apps/calendar/js/loader.js
@@ -0,0 +1,16 @@
+function importdialog(directory, filename){
+ $("body").append("
");
+ $("#importdialogholder").load(OC.filePath('calendar', 'ajax', 'importdialog.php?filename=' + filename + '&path=' + directory));
+}
+
+$(document).ready(function(){
+ $('tr[data-file$=".ics"]').attr("data-mime", "text/calendar");
+ $('tr[data-file$=".vcs"]').attr("data-mime", "text/calendar");
+ $('tr[data-file$=".ical"]').attr("data-mime", "text/calendar");
+ if(typeof FileActions!=='undefined'){
+ FileActions.register('text/calendar','Import to Calendar','',function(filename){
+ importdialog($('#dir').val(),filename);
+ });
+ FileActions.setDefault('text/calendar','Import to Calendar');
+ }
+});
\ No newline at end of file
diff --git a/apps/calendar/templates/part.eventinfo.php b/apps/calendar/templates/part.eventinfo.php
deleted file mode 100644
index edccaaa2227..00000000000
--- a/apps/calendar/templates/part.eventinfo.php
+++ /dev/null
@@ -1,87 +0,0 @@
-
">
-
-
-
t("Title");?>:
-
-
-
-
-
t("Location");?>:
-
-
-
-
-
-
-
t("Category");?>:
-
-
t("Calendar");?>:
-
-
-
-
-
-
-
-
-
-
-
-
-
t("From");?>:
-
-
-
-
-
-
-
t("To");?>:
-
-
-
-
-
-
t("Repeat");?>:
-
-
-
-
-
-
-
t("Attendees");?>:
-
-
-
-
-
-
-
t("Description");?>:
-
-
-
-
- ">
- ">
-
-
-
\ No newline at end of file
diff --git a/apps/calendar/templates/part.import.php b/apps/calendar/templates/part.import.php
new file mode 100644
index 00000000000..c1beb49a7f7
--- /dev/null
+++ b/apps/calendar/templates/part.import.php
@@ -0,0 +1,70 @@
+