diff --git a/apps/calendar/ajax/import/dropimport.php b/apps/calendar/ajax/import/dropimport.php index 25b404787f..a3bef1ac29 100644 --- a/apps/calendar/ajax/import/dropimport.php +++ b/apps/calendar/ajax/import/dropimport.php @@ -19,7 +19,8 @@ if(!$import->isValid()){ OCP\JSON::error(); exit; } -$newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(),strip_tags($import->createCalendarName()),'VEVENT,VTODO,VJOURNAL',null,0,$import->createCalendarColor()); +$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(); -OCP\JSON::success(); \ No newline at end of file +OCP\JSON::success(array('newcalendarname'=>$newcalendarname, 'count'=>$import->getCount(), 'newcalendarid'=>$newid, 'eventSource'=>OC_Calendar_Calendar::getEventSourceInfo(OC_Calendar_Calendar::find($newid)))); \ No newline at end of file diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 251522802a..0c4d44769c 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -634,6 +634,10 @@ Calendar={ import:function(data){ $.post(OC.filePath('calendar', 'ajax/import', 'dropimport.php'), {'data':data},function(result) { if(result.status == 'success'){ + $('#calendar_holder').fullCalendar('addEventSource', result.eventSource); + $('#notification').html(result.count + ' Events has been saved in the new calendar ' + result.newcalendarname); + $('#notification').slideDown(); + window.setTimeout(function(){$('#notification').slideUp();}, 5000); return true; }else{ $('#notification').html('ownCloud wasn\'t able to import at least one file. File skipped.'); diff --git a/apps/calendar/lib/import.php b/apps/calendar/lib/import.php index 969725f527..9076a747a4 100644 --- a/apps/calendar/lib/import.php +++ b/apps/calendar/lib/import.php @@ -19,6 +19,11 @@ class OC_Calendar_Import{ */ private $calobject; + /* + * @brief var counts the number of imported elements + */ + private $count; + /* * @brief var to check if errors happend while initialization */ @@ -62,6 +67,7 @@ class OC_Calendar_Import{ public function __construct($ical){ $this->error = null; $this->ical = $ical; + $this->count = 0; try{ $this->calobject = OC_VObject::parse($this->ical); }catch(Exception $e){ @@ -89,6 +95,7 @@ class OC_Calendar_Import{ $object->DTEND->getDateTime()->setTimezone(new DateTimeZone($this->tz)); $vcalendar = $this->createVCalendar($object->serialize()); OC_Calendar_Object::add($this->id, $vcalendar); + $this->count++; } return true; } @@ -184,6 +191,15 @@ class OC_Calendar_Import{ $this->userid = $userid; return true; } + + /* + * @brief returns the private + * @param string $id of the user + * @return boolean + */ + public function getCount(){ + return $this->count; + } /* * private methods