summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-06-30 22:08:30 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-06-30 22:08:30 +0200
commit376431fa0d20f6fade8d4e9cb7b1240e3e6eaf34 (patch)
treefc7206d31423e8cf091eb4ee9b6d26f2b096cf11
parent390f5cc89fc956b021c0566534ca969ed0377f11 (diff)
downloadnextcloud-server-376431fa0d20f6fade8d4e9cb7b1240e3e6eaf34.tar.gz
nextcloud-server-376431fa0d20f6fade8d4e9cb7b1240e3e6eaf34.zip
import works now for dropimport
-rw-r--r--apps/calendar/ajax/import/dropimport.php5
-rw-r--r--apps/calendar/lib/import.php53
2 files changed, 36 insertions, 22 deletions
diff --git a/apps/calendar/ajax/import/dropimport.php b/apps/calendar/ajax/import/dropimport.php
index 41dfd7d9346..25b404787f2 100644
--- a/apps/calendar/ajax/import/dropimport.php
+++ b/apps/calendar/ajax/import/dropimport.php
@@ -12,15 +12,14 @@ $data = base64_decode($data);
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
$import = new OC_Calendar_Import($data);
+$import->setUserID(OCP\User::getUser());
$import->setTimeZone(OC_Calendar_App::$tz);
$import->disableProgressCache();
if(!$import->isValid()){
OCP\JSON::error();
exit;
}
-$calendarname = $import->createCalendarName(OCP\User::getUser());
-$calendarcolor = $import->createCalendarColor();
-$newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(),strip_tags($calendarname),'VEVENT,VTODO,VJOURNAL',null,0,$calendarcolor);
+$newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(),strip_tags($import->createCalendarName()),'VEVENT,VTODO,VJOURNAL',null,0,$import->createCalendarColor());
$import->setCalendarID($newid);
$import->import();
OCP\JSON::success(); \ No newline at end of file
diff --git a/apps/calendar/lib/import.php b/apps/calendar/lib/import.php
index d23a55a6209..969725f5274 100644
--- a/apps/calendar/lib/import.php
+++ b/apps/calendar/lib/import.php
@@ -43,6 +43,11 @@ class OC_Calendar_Import{
* @brief var saves the timezone the events shell converted to
*/
private $tz;
+
+ /*
+ * @brief var saves the userid
+ */
+ private $userid;
/*
* public methods
@@ -69,20 +74,21 @@ class OC_Calendar_Import{
/*
* @brief imports a calendar
- * @param boolean $force force import even though calendar is not valid
* @return boolean
*/
- public function import($force = false){
- if(!$this->isValid() && !$force){
+ public function import(){
+ if(!$this->isValid()){
return false;
}
foreach($this->calobject->getComponents() as $object){
if(!($object instanceof Sabre_VObject_Component_VEvent) && !($object instanceof Sabre_VObject_Component_VJournal) && !($object instanceof Sabre_VObject_Component_VTodo)){
continue;
}
-
-
-
+ $object->DTSTART->getDateTime()->setTimezone(new DateTimeZone($this->tz));
+ $object->DTEND = OC_Calendar_Object::getDTEndFromVEvent($object);
+ $object->DTEND->getDateTime()->setTimezone(new DateTimeZone($this->tz));
+ $vcalendar = $this->createVCalendar($object->serialize());
+ OC_Calendar_Object::add($this->id, $vcalendar);
}
return true;
}
@@ -135,14 +141,13 @@ class OC_Calendar_Import{
/*
* @brief generates a new calendar name
- * @param string $userid
* @return string
*/
- public function createCalendarName($userid){
- $calendars = OC_Calendar_Calendar::allCalendars($userid);
+ public function createCalendarName(){
+ $calendars = OC_Calendar_Calendar::allCalendars($this->userid);
$calendarname = $guessedcalendarname = !is_null($this->guessCalendarName())?($this->guessCalendarName()):(OC_Calendar_App::$l10n->t('New Calendar'));
$i = 1;
- while(!OC_Calendar_Calendar::isCalendarNameavailable($calendarname, $userid)){
+ while(!OC_Calendar_Calendar::isCalendarNameavailable($calendarname, $this->userid)){
$calendarname = $guessedcalendarname . ' (' . $i . ')';
$i++;
}
@@ -153,8 +158,8 @@ class OC_Calendar_Import{
* @brief generates a new calendar color
* @return string
*/
- public function createCalendarColor($userid){
- if(is_null($this->guessCalendarColor()))){
+ public function createCalendarColor(){
+ if(is_null($this->guessCalendarColor())){
return '#9fc6e7';
}
return $this->guessCalendarColor();
@@ -165,9 +170,19 @@ class OC_Calendar_Import{
* @param integer $id of the calendar
* @return boolean
*/
- public static function setCalendarID($id){
+ public function setCalendarID($id){
$this->id = $id;
- return true:
+ return true;
+ }
+
+ /*
+ * @brief sets the userid to import the calendar
+ * @param string $id of the user
+ * @return boolean
+ */
+ public function setUserID($userid){
+ $this->userid = $userid;
+ return true;
}
/*
@@ -207,12 +222,12 @@ class OC_Calendar_Import{
}
/*
- * @brief
- * @return
+ * @brief checks if an event already exists in the user's calendars
+ * @return boolean
*/
- //private function (){
+ private function isDuplicate(){
- //}
+ }
/*
* @brief
@@ -223,7 +238,7 @@ class OC_Calendar_Import{
//}
/*
- * private methods for prerendering of X-... Attributes
+ * private methods for (pre)rendering of X-... Attributes
*/
/*