improve dropimport
This commit is contained in:
parent
4890bbb30d
commit
f15941a967
|
@ -19,7 +19,8 @@ if(!$import->isValid()){
|
||||||
OCP\JSON::error();
|
OCP\JSON::error();
|
||||||
exit;
|
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->setCalendarID($newid);
|
||||||
$import->import();
|
$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))));
|
|
@ -634,6 +634,10 @@ Calendar={
|
||||||
import:function(data){
|
import:function(data){
|
||||||
$.post(OC.filePath('calendar', 'ajax/import', 'dropimport.php'), {'data':data},function(result) {
|
$.post(OC.filePath('calendar', 'ajax/import', 'dropimport.php'), {'data':data},function(result) {
|
||||||
if(result.status == 'success'){
|
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;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
$('#notification').html('ownCloud wasn\'t able to import at least one file. File skipped.');
|
$('#notification').html('ownCloud wasn\'t able to import at least one file. File skipped.');
|
||||||
|
|
|
@ -19,6 +19,11 @@ class OC_Calendar_Import{
|
||||||
*/
|
*/
|
||||||
private $calobject;
|
private $calobject;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief var counts the number of imported elements
|
||||||
|
*/
|
||||||
|
private $count;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief var to check if errors happend while initialization
|
* @brief var to check if errors happend while initialization
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +67,7 @@ class OC_Calendar_Import{
|
||||||
public function __construct($ical){
|
public function __construct($ical){
|
||||||
$this->error = null;
|
$this->error = null;
|
||||||
$this->ical = $ical;
|
$this->ical = $ical;
|
||||||
|
$this->count = 0;
|
||||||
try{
|
try{
|
||||||
$this->calobject = OC_VObject::parse($this->ical);
|
$this->calobject = OC_VObject::parse($this->ical);
|
||||||
}catch(Exception $e){
|
}catch(Exception $e){
|
||||||
|
@ -89,6 +95,7 @@ class OC_Calendar_Import{
|
||||||
$object->DTEND->getDateTime()->setTimezone(new DateTimeZone($this->tz));
|
$object->DTEND->getDateTime()->setTimezone(new DateTimeZone($this->tz));
|
||||||
$vcalendar = $this->createVCalendar($object->serialize());
|
$vcalendar = $this->createVCalendar($object->serialize());
|
||||||
OC_Calendar_Object::add($this->id, $vcalendar);
|
OC_Calendar_Object::add($this->id, $vcalendar);
|
||||||
|
$this->count++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -185,6 +192,15 @@ class OC_Calendar_Import{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief returns the private
|
||||||
|
* @param string $id of the user
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function getCount(){
|
||||||
|
return $this->count;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* private methods
|
* private methods
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue