]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move Calendar Object code to its own class OC_Calendar_Object
authorBart Visscher <bartv@thisnet.nl>
Thu, 15 Sep 2011 08:14:47 +0000 (10:14 +0200)
committerBart Visscher <bartv@thisnet.nl>
Thu, 15 Sep 2011 22:19:43 +0000 (00:19 +0200)
apps/calendar/ajax/newevent.php
apps/calendar/appinfo/app.php
apps/calendar/export.php
apps/calendar/lib/calendar.php
apps/calendar/lib/connector_sabre.php
apps/calendar/lib/object.php [new file with mode: 0644]
apps/calendar/templates/part.getcal.php

index 32fe964170f31aad19699b06ea336564c7b99e59..b81190fd64254798ca92dc0b2a698e1940851bfb 100644 (file)
@@ -151,7 +151,7 @@ if($errnum != 0){
                $data .= "RRULE:" . $repeat . "\n";
        }*/
        $data .= "END:VEVENT\nEND:VCALENDAR";
-       $result = OC_Calendar_Calendar::addCalendarObject($cal, $data);
+       $result = OC_Calendar_Object::add($cal, $data);
        echo json_encode(array("success"=>"true"));
 }
 ?>
index 5ec2177e20cff91f27849ab96857185019349cea..837c6d6b124d93829fac986d1a6a5c26e9167d64 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 $l=new OC_L10N('calendar');
 OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php';
+OC::$CLASSPATH['OC_Calendar_Object'] = 'apps/calendar/lib/object.php';
 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');
index 3ed7ba0445e8e8cd28e5dc2e284099807ff7163f..f03a5d23e68f27cbb4274e24dca96a148aee0d51 100644 (file)
@@ -28,10 +28,10 @@ if($calendar["userid"] != OC_User::getUser()){
        header("Location: " . OC_HELPER::linkTo("", "index.php"));
        exit;
 }
-$calobjects = OC_Calendar_Calendar::allCalendarObjects($cal);
+$calobjects = OC_Calendar_Object::all($cal);
 header("Content-Type: text/Calendar");
 header("Content-Disposition: inline; filename=calendar.ics"); 
 for($i = 0;$i <= count($calobjects); $i++){
        echo $calobjects[$i]["calendardata"] . "\n";
 }
-?>
\ No newline at end of file
+?>
index c13fdc7d81d5f0f43bb485d79b6428bf8ea1c351..571e3d695eb08c9b1049b01ec2e3f77b1e271ac0 100644 (file)
@@ -222,162 +222,6 @@ class OC_Calendar_Calendar{
                return true;
        }
 
-       /**
-        * @brief Returns all objects of a calendar
-        * @param integer $id
-        * @return array
-        *
-        * The objects are associative arrays. You'll find the original vObject in
-        * ['carddata']
-        */
-       public static function allCalendarObjects($id){
-               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' );
-               $result = $stmt->execute(array($id));
-
-               $calendarobjects = array();
-               while( $row = $result->fetchRow()){
-                       $calendarobjects[] = $row;
-               }
-
-               return $calendarobjects;
-       }
-
-       /**
-        * @brief Returns an object
-        * @param integer $id
-        * @return associative array
-        */
-       public static function findCalendarObject($id){
-               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE id = ?' );
-               $result = $stmt->execute(array($id));
-
-               return $result->fetchRow();
-       }
-
-       /**
-        * @brief finds an object by its DAV Data
-        * @param integer $cid Calendar id
-        * @param string $uri the uri ('filename')
-        * @return associative array
-        */
-       public static function findCalendarObjectWhereDAVDataIs($cid,$uri){
-               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri = ?' );
-               $result = $stmt->execute(array($cid,$uri));
-
-               return $result->fetchRow();
-       }
-
-       /**
-        * @brief Adds an object
-        * @param integer $id Calendar id
-        * @param string $data  object
-        * @return insertid
-        */
-       public static function addCalendarObject($id,$data){
-               $object = self::parse($data);
-               list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
-
-               if(is_null($uid)){
-                       $uid = self::createUID();
-                       $object->add('UID',$uid);
-                       $data = $object->serialize();
-               }
-
-               $uri = 'owncloud-'.md5($data.rand().time()).'.ics';
-
-               $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' );
-               $result = $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time()));
-
-               self::touchCalendar($id);
-
-               return OC_DB::insertid();
-       }
-
-       /**
-        * @brief Adds an object with the data provided by sabredav
-        * @param integer $id Calendar id
-        * @param string $uri   the uri the card will have
-        * @param string $data  object
-        * @return insertid
-        */
-       public static function addCalendarObjectFromDAVData($id,$uri,$data){
-               $object = self::parse($data);
-               list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
-
-               $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' );
-               $result = $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time()));
-
-               self::touchCalendar($id);
-
-               return OC_DB::insertid();
-       }
-
-       /**
-        * @brief edits an object
-        * @param integer $id id of object
-        * @param string $data  object
-        * @return boolean
-        */
-       public static function editCalendarObject($id, $data){
-               $oldobject = self::findCalendarObject($id);
-
-               $object = self::parse($data);
-               list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
-
-               $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
-               $result = $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$id));
-
-               self::touchCalendar($id);
-
-               return true;
-       }
-
-       /**
-        * @brief edits an object with the data provided by sabredav
-        * @param integer $id calendar id
-        * @param string $uri   the uri of the object
-        * @param string $data  object
-        * @return boolean
-        */
-       public static function editCalendarObjectFromDAVData($cid,$uri,$data){
-               $oldobject = self::findCalendarObjectWhereDAVDataIs($cid,$uri);
-
-               $object = self::parse($data);
-               list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
-
-               $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
-               $result = $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$oldobject['id']));
-
-               self::touchCalendar($oldobject['calendarid']);
-
-               return true;
-       }
-
-       /**
-        * @brief deletes an object
-        * @param integer $id id of object
-        * @return boolean
-        */
-       public static function deleteCalendarObject($id){
-               $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE id = ?' );
-               $stmt->execute(array($id));
-
-               return true;
-       }
-
-       /**
-        * @brief deletes an  object with the data provided by sabredav
-        * @param integer $cid calendar id
-        * @param string $uri the uri of the object
-        * @return boolean
-        */
-       public static function deleteCalendarObjectFromDAVData($cid,$uri){
-               $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri=?' );
-               $stmt->execute(array($cid,$uri));
-
-               return true;
-       }
-
        /**
         * @brief Creates a URI for Calendar
         * @param string $name name of the calendar
@@ -395,14 +239,6 @@ class OC_Calendar_Calendar{
                return $newname;
        }
 
-       /**
-        * @brief Creates a UID
-        * @return string
-        */
-       public static function createUID(){
-               return substr(md5(rand().time()),0,10);
-       }
-
        /**
         * @brief gets the userid from a principal path
         * @return string
@@ -411,108 +247,4 @@ class OC_Calendar_Calendar{
                list($prefix,$userid) = Sabre_DAV_URLUtil::splitPath($principaluri);
                return $userid;
        }
-
-       /**
-        * @brief Extracts data from a vObject-Object
-        * @param Sabre_VObject $object
-        * @return array
-        *
-        * [type, start, end, summary, repeating, uid]
-        */
-       protected static function extractData($object){
-               $return = array('',null,null,'',0,null);
-
-               // Child to use
-               $children = 0;
-               $use = null;
-               foreach($object->children as &$property){
-                       if($property->name == 'VEVENT'){
-                               $children++;
-                               $thisone = true;
-
-                               foreach($property->children as &$element){
-                                       if($element->name == 'RECURRENCE-ID'){
-                                               $thisone = false;
-                                       }
-                               } unset($element);
-
-                               if($thisone){
-                                       $use = $property;
-                               }
-                       }
-                       elseif($property->name == 'VTODO' || $property->name == 'VJOURNAL'){
-                               $return[0] = $use->name;
-                               foreach($property->children as &$element){
-                                       if($property->name == 'SUMMARY'){
-                                               $return[3] = $property->value;
-                                       }
-                                       elseif($property->name == 'UID'){
-                                               $return[5] = $property->value;
-                                       }
-                               };
-
-                               // Only one VTODO or VJOURNAL per object
-                               // (only one UID per object but a UID is required by a VTODO =>
-                               //    one VTODO per object)
-                               break;
-                       }
-               } unset($property);
-
-               // find the data
-               if(!is_null($use)){
-                       $return[0] = $use->name;
-                       foreach($use->children as &$property){
-                               if($property->name == 'DTSTART'){
-                                       $return[1] = self::getUTCforMDB($property->getDateTime());
-                               }
-                               elseif($property->name == 'DTEND'){
-                                       $return[2] = self::getUTCforMDB($property->getDateTime());
-                               }
-                               elseif($property->name == 'SUMMARY'){
-                                       $return[3] = $property->value;
-                               }
-                               elseif($property->name == 'RRULE'){
-                                       $return[4] = 1;
-                               }
-                               elseif($property->name == 'UID'){
-                                       $return[5] = $property->value;
-                               }
-                       } unset($property);
-               }
-
-               // More than one child means reoccuring!
-               if($children > 1){
-                       $return[4] = 1;
-               }
-               return $return;
-       }
-
-       /**
-        * @brief DateTime to UTC string
-        * @param DateTime $datetime The date to convert
-        * @returns date as YYYY-MM-DD hh:mm
-        *
-        * This function creates a date string that can be used by MDB2.
-        * Furthermore it converts the time to UTC.
-        */
-       protected static function getUTCforMDB($datetime){
-               return date('Y-m-d H:i', $datetime->format('U') - $datetime->getOffset());
-       }
-
-       /**
-        * @brief Parses the VObject
-        * @param string VObject as string
-        * @returns Sabre_VObject or null
-        *
-        * This function creates a date string that can be used by MDB2.
-        * Furthermore it converts the time to UTC.
-        */
-       public static function parse($data){
-               try {
-                       $card = Sabre_VObject_Reader::read($data);
-                       return $card;
-               } catch (Exception $e) {
-                       return null;
-               }
-       }
 }
index 67f263903db75afa2151533a118497128eecd497..b94e6fb3ae79aca7e7108dfc1de41f7d468c51ff 100644 (file)
@@ -236,7 +236,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
         */
        public function getCalendarObjects($calendarId) {
                $data = array();
-               foreach(OC_Calendar_Calendar::allCalendarObjects($calendarId) as $row){
+               foreach(OC_Calendar_Object::all($calendarId) as $row){
                        $data[] = $this->OCAddETag($row);
                }
                return $data;
@@ -255,7 +255,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
         * @return array
         */
        public function getCalendarObject($calendarId,$objectUri) {
-               $data = OC_Calendar_Calendar::findCalendarObjectWhereDAVDataIs($calendarId,$objectUri);
+               $data = OC_Calendar_Object::findWhereDAVDataIs($calendarId,$objectUri);
                if(is_array($data)){
                        $data = $this->OCAddETag($data);
                }
@@ -271,7 +271,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
         * @return void
         */
        public function createCalendarObject($calendarId,$objectUri,$calendarData) {
-               OC_Calendar_Calendar::addCalendarObjectFromDAVData($calendarId,$objectUri,$calendarData);
+               OC_Calendar_Object::addFromDAVData($calendarId,$objectUri,$calendarData);
        }
 
        /**
@@ -283,7 +283,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
         * @return void
         */
        public function updateCalendarObject($calendarId,$objectUri,$calendarData){
-               OC_Calendar_Calendar::editCalendarObjectFromDAVData($calendarId,$objectUri,$calendarData);
+               OC_Calendar_Object::editFromDAVData($calendarId,$objectUri,$calendarData);
        }
 
        /**
@@ -294,7 +294,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
         * @return void
         */
        public function deleteCalendarObject($calendarId,$objectUri){
-               OC_Calendar_Calendar::deleteCalendarObjectFromDAVData($calendarId,$objectUri);
+               OC_Calendar_Object::deleteFromDAVData($calendarId,$objectUri);
        }
        
        /**
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
new file mode 100644 (file)
index 0000000..bf9831d
--- /dev/null
@@ -0,0 +1,291 @@
+<?php
+/**
+ * ownCloud - Calendar
+ *
+ * @author Jakob Sack
+ * @copyright 2011 Jakob Sack mail@jakobsack.de
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * This class manages our calendars
+ */
+class OC_Calendar_Object{
+       /**
+        * @brief Returns all objects of a calendar
+        * @param integer $id
+        * @return array
+        *
+        * The objects are associative arrays. You'll find the original vObject in
+        * ['calendardata']
+        */
+       public static function all($id){
+               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ?' );
+               $result = $stmt->execute(array($id));
+
+               $calendarobjects = array();
+               while( $row = $result->fetchRow()){
+                       $calendarobjects[] = $row;
+               }
+
+               return $calendarobjects;
+       }
+
+       /**
+        * @brief Returns an object
+        * @param integer $id
+        * @return associative array
+        */
+       public static function find($id){
+               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE id = ?' );
+               $result = $stmt->execute(array($id));
+
+               return $result->fetchRow();
+       }
+
+       /**
+        * @brief finds an object by its DAV Data
+        * @param integer $cid Calendar id
+        * @param string $uri the uri ('filename')
+        * @return associative array
+        */
+       public static function findWhereDAVDataIs($cid,$uri){
+               $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri = ?' );
+               $result = $stmt->execute(array($cid,$uri));
+
+               return $result->fetchRow();
+       }
+
+       /**
+        * @brief Adds an object
+        * @param integer $id Calendar id
+        * @param string $data  object
+        * @return insertid
+        */
+       public static function add($id,$data){
+               $object = self::parse($data);
+               list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
+
+               if(is_null($uid)){
+                       $uid = self::createUID();
+                       $object->add('UID',$uid);
+                       $data = $object->serialize();
+               }
+
+               $uri = 'owncloud-'.md5($data.rand().time()).'.ics';
+
+               $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' );
+               $result = $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time()));
+
+               OC_Calendar_Calendar::touchCalendar($id);
+
+               return OC_DB::insertid();
+       }
+
+       /**
+        * @brief Adds an object with the data provided by sabredav
+        * @param integer $id Calendar id
+        * @param string $uri   the uri the card will have
+        * @param string $data  object
+        * @return insertid
+        */
+       public static function addFromDAVData($id,$uri,$data){
+               $object = self::parse($data);
+               list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
+
+               $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_objects (calendarid,objecttype,startdate,enddate,repeating,summary,calendardata,uri,lastmodified) VALUES(?,?,?,?,?,?,?,?,?)' );
+               $result = $stmt->execute(array($id,$type,$startdate,$enddate,$repeating,$summary,$data,$uri,time()));
+
+               OC_Calendar_Calendar::touchCalendar($id);
+
+               return OC_DB::insertid();
+       }
+
+       /**
+        * @brief edits an object
+        * @param integer $id id of object
+        * @param string $data  object
+        * @return boolean
+        */
+       public static function edit($id, $data){
+               $oldobject = self::find($id);
+
+               $object = self::parse($data);
+               list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
+
+               $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
+               $result = $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$id));
+
+               OC_Calendar_Calendar::touchCalendar($id);
+
+               return true;
+       }
+
+       /**
+        * @brief edits an object with the data provided by sabredav
+        * @param integer $id calendar id
+        * @param string $uri   the uri of the object
+        * @param string $data  object
+        * @return boolean
+        */
+       public static function editFromDAVData($cid,$uri,$data){
+               $oldobject = self::findWhereDAVDataIs($cid,$uri);
+
+               $object = self::parse($data);
+               list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
+
+               $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' );
+               $result = $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$oldobject['id']));
+
+               OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']);
+
+               return true;
+       }
+
+       /**
+        * @brief deletes an object
+        * @param integer $id id of object
+        * @return boolean
+        */
+       public static function delete($id){
+               $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE id = ?' );
+               $stmt->execute(array($id));
+
+               return true;
+       }
+
+       /**
+        * @brief deletes an  object with the data provided by sabredav
+        * @param integer $cid calendar id
+        * @param string $uri the uri of the object
+        * @return boolean
+        */
+       public static function deleteFromDAVData($cid,$uri){
+               $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ? AND uri=?' );
+               $stmt->execute(array($cid,$uri));
+
+               return true;
+       }
+
+       /**
+        * @brief Creates a UID
+        * @return string
+        */
+       protected static function createUID(){
+               return substr(md5(rand().time()),0,10);
+       }
+
+       /**
+        * @brief Extracts data from a vObject-Object
+        * @param Sabre_VObject $object
+        * @return array
+        *
+        * [type, start, end, summary, repeating, uid]
+        */
+       protected static function extractData($object){
+               $return = array('',null,null,'',0,null);
+
+               // Child to use
+               $children = 0;
+               $use = null;
+               foreach($object->children as &$property){
+                       if($property->name == 'VEVENT'){
+                               $children++;
+                               $thisone = true;
+
+                               foreach($property->children as &$element){
+                                       if($element->name == 'RECURRENCE-ID'){
+                                               $thisone = false;
+                                       }
+                               } unset($element);
+
+                               if($thisone){
+                                       $use = $property;
+                               }
+                       }
+                       elseif($property->name == 'VTODO' || $property->name == 'VJOURNAL'){
+                               $return[0] = $use->name;
+                               foreach($property->children as &$element){
+                                       if($property->name == 'SUMMARY'){
+                                               $return[3] = $property->value;
+                                       }
+                                       elseif($property->name == 'UID'){
+                                               $return[5] = $property->value;
+                                       }
+                               };
+
+                               // Only one VTODO or VJOURNAL per object
+                               // (only one UID per object but a UID is required by a VTODO =>
+                               //    one VTODO per object)
+                               break;
+                       }
+               } unset($property);
+
+               // find the data
+               if(!is_null($use)){
+                       $return[0] = $use->name;
+                       foreach($use->children as &$property){
+                               if($property->name == 'DTSTART'){
+                                       $return[1] = self::getUTCforMDB($property->getDateTime());
+                               }
+                               elseif($property->name == 'DTEND'){
+                                       $return[2] = self::getUTCforMDB($property->getDateTime());
+                               }
+                               elseif($property->name == 'SUMMARY'){
+                                       $return[3] = $property->value;
+                               }
+                               elseif($property->name == 'RRULE'){
+                                       $return[4] = 1;
+                               }
+                               elseif($property->name == 'UID'){
+                                       $return[5] = $property->value;
+                               }
+                       } unset($property);
+               }
+
+               // More than one child means reoccuring!
+               if($children > 1){
+                       $return[4] = 1;
+               }
+               return $return;
+       }
+
+       /**
+        * @brief DateTime to UTC string
+        * @param DateTime $datetime The date to convert
+        * @returns date as YYYY-MM-DD hh:mm
+        *
+        * This function creates a date string that can be used by MDB2.
+        * Furthermore it converts the time to UTC.
+        */
+       protected static function getUTCforMDB($datetime){
+               return date('Y-m-d H:i', $datetime->format('U') - $datetime->getOffset());
+       }
+
+       /**
+        * @brief Parses the VObject
+        * @param string VObject as string
+        * @returns Sabre_VObject or null
+        */
+       public static function parse($data){
+               try {
+                       $calendar = Sabre_VObject_Reader::read($data);
+                       return $calendar;
+               } catch (Exception $e) {
+                       return null;
+               }
+       }
+}
index db71e6cb725141102de23306b4e58248eda26f34..69cd09dafeea6ee405b79bcf26ae27c4655748a3 100644 (file)
@@ -13,7 +13,7 @@
  * MA 02111-1307  USA                             *
  *************************************************/
 $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
-$events = OC_Calendar_Calendar::allCalendarObjects($calendars[0]['id']);
+$events = OC_Calendar_Object::all($calendars[0]['id']);
 $select_year = $_GET["year"];
 $return_events = array();
 $user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");