improve dropimport

This commit is contained in:
Georg Ehrke 2012-06-30 22:26:29 +02:00
parent 4890bbb30d
commit f15941a967
3 changed files with 23 additions and 2 deletions

View File

@ -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();
OCP\JSON::success(array('newcalendarname'=>$newcalendarname, 'count'=>$import->getCount(), 'newcalendarid'=>$newid, 'eventSource'=>OC_Calendar_Calendar::getEventSourceInfo(OC_Calendar_Calendar::find($newid))));

View File

@ -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.');

View File

@ -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