From: Jakob Sack Date: Tue, 2 Aug 2011 17:38:44 +0000 (+0200) Subject: Updating SabreDAV to current head X-Git-Tag: v3.0~267^2~304 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3faa22c6e5128cf9f8542d7079acd6f63d9dcf1e;p=nextcloud-server.git Updating SabreDAV to current head --- diff --git a/3dparty/Sabre.includes.php b/3dparty/Sabre.includes.php index 6b179e34fd8..9d389288c78 100644 --- a/3dparty/Sabre.includes.php +++ b/3dparty/Sabre.includes.php @@ -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'; diff --git a/3dparty/Sabre/CalDAV/Calendar.php b/3dparty/Sabre/CalDAV/Calendar.php index 010554b6d92..a50aef12b4f 100644 --- a/3dparty/Sabre/CalDAV/Calendar.php +++ b/3dparty/Sabre/CalDAV/Calendar.php @@ -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); diff --git a/3dparty/Sabre/CalDAV/CalendarObject.php b/3dparty/Sabre/CalDAV/CalendarObject.php index efec35dccad..b5c4e49b838 100644 --- a/3dparty/Sabre/CalDAV/CalendarObject.php +++ b/3dparty/Sabre/CalDAV/CalendarObject.php @@ -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); diff --git a/3dparty/Sabre/CalDAV/CalendarRootNode.php b/3dparty/Sabre/CalDAV/CalendarRootNode.php index 5c9b37e7d5d..69669a9d7fd 100644 --- a/3dparty/Sabre/CalDAV/CalendarRootNode.php +++ b/3dparty/Sabre/CalDAV/CalendarRootNode.php @@ -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') { diff --git a/3dparty/Sabre/CalDAV/ICalendarUtil.php b/3dparty/Sabre/CalDAV/ICalendarUtil.php index fbfef397ac6..699abfdd6f5 100644 --- a/3dparty/Sabre/CalDAV/ICalendarUtil.php +++ b/3dparty/Sabre/CalDAV/ICalendarUtil.php @@ -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)) { diff --git a/3dparty/Sabre/CardDAV/AddressBook.php b/3dparty/Sabre/CardDAV/AddressBook.php index a4d2d0c4783..04e4c227b86 100644 --- a/3dparty/Sabre/CardDAV/AddressBook.php +++ b/3dparty/Sabre/CardDAV/AddressBook.php @@ -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'); + + } + + } diff --git a/3dparty/Sabre/CardDAV/AddressBookRoot.php b/3dparty/Sabre/CardDAV/AddressBookRoot.php index 88c8ed2e061..1a80efba35e 100644 --- a/3dparty/Sabre/CardDAV/AddressBookRoot.php +++ b/3dparty/Sabre/CardDAV/AddressBookRoot.php @@ -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); } diff --git a/3dparty/Sabre/CardDAV/Backend/PDO.php b/3dparty/Sabre/CardDAV/Backend/PDO.php index e7cd4ecd4df..63a74745aac 100644 --- a/3dparty/Sabre/CardDAV/Backend/PDO.php +++ b/3dparty/Sabre/CardDAV/Backend/PDO.php @@ -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; diff --git a/3dparty/Sabre/CardDAV/Card.php b/3dparty/Sabre/CardDAV/Card.php index a12e6d3914b..98189aa9fd8 100644 --- a/3dparty/Sabre/CardDAV/Card.php +++ b/3dparty/Sabre/CardDAV/Card.php @@ -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'); + + } + } diff --git a/3dparty/Sabre/CardDAV/Plugin.php b/3dparty/Sabre/CardDAV/Plugin.php index 16fadc526e4..a96f9aaebb6 100644 --- a/3dparty/Sabre/CardDAV/Plugin.php +++ b/3dparty/Sabre/CardDAV/Plugin.php @@ -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; diff --git a/3dparty/Sabre/CardDAV/UserAddressBooks.php b/3dparty/Sabre/CardDAV/UserAddressBooks.php index 186bf016a1e..564ecd701f0 100644 --- a/3dparty/Sabre/CardDAV/UserAddressBooks.php +++ b/3dparty/Sabre/CardDAV/UserAddressBooks.php @@ -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 index 00000000000..9da04c12792 --- /dev/null +++ b/3dparty/Sabre/DAV/Collection.php @@ -0,0 +1,90 @@ +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'); + + } + + +} + diff --git a/3dparty/Sabre/DAV/Directory.php b/3dparty/Sabre/DAV/Directory.php index 14d7f2cb679..86af4827b3e 100644 --- a/3dparty/Sabre/DAV/Directory.php +++ b/3dparty/Sabre/DAV/Directory.php @@ -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 { } diff --git a/3dparty/Sabre/DAV/ObjectTree.php b/3dparty/Sabre/DAV/ObjectTree.php index 1319c7daefa..f12a3683705 100644 --- a/3dparty/Sabre/DAV/ObjectTree.php +++ b/3dparty/Sabre/DAV/ObjectTree.php @@ -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) { diff --git a/3dparty/Sabre/DAV/Server.php b/3dparty/Sabre/DAV/Server.php index e912dea0f1d..e5e9e482fee 100644 --- a/3dparty/Sabre/DAV/Server.php +++ b/3dparty/Sabre/DAV/Server.php @@ -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 index 00000000000..223d05fed55 --- /dev/null +++ b/3dparty/Sabre/DAV/SimpleCollection.php @@ -0,0 +1,106 @@ +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); + + } + + +} + diff --git a/3dparty/Sabre/DAV/SimpleDirectory.php b/3dparty/Sabre/DAV/SimpleDirectory.php index 8c79962a95f..516a3aa907c 100644 --- a/3dparty/Sabre/DAV/SimpleDirectory.php +++ b/3dparty/Sabre/DAV/SimpleDirectory.php @@ -6,101 +6,16 @@ * 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 { } diff --git a/3dparty/Sabre/DAVACL/AbstractPrincipalCollection.php b/3dparty/Sabre/DAVACL/AbstractPrincipalCollection.php index 7d120feb2bf..a361e054610 100644 --- a/3dparty/Sabre/DAVACL/AbstractPrincipalCollection.php +++ b/3dparty/Sabre/DAVACL/AbstractPrincipalCollection.php @@ -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. diff --git a/3dparty/Sabre/VObject/Reader.php b/3dparty/Sabre/VObject/Reader.php index a1d47d41bb8..9c20e33cea0 100644 --- a/3dparty/Sabre/VObject/Reader.php +++ b/3dparty/Sabre/VObject/Reader.php @@ -168,16 +168,20 @@ class Sabre_VObject_Reader { $paramValue = '(?P[^\"^;]*|"[^"]*")'; - $regex = "/(?<=^|;)(?P$token)=$paramValue(?=$|;)/i"; + $regex = "/(?<=^|;)(?P$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));