]> source.dussan.org Git - nextcloud-server.git/commitdiff
upgrade to Sabredav 1.5.4
authorRobin Appelman <icewind1991@gmail.com>
Fri, 28 Oct 2011 22:49:52 +0000 (00:49 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Fri, 28 Oct 2011 22:50:07 +0000 (00:50 +0200)
21 files changed:
3rdparty/Sabre.includes.php
3rdparty/Sabre/CardDAV/AddressBook.php
3rdparty/Sabre/CardDAV/Backend/Abstract.php
3rdparty/Sabre/CardDAV/Backend/PDO.php
3rdparty/Sabre/CardDAV/Card.php
3rdparty/Sabre/CardDAV/ICard.php
3rdparty/Sabre/CardDAV/Plugin.php
3rdparty/Sabre/CardDAV/UserAddressBooks.php
3rdparty/Sabre/CardDAV/Version.php
3rdparty/Sabre/DAV/Browser/GuessContentType.php
3rdparty/Sabre/DAV/Server.php
3rdparty/Sabre/DAV/Version.php
3rdparty/Sabre/DAVACL/Exception/NeedPrivileges.php
3rdparty/Sabre/DAVACL/PrincipalCollection.php
3rdparty/Sabre/VObject/Component.php
3rdparty/Sabre/VObject/Element/DateTime.php
3rdparty/Sabre/VObject/Element/MultiDateTime.php
3rdparty/Sabre/VObject/Node.php
3rdparty/Sabre/VObject/Property.php
3rdparty/Sabre/VObject/Reader.php
3rdparty/Sabre/VObject/Version.php

index 9d389288c78484005db03fb20e3501b614908a1d..d41b287b77db5ea8f1ad7b4be78ab68046a803d5 100644 (file)
@@ -71,6 +71,7 @@ include 'Sabre/DAV/IExtendedCollection.php';
 /* Node abstract implementations */
 include 'Sabre/DAV/Node.php';
 include 'Sabre/DAV/File.php';
+include 'Sabre/DAV/Collection.php';
 include 'Sabre/DAV/Directory.php';
 
 /* Utilities */
@@ -124,4 +125,3 @@ include 'Sabre/DAV/Auth/Backend/PDO.php';
 /* DavMount plugin */
 include 'Sabre/DAV/Mount/Plugin.php';
 
-
index 3333480ea8549f4da860127a240c375cf2ca6c10..471ca7b338a7734e392ddfd92fcb0c4db8bcf729 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 
 /**
- * UserAddressBook class
+ * The AddressBook class represents a CardDAV addressbook, owned by a specific user
+ *
+ * The AddressBook can contain multiple vcards
  *
  * @package Sabre
  * @subpackage CardDAV
@@ -9,12 +11,6 @@
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-
-/**
- * The AddressBook class represents a CardDAV addressbook, owned by a specific user
- *
- * The AddressBook can contain multiple vcards
- */
 class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_CardDAV_IAddressBook, Sabre_DAV_IProperties, Sabre_DAVACL_IACL {
 
     /**
index f6d10291ca61dd025f7c49f7c50210db57ab2463..1f0253ddab802d28fbdbe121311fcb88f28af02c 100644 (file)
@@ -2,6 +2,12 @@
 
 /**
  * Abstract Backend class
+ *
+ * This class serves as a base-class for addressbook backends
+ *
+ * Note that there are references to 'addressBookId' scattered throughout the 
+ * class. The value of the addressBookId is completely up to you, it can be any 
+ * arbitrary value you can use as an unique identifier.
  * 
  * @package Sabre
  * @subpackage CardDAV
@@ -9,14 +15,6 @@
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-
-/**
- * This class serves as a base-class for addressbook backends
- *
- * Note that there are references to 'addressBookId' scattered throughout the 
- * class. The value of the addressBookId is completely up to you, it can be any 
- * arbitrary value you can use as an unique identifier.
- */
 abstract class Sabre_CardDAV_Backend_Abstract {
 
     /**
index 5556d0a7648f1dcf0211afdd7899c03507e20cdd..f4e44610ccf1146bc3acf3548f23a78d91797977 100644 (file)
@@ -2,6 +2,8 @@
 
 /**
  * PDO CardDAV backend
+ *
+ * This CardDAV backend uses PDO to store addressbooks
  * 
  * @package Sabre
  * @subpackage CardDAV
@@ -9,10 +11,6 @@
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-
-/**
- * This CardDAV backend uses PDO to store addressbooks
- */
 class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
 
     /**
index 5298d31e2455f55fccb44b97c00b1cf53140cb61..2844eaf7ed6b06f06f3a6fbea2c609a544cc16dd 100644 (file)
@@ -1,18 +1,14 @@
 <?php
 
 /**
- * Card class
+ * The Card object represents a single Card from an addressbook
  * 
  * @package Sabre
  * @subpackage CardDAV
  * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
- *
- /
-/**
- * The Card object represents a single Card from an addressbook
- */ 
+ */
 class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard, Sabre_DAVACL_IACL {
 
     /**
index 8f9bb097b5685e6ef99363850232569c4b5c69a0..25bcc551b73d98994a9c5c4d4d13eec939768e15 100644 (file)
@@ -2,18 +2,16 @@
 
 /**
  * Card interface 
+ *
+ * Extend the ICard interface to allow your custom nodes to be picked up as 
+ * 'Cards'. 
  * 
  * @package Sabre
  * @subpackage CardDAV
  * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
- *
- /
-/**
- * Extend the ICard interface to allow your custom nodes to be picked up as 
- * 'Cards'. 
- */ 
+ */
 interface Sabre_CardDAV_ICard extends Sabre_DAV_IFile { 
 
 }
index 17766b78278c84a14cb530880078ca04ac85ad9c..14c9c72b0d532e5d009135547b9136396c15ab4e 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 
 /**
- * CardDAV plugin 
+ * CardDAV plugin
+ *
+ * The CardDAV plugin adds CardDAV functionality to the WebDAV server
  *
  * @package Sabre
  * @subpackage CardDAV
@@ -9,11 +11,6 @@
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-
-
-/**
- * The CardDAV plugin adds CardDAV functionality to the WebDAV server
- */
 class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
 
     /**
index 564ecd701f0ce9b461a95d705664e538e77bed95..e9f2de7f741e0ed553911b3acf61e973390932ed 100644 (file)
@@ -2,17 +2,15 @@
 
 /**
  * UserAddressBooks class
- * 
+ *
+ * The UserAddressBooks collection contains a list of addressbooks associated with a user
+ *
  * @package Sabre
  * @subpackage CardDAV
  * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-
-/**
- * The UserAddressBooks collection contains a list of addressbooks associated with a user
- */
 class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sabre_DAV_IExtendedCollection, Sabre_DAVACL_IACL {
 
     /**
index c76ee3603547f3ff0be211dc613e13809cca8ddb..900fbf5e75c22861fd27901ea93ae8fe81c211b5 100644 (file)
@@ -2,6 +2,8 @@
 
 /**
  * Version Class
+ *
+ * This class contains the Sabre_CardDAV version information
  * 
  * @package Sabre
  * @subpackage CardDAV 
@@ -9,10 +11,6 @@
  * @author Evert Pot (http://www.rooftopsolutions.nl/)
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-
-/**
- * This class contains the Sabre_CardDAV version information
- */
 class Sabre_CardDAV_Version {
 
     /**
index 8b55ec3ad9f4d5ac957b21889caa3fa767af0d34..ee8c698d782412ef00ba66327a3053ec0c8bd0c6 100644 (file)
@@ -88,7 +88,7 @@ class Sabre_DAV_Browser_GuessContentType extends Sabre_DAV_ServerPlugin {
     protected function getContentType($fileName) {
 
         // Just grabbing the extension
-        $extension = substr($fileName,strrpos($fileName,'.')+1);
+        $extension = strtolower(substr($fileName,strrpos($fileName,'.')+1));
         if (isset($this->extensionMap[$extension]))
             return $this->extensionMap[$extension];
 
index b99866dad5e12b1404795694be3d3dbe1dab4cb2..3d76d4f1918e9cabff7576e6d94805d4cdd02d5d 100644 (file)
@@ -821,7 +821,7 @@ class Sabre_DAV_Server {
 
             $node->put($body);
             $this->httpResponse->setHeader('Content-Length','0');
-            $this->httpResponse->sendStatus(200);
+            $this->httpResponse->sendStatus(204);
 
         } else {
 
index e7f7f83e6fffa9b1c1874e0fec4b123f9df30665..6bece1985e4e9706b7a7e41f1b738a61672e7b73 100644 (file)
@@ -14,7 +14,7 @@ class Sabre_DAV_Version {
     /**
      * Full version number
      */
-    const VERSION = '1.5.3';
+    const VERSION = '1.5.4';
 
     /**
      * Stability : alpha, beta, stable
index 640ab8efff4277be9d455631dc6ca06175103ba4..024ab6641f35a851aad6d01b1790482dda6e058d 100644 (file)
@@ -2,6 +2,9 @@
 
 /**
  * NeedPrivileges 
+ *
+ * The 403-need privileges is thrown when a user didn't have the appropriate
+ * permissions to perform an operation
  * 
  * @package Sabre
  * @subpackage DAVACL
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-
-/**
- * NeedPrivileges 
- *
- * The 403-need privileges is thrown when a user didn't have the appropriate
- * permissions to perform an operation
- */
 class Sabre_DAVACL_Exception_NeedPrivileges extends Sabre_DAV_Exception_Forbidden {
 
     /**
index 3cc0ae84621aed9862701d1cb9b807922c9bd620..4d22bf8aa7509b5e6d153e8f4788ffa3bbf80df6 100644 (file)
@@ -9,7 +9,7 @@
  * The users are instances of Sabre_DAV_Auth_Principal
  * 
  * @package Sabre
- * @subpackage DAV
+ * @subpackage DAVACL
  * @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
index 3d5a3d75635c80beeae49e9fde10d9925b75229e..47cf9f3d8125b889cdf16ac9c49199c22cc38170 100644 (file)
@@ -83,13 +83,16 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
             if (!is_null($itemValue)) {
                 throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject');
             }
+            $item->parent = $this;
             $this->children[] = $item;
         } elseif(is_string($item)) {
 
             if (!is_scalar($itemValue)) {
                 throw new InvalidArgumentException('The second argument must be scalar');
             }
-            $this->children[] = new Sabre_VObject_Property($item,$itemValue);
+            $item = new Sabre_VObject_Property($item,$itemValue);
+            $item->parent = $this;
+            $this->children[] = $item;
 
         } else {
             
@@ -208,16 +211,19 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
         $overWrite = count($matches)?key($matches):null;
 
         if ($value instanceof Sabre_VObject_Component || $value instanceof Sabre_VObject_Property) {
+            $value->parent = $this;
             if (!is_null($overWrite)) {
                 $this->children[$overWrite] = $value;
             } else {
                 $this->children[] = $value;
             }
         } elseif (is_scalar($value)) {
+            $property = new Sabre_VObject_Property($name,$value);
+            $property->parent = $this;
             if (!is_null($overWrite)) {
-                $this->children[$overWrite] = new Sabre_VObject_Property($name,$value);
+                $this->children[$overWrite] = $property;
             } else {
-                $this->children[] = new Sabre_VObject_Property($name,$value);
+                $this->children[] = $property;
             }
         } else {
             throw new InvalidArgumentException('You must pass a Sabre_VObject_Component, Sabre_VObject_Property or scalar type');
@@ -237,6 +243,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
         foreach($matches as $k=>$child) {
 
             unset($this->children[$k]);
+            $child->parent = null;
 
         }
 
index 30e5c6ca86a0695cec99e0a8ab99dbcdf593d475..3350ec02c88a9b00705790e338a1e3c9e9303fb3 100644 (file)
@@ -70,7 +70,7 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
                 $this->setValue($dt->format('Ymd\\THis'));
                 $this->offsetUnset('VALUE');
                 $this->offsetUnset('TZID');
-                $this->offsetSet('VALUE','DATE-TIME');
+                $this->offsetSet('VALUE','DATE-TIME'); 
                 break;
             case self::UTC :
                 $dt->setTimeZone(new DateTimeZone('UTC'));
@@ -116,7 +116,7 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
         list(
             $this->dateType,
             $this->dateTime
-        ) = self::parseData($this->value, $this->offsetGet('TZID'));
+        ) = self::parseData($this->value, $this);
         return $this->dateTime;
 
     }
@@ -137,7 +137,7 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
         list(
             $this->dateType,
             $this->dateTime,
-        ) = self::parseData($this->value, $this->offsetGet('TZID'));
+        ) = self::parseData($this->value, $this);
         return $this->dateType;
 
     }
@@ -151,12 +151,12 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
      *   2. A DateTime object (or null)
      *
      * @param string|null $propertyValue The string to parse (yymmdd or 
-     *    ymmddThhmmss, etc..)
-     * @param string|null $tzid The value of the 'TZID' property.
+     *                                   ymmddThhmmss, etc..)
+     * @param Sabre_VObject_Property|null $property The instance of the 
+     *                                              property we're parsing. 
      * @return array 
      */
-    static public function parseData($propertyValue, $tzid) {
-        
+    static public function parseData($propertyValue, Sabre_VObject_Property $property = null) {
 
         if (is_null($propertyValue)) {
             return array(null, null);
@@ -195,6 +195,8 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
             );
         }
 
+        // Finding the timezone.
+        $tzid = $property['TZID'];
         if (!$tzid) {
             return array(
                 self::LOCAL,
@@ -202,7 +204,32 @@ class Sabre_VObject_Element_DateTime extends Sabre_VObject_Property {
             );
         }
 
-        $tz = new DateTimeZone($tzid->value);
+        try {
+            $tz = new DateTimeZone($tzid->value);
+        } catch (Exception $e) {
+
+            // The id was invalid, we're going to try to find the information 
+            // through the VTIMEZONE object.
+
+            // First we find the root object
+            $root = $property;
+            while($root->parent) {
+                $root = $root->parent;
+            }
+
+            if (isset($root->VTIMEZONE)) {
+                foreach($root->VTIMEZONE as $vtimezone) {
+                    if (((string)$vtimezone->TZID) == $tzid) {
+                        if (isset($vtimezone->{'X-LIC-LOCATION'})) {
+                            $tzid = (string)$vtimezone->{'X-LIC-LOCATION'};
+                        }
+                    }
+                }
+            }
+
+            $tz = new DateTimeZone($tzid);
+            
+        }
         $dt = new DateTime($dateStr, $tz);
         $dt->setTimeZone($tz);
 
index 5e677f5e5b5feab9f3968f9c925d61675269c3fc..dc6ca5abb8021e90300f97176c05ec0686fd6530 100644 (file)
@@ -60,7 +60,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
                     $val[] = $i->format('Ymd\\THis');
                 }
                 $this->setValue(implode(',',$val));
-                $this->offsetSet('VALUE','DATE-TIME');
+                $this->offsetSet('VALUE','DATE-TIME'); 
                 break;
             case Sabre_VObject_Element_DateTime::UTC :
                 $val = array();
@@ -121,7 +121,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
             list(
                 $type,
                 $dt
-            ) = Sabre_VObject_Element_DateTime::parseData($val, $this->offsetGet('TZID'));
+            ) = Sabre_VObject_Element_DateTime::parseData($val, $this);
             $dts[] = $dt;
             $this->dateType = $type;
         }
@@ -154,7 +154,7 @@ class Sabre_VObject_Element_MultiDateTime extends Sabre_VObject_Property {
             list(
                 $type,
                 $dt
-            ) = Sabre_VObject_Element_DateTime::parseData($val, $this->offsetGet('TZID'));
+            ) = Sabre_VObject_Element_DateTime::parseData($val, $this);
             $dts[] = $dt;
             $this->dateType = $type; 
         }
index efc7f76da79894a366358e82d0b8f7e1191a36cc..7100b62f1cb2a916f43bb64190fae8734539172a 100644 (file)
@@ -25,6 +25,13 @@ abstract class Sabre_VObject_Node implements IteratorAggregate, ArrayAccess, Cou
      */
     protected $iterator = null;
 
+    /**
+     * A link to the parent node
+     * 
+     * @var Sabre_VObject_Node 
+     */
+    protected $parent = null;
+
     /* {{{ IteratorAggregator interface */
 
     /**
index 624dd4b8a58e3fe2398e0295f8431a34384792d2..060582290438d8dd520960c54b79a108305eb2e9 100644 (file)
@@ -149,13 +149,16 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
             if (!is_null($itemValue)) {
                 throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject');
             }
+            $item->parent = $this;
             $this->parameters[] = $item;
         } elseif(is_string($item)) {
 
             if (!is_scalar($itemValue)) {
                 throw new InvalidArgumentException('The second argument must be scalar');
             }
-            $this->parameters[] = new Sabre_VObject_Parameter($item,$itemValue);
+            $parameter = new Sabre_VObject_Parameter($item,$itemValue);
+            $parameter->parent = $this;
+            $this->parameters[] = $parameter;
 
         } else {
             
@@ -231,12 +234,15 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
                 throw new InvalidArgumentException('A parameter name must be specified. This means you cannot use the $array[]="string" to add parameters.');
 
             $this->offsetUnset($name);
-            $this->parameters[] = new Sabre_VObject_Parameter($name, $value);
+            $parameter = new Sabre_VObject_Parameter($name, $value);
+            $parameter->parent = $this;
+            $this->parameters[] = $parameter;
 
         } elseif ($value instanceof Sabre_VObject_Parameter) {
             if (!is_null($name))
                 throw new InvalidArgumentException('Don\'t specify a parameter name if you\'re passing a Sabre_VObject_Parameter. Add using $array[]=$parameterObject.');
-            
+
+            $value->parent = $this; 
             $this->parameters[] = $value;
         } else {
             throw new InvalidArgumentException('You can only add parameters to the property object');
@@ -258,6 +264,7 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
         $result = array();
         foreach($this->parameters as $key=>$parameter) {
             if ($parameter->name == $name) {
+                $parameter->parent = null;
                 unset($this->parameters[$key]);
             }
 
index c38afbfb632b419592fd0c536539b568a6094d83..5ed7882ac91fabee3f8fc7607293736b112d06eb 100644 (file)
@@ -95,7 +95,7 @@ class Sabre_VObject_Reader {
 
             while(stripos($nextLine,"END:")!==0) {
 
-                $obj->children[] = self::readLine($lines);
+                $obj->add(self::readLine($lines));
                 $nextLine = current($lines);
 
                 if ($nextLine===false) 
@@ -140,7 +140,9 @@ class Sabre_VObject_Reader {
 
         if ($matches['parameters']) {
 
-            $obj->parameters = self::readParameters($matches['parameters']);
+            foreach(self::readParameters($matches['parameters']) as $param) {
+                $obj->add($param);
+            }
         } 
 
         return $obj;
index 950c1c51104d54a82e16b8955424e27efd296204..937c367e222afa447e57a3628519d860939e21e9 100644 (file)
@@ -14,7 +14,7 @@ class Sabre_VObject_Version {
     /**
      * Full version number
      */
-    const VERSION = '1.2.2';
+    const VERSION = '1.2.4';
 
     /**
      * Stability : alpha, beta, stable