]> source.dussan.org Git - nextcloud-server.git/commitdiff
Updating SabreDAV to current head
authorJakob Sack <kde@jakobsack.de>
Tue, 2 Aug 2011 17:38:44 +0000 (19:38 +0200)
committerJakob Sack <kde@jakobsack.de>
Tue, 2 Aug 2011 17:38:44 +0000 (19:38 +0200)
19 files changed:
3dparty/Sabre.includes.php
3dparty/Sabre/CalDAV/Calendar.php
3dparty/Sabre/CalDAV/CalendarObject.php
3dparty/Sabre/CalDAV/CalendarRootNode.php
3dparty/Sabre/CalDAV/ICalendarUtil.php
3dparty/Sabre/CardDAV/AddressBook.php
3dparty/Sabre/CardDAV/AddressBookRoot.php
3dparty/Sabre/CardDAV/Backend/PDO.php
3dparty/Sabre/CardDAV/Card.php
3dparty/Sabre/CardDAV/Plugin.php
3dparty/Sabre/CardDAV/UserAddressBooks.php
3dparty/Sabre/DAV/Collection.php [new file with mode: 0644]
3dparty/Sabre/DAV/Directory.php
3dparty/Sabre/DAV/ObjectTree.php
3dparty/Sabre/DAV/Server.php
3dparty/Sabre/DAV/SimpleCollection.php [new file with mode: 0644]
3dparty/Sabre/DAV/SimpleDirectory.php
3dparty/Sabre/DAVACL/AbstractPrincipalCollection.php
3dparty/Sabre/VObject/Reader.php

index 6b179e34fd8c662b8b431905868f2482179a0020..9d389288c78484005db03fb20e3501b614908a1d 100644 (file)
@@ -74,6 +74,7 @@ include 'Sabre/DAV/File.php';
 include 'Sabre/DAV/Directory.php';
 
 /* Utilities */
+include 'Sabre/DAV/SimpleCollection.php';
 include 'Sabre/DAV/SimpleDirectory.php';
 include 'Sabre/DAV/XMLUtil.php';
 include 'Sabre/DAV/URLUtil.php';
index 010554b6d92927b8ac64d8cf84be2e0b4ec02bf9..a50aef12b4f6fc4e4515e211efa15f0e46c6bc3e 100644 (file)
@@ -179,7 +179,12 @@ class Sabre_CalDAV_Calendar implements Sabre_DAV_ICollection, Sabre_DAV_IPropert
 
         $calendarData = stream_get_contents($calendarData);
 
-        $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set']->getValue();
+        $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set'];
+        if ($supportedComponents) {
+            $supportedComponents = $supportedComponents->getValue();
+        } else {
+            $supportedComponents = null;
+        }
         Sabre_CalDAV_ICalendarUtil::validateICalendarObject($calendarData, $supportedComponents);
 
         $this->caldavBackend->createCalendarObject($this->calendarInfo['id'],$name,$calendarData);
index efec35dccad4c0a5733d0dc4ad05b054cee448be..b5c4e49b838ce669eac8cd74a3b82491c05e3f65 100644 (file)
@@ -93,7 +93,12 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_DAVACL
         if (is_resource($calendarData))
             $calendarData = stream_get_contents($calendarData);
 
-        $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set']->getValue();
+        $supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set'];
+        if ($supportedComponents) {
+            $supportedComponents = $supportedComponents->getValue();
+        } else {
+            $supportedComponents = null;
+        }
         Sabre_CalDAV_ICalendarUtil::validateICalendarObject($calendarData, $supportedComponents);
 
         $this->caldavBackend->updateCalendarObject($this->calendarInfo['id'],$this->objectData['uri'],$calendarData);
index 5c9b37e7d5d3fcc2d9049d6d07007771e15f4a94..69669a9d7fd96a5612661cf463621f242c8fcd3e 100644 (file)
@@ -25,8 +25,15 @@ class Sabre_CalDAV_CalendarRootNode extends Sabre_DAVACL_AbstractPrincipalCollec
      *
      * This constructor needs both an authentication and a caldav backend.
      *
+     * By default this class will show a list of calendar collections for 
+     * principals in the 'principals' collection. If your main principals are 
+     * actually located in a different path, use the $principalPrefix argument 
+     * to override this.
+     *
+     *
      * @param Sabre_DAVACL_IPrincipalBackend $principalBackend 
      * @param Sabre_CalDAV_Backend_Abstract $caldavBackend 
+     * @param string $principalPrefix
      */
     public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend,Sabre_CalDAV_Backend_Abstract $caldavBackend, $principalPrefix = 'principals') {
 
index fbfef397ac6f2367c2a12777196e1b61321cf79f..699abfdd6f5e0726701664a849405df4b422fe32 100644 (file)
@@ -20,12 +20,12 @@ class Sabre_CalDAV_ICalendarUtil {
      *
      * This method makes sure this ICalendar object is properly formatted.
      * If we can't parse it, we'll throw exceptions.
-     * 
+     *
      * @param string $icalData 
      * @param array $allowedComponents 
      * @return bool 
      */
-    static function validateICalendarObject($icalData, array $allowedComponents) {
+    static function validateICalendarObject($icalData, array $allowedComponents = null) {
 
         $xcal = simplexml_load_string(self::toXCal($icalData));
         if (!$xcal) throw new Sabre_CalDAV_Exception_InvalidICalendarObject('Invalid calendarobject format');
@@ -44,7 +44,9 @@ class Sabre_CalDAV_ICalendarUtil {
             throw new Sabre_CalDAV_Exception_InvalidICalendarObject('One VEVENT, VTODO, VJOURNAL or VFREEBUSY must be specified. 0 found.');
         }
         $component = $componentsFound[0];
-        
+
+        if (is_null($allowedComponents)) return true;
+
         // Check if the component is allowed
         $name = $component->getName();
         if (!in_array(strtoupper($name),$allowedComponents)) {
index a4d2d0c47839eb045240587561190d3be4e30f03..04e4c227b86574104449a77d237893560698da51 100644 (file)
@@ -15,7 +15,7 @@
  *
  * The AddressBook can contain multiple vcards
  */
-class Sabre_CardDAV_AddressBook extends Sabre_DAV_Directory implements Sabre_CardDAV_IAddressBook, Sabre_DAV_IProperties {
+class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_CardDAV_IAddressBook, Sabre_DAV_IProperties, Sabre_DAVACL_IACL {
 
     /**
      * This is an array with addressbook information 
@@ -129,8 +129,7 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Directory implements Sabre_Car
     }
 
     /**
-     * Renames the addressbook. Note that most calendars use the 
-     * {DAV:}displayname to display a name to display a name. 
+     * Renames the addressbook
      * 
      * @param string $newName 
      * @return void
@@ -221,5 +220,76 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Directory implements Sabre_Car
 
     }
 
+    /**
+     * Returns the owner principal
+     *
+     * This must be a url to a principal, or null if there's no owner 
+     * 
+     * @return string|null
+     */
+    public function getOwner() {
+
+        return $this->addressBookInfo['principaluri'];
+
+    }
+
+    /**
+     * Returns a group principal
+     *
+     * This must be a url to a principal, or null if there's no owner
+     * 
+     * @return string|null 
+     */
+    public function getGroup() {
+
+        return null;
+
+    }
+
+    /**
+     * Returns a list of ACE's for this node.
+     *
+     * Each ACE has the following properties:
+     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are 
+     *     currently the only supported privileges
+     *   * 'principal', a url to the principal who owns the node
+     *   * 'protected' (optional), indicating that this ACE is not allowed to 
+     *      be updated. 
+     * 
+     * @return array 
+     */
+    public function getACL() {
+
+        return array(
+            array(
+                'privilege' => '{DAV:}read',
+                'principal' => $this->addressBookInfo['principaluri'],
+                'protected' => true,
+            ),
+            array(
+                'privilege' => '{DAV:}write',
+                'principal' => $this->addressBookInfo['principaluri'],
+                'protected' => true,
+            ),
+
+        );
+
+    }
+
+    /**
+     * Updates the ACL
+     *
+     * This method will receive a list of new ACE's. 
+     * 
+     * @param array $acl 
+     * @return void
+     */
+    public function setACL(array $acl) {
+
+        throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported');
+
+    }
+
+
 
 }
index 88c8ed2e061e6ea655161a16dfcc4e74f8d6f3b2..1a80efba35e38e58251f0b13e815843f5e4d8f06 100644 (file)
@@ -32,13 +32,19 @@ class Sabre_CardDAV_AddressBookRoot extends Sabre_DAVACL_AbstractPrincipalCollec
      *
      * This constructor needs both a principal and a carddav backend.
      *
+     * By default this class will show a list of addressbook collections for 
+     * principals in the 'principals' collection. If your main principals are 
+     * actually located in a different path, use the $principalPrefix argument 
+     * to override this.
+     *
      * @param Sabre_DAVACL_IPrincipalBackend $principalBackend 
-     * @param Sabre_CardDAV_Backend_Abstract $carddavBackend 
+     * @param Sabre_CardDAV_Backend_Abstract $carddavBackend
+     * @param string $principalPrefix 
      */
-    public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend,Sabre_CardDAV_Backend_Abstract $carddavBackend) {
+    public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend,Sabre_CardDAV_Backend_Abstract $carddavBackend, $principalPrefix = 'principals') {
 
         $this->carddavBackend = $carddavBackend;
-        parent::__construct($principalBackend);
+        parent::__construct($principalBackend, $principalPrefix);
 
     }
 
index e7cd4ecd4df473c59b85952ca42a739d3f867834..63a74745aaca8c18a8f9132f442b4cbc5e339fa0 100644 (file)
@@ -22,14 +22,26 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
      */
     protected $pdo;
 
+    /**
+     * The PDO table name used to store addressbooks
+     */
+    protected $addressBooksTableName;
+
+    /**
+     * The PDO table name used to store cards
+     */
+    protected $cardsTableName;
+
     /**
      * Sets up the object 
      * 
      * @param PDO $pdo 
      */
-    public function __construct(PDO $pdo) {
+    public function __construct(PDO $pdo, $addressBooksTableName = 'addressbooks', $cardsTableName = 'cards') {
 
         $this->pdo = $pdo;
+        $this->addressBooksTableName = $addressBooksTableName;
+        $this->cardsTableName = $cardsTableName; 
 
     }
 
@@ -41,7 +53,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
      */
     public function getAddressBooksForUser($principalUri) {
 
-        $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, ctag FROM addressbooks WHERE principaluri = ?');
+        $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, ctag FROM `'.$this->addressBooksTableName.'` WHERE principaluri = ?');
         $result = $stmt->execute(array($principalUri));
 
         $addressBooks = array();
@@ -101,7 +113,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
             return false;
         }
 
-        $query = 'UPDATE addressbooks SET ctag = ctag + 1 ';
+        $query = 'UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 ';
         foreach($updates as $key=>$value) {
             $query.=', `' . $key . '` = :' . $key . ' ';
         }
@@ -148,7 +160,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
 
         }
 
-        $query = 'INSERT INTO addressbooks (uri, displayname, description, principaluri, ctag) VALUES (:uri, :displayname, :description, :principaluri, 1)';
+        $query = 'INSERT INTO `' . $this->addressBooksTableName . '` (uri, displayname, description, principaluri, ctag) VALUES (:uri, :displayname, :description, :principaluri, 1)';
         $stmt = $this->pdo->prepare($query);
         $stmt->execute($values);
 
@@ -162,10 +174,10 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
      */
     public function deleteAddressBook($addressBookId) {
 
-        $stmt = $this->pdo->prepare('DELETE FROM cards WHERE addressbookid = ?');
+        $stmt = $this->pdo->prepare('DELETE FROM `' . $this->cardsTableName . '` WHERE addressbookid = ?');
         $stmt->execute(array($addressBookId));
 
-        $stmt = $this->pdo->prepare('DELETE FROM addressbooks WHERE id = ?');
+        $stmt = $this->pdo->prepare('DELETE FROM `' . $this->addressBooksTableName . '` WHERE id = ?');
         $stmt->execute(array($addressBookId));
 
     }
@@ -178,7 +190,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
      */
     public function getCards($addressbookId) {
 
-        $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM cards WHERE addressbookid = ?');
+        $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM `' . $this->cardsTableName . '` WHERE addressbookid = ?');
         $stmt->execute(array($addressbookId));
 
         return $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -194,7 +206,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
      */
     public function getCard($addressBookId, $cardUri) {
 
-        $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM cards WHERE addressbookid = ? AND uri = ? LIMIT 1');
+        $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM `' . $this->cardsTableName . '` WHERE addressbookid = ? AND uri = ? LIMIT 1');
         $stmt->execute(array($addressBookId, $cardUri));
 
         $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -213,11 +225,11 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
      */
     public function createCard($addressBookId, $cardUri, $cardData) {
 
-        $stmt = $this->pdo->prepare('INSERT INTO cards (carddata, uri, lastmodified, addressbookid) VALUES (?, ?, ?, ?)');
+        $stmt = $this->pdo->prepare('INSERT INTO `' . $this->cardsTableName . '` (carddata, uri, lastmodified, addressbookid) VALUES (?, ?, ?, ?)');
 
         $result = $stmt->execute(array($cardData, $cardUri, time(), $addressBookId));
 
-        $stmt2 = $this->pdo->prepare('UPDATE addressbooks SET ctag = ctag + 1 WHERE id = ?');
+        $stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?');
         $stmt2->execute(array($addressBookId));
 
         return $result;
@@ -234,10 +246,10 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
      */
     public function updateCard($addressBookId, $cardUri, $cardData) {
 
-        $stmt = $this->pdo->prepare('UPDATE cards SET carddata = ?, lastmodified = ? WHERE uri = ? AND addressbookid =?');
+        $stmt = $this->pdo->prepare('UPDATE `' . $this->cardsTableName . '` SET carddata = ?, lastmodified = ? WHERE uri = ? AND addressbookid =?');
         $result = $stmt->execute(array($cardData, time(), $cardUri, $addressBookId));
 
-        $stmt2 = $this->pdo->prepare('UPDATE addressbooks SET ctag = ctag + 1 WHERE id = ?');
+        $stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?');
         $stmt2->execute(array($addressBookId));
 
         return $stmt->rowCount()===1;
@@ -253,10 +265,10 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
      */
     public function deleteCard($addressBookId, $cardUri) {
 
-        $stmt = $this->pdo->prepare('DELETE FROM cards WHERE addressbookid = ? AND uri = ?');
+        $stmt = $this->pdo->prepare('DELETE FROM `' . $this->cardsTableName . '` WHERE addressbookid = ? AND uri = ?');
         $stmt->execute(array($addressBookId, $cardUri));
 
-        $stmt2 = $this->pdo->prepare('UPDATE addressbooks SET ctag = ctag + 1 WHERE id = ?');
+        $stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?');
         $stmt2->execute(array($addressBookId));
 
         return $stmt->rowCount()===1;
index a12e6d3914b5bbf004bd926a88c24da364266532..98189aa9fd8327e28c204555695ca84963f438d6 100644 (file)
@@ -13,7 +13,7 @@
 /**
  * The Card object represents a single Card from an addressbook
  */ 
-class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard {
+class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard, Sabre_DAVACL_IACL {
 
     /**
      * CardDAV backend
@@ -147,5 +147,75 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard {
         return strlen($this->cardData['carddata']);
 
     }
+
+    /**
+     * Returns the owner principal
+     *
+     * This must be a url to a principal, or null if there's no owner 
+     * 
+     * @return string|null
+     */
+    public function getOwner() {
+
+        return $this->addressBookInfo['principaluri'];
+
+    }
+
+    /**
+     * Returns a group principal
+     *
+     * This must be a url to a principal, or null if there's no owner
+     * 
+     * @return string|null 
+     */
+    public function getGroup() {
+
+        return null;
+
+    }
+
+    /**
+     * Returns a list of ACE's for this node.
+     *
+     * Each ACE has the following properties:
+     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are 
+     *     currently the only supported privileges
+     *   * 'principal', a url to the principal who owns the node
+     *   * 'protected' (optional), indicating that this ACE is not allowed to 
+     *      be updated. 
+     * 
+     * @return array 
+     */
+    public function getACL() {
+
+        return array(
+            array(
+                'privilege' => '{DAV:}read',
+                'principal' => $this->addressBookInfo['principaluri'],
+                'protected' => true,
+            ),
+            array(
+                'privilege' => '{DAV:}write',
+                'principal' => $this->addressBookInfo['principaluri'],
+                'protected' => true,
+            ),
+        );
+
+    }
+
+    /**
+     * Updates the ACL
+     *
+     * This method will receive a list of new ACE's. 
+     * 
+     * @param array $acl 
+     * @return void
+     */
+    public function setACL(array $acl) {
+
+        throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported');
+
+    }
+
 }
 
index 16fadc526e456e402de86da840b753d59ef14a8c..a96f9aaebb6872be472ab4f4861f1cc611d8213f 100644 (file)
@@ -391,7 +391,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
                 foreach($vProperties as $vProperty) {
                     // If we got all the way here, we'll need to validate the 
                     // text-match filter.
-                    $success = Sabre_DAV_StringUtil::textMatch($vProperty[$filter['name']]->value, $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['matchType']);
+                    $success = Sabre_DAV_StringUtil::textMatch($vProperty[$filter['name']]->value, $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['match-type']);
                     if ($success) break;
                 }
                 if ($filter['text-match']['negate-condition']) {
@@ -434,7 +434,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
 
             $success = false;
             foreach($texts as $haystack) {
-                $success = Sabre_DAV_StringUtil::textMatch($haystack, $filter['value'], $filter['collation'], $filter['matchType']);
+                $success = Sabre_DAV_StringUtil::textMatch($haystack, $filter['value'], $filter['collation'], $filter['match-type']);
 
                 // Breaking on the first match
                 if ($success) break;
index 186bf016a1e036418e91bc538c004ad6b2aa8e10..564ecd701f0ce9b461a95d705664e538e77bed95 100644 (file)
@@ -13,7 +13,7 @@
 /**
  * The UserAddressBooks collection contains a list of addressbooks associated with a user
  */
-class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Directory implements Sabre_DAV_IExtendedCollection {
+class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sabre_DAV_IExtendedCollection, Sabre_DAVACL_IACL {
 
     /**
      * Principal uri
@@ -168,4 +168,75 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Directory implements Sabr
 
     }
 
+    /**
+     * Returns the owner principal
+     *
+     * This must be a url to a principal, or null if there's no owner 
+     * 
+     * @return string|null
+     */
+    public function getOwner() {
+
+        return $this->principalUri;
+
+    }
+
+    /**
+     * Returns a group principal
+     *
+     * This must be a url to a principal, or null if there's no owner
+     * 
+     * @return string|null 
+     */
+    public function getGroup() {
+
+        return null;
+
+    }
+
+    /**
+     * Returns a list of ACE's for this node.
+     *
+     * Each ACE has the following properties:
+     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are 
+     *     currently the only supported privileges
+     *   * 'principal', a url to the principal who owns the node
+     *   * 'protected' (optional), indicating that this ACE is not allowed to 
+     *      be updated. 
+     * 
+     * @return array 
+     */
+    public function getACL() {
+
+        return array(
+            array(
+                'privilege' => '{DAV:}read',
+                'principal' => $this->principalUri,
+                'protected' => true,
+            ),
+            array(
+                'privilege' => '{DAV:}write',
+                'principal' => $this->principalUri,
+                'protected' => true,
+            ),
+
+        );
+
+    }
+
+    /**
+     * Updates the ACL
+     *
+     * This method will receive a list of new ACE's. 
+     * 
+     * @param array $acl 
+     * @return void
+     */
+    public function setACL(array $acl) {
+
+        throw new Sabre_DAV_Exception_MethodNotAllowed('Changing ACL is not yet supported');
+
+    }
+
+
 }
diff --git a/3dparty/Sabre/DAV/Collection.php b/3dparty/Sabre/DAV/Collection.php
new file mode 100644 (file)
index 0000000..9da04c1
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+
+/**
+ * Collection class
+ *
+ * This is a helper class, that should aid in getting collections classes setup.
+ * Most of its methods are implemented, and throw permission denied exceptions 
+ * 
+ * @package Sabre
+ * @subpackage DAV
+ * @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
+ */
+abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_ICollection {
+
+    /**
+     * Returns a child object, by its name.
+     *
+     * This method makes use of the getChildren method to grab all the child nodes, and compares the name. 
+     * Generally its wise to override this, as this can usually be optimized
+     * 
+     * @param string $name
+     * @throws Sabre_DAV_Exception_FileNotFound
+     * @return Sabre_DAV_INode 
+     */
+    public function getChild($name) {
+
+        foreach($this->getChildren() as $child) {
+
+            if ($child->getName()==$name) return $child;
+
+        }
+        throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name);
+
+    }
+
+    /**
+     * Checks is a child-node exists.
+     *
+     * It is generally a good idea to try and override this. Usually it can be optimized.
+     * 
+     * @param string $name 
+     * @return bool 
+     */
+    public function childExists($name) {
+
+        try {
+
+            $this->getChild($name);
+            return true;
+
+        } catch(Sabre_DAV_Exception_FileNotFound $e) {
+
+            return false;
+
+        }
+
+    }
+
+    /**
+     * Creates a new file in the directory 
+     * 
+     * @param string $name Name of the file 
+     * @param resource $data Initial payload, passed as a readable stream resource. 
+     * @throws Sabre_DAV_Exception_Forbidden
+     * @return void
+     */
+    public function createFile($name, $data = null) {
+
+        throw new Sabre_DAV_Exception_Forbidden('Permission denied to create file (filename ' . $name . ')');
+
+    }
+
+    /**
+     * Creates a new subdirectory 
+     * 
+     * @param string $name 
+     * @throws Sabre_DAV_Exception_Forbidden
+     * @return void
+     */
+    public function createDirectory($name) {
+
+        throw new Sabre_DAV_Exception_Forbidden('Permission denied to create directory');
+
+    }
+
+
+}
+
index 14d7f2cb679a77264dec7765b2eb7ac0f6b57131..86af4827b3edf5555142e6e875b28f060fe7f338 100644 (file)
@@ -3,88 +3,15 @@
 /**
  * Directory class
  *
- * This is a helper class, that should aid in getting directory classes setup.
- * Most of its methods are implemented, and throw permission denied exceptions 
- * 
+ * This class is now deprecated in favor of the Sabre_DAV_Collection class.
+ *
  * @package Sabre
  * @subpackage DAV
+ * @deprecated Use Sabre_DAV_Collection instead
  * @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
  */
-abstract class Sabre_DAV_Directory extends Sabre_DAV_Node implements Sabre_DAV_ICollection {
-
-    /**
-     * Returns a child object, by its name.
-     *
-     * This method makes use of the getChildren method to grab all the child nodes, and compares the name. 
-     * Generally its wise to override this, as this can usually be optimized
-     * 
-     * @param string $name
-     * @throws Sabre_DAV_Exception_FileNotFound
-     * @return Sabre_DAV_INode 
-     */
-    public function getChild($name) {
-
-        foreach($this->getChildren() as $child) {
-
-            if ($child->getName()==$name) return $child;
-
-        }
-        throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name);
-
-    }
-
-    /**
-     * Checks is a child-node exists.
-     *
-     * It is generally a good idea to try and override this. Usually it can be optimized.
-     * 
-     * @param string $name 
-     * @return bool 
-     */
-    public function childExists($name) {
-
-        try {
-
-            $this->getChild($name);
-            return true;
-
-        } catch(Sabre_DAV_Exception_FileNotFound $e) {
-
-            return false;
-
-        }
-
-    }
-
-    /**
-     * Creates a new file in the directory 
-     * 
-     * @param string $name Name of the file 
-     * @param resource $data Initial payload, passed as a readable stream resource. 
-     * @throws Sabre_DAV_Exception_Forbidden
-     * @return void
-     */
-    public function createFile($name, $data = null) {
-
-        throw new Sabre_DAV_Exception_Forbidden('Permission denied to create file (filename ' . $name . ')');
-
-    }
-
-    /**
-     * Creates a new subdirectory 
-     * 
-     * @param string $name 
-     * @throws Sabre_DAV_Exception_Forbidden
-     * @return void
-     */
-    public function createDirectory($name) {
-
-        throw new Sabre_DAV_Exception_Forbidden('Permission denied to create directory');
-
-    }
-
-
+abstract class Sabre_DAV_Directory extends Sabre_DAV_Collection {
 }
 
index 1319c7daefa2cc870e8208d1d096fc2cb7d797fd..f12a36837052c058d4a35e7ae30a0c48d4aeb13e 100644 (file)
@@ -89,6 +89,7 @@ class Sabre_DAV_ObjectTree extends Sabre_DAV_Tree {
             list($parent, $base) = Sabre_DAV_URLUtil::splitPath($path);
 
             $parentNode = $this->getNodeForPath($parent);
+            if (!$parentNode instanceof Sabre_DAV_ICollection) return false;
             return $parentNode->childExists($base);
 
         } catch (Sabre_DAV_Exception_FileNotFound $e) {
index e912dea0f1d8ecf70c0ce1bb36774caa0461a4fe..e5e9e482fee3da8d7d5052e3ace5e0ecbc1aa2b4 100644 (file)
@@ -150,7 +150,7 @@ class Sabre_DAV_Server {
      * use it as the directory tree. If a Sabre_DAV_INode is passed, it
      * will create a Sabre_DAV_ObjectTree and use the node as the root.
      *
-     * If nothing is passed, a Sabre_DAV_SimpleDirectory is created in 
+     * If nothing is passed, a Sabre_DAV_SimpleCollection is created in 
      * a Sabre_DAV_ObjectTree.
      *
      * If an array is passed, we automatically create a root node, and use
@@ -175,11 +175,11 @@ class Sabre_DAV_Server {
                 }
             }
 
-            $root = new Sabre_DAV_SimpleDirectory('root', $treeOrNode);
+            $root = new Sabre_DAV_SimpleCollection('root', $treeOrNode);
             $this->tree = new Sabre_DAV_ObjectTree($root);
 
         } elseif (is_null($treeOrNode)) {
-            $root = new Sabre_DAV_SimpleDirectory('root');
+            $root = new Sabre_DAV_SimpleCollection('root');
             $this->tree = new Sabre_DAV_ObjectTree($root);
         } else {
             throw new Sabre_DAV_Exception('Invalid argument passed to constructor. Argument must either be an instance of Sabre_DAV_Tree, Sabre_DAV_INode, an array or null');
@@ -1396,18 +1396,6 @@ class Sabre_DAV_Server {
         $this->broadcastEvent('afterBind',array($uri));
     }
 
-    /**
-     * This method is invoked by sub-systems creating a new directory.
-     *
-     * @param string $uri 
-     * @return void
-     */
-    public function createDirectory($uri) {
-
-        $this->createCollection($uri,array('{DAV:}collection'),array());
-
-    }
-
     /**
      * Use this method to create a new collection
      *
diff --git a/3dparty/Sabre/DAV/SimpleCollection.php b/3dparty/Sabre/DAV/SimpleCollection.php
new file mode 100644 (file)
index 0000000..223d05f
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+
+/**
+ * SimpleCollection
+ *
+ * The SimpleCollection is used to quickly setup static directory structures.
+ * Just create the object with a proper name, and add children to use it.
+ *
+ * @package Sabre
+ * @subpackage DAV
+ * @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
+ */
+class Sabre_DAV_SimpleCollection extends Sabre_DAV_Collection {
+
+    /**
+     * List of childnodes 
+     *
+     * @var array
+     */
+    protected $children = array();
+
+    /**
+     * Name of this resource 
+     * 
+     * @var string 
+     */
+    protected $name;
+
+    /**
+     * Creates this node
+     *
+     * The name of the node must be passed, child nodes can also be bassed.
+     * This nodes must be instances of Sabre_DAV_INode
+     * 
+     * @param string $name 
+     * @param array $children 
+     * @return void
+     */
+    public function __construct($name,array $children = array()) {
+
+        $this->name = $name;
+        foreach($children as $child) {
+
+            if (!($child instanceof Sabre_DAV_INode)) throw new Sabre_DAV_Exception('Only instances of Sabre_DAV_INode are allowed to be passed in the children argument');
+            $this->addChild($child);
+
+        }
+
+    }
+
+    /**
+     * Adds a new childnode to this collection 
+     * 
+     * @param Sabre_DAV_INode $child 
+     * @return void
+     */
+    public function addChild(Sabre_DAV_INode $child) {
+
+        $this->children[$child->getName()] = $child;
+
+    }
+
+    /**
+     * Returns the name of the collection 
+     * 
+     * @return string 
+     */
+    public function getName() {
+
+        return $this->name;
+
+    }
+
+    /**
+     * Returns a child object, by its name.
+     *
+     * This method makes use of the getChildren method to grab all the child nodes, and compares the name. 
+     * Generally its wise to override this, as this can usually be optimized
+     * 
+     * @param string $name
+     * @throws Sabre_DAV_Exception_FileNotFound
+     * @return Sabre_DAV_INode 
+     */
+    public function getChild($name) {
+
+        if (isset($this->children[$name])) return $this->children[$name];
+        throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\'');
+
+    }
+
+    /**
+     * Returns a list of children for this collection 
+     * 
+     * @return array 
+     */
+    public function getChildren() {
+
+        return array_values($this->children);
+
+    }
+
+
+}
+
index 8c79962a95f71be79e9426cc978e3f63b6723b83..516a3aa907c8d55511e7d15d421baa29e17a1738 100644 (file)
  * The SimpleDirectory is used to quickly setup static directory structures.
  * Just create the object with a proper name, and add children to use it.
  *
+ * This class is now deprecated, use Sabre_DAV_SimpleCollection instead.
+ *
  * @package Sabre
  * @subpackage DAV
+ * @deprecated Use Sabre_DAV_SimpleCollection instead.
  * @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
  */
-class Sabre_DAV_SimpleDirectory extends Sabre_DAV_Directory {
-
-    /**
-     * List of childnodes 
-     *
-     * @var array
-     */
-    protected $children = array();
-
-    /**
-     * Name of this resource 
-     * 
-     * @var string 
-     */
-    protected $name;
-
-    /**
-     * Creates this node
-     *
-     * The name of the node must be passed, child nodes can also be bassed.
-     * This nodes must be instances of Sabre_DAV_INode
-     * 
-     * @param string $name 
-     * @param array $children 
-     * @return void
-     */
-    public function __construct($name,array $children = array()) {
-
-        $this->name = $name;
-        foreach($children as $child) {
-
-            if (!($child instanceof Sabre_DAV_INode)) throw new Sabre_DAV_Exception('Only instances of Sabre_DAV_INode are allowed to be passed in the children argument');
-            $this->addChild($child);
-
-        }
-
-    }
-
-    /**
-     * Adds a new childnode to this collection 
-     * 
-     * @param Sabre_DAV_INode $child 
-     * @return void
-     */
-    public function addChild(Sabre_DAV_INode $child) {
-
-        $this->children[$child->getName()] = $child;
-
-    }
-
-    /**
-     * Returns the name of the collection 
-     * 
-     * @return string 
-     */
-    public function getName() {
-
-        return $this->name;
-
-    }
-
-    /**
-     * Returns a child object, by its name.
-     *
-     * This method makes use of the getChildren method to grab all the child nodes, and compares the name. 
-     * Generally its wise to override this, as this can usually be optimized
-     * 
-     * @param string $name
-     * @throws Sabre_DAV_Exception_FileNotFound
-     * @return Sabre_DAV_INode 
-     */
-    public function getChild($name) {
-
-        if (isset($this->children[$name])) return $this->children[$name];
-        throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\'');
-
-    }
-
-    /**
-     * Returns a list of children for this collection 
-     * 
-     * @return array 
-     */
-    public function getChildren() {
-
-        return array_values($this->children);
-
-    }
-
+class Sabre_DAV_SimpleDirectory extends Sabre_DAV_SimpleCollection {
 
 }
 
index 7d120feb2bf5ccf6dd3c5ef9c0560291bf069daa..a361e054610dd2251f3bb1961b879a95de39d79a 100644 (file)
@@ -14,7 +14,7 @@
  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
  */
-abstract class Sabre_DAVACL_AbstractPrincipalCollection extends Sabre_DAV_Directory  {
+abstract class Sabre_DAVACL_AbstractPrincipalCollection extends Sabre_DAV_Collection  {
 
     /**
      * Node or 'directory' name. 
index a1d47d41bb87fe1f44c8a78fe89861699f109315..9c20e33cea0520b0276ff5dd104483530ffa6489 100644 (file)
@@ -168,16 +168,20 @@ class Sabre_VObject_Reader {
 
         $paramValue = '(?P<paramValue>[^\"^;]*|"[^"]*")';
 
-        $regex = "/(?<=^|;)(?P<paramName>$token)=$paramValue(?=$|;)/i";
+        $regex = "/(?<=^|;)(?P<paramName>$token)(=$paramValue(?=$|;))?/i";
         preg_match_all($regex, $parameters, $matches,  PREG_SET_ORDER);
 
         $params = array();
         foreach($matches as $match) {
 
-            $value = $match['paramValue'];
+            $value = isset($match['paramValue'])?$match['paramValue']:null;
 
-            // Stripping quotes, if needed
-            if ($value[0] === '"') $value = substr($value,1,strlen($value)-2);
+            if (isset($value[0])) {
+                // Stripping quotes, if needed
+                if ($value[0] === '"') $value = substr($value,1,strlen($value)-2);
+            } else {
+                $value = '';
+            }
 
             $params[] = new Sabre_VObject_Parameter($match['paramName'], stripcslashes($value));