diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/AbstractBackend.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/AbstractBackend.php index 16bf861935..c83409eab1 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/AbstractBackend.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/AbstractBackend.php @@ -10,12 +10,12 @@ * * Checkout the BackendInterface for all the methods that must be implemented. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface -{ +abstract class AbstractBackend implements BackendInterface { + /** * Updates properties for a calendar. * @@ -52,8 +52,8 @@ abstract class AbstractBackend implements BackendInterface * @param array $mutations * @return bool|array */ - public function updateCalendar($calendarId, array $mutations) - { + public function updateCalendar($calendarId, array $mutations) { + return false; } @@ -107,14 +107,14 @@ public function updateCalendar($calendarId, array $mutations) * @param array $filters * @return array */ - public function calendarQuery($calendarId, array $filters) - { + public function calendarQuery($calendarId, array $filters) { + $result = array(); $objects = $this->getCalendarObjects($calendarId); $validator = new \Sabre\CalDAV\CalendarQueryValidator(); - foreach ($objects as $object) { + foreach($objects as $object) { if ($this->validateFilterForObject($object, $filters)) { $result[] = $object['uri']; @@ -134,8 +134,8 @@ public function calendarQuery($calendarId, array $filters) * @param array $filters * @return bool */ - protected function validateFilterForObject(array $object, array $filters) - { + protected function validateFilterForObject(array $object, array $filters) { + // Unfortunately, setting the 'calendardata' here is optional. If // it was excluded, we actually need another call to get this as // well. diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/BackendInterface.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/BackendInterface.php index fd30fd3510..0dc31e5f4a 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/BackendInterface.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/BackendInterface.php @@ -5,12 +5,12 @@ /** * Every CalDAV backend must at least implement this interface. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface -{ +interface BackendInterface { + /** * Returns a list of calendars for a principal. * @@ -126,9 +126,11 @@ public function getCalendarObjects($calendarId); * 'calendardata' object is required here though, while it's not required * for getCalendarObjects. * + * This method must return null if the object did not exist. + * * @param mixed $calendarId * @param string $objectUri - * @return array + * @return array|null */ public function getCalendarObject($calendarId,$objectUri); diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/NotificationSupport.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/NotificationSupport.php index 0ec87bf302..96533ad6ab 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/NotificationSupport.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/NotificationSupport.php @@ -16,12 +16,12 @@ * * The primary usecase is to allow for calendar-sharing. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface NotificationSupport extends BackendInterface -{ +interface NotificationSupport extends BackendInterface { + /** * Returns a list of notifications for a given principal url. * diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/PDO.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/PDO.php index ff74daabb0..2e93a7b252 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/PDO.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/PDO.php @@ -12,12 +12,12 @@ * This backend is used to store calendar-data in a PDO database, such as * sqlite or MySQL * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend -{ +class PDO extends AbstractBackend { + /** * We need to specify a max date, because we need to stop *somewhere* * @@ -72,8 +72,8 @@ class PDO extends AbstractBackend * @param string $calendarTableName * @param string $calendarObjectTableName */ - public function __construct(\PDO $pdo, $calendarTableName = 'calendars', $calendarObjectTableName = 'calendarobjects') - { + public function __construct(\PDO $pdo, $calendarTableName = 'calendars', $calendarObjectTableName = 'calendarobjects') { + $this->pdo = $pdo; $this->calendarTableName = $calendarTableName; $this->calendarObjectTableName = $calendarObjectTableName; @@ -97,8 +97,8 @@ public function __construct(\PDO $pdo, $calendarTableName = 'calendars', $calend * @param string $principalUri * @return array */ - public function getCalendarsForUser($principalUri) - { + public function getCalendarsForUser($principalUri) { + $fields = array_values($this->propertyMap); $fields[] = 'id'; $fields[] = 'uri'; @@ -113,7 +113,7 @@ public function getCalendarsForUser($principalUri) $stmt->execute(array($principalUri)); $calendars = array(); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $components = array(); if ($row['components']) { @@ -130,7 +130,7 @@ public function getCalendarsForUser($principalUri) ); - foreach ($this->propertyMap as $xmlName=>$dbName) { + foreach($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } @@ -153,8 +153,8 @@ public function getCalendarsForUser($principalUri) * @param array $properties * @return string */ - public function createCalendar($principalUri, $calendarUri, array $properties) - { + public function createCalendar($principalUri, $calendarUri, array $properties) { + $fieldNames = array( 'principaluri', 'uri', @@ -184,7 +184,7 @@ public function createCalendar($principalUri, $calendarUri, array $properties) $values[':transparent'] = $properties[$transp]->getValue()==='transparent'; } - foreach ($this->propertyMap as $xmlName=>$dbName) { + foreach($this->propertyMap as $xmlName=>$dbName) { if (isset($properties[$xmlName])) { $values[':' . $dbName] = $properties[$xmlName]; @@ -235,8 +235,8 @@ public function createCalendar($principalUri, $calendarUri, array $properties) * @param array $mutations * @return bool|array */ - public function updateCalendar($calendarId, array $mutations) - { + public function updateCalendar($calendarId, array $mutations) { + $newValues = array(); $result = array( 200 => array(), // Ok @@ -246,9 +246,9 @@ public function updateCalendar($calendarId, array $mutations) $hasError = false; - foreach ($mutations as $propertyName=>$propertyValue) { + foreach($mutations as $propertyName=>$propertyValue) { - switch ($propertyName) { + switch($propertyName) { case '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' : $fieldName = 'transparent'; $newValues[$fieldName] = $propertyValue->getValue()==='transparent'; @@ -272,12 +272,12 @@ public function updateCalendar($calendarId, array $mutations) // If there were any errors we need to fail the request if ($hasError) { // Properties has the remaining properties - foreach ($mutations as $propertyName=>$propertyValue) { + foreach($mutations as $propertyName=>$propertyValue) { $result[424][$propertyName] = null; } // Removing unused statuscodes for cleanliness - foreach ($result as $status=>$properties) { + foreach($result as $status=>$properties) { if (is_array($properties) && count($properties)===0) unset($result[$status]); } @@ -289,7 +289,7 @@ public function updateCalendar($calendarId, array $mutations) // Now we're generating the sql query. $valuesSql = array(); - foreach ($newValues as $fieldName=>$value) { + foreach($newValues as $fieldName=>$value) { $valuesSql[] = $fieldName . ' = ?'; } $valuesSql[] = 'ctag = ctag + 1'; @@ -308,8 +308,8 @@ public function updateCalendar($calendarId, array $mutations) * @param string $calendarId * @return void */ - public function deleteCalendar($calendarId) - { + public function deleteCalendar($calendarId) { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?'); $stmt->execute(array($calendarId)); @@ -345,20 +345,20 @@ public function deleteCalendar($calendarId) * @param string $calendarId * @return array */ - public function getCalendarObjects($calendarId) - { + public function getCalendarObjects($calendarId) { + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?'); $stmt->execute(array($calendarId)); $result = array(); - foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { + foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) { $result[] = array( 'id' => $row['id'], 'uri' => $row['uri'], 'lastmodified' => $row['lastmodified'], 'etag' => '"' . $row['etag'] . '"', 'calendarid' => $row['calendarid'], - 'size' => (int) $row['size'], + 'size' => (int)$row['size'], ); } @@ -374,12 +374,14 @@ public function getCalendarObjects($calendarId) * 'calendardata' object is required here though, while it's not required * for getCalendarObjects. * + * This method must return null if the object did not exist. + * * @param string $calendarId * @param string $objectUri - * @return array + * @return array|null */ - public function getCalendarObject($calendarId,$objectUri) - { + public function getCalendarObject($calendarId,$objectUri) { + $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, calendardata FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?'); $stmt->execute(array($calendarId, $objectUri)); $row = $stmt->fetch(\PDO::FETCH_ASSOC); @@ -392,7 +394,7 @@ public function getCalendarObject($calendarId,$objectUri) 'lastmodified' => $row['lastmodified'], 'etag' => '"' . $row['etag'] . '"', 'calendarid' => $row['calendarid'], - 'size' => (int) $row['size'], + 'size' => (int)$row['size'], 'calendardata' => $row['calendardata'], ); @@ -415,8 +417,8 @@ public function getCalendarObject($calendarId,$objectUri) * @param string $calendarData * @return string|null */ - public function createCalendarObject($calendarId,$objectUri,$calendarData) - { + public function createCalendarObject($calendarId,$objectUri,$calendarData) { + $extraData = $this->getDenormalizedData($calendarData); $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarObjectTableName.' (calendarid, uri, calendardata, lastmodified, etag, size, componenttype, firstoccurence, lastoccurence) VALUES (?,?,?,?,?,?,?,?,?)'); @@ -454,8 +456,8 @@ public function createCalendarObject($calendarId,$objectUri,$calendarData) * @param string $calendarData * @return string|null */ - public function updateCalendarObject($calendarId,$objectUri,$calendarData) - { + public function updateCalendarObject($calendarId,$objectUri,$calendarData) { + $extraData = $this->getDenormalizedData($calendarData); $stmt = $this->pdo->prepare('UPDATE '.$this->calendarObjectTableName.' SET calendardata = ?, lastmodified = ?, etag = ?, size = ?, componenttype = ?, firstoccurence = ?, lastoccurence = ? WHERE calendarid = ? AND uri = ?'); @@ -481,14 +483,14 @@ public function updateCalendarObject($calendarId,$objectUri,$calendarData) * @param string $calendarData * @return array */ - protected function getDenormalizedData($calendarData) - { + protected function getDenormalizedData($calendarData) { + $vObject = VObject\Reader::read($calendarData); $componentType = null; $component = null; $firstOccurence = null; $lastOccurence = null; - foreach ($vObject->getComponents() as $component) { + foreach($vObject->getComponents() as $component) { if ($component->name!=='VTIMEZONE') { $componentType = $component->name; break; @@ -505,9 +507,9 @@ protected function getDenormalizedData($calendarData) $lastOccurence = $component->DTEND->getDateTime()->getTimeStamp(); } elseif (isset($component->DURATION)) { $endDate = clone $component->DTSTART->getDateTime(); - $endDate->add(VObject\DateTimeParser::parse($component->DURATION->value)); + $endDate->add(VObject\DateTimeParser::parse($component->DURATION->getValue())); $lastOccurence = $endDate->getTimeStamp(); - } elseif ($component->DTSTART->getDateType()===VObject\Property\DateTime::DATE) { + } elseif (!$component->DTSTART->hasTime()) { $endDate = clone $component->DTSTART->getDateTime(); $endDate->modify('+1 day'); $lastOccurence = $endDate->getTimeStamp(); @@ -515,13 +517,13 @@ protected function getDenormalizedData($calendarData) $lastOccurence = $firstOccurence; } } else { - $it = new VObject\RecurrenceIterator($vObject, (string) $component->UID); + $it = new VObject\RecurrenceIterator($vObject, (string)$component->UID); $maxDate = new \DateTime(self::MAX_DATE); if ($it->isInfinite()) { $lastOccurence = $maxDate->getTimeStamp(); } else { $end = $it->getDtEnd(); - while ($it->valid() && $end < $maxDate) { + while($it->valid() && $end < $maxDate) { $end = $it->getDtEnd(); $it->next(); @@ -549,8 +551,8 @@ protected function getDenormalizedData($calendarData) * @param string $objectUri * @return void */ - public function deleteCalendarObject($calendarId,$objectUri) - { + public function deleteCalendarObject($calendarId,$objectUri) { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?'); $stmt->execute(array($calendarId,$objectUri)); $stmt = $this->pdo->prepare('UPDATE '. $this->calendarTableName .' SET ctag = ctag + 1 WHERE id = ?'); @@ -610,8 +612,8 @@ public function deleteCalendarObject($calendarId,$objectUri) * @param array $filters * @return array */ - public function calendarQuery($calendarId, array $filters) - { + public function calendarQuery($calendarId, array $filters) { + $result = array(); $validator = new \Sabre\CalDAV\CalendarQueryValidator(); @@ -673,7 +675,7 @@ public function calendarQuery($calendarId, array $filters) $stmt->execute($values); $result = array(); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { if ($requirePostFilter) { if (!$this->validateFilterForObject($row, $filters)) { continue; diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/SharingSupport.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/SharingSupport.php index aaaa97bd52..4538fa5b58 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/SharingSupport.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/SharingSupport.php @@ -157,7 +157,7 @@ * ============================================== * * If Sabre\CalDAV\Property\AllowedSharingModes is returned from - * getCalendarsByUser, this allows the server to specify wether either sharing, + * getCalendarsByUser, this allows the server to specify whether either sharing, * or publishing is supported. * * This allows a client to determine in advance which features are available, @@ -165,12 +165,12 @@ * the backend, the SharingPlugin automatically injects it and assumes both * features are available. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface SharingSupport extends NotificationSupport -{ +interface SharingSupport extends NotificationSupport { + /** * Updates the list of shares. * @@ -194,7 +194,7 @@ interface SharingSupport extends NotificationSupport * @param array $remove * @return void */ - public function updateShares($calendarId, array $add, array $remove); + function updateShares($calendarId, array $add, array $remove); /** * Returns the list of people whom this calendar is shared with. @@ -214,7 +214,7 @@ public function updateShares($calendarId, array $add, array $remove); * @param mixed $calendarId * @return array */ - public function getShares($calendarId); + function getShares($calendarId); /** * This method is called when a user replied to a request to share. @@ -229,7 +229,7 @@ public function getShares($calendarId); * @param string $summary A description of the reply * @return null|string */ - public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null); + function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null); /** * Publishes a calendar @@ -238,6 +238,6 @@ public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = * @param bool $value * @return void */ - public function setPublishStatus($calendarId, $value); + function setPublishStatus($calendarId, $value); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Calendar.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Calendar.php index 2ddda6e3a3..74fa15bb15 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Calendar.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Calendar.php @@ -11,12 +11,12 @@ * A calendar can contain multiple TODO and or Events. These are represented * as \Sabre\CalDAV\CalendarObject objects. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Calendar implements ICalendar, DAV\IProperties, DAVACL\IACL -{ +class Calendar implements ICalendar, DAV\IProperties, DAVACL\IACL { + /** * This is an array with calendar information * @@ -37,8 +37,8 @@ class Calendar implements ICalendar, DAV\IProperties, DAVACL\IACL * @param Backend\BackendInterface $caldavBackend * @param array $calendarInfo */ - public function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) - { + public function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) { + $this->caldavBackend = $caldavBackend; $this->calendarInfo = $calendarInfo; @@ -49,8 +49,8 @@ public function __construct(Backend\BackendInterface $caldavBackend, $calendarIn * * @return string */ - public function getName() - { + public function getName() { + return $this->calendarInfo['uri']; } @@ -61,8 +61,8 @@ public function getName() * @param array $mutations * @return array */ - public function updateProperties($mutations) - { + public function updateProperties($mutations) { + return $this->caldavBackend->updateCalendar($this->calendarInfo['id'],$mutations); } @@ -73,11 +73,11 @@ public function updateProperties($mutations) * @param array $requestedProperties * @return array */ - public function getProperties($requestedProperties) - { + public function getProperties($requestedProperties) { + $response = array(); - foreach ($requestedProperties as $prop) switch ($prop) { + foreach($requestedProperties as $prop) switch($prop) { case '{urn:ietf:params:xml:ns:caldav}supported-calendar-data' : $response[$prop] = new Property\SupportedCalendarData(); @@ -105,15 +105,15 @@ public function getProperties($requestedProperties) * @param string $name * @return \Sabre\CalDAV\ICalendarObject */ - public function getChild($name) - { + public function getChild($name) { + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'],$name); if (!$obj) throw new DAV\Exception\NotFound('Calendar object not found'); $obj['acl'] = $this->getACL(); // Removing the irrelivant - foreach ($obj['acl'] as $key=>$acl) { + foreach($obj['acl'] as $key=>$acl) { if ($acl['privilege'] === '{' . Plugin::NS_CALDAV . '}read-free-busy') { unset($obj['acl'][$key]); } @@ -128,14 +128,14 @@ public function getChild($name) * * @return array */ - public function getChildren() - { + public function getChildren() { + $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']); $children = array(); - foreach ($objs as $obj) { + foreach($objs as $obj) { $obj['acl'] = $this->getACL(); // Removing the irrelivant - foreach ($obj['acl'] as $key=>$acl) { + foreach($obj['acl'] as $key=>$acl) { if ($acl['privilege'] === '{' . Plugin::NS_CALDAV . '}read-free-busy') { unset($obj['acl'][$key]); } @@ -152,8 +152,8 @@ public function getChildren() * @param string $name * @return bool */ - public function childExists($name) - { + public function childExists($name) { + $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'],$name); if (!$obj) return false; @@ -170,8 +170,8 @@ public function childExists($name) * @param string $name * @return void */ - public function createDirectory($name) - { + public function createDirectory($name) { + throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed'); } @@ -185,8 +185,8 @@ public function createDirectory($name) * @param resource $calendarData * @return string|null */ - public function createFile($name,$calendarData = null) - { + public function createFile($name,$calendarData = null) { + if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); } @@ -199,8 +199,8 @@ public function createFile($name,$calendarData = null) * * @return void */ - public function delete() - { + public function delete() { + $this->caldavBackend->deleteCalendar($this->calendarInfo['id']); } @@ -212,8 +212,8 @@ public function delete() * @param string $newName * @return void */ - public function setName($newName) - { + public function setName($newName) { + throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported'); } @@ -223,8 +223,8 @@ public function setName($newName) * * @return void */ - public function getLastModified() - { + public function getLastModified() { + return null; } @@ -236,8 +236,8 @@ public function getLastModified() * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->calendarInfo['principaluri']; } @@ -249,8 +249,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -267,8 +267,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'privilege' => '{DAV:}read', @@ -313,8 +313,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); } @@ -331,13 +331,13 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet(); // We need to inject 'read-free-busy' in the tree, aggregated under // {DAV:}read. - foreach ($default['aggregates'] as &$agg) { + foreach($default['aggregates'] as &$agg) { if ($agg['privilege'] !== '{DAV:}read') continue; @@ -367,8 +367,8 @@ public function getSupportedPrivilegeSet() * @param array $filters * @return array */ - public function calendarQuery(array $filters) - { + public function calendarQuery(array $filters) { + return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarObject.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarObject.php index 096fc9ea2f..2b9d2877e2 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarObject.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarObject.php @@ -5,12 +5,12 @@ /** * The CalendarObject represents a single VEVENT or VTODO within a Calendar. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\DAVACL\IACL -{ +class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\DAVACL\IACL { + /** * Sabre\CalDAV\Backend\BackendInterface * @@ -39,8 +39,8 @@ class CalendarObject extends \Sabre\DAV\File implements ICalendarObject, \Sabre\ * @param array $calendarInfo * @param array $objectData */ - public function __construct(Backend\BackendInterface $caldavBackend,array $calendarInfo,array $objectData) - { + public function __construct(Backend\BackendInterface $caldavBackend,array $calendarInfo,array $objectData) { + $this->caldavBackend = $caldavBackend; if (!isset($objectData['calendarid'])) { @@ -60,8 +60,8 @@ public function __construct(Backend\BackendInterface $caldavBackend,array $calen * * @return string */ - public function getName() - { + public function getName() { + return $this->objectData['uri']; } @@ -71,8 +71,8 @@ public function getName() * * @return string */ - public function get() - { + public function get() { + // Pre-populating the 'calendardata' is optional, if we don't have it // already we fetch it from the backend. if (!isset($this->objectData['calendardata'])) { @@ -88,8 +88,8 @@ public function get() * @param string|resource $calendarData * @return string */ - public function put($calendarData) - { + public function put($calendarData) { + if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); } @@ -106,8 +106,8 @@ public function put($calendarData) * * @return void */ - public function delete() - { + public function delete() { + $this->caldavBackend->deleteCalendarObject($this->calendarInfo['id'],$this->objectData['uri']); } @@ -117,8 +117,8 @@ public function delete() * * @return string */ - public function getContentType() - { + public function getContentType() { + return 'text/calendar; charset=utf-8'; } @@ -130,8 +130,8 @@ public function getContentType() * * @return string */ - public function getETag() - { + public function getETag() { + if (isset($this->objectData['etag'])) { return $this->objectData['etag']; } else { @@ -145,8 +145,8 @@ public function getETag() * * @return int */ - public function getLastModified() - { + public function getLastModified() { + return $this->objectData['lastmodified']; } @@ -156,8 +156,8 @@ public function getLastModified() * * @return int */ - public function getSize() - { + public function getSize() { + if (array_key_exists('size',$this->objectData)) { return $this->objectData['size']; } else { @@ -173,8 +173,8 @@ public function getSize() * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->calendarInfo['principaluri']; } @@ -186,8 +186,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -204,8 +204,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + // An alternative acl may be specified in the object data. if (isset($this->objectData['acl'])) { return $this->objectData['acl']; @@ -251,8 +251,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new \Sabre\DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); } @@ -269,10 +269,11 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + return null; } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarQueryParser.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarQueryParser.php index 1caebd64c1..0a3472408a 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarQueryParser.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarQueryParser.php @@ -10,12 +10,12 @@ * Whoever designed this format, and the CalDAV equivalent even more so, * has no feel for design. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class CalendarQueryParser -{ +class CalendarQueryParser { + /** * List of requested properties the client wanted * @@ -64,8 +64,8 @@ class CalendarQueryParser * * @param \DOMDocument $dom */ - public function __construct(\DOMDocument $dom) - { + public function __construct(\DOMDocument $dom) { + $this->dom = $dom; $this->xpath = new \DOMXPath($dom); $this->xpath->registerNameSpace('cal',Plugin::NS_CALDAV); @@ -78,8 +78,8 @@ public function __construct(\DOMDocument $dom) * * @return void */ - public function parse() - { + public function parse() { + $filterNode = null; $filter = $this->xpath->query('/cal:calendar-query/cal:filter'); @@ -109,12 +109,12 @@ public function parse() * @param \DOMElement $parentNode * @return array */ - protected function parseCompFilters(\DOMElement $parentNode) - { + protected function parseCompFilters(\DOMElement $parentNode) { + $compFilterNodes = $this->xpath->query('cal:comp-filter', $parentNode); $result = array(); - for ($ii=0; $ii < $compFilterNodes->length; $ii++) { + for($ii=0; $ii < $compFilterNodes->length; $ii++) { $compFilterNode = $compFilterNodes->item($ii); @@ -149,8 +149,8 @@ protected function parseCompFilters(\DOMElement $parentNode) * @param \DOMElement $parentNode * @return array */ - protected function parsePropFilters(\DOMElement $parentNode) - { + protected function parsePropFilters(\DOMElement $parentNode) { + $propFilterNodes = $this->xpath->query('cal:prop-filter', $parentNode); $result = array(); @@ -178,12 +178,12 @@ protected function parsePropFilters(\DOMElement $parentNode) * @param \DOMElement $parentNode * @return array */ - protected function parseParamFilters(\DOMElement $parentNode) - { + protected function parseParamFilters(\DOMElement $parentNode) { + $paramFilterNodes = $this->xpath->query('cal:param-filter', $parentNode); $result = array(); - for ($ii=0;$ii<$paramFilterNodes->length;$ii++) { + for($ii=0;$ii<$paramFilterNodes->length;$ii++) { $paramFilterNode = $paramFilterNodes->item($ii); $paramFilter = array(); @@ -205,8 +205,8 @@ protected function parseParamFilters(\DOMElement $parentNode) * @param \DOMElement $parentNode * @return array|null */ - protected function parseTextMatch(\DOMElement $parentNode) - { + protected function parseTextMatch(\DOMElement $parentNode) { + $textMatchNodes = $this->xpath->query('cal:text-match', $parentNode); if ($textMatchNodes->length === 0) @@ -232,8 +232,8 @@ protected function parseTextMatch(\DOMElement $parentNode) * @param \DOMElement $parentNode * @return array|null */ - protected function parseTimeRange(\DOMElement $parentNode) - { + protected function parseTimeRange(\DOMElement $parentNode) { + $timeRangeNodes = $this->xpath->query('cal:time-range', $parentNode); if ($timeRangeNodes->length === 0) { return null; @@ -269,16 +269,16 @@ protected function parseTimeRange(\DOMElement $parentNode) * @param \DOMElement $parentNode * @return void */ - protected function parseExpand(\DOMElement $parentNode) - { + protected function parseExpand(\DOMElement $parentNode) { + $start = $parentNode->getAttribute('start'); - if (!$start) { + if(!$start) { throw new \Sabre\DAV\Exception\BadRequest('The "start" attribute is required for the CALDAV:expand element'); } $start = VObject\DateTimeParser::parseDateTime($start); $end = $parentNode->getAttribute('end'); - if (!$end) { + if(!$end) { throw new \Sabre\DAV\Exception\BadRequest('The "end" attribute is required for the CALDAV:expand element'); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarQueryValidator.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarQueryValidator.php index 3d0fb1b32e..494aed1a7d 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarQueryValidator.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarQueryValidator.php @@ -14,12 +14,12 @@ * This is used to determine which icalendar objects should be returned for a * calendar-query REPORT request. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class CalendarQueryValidator -{ +class CalendarQueryValidator { + /** * Verify if a list of filters applies to the calendar data object * @@ -29,8 +29,8 @@ class CalendarQueryValidator * @param array $filters * @return bool */ - public function validate(VObject\Component $vObject,array $filters) - { + public function validate(VObject\Component $vObject,array $filters) { + // The top level object is always a component filter. // We'll parse it manually, as it's pretty simple. if ($vObject->name !== $filters['name']) { @@ -55,9 +55,9 @@ public function validate(VObject\Component $vObject,array $filters) * @param array $filters * @return bool */ - protected function validateCompFilters(VObject\Component $parent, array $filters) - { - foreach ($filters as $filter) { + protected function validateCompFilters(VObject\Component $parent, array $filters) { + + foreach($filters as $filter) { $isDefined = isset($parent->$filter['name']); @@ -75,7 +75,7 @@ protected function validateCompFilters(VObject\Component $parent, array $filters } if ($filter['time-range']) { - foreach ($parent->$filter['name'] as $subComponent) { + foreach($parent->$filter['name'] as $subComponent) { if ($this->validateTimeRange($subComponent, $filter['time-range']['start'], $filter['time-range']['end'])) { continue 2; } @@ -89,7 +89,7 @@ protected function validateCompFilters(VObject\Component $parent, array $filters // If there are sub-filters, we need to find at least one component // for which the subfilters hold true. - foreach ($parent->$filter['name'] as $subComponent) { + foreach($parent->$filter['name'] as $subComponent) { if ( $this->validateCompFilters($subComponent, $filter['comp-filters']) && @@ -124,9 +124,9 @@ protected function validateCompFilters(VObject\Component $parent, array $filters * @param array $filters * @return bool */ - protected function validatePropFilters(VObject\Component $parent, array $filters) - { - foreach ($filters as $filter) { + protected function validatePropFilters(VObject\Component $parent, array $filters) { + + foreach($filters as $filter) { $isDefined = isset($parent->$filter['name']); @@ -144,7 +144,7 @@ protected function validatePropFilters(VObject\Component $parent, array $filters } if ($filter['time-range']) { - foreach ($parent->$filter['name'] as $subComponent) { + foreach($parent->$filter['name'] as $subComponent) { if ($this->validateTimeRange($subComponent, $filter['time-range']['start'], $filter['time-range']['end'])) { continue 2; } @@ -158,7 +158,7 @@ protected function validatePropFilters(VObject\Component $parent, array $filters // If there are sub-filters, we need to find at least one property // for which the subfilters hold true. - foreach ($parent->$filter['name'] as $subComponent) { + foreach($parent->$filter['name'] as $subComponent) { if( $this->validateParamFilters($subComponent, $filter['param-filters']) && @@ -194,9 +194,9 @@ protected function validatePropFilters(VObject\Component $parent, array $filters * @param array $filters * @return bool */ - protected function validateParamFilters(VObject\Property $parent, array $filters) - { - foreach ($filters as $filter) { + protected function validateParamFilters(VObject\Property $parent, array $filters) { + + foreach($filters as $filter) { $isDefined = isset($parent[$filter['name']]); @@ -217,13 +217,30 @@ protected function validateParamFilters(VObject\Property $parent, array $filters continue; } - // If there are sub-filters, we need to find at least one parameter - // for which the subfilters hold true. - foreach ($parent[$filter['name']] as $subParam) { + if (version_compare(VObject\Version::VERSION, '3.0.0beta1', '>=')) { + + // If there are sub-filters, we need to find at least one parameter + // for which the subfilters hold true. + foreach($parent[$filter['name']]->getParts() as $subParam) { + + if($this->validateTextMatch($subParam,$filter['text-match'])) { + // We had a match, so this param-filter succeeds + continue 2; + } + + } + + } else { + + // If there are sub-filters, we need to find at least one parameter + // for which the subfilters hold true. + foreach($parent[$filter['name']] as $subParam) { + + if($this->validateTextMatch($subParam,$filter['text-match'])) { + // We had a match, so this param-filter succeeds + continue 2; + } - if ($this->validateTextMatch($subParam,$filter['text-match'])) { - // We had a match, so this param-filter succeeds - continue 2; } } @@ -246,15 +263,17 @@ protected function validateParamFilters(VObject\Property $parent, array $filters * A single text-match should be specified as well as the specific property * or parameter we need to validate. * - * @param VObject\Node $parent + * @param VObject\Node|string $check Value to check against. * @param array $textMatch * @return bool */ - protected function validateTextMatch(VObject\Node $parent, array $textMatch) - { - $value = (string) $parent; + protected function validateTextMatch($check, array $textMatch) { - $isMatching = \Sabre\DAV\StringUtil::textMatch($value, $textMatch['value'], $textMatch['collation']); + if ($check instanceof VObject\Node) { + $check = (string)$check; + } + + $isMatching = \Sabre\DAV\StringUtil::textMatch($check, $textMatch['value'], $textMatch['collation']); return ($textMatch['negate-condition'] xor $isMatching); @@ -271,8 +290,8 @@ protected function validateTextMatch(VObject\Node $parent, array $textMatch) * @param DateTime $end * @return bool */ - protected function validateTimeRange(VObject\Node $component, $start, $end) - { + protected function validateTimeRange(VObject\Node $component, $start, $end) { + if (is_null($start)) { $start = new DateTime('1900-01-01'); } @@ -280,7 +299,7 @@ protected function validateTimeRange(VObject\Node $component, $start, $end) $end = new DateTime('3000-01-01'); } - switch ($component->name) { + switch($component->name) { case 'VEVENT' : case 'VTODO' : @@ -299,8 +318,8 @@ protected function validateTimeRange(VObject\Node $component, $start, $end) if ($component->parent->name === 'VEVENT' && $component->parent->RRULE) { // Fire up the iterator! - $it = new VObject\RecurrenceIterator($component->parent->parent, (string) $component->parent->UID); - while ($it->valid()) { + $it = new VObject\RecurrenceIterator($component->parent->parent, (string)$component->parent->UID); + while($it->valid()) { $expandedEvent = $it->getEventObject(); // We need to check from these expanded alarms, which @@ -308,14 +327,14 @@ protected function validateTimeRange(VObject\Node $component, $start, $end) // determine if we can 'give up' expanding events. $firstAlarm = null; if ($expandedEvent->VALARM !== null) { - foreach ($expandedEvent->VALARM as $expandedAlarm) { + foreach($expandedEvent->VALARM as $expandedAlarm) { $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime(); if ($expandedAlarm->isInTimeRange($start, $end)) { return true; } - if ((string) $expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') { + if ((string)$expandedAlarm->TRIGGER['VALUE'] === 'DATE-TIME') { // This is an alarm with a non-relative trigger // time, likely created by a buggy client. The // implication is that every alarm in this diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarRootNode.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarRootNode.php index e86064cd5a..4f72ad4444 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarRootNode.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/CalendarRootNode.php @@ -10,12 +10,12 @@ * This object is responsible for generating a list of calendar-homes for each * user. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class CalendarRootNode extends \Sabre\DAVACL\AbstractPrincipalCollection -{ +class CalendarRootNode extends \Sabre\DAVACL\AbstractPrincipalCollection { + /** * CalDAV backend * @@ -37,8 +37,8 @@ class CalendarRootNode extends \Sabre\DAVACL\AbstractPrincipalCollection * @param Backend\BackendInterface $caldavBackend * @param string $principalPrefix */ - public function __construct(PrincipalBackend\BackendInterface $principalBackend,Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') - { + public function __construct(PrincipalBackend\BackendInterface $principalBackend,Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') { + parent::__construct($principalBackend, $principalPrefix); $this->caldavBackend = $caldavBackend; @@ -52,8 +52,8 @@ public function __construct(PrincipalBackend\BackendInterface $principalBackend, * * @return string */ - public function getName() - { + public function getName() { + return Plugin::CALENDAR_ROOT; } @@ -68,8 +68,8 @@ public function getName() * @param array $principal * @return \Sabre\DAV\INode */ - public function getChildForPrincipal(array $principal) - { + public function getChildForPrincipal(array $principal) { + return new UserCalendars($this->caldavBackend, $principal); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Exception/InvalidComponentType.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Exception/InvalidComponentType.php index 1403e04564..f2a64e33f2 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Exception/InvalidComponentType.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Exception/InvalidComponentType.php @@ -8,12 +8,12 @@ /** * InvalidComponentType * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class InvalidComponentType extends DAV\Exception\Forbidden -{ +class InvalidComponentType extends DAV\Exception\Forbidden { + /** * Adds in extra information in the xml response. * @@ -23,8 +23,8 @@ class InvalidComponentType extends DAV\Exception\Forbidden * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server, \DOMElement $errorNode) - { + public function serialize(DAV\Server $server, \DOMElement $errorNode) { + $doc = $errorNode->ownerDocument; $np = $doc->createElementNS(CalDAV\Plugin::NS_CALDAV,'cal:supported-calendar-component'); diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICSExportPlugin.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICSExportPlugin.php index 527f06c56c..bba7fbd5ad 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICSExportPlugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICSExportPlugin.php @@ -12,12 +12,12 @@ * This is useful for clients that don't support CalDAV yet. They often do * support ics files. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ICSExportPlugin extends DAV\ServerPlugin -{ +class ICSExportPlugin extends DAV\ServerPlugin { + /** * Reference to Server class * @@ -31,8 +31,8 @@ class ICSExportPlugin extends DAV\ServerPlugin * @param \Sabre\DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90); @@ -46,8 +46,8 @@ public function initialize(DAV\Server $server) * @param string $uri * @return bool */ - public function beforeMethod($method, $uri) - { + public function beforeMethod($method, $uri) { + if ($method!='GET') return; if ($this->server->httpRequest->getQueryString()!='export') return; @@ -83,9 +83,9 @@ public function beforeMethod($method, $uri) * @param array $nodes * @return string */ - public function generateICS(array $nodes) - { - $calendar = new VObject\Component('vcalendar'); + public function generateICS(array $nodes) { + + $calendar = new VObject\Component\VCalendar(); $calendar->version = '2.0'; if (DAV\Server::$exposeVersion) { $calendar->prodid = '-//SabreDAV//SabreDAV ' . DAV\Version::VERSION . '//EN'; @@ -99,7 +99,7 @@ public function generateICS(array $nodes) $timezones = array(); $objects = array(); - foreach ($nodes as $node) { + foreach($nodes as $node) { if (!isset($node[200]['{' . Plugin::NS_CALDAV . '}calendar-data'])) { continue; @@ -108,9 +108,9 @@ public function generateICS(array $nodes) $nodeComp = VObject\Reader::read($nodeData); - foreach ($nodeComp->children() as $child) { + foreach($nodeComp->children() as $child) { - switch ($child->name) { + switch($child->name) { case 'VEVENT' : case 'VTODO' : case 'VJOURNAL' : @@ -120,7 +120,7 @@ public function generateICS(array $nodes) // VTIMEZONE is special, because we need to filter out the duplicates case 'VTIMEZONE' : // Naively just checking tzid. - if (in_array((string) $child->TZID, $collectedTimezones)) continue; + if (in_array((string)$child->TZID, $collectedTimezones)) continue; $timezones[] = $child; $collectedTimezones[] = $child->TZID; diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICalendar.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICalendar.php index fafa8d848d..0f0547046f 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICalendar.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICalendar.php @@ -8,12 +8,12 @@ * * Implement this interface to allow a node to be recognized as an calendar. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface ICalendar extends DAV\ICollection -{ +interface ICalendar extends DAV\ICollection { + /** * Performs a calendar-query on the contents of this calendar. * diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICalendarObject.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICalendarObject.php index 7df5fcce49..0776abff0f 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICalendarObject.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ICalendarObject.php @@ -11,10 +11,11 @@ * * Calendar objects are resources such as Events, Todo's or Journals. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface ICalendarObject extends DAV\IFile -{ +interface ICalendarObject extends DAV\IFile { + } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/IShareableCalendar.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/IShareableCalendar.php index 9dca98c0d3..4dd62e5c68 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/IShareableCalendar.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/IShareableCalendar.php @@ -5,12 +5,12 @@ /** * This interface represents a Calendar that can be shared with other users. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IShareableCalendar extends ICalendar -{ +interface IShareableCalendar extends ICalendar { + /** * Updates the list of shares. * @@ -29,7 +29,7 @@ interface IShareableCalendar extends ICalendar * @param array $remove * @return void */ - public function updateShares(array $add, array $remove); + function updateShares(array $add, array $remove); /** * Returns the list of people whom this calendar is shared with. @@ -43,6 +43,6 @@ public function updateShares(array $add, array $remove); * * @return array */ - public function getShares(); + function getShares(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ISharedCalendar.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ISharedCalendar.php index 61c96a9381..917d1c4983 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ISharedCalendar.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ISharedCalendar.php @@ -5,19 +5,19 @@ /** * This interface represents a Calendar that is shared by a different user. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface ISharedCalendar extends ICalendar -{ +interface ISharedCalendar extends ICalendar { + /** * This method should return the url of the owners' copy of the shared * calendar. * * @return string */ - public function getSharedUrl(); + function getSharedUrl(); /** * Returns the list of people whom this calendar is shared with. @@ -31,6 +31,6 @@ public function getSharedUrl(); * * @return array */ - public function getShares(); + function getShares(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Collection.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Collection.php index ec337bf8eb..028b00d879 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Collection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Collection.php @@ -16,12 +16,12 @@ * This collection should only return Sabre\CalDAV\Notifications\INode nodes as * its children. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAV\Collection implements ICollection, DAVACL\IACL -{ +class Collection extends DAV\Collection implements ICollection, DAVACL\IACL { + /** * The notification backend * @@ -42,8 +42,8 @@ class Collection extends DAV\Collection implements ICollection, DAVACL\IACL * @param CalDAV\Backend\NotificationSupport $caldavBackend * @param string $principalUri */ - public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri) - { + public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri) { + $this->caldavBackend = $caldavBackend; $this->principalUri = $principalUri; @@ -54,12 +54,12 @@ public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $ * * @return array */ - public function getChildren() - { + public function getChildren() { + $children = array(); $notifications = $this->caldavBackend->getNotificationsForPrincipal($this->principalUri); - foreach ($notifications as $notification) { + foreach($notifications as $notification) { $children[] = new Node( $this->caldavBackend, @@ -77,8 +77,8 @@ public function getChildren() * * @return string */ - public function getName() - { + public function getName() { + return 'notifications'; } @@ -90,8 +90,8 @@ public function getName() * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->principalUri; } @@ -103,8 +103,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -121,8 +121,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'principal' => $this->getOwner(), @@ -146,8 +146,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\NotImplemented('Updating ACLs is not implemented here'); } @@ -164,8 +164,8 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + return null; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/ICollection.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/ICollection.php index e383f6e3cc..26e13b2119 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/ICollection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/ICollection.php @@ -14,10 +14,11 @@ * This collection should only return Sabre\CalDAV\Notifications\INode nodes as * its children. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface ICollection extends DAV\ICollection -{ +interface ICollection extends DAV\ICollection { + + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/INode.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/INode.php index f618d0b794..cd7fc57987 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/INode.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/INode.php @@ -12,19 +12,19 @@ * For a complete example, check out the Notification class, which contains * some helper functions. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface INode -{ +interface INode { + /** * This method must return an xml element, using the * Sabre\CalDAV\Notifications\INotificationType classes. * * @return INotificationType */ - public function getNotificationType(); + function getNotificationType(); /** * Returns the etag for the notification. @@ -33,6 +33,6 @@ public function getNotificationType(); * * @return string */ - public function getETag(); + function getETag(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/INotificationType.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/INotificationType.php index dd91e7ae49..b646399b9d 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/INotificationType.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/INotificationType.php @@ -6,12 +6,12 @@ /** * This interface reflects a single notification type. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface INotificationType extends DAV\PropertyInterface -{ +interface INotificationType extends DAV\PropertyInterface { + /** * This method serializes the entire notification, as it is used in the * response body. @@ -20,7 +20,7 @@ interface INotificationType extends DAV\PropertyInterface * @param \DOMElement $node * @return void */ - public function serializeBody(DAV\Server $server, \DOMElement $node); + function serializeBody(DAV\Server $server, \DOMElement $node); /** * Returns a unique id for this notification @@ -30,7 +30,7 @@ public function serializeBody(DAV\Server $server, \DOMElement $node); * * @return string */ - public function getId(); + function getId(); /** * Returns the ETag for this notification. @@ -39,6 +39,6 @@ public function getId(); * * @return string */ - public function getETag(); + function getETag(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Node.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Node.php index a571fb4b8f..6367e9388b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Node.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Node.php @@ -13,12 +13,12 @@ * MUST return an xml document that matches the requirements of the * 'caldav-notifications.txt' spec. - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Node extends DAV\File implements INode, DAVACL\IACL -{ +class Node extends DAV\File implements INode, DAVACL\IACL { + /** * The notification backend * @@ -47,8 +47,8 @@ class Node extends DAV\File implements INode, DAVACL\IACL * @param string $principalUri * @param CalDAV\Notifications\INotificationType $notification */ - public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri, INotificationType $notification) - { + public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri, INotificationType $notification) { + $this->caldavBackend = $caldavBackend; $this->principalUri = $principalUri; $this->notification = $notification; @@ -60,8 +60,8 @@ public function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $ * * @return id */ - public function getName() - { + public function getName() { + return $this->notification->getId() . '.xml'; } @@ -73,8 +73,8 @@ public function getName() * * @return string */ - public function getETag() - { + public function getETag() { + return $this->notification->getETag(); } @@ -85,8 +85,8 @@ public function getETag() * * @return INotificationType */ - public function getNotificationType() - { + public function getNotificationType() { + return $this->notification; } @@ -96,8 +96,8 @@ public function getNotificationType() * * @return void */ - public function delete() - { + public function delete() { + $this->caldavBackend->deleteNotification($this->getOwner(), $this->notification); } @@ -109,8 +109,8 @@ public function delete() * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->principalUri; } @@ -122,8 +122,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -140,8 +140,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'principal' => $this->getOwner(), @@ -165,8 +165,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\NotImplemented('Updating ACLs is not implemented here'); } @@ -183,8 +183,8 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + return null; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/Invite.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/Invite.php index 944a04e0b4..8d6974d459 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/Invite.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/Invite.php @@ -9,12 +9,12 @@ /** * This class represents the cs:invite-notification notification element. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Invite extends DAV\Property implements CalDAV\Notifications\INotificationType -{ +class Invite extends DAV\Property implements CalDAV\Notifications\INotificationType { + /** * A unique id for the message * @@ -134,8 +134,8 @@ class Invite extends DAV\Property implements CalDAV\Notifications\INotificationT * * @param array $values All the options */ - public function __construct(array $values) - { + public function __construct(array $values) { + $required = array( 'id', 'etag', @@ -146,13 +146,13 @@ public function __construct(array $values) 'hostUrl', 'organizer', ); - foreach ($required as $item) { + foreach($required as $item) { if (!isset($values[$item])) { throw new \InvalidArgumentException($item . ' is a required constructor option'); } } - foreach ($values as $key=>$value) { + foreach($values as $key=>$value) { if (!property_exists($this, $key)) { throw new \InvalidArgumentException('Unknown option: ' . $key); } @@ -171,8 +171,8 @@ public function __construct(array $values) * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server, \DOMElement $node) - { + public function serialize(DAV\Server $server, \DOMElement $node) { + $prop = $node->ownerDocument->createElement('cs:invite-notification'); $node->appendChild($prop); @@ -186,8 +186,8 @@ public function serialize(DAV\Server $server, \DOMElement $node) * @param \DOMElement $node * @return void */ - public function serializeBody(DAV\Server $server, \DOMElement $node) - { + public function serializeBody(DAV\Server $server, \DOMElement $node) { + $doc = $node->ownerDocument; $dt = $doc->createElement('cs:dtstamp'); @@ -207,7 +207,7 @@ public function serializeBody(DAV\Server $server, \DOMElement $node) $prop->appendChild($href); $nodeName = null; - switch ($this->type) { + switch($this->type) { case SharingPlugin::STATUS_ACCEPTED : $nodeName = 'cs:invite-accepted'; @@ -302,8 +302,8 @@ public function serializeBody(DAV\Server $server, \DOMElement $node) * * @return string */ - public function getId() - { + public function getId() { + return $this->id; } @@ -315,8 +315,8 @@ public function getId() * * @return string */ - public function getETag() - { + public function getETag() { + return $this->etag; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/InviteReply.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/InviteReply.php index 2650ebfcf7..e40751346b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/InviteReply.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/InviteReply.php @@ -9,12 +9,12 @@ /** * This class represents the cs:invite-reply notification element. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class InviteReply extends DAV\Property implements CalDAV\Notifications\INotificationType -{ +class InviteReply extends DAV\Property implements CalDAV\Notifications\INotificationType { + /** * A unique id for the message * @@ -87,8 +87,8 @@ class InviteReply extends DAV\Property implements CalDAV\Notifications\INotifica * * summary - Description of the share, can be the same as the * calendar, but may also be modified (optional). */ - public function __construct(array $values) - { + public function __construct(array $values) { + $required = array( 'id', 'etag', @@ -98,13 +98,13 @@ public function __construct(array $values) 'type', 'hostUrl', ); - foreach ($required as $item) { + foreach($required as $item) { if (!isset($values[$item])) { throw new \InvalidArgumentException($item . ' is a required constructor option'); } } - foreach ($values as $key=>$value) { + foreach($values as $key=>$value) { if (!property_exists($this, $key)) { throw new \InvalidArgumentException('Unknown option: ' . $key); } @@ -123,8 +123,8 @@ public function __construct(array $values) * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server, \DOMElement $node) - { + public function serialize(DAV\Server $server, \DOMElement $node) { + $prop = $node->ownerDocument->createElement('cs:invite-reply'); $node->appendChild($prop); @@ -138,8 +138,8 @@ public function serialize(DAV\Server $server, \DOMElement $node) * @param \DOMElement $node * @return void */ - public function serializeBody(DAV\Server $server, \DOMElement $node) - { + public function serializeBody(DAV\Server $server, \DOMElement $node) { + $doc = $node->ownerDocument; $dt = $doc->createElement('cs:dtstamp'); @@ -163,7 +163,7 @@ public function serializeBody(DAV\Server $server, \DOMElement $node) $prop->appendChild($href); $nodeName = null; - switch ($this->type) { + switch($this->type) { case SharingPlugin::STATUS_ACCEPTED : $nodeName = 'cs:invite-accepted'; @@ -197,8 +197,8 @@ public function serializeBody(DAV\Server $server, \DOMElement $node) * * @return string */ - public function getId() - { + public function getId() { + return $this->id; } @@ -210,8 +210,8 @@ public function getId() * * @return string */ - public function getETag() - { + public function getETag() { + return $this->etag; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/SystemStatus.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/SystemStatus.php index af9c8a8a44..608892dab0 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/SystemStatus.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Notifications/Notification/SystemStatus.php @@ -11,12 +11,12 @@ * This notification can be used to indicate to the user that the system is * down. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SystemStatus extends DAV\Property implements CalDAV\Notifications\INotificationType -{ +class SystemStatus extends DAV\Property implements CalDAV\Notifications\INotificationType { + const TYPE_LOW = 1; const TYPE_MEDIUM = 2; const TYPE_HIGH = 3; @@ -68,8 +68,8 @@ class SystemStatus extends DAV\Property implements CalDAV\Notifications\INotific * @param string $description * @param string $href */ - public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) - { + public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) { + $this->id = $id; $this->type = $type; $this->description = $description; @@ -88,9 +88,9 @@ public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server, \DOMElement $node) - { - switch ($this->type) { + public function serialize(DAV\Server $server, \DOMElement $node) { + + switch($this->type) { case self::TYPE_LOW : $type = 'low'; break; @@ -118,9 +118,9 @@ public function serialize(DAV\Server $server, \DOMElement $node) * @param \DOMElement $node * @return void */ - public function serializeBody(DAV\Server $server, \DOMElement $node) - { - switch ($this->type) { + public function serializeBody(DAV\Server $server, \DOMElement $node) { + + switch($this->type) { case self::TYPE_LOW : $type = 'low'; break; @@ -161,8 +161,8 @@ public function serializeBody(DAV\Server $server, \DOMElement $node) * * @return string */ - public function getId() - { + public function getId() { + return $this->id; } @@ -174,8 +174,8 @@ public function getId() * * @return string */ - public function getETag() - { + public function getETag() { + return $this->etag; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Plugin.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Plugin.php index db61c6c7d8..610929388c 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Plugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Plugin.php @@ -12,12 +12,12 @@ * This plugin provides functionality added by CalDAV (RFC 4791) * It implements new reports, and the MKCALENDAR method. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin -{ +class Plugin extends DAV\ServerPlugin { + /** * This is the official CalDAV namespace */ @@ -62,8 +62,8 @@ class Plugin extends DAV\ServerPlugin * @param Schedule\IMip $imipHandler * @return void */ - public function setIMipHandler(Schedule\IMip $imipHandler) - { + public function setIMipHandler(Schedule\IMip $imipHandler) { + $this->imipHandler = $imipHandler; } @@ -78,8 +78,8 @@ public function setIMipHandler(Schedule\IMip $imipHandler) * @param string $uri * @return array */ - public function getHTTPMethods($uri) - { + public function getHTTPMethods($uri) { + // The MKCALENDAR is only available on unmapped uri's, whose // parents extend IExtendedCollection list($parent, $name) = DAV\URLUtil::splitPath($uri); @@ -102,8 +102,8 @@ public function getHTTPMethods($uri) * * @return array */ - public function getFeatures() - { + public function getFeatures() { + return array('calendar-access', 'calendar-proxy'); } @@ -116,8 +116,8 @@ public function getFeatures() * * @return string */ - public function getPluginName() - { + public function getPluginName() { + return 'caldav'; } @@ -132,8 +132,8 @@ public function getPluginName() * @param string $uri * @return array */ - public function getSupportedReportSet($uri) - { + public function getSupportedReportSet($uri) { + $node = $this->server->tree->getNodeForPath($uri); $reports = array(); @@ -154,8 +154,8 @@ public function getSupportedReportSet($uri) * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $server->subscribeEvent('unknownMethod',array($this,'unknownMethod')); @@ -216,8 +216,8 @@ public function initialize(DAV\Server $server) * @param string $uri * @return bool */ - public function unknownMethod($method, $uri) - { + public function unknownMethod($method, $uri) { + switch ($method) { case 'MKCALENDAR' : $this->httpMkCalendar($uri); @@ -255,9 +255,9 @@ public function unknownMethod($method, $uri) * @param \DOMNode $dom * @return bool */ - public function report($reportName,$dom) - { - switch ($reportName) { + public function report($reportName,$dom) { + + switch($reportName) { case '{'.self::NS_CALDAV.'}calendar-multiget' : $this->calendarMultiGetReport($dom); return false; @@ -280,8 +280,8 @@ public function report($reportName,$dom) * @param string $uri * @return void */ - public function httpMkCalendar($uri) - { + public function httpMkCalendar($uri) { + // Due to unforgivable bugs in iCal, we're completely disabling MKCALENDAR support // for clients matching iCal in the user agent //$ua = $this->server->httpRequest->getHeader('User-Agent'); @@ -296,10 +296,10 @@ public function httpMkCalendar($uri) $dom = DAV\XMLUtil::loadDOMDocument($body); - foreach ($dom->firstChild->childNodes as $child) { + foreach($dom->firstChild->childNodes as $child) { if (DAV\XMLUtil::toClarkNotation($child)!=='{DAV:}set') continue; - foreach (DAV\XMLUtil::parseProperties($child,$this->server->propertyMap) as $k=>$prop) { + foreach(DAV\XMLUtil::parseProperties($child,$this->server->propertyMap) as $k=>$prop) { $properties[$k] = $prop; } @@ -327,8 +327,8 @@ public function httpMkCalendar($uri) * @param array $returnedProperties * @return void */ - public function beforeGetProperties($path, DAV\INode $node, &$requestedProperties, &$returnedProperties) - { + public function beforeGetProperties($path, DAV\INode $node, &$requestedProperties, &$returnedProperties) { + if ($node instanceof DAVACL\IPrincipal) { // calendar-home-set property @@ -358,7 +358,7 @@ public function beforeGetProperties($path, DAV\INode $node, &$requestedPropertie if (in_array($calProp,$requestedProperties)) { $addresses = $node->getAlternateUriSet(); - $addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/'; + $addresses[] = $this->server->getBaseUri() . DAV\URLUtil::encodePath($node->getPrincipalUrl() . '/'); unset($requestedProperties[array_search($calProp, $requestedProperties)]); $returnedProperties[200][$calProp] = new DAV\Property\HrefList($addresses, false); @@ -375,7 +375,7 @@ public function beforeGetProperties($path, DAV\INode $node, &$requestedPropertie $readList = array(); $writeList = array(); - foreach ($membership as $group) { + foreach($membership as $group) { $groupNode = $this->server->tree->getNodeForPath($group); @@ -455,8 +455,8 @@ public function beforeGetProperties($path, DAV\INode $node, &$requestedPropertie * @param \DOMNode $dom * @return void */ - public function calendarMultiGetReport($dom) - { + public function calendarMultiGetReport($dom) { + $properties = array_keys(DAV\XMLUtil::parseProperties($dom->firstChild)); $hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href'); @@ -469,7 +469,7 @@ public function calendarMultiGetReport($dom) $expandElem = $expand->item(0); $start = $expandElem->getAttribute('start'); $end = $expandElem->getAttribute('end'); - if (!$start || !$end) { + if(!$start || !$end) { throw new DAV\Exception\BadRequest('The "start" and "end" attributes are required for the CALDAV:expand element'); } $start = VObject\DateTimeParser::parseDateTime($start); @@ -487,7 +487,7 @@ public function calendarMultiGetReport($dom) } - foreach ($hrefElems as $elem) { + foreach($hrefElems as $elem) { $uri = $this->server->calculateUri($elem->nodeValue); list($objProps) = $this->server->getPropertiesForPath($uri,$properties); @@ -519,8 +519,8 @@ public function calendarMultiGetReport($dom) * @param \DOMNode $dom * @return void */ - public function calendarQueryReport($dom) - { + public function calendarQueryReport($dom) { + $parser = new CalendarQueryParser($dom); $parser->parse(); @@ -590,7 +590,7 @@ public function calendarQueryReport($dom) $nodePaths = $node->calendarQuery($parser->filters); - foreach ($nodePaths as $path) { + foreach($nodePaths as $path) { list($properties) = $this->server->getPropertiesForPath($this->server->getRequestUri() . '/' . $path, $parser->requestedProperties); @@ -624,12 +624,12 @@ public function calendarQueryReport($dom) * @param \DOMNode $dom * @return void */ - protected function freeBusyQueryReport(\DOMNode $dom) - { + protected function freeBusyQueryReport(\DOMNode $dom) { + $start = null; $end = null; - foreach ($dom->firstChild->childNodes as $childNode) { + foreach($dom->firstChild->childNodes as $childNode) { $clark = DAV\XMLUtil::toClarkNotation($childNode); if ($clark == '{' . self::NS_CALDAV . '}time-range') { @@ -712,8 +712,8 @@ protected function freeBusyQueryReport(\DOMNode $dom) * @param resource $data * @return void */ - public function beforeWriteContent($path, DAV\IFile $node, &$data) - { + public function beforeWriteContent($path, DAV\IFile $node, &$data) { + if (!$node instanceof ICalendarObject) return; @@ -732,8 +732,8 @@ public function beforeWriteContent($path, DAV\IFile $node, &$data) * @param DAV\ICollection $parentNode * @return void */ - public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode) - { + public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode) { + if (!$parentNode instanceof Calendar) return; @@ -751,8 +751,8 @@ public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode) * @param string $path * @return void */ - public function beforeMethod($method, $path) - { + public function beforeMethod($method, $path) { + if ($method!=='GET') return; try { @@ -770,7 +770,7 @@ public function beforeMethod($method, $path) $dom->formatOutput = true; $root = $dom->createElement('cs:notification'); - foreach ($this->server->xmlNamespaces as $namespace => $prefix) { + foreach($this->server->xmlNamespaces as $namespace => $prefix) { $root->setAttribute('xmlns:' . $prefix, $namespace); } @@ -795,8 +795,8 @@ public function beforeMethod($method, $path) * @param string $path * @return void */ - protected function validateICalendar(&$data, $path) - { + protected function validateICalendar(&$data, $path) { + // If it's a stream, we convert it to a string first. if (is_resource($data)) { $data = stream_get_contents($data); @@ -826,8 +826,8 @@ protected function validateICalendar(&$data, $path) $foundType = null; $foundUID = null; - foreach ($vobj->getComponents() as $component) { - switch ($component->name) { + foreach($vobj->getComponents() as $component) { + switch($component->name) { case 'VTIMEZONE' : continue 2; case 'VEVENT' : @@ -841,12 +841,12 @@ protected function validateICalendar(&$data, $path) if (!isset($component->UID)) { throw new DAV\Exception\BadRequest('Every ' . $component->name . ' component must have an UID'); } - $foundUID = (string) $component->UID; + $foundUID = (string)$component->UID; } else { if ($foundType !== $component->name) { throw new DAV\Exception\BadRequest('A calendar object must only contain 1 component. We found a ' . $component->name . ' as well as a ' . $foundType); } - if ($foundUID !== (string) $component->UID) { + if ($foundUID !== (string)$component->UID) { throw new DAV\Exception\BadRequest('Every ' . $component->name . ' in this object must have identical UIDs'); } } @@ -876,8 +876,8 @@ protected function validateICalendar(&$data, $path) * @param string $outboxUri * @return void */ - public function outboxRequest(Schedule\IOutbox $outboxNode, $outboxUri) - { + public function outboxRequest(Schedule\IOutbox $outboxNode, $outboxUri) { + // Parsing the request body try { $vObject = VObject\Reader::read($this->server->httpRequest->getBody(true)); @@ -889,7 +889,7 @@ public function outboxRequest(Schedule\IOutbox $outboxNode, $outboxUri) // component. The combination of both determines what type of request // this is. $componentType = null; - foreach ($vObject->getComponents() as $component) { + foreach($vObject->getComponents() as $component) { if ($component->name !== 'VTIMEZONE') { $componentType = $component->name; break; @@ -900,7 +900,7 @@ public function outboxRequest(Schedule\IOutbox $outboxNode, $outboxUri) } // Validating the METHOD - $method = strtoupper((string) $vObject->METHOD); + $method = strtoupper((string)$vObject->METHOD); if (!$method) { throw new DAV\Exception\BadRequest('A METHOD property must be specified in iTIP messages'); } @@ -936,8 +936,8 @@ public function outboxRequest(Schedule\IOutbox $outboxNode, $outboxUri) * * @return void */ - protected function handleEventNotification(Schedule\IOutbox $outboxNode, VObject\Component $vObject) - { + protected function handleEventNotification(Schedule\IOutbox $outboxNode, VObject\Component $vObject) { + $originator = $this->server->httpRequest->getHeader('Originator'); $recipients = $this->server->httpRequest->getHeader('Recipient'); @@ -949,7 +949,7 @@ protected function handleEventNotification(Schedule\IOutbox $outboxNode, VObject } $recipients = explode(',',$recipients); - foreach ($recipients as $k=>$recipient) { + foreach($recipients as $k=>$recipient) { $recipient = trim($recipient); if (!preg_match('/^mailto:(.*)@(.*)$/i', $recipient)) { @@ -972,7 +972,7 @@ protected function handleEventNotification(Schedule\IOutbox $outboxNode, VObject } $found = false; - foreach ($addresses as $address) { + foreach($addresses as $address) { // Trimming the / on both sides, just in case.. if (rtrim(strtolower($originator),'/') === rtrim(strtolower($address),'/')) { @@ -989,7 +989,7 @@ protected function handleEventNotification(Schedule\IOutbox $outboxNode, VObject // If the Originator header was a url, and not a mailto: address.. // we're going to try to pull the mailto: from the vobject body. if (strtolower(substr($originator,0,7)) !== 'mailto:') { - $originator = (string) $vObject->VEVENT->ORGANIZER; + $originator = (string)$vObject->VEVENT->ORGANIZER; } if (strtolower(substr($originator,0,7)) !== 'mailto:') { @@ -1024,10 +1024,10 @@ protected function handleEventNotification(Schedule\IOutbox $outboxNode, VObject * @param array $recipients * @param VObject\Component $vObject * @param string $principal Principal url - * @return array + * @return array */ - protected function iMIPMessage($originator, array $recipients, VObject\Component $vObject, $principal) - { + protected function iMIPMessage($originator, array $recipients, VObject\Component $vObject, $principal) { + if (!$this->imipHandler) { $resultStatus = '5.2;This server does not support this operation'; } else { @@ -1036,7 +1036,7 @@ protected function iMIPMessage($originator, array $recipients, VObject\Component } $result = array(); - foreach ($recipients as $recipient) { + foreach($recipients as $recipient) { $result[$recipient] = $resultStatus; } @@ -1054,20 +1054,20 @@ protected function iMIPMessage($originator, array $recipients, VObject\Component * @param array $recipients * @return string */ - public function generateScheduleResponse(array $recipients) - { + public function generateScheduleResponse(array $recipients) { + $dom = new \DOMDocument('1.0','utf-8'); $dom->formatOutput = true; $xscheduleResponse = $dom->createElement('cal:schedule-response'); $dom->appendChild($xscheduleResponse); - foreach ($this->server->xmlNamespaces as $namespace=>$prefix) { + foreach($this->server->xmlNamespaces as $namespace=>$prefix) { $xscheduleResponse->setAttribute('xmlns:' . $prefix, $namespace); } - foreach ($recipients as $recipient=>$status) { + foreach($recipients as $recipient=>$status) { $xresponse = $dom->createElement('cal:response'); $xrecipient = $dom->createElement('cal:recipient'); @@ -1094,12 +1094,12 @@ public function generateScheduleResponse(array $recipients) * @param string $request * @return string */ - protected function handleFreeBusyRequest(Schedule\IOutbox $outbox, VObject\Component $vObject) - { + protected function handleFreeBusyRequest(Schedule\IOutbox $outbox, VObject\Component $vObject) { + $vFreeBusy = $vObject->VFREEBUSY; $organizer = $vFreeBusy->organizer; - $organizer = (string) $organizer; + $organizer = (string)$organizer; // Validating if the organizer matches the owner of the inbox. $owner = $outbox->getOwner(); @@ -1118,8 +1118,8 @@ protected function handleFreeBusyRequest(Schedule\IOutbox $outbox, VObject\Compo } $attendees = array(); - foreach ($vFreeBusy->ATTENDEE as $attendee) { - $attendees[]= (string) $attendee; + foreach($vFreeBusy->ATTENDEE as $attendee) { + $attendees[]= (string)$attendee; } @@ -1131,21 +1131,21 @@ protected function handleFreeBusyRequest(Schedule\IOutbox $outbox, VObject\Compo $endRange = $vFreeBusy->DTEND->getDateTime(); $results = array(); - foreach ($attendees as $attendee) { + foreach($attendees as $attendee) { $results[] = $this->getFreeBusyForEmail($attendee, $startRange, $endRange, $vObject); } $dom = new \DOMDocument('1.0','utf-8'); $dom->formatOutput = true; $scheduleResponse = $dom->createElement('cal:schedule-response'); - foreach ($this->server->xmlNamespaces as $namespace=>$prefix) { + foreach($this->server->xmlNamespaces as $namespace=>$prefix) { $scheduleResponse->setAttribute('xmlns:' . $prefix,$namespace); } $dom->appendChild($scheduleResponse); - foreach ($results as $result) { + foreach($results as $result) { $response = $dom->createElement('cal:response'); $recipient = $dom->createElement('cal:recipient'); @@ -1193,8 +1193,8 @@ protected function handleFreeBusyRequest(Schedule\IOutbox $outbox, VObject\Compo * @param VObject\Component $request * @return array */ - protected function getFreeBusyForEmail($email, \DateTime $start, \DateTime $end, VObject\Component $request) - { + protected function getFreeBusyForEmail($email, \DateTime $start, \DateTime $end, VObject\Component $request) { + $caldavNS = '{' . Plugin::NS_CALDAV . '}'; $aclPlugin = $this->server->getPlugin('acl'); @@ -1225,7 +1225,7 @@ protected function getFreeBusyForEmail($email, \DateTime $start, \DateTime $end, // Grabbing the calendar list $objects = array(); - foreach ($this->server->tree->getNodeForPath($homeSet)->getChildren() as $node) { + foreach($this->server->tree->getNodeForPath($homeSet)->getChildren() as $node) { if (!$node instanceof ICalendar) { continue; } @@ -1260,7 +1260,7 @@ protected function getFreeBusyForEmail($email, \DateTime $start, \DateTime $end, } - $vcalendar = VObject\Component::create('VCALENDAR'); + $vcalendar = new VObject\Component\VCalendar(); $vcalendar->VERSION = '2.0'; $vcalendar->METHOD = 'REPLY'; $vcalendar->CALSCALE = 'GREGORIAN'; @@ -1274,7 +1274,7 @@ protected function getFreeBusyForEmail($email, \DateTime $start, \DateTime $end, $result = $generator->getResult(); $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:' . $email; - $vcalendar->VFREEBUSY->UID = (string) $request->VFREEBUSY->UID; + $vcalendar->VFREEBUSY->UID = (string)$request->VFREEBUSY->UID; $vcalendar->VFREEBUSY->ORGANIZER = clone $request->VFREEBUSY->ORGANIZER; return array( @@ -1293,8 +1293,8 @@ protected function getFreeBusyForEmail($email, \DateTime $start, \DateTime $end, * @param string $output * @return bool */ - public function htmlActionsPanel(DAV\INode $node, &$output) - { + public function htmlActionsPanel(DAV\INode $node, &$output) { + if (!$node instanceof UserCalendars) return; @@ -1320,8 +1320,8 @@ public function htmlActionsPanel(DAV\INode $node, &$output) * @param array $postVars * @return bool */ - public function browserPostAction($uri, $action, array $postVars) - { + public function browserPostAction($uri, $action, array $postVars) { + if ($action!=='mkcalendar') return; diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/Collection.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/Collection.php index 2f502ac5e2..8a747a644b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/Collection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/Collection.php @@ -11,20 +11,20 @@ * calendar-proxy-write sub-principals, as defined by the caldav-proxy * specification. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Collection extends DAVACL\AbstractPrincipalCollection -{ +class Collection extends DAVACL\AbstractPrincipalCollection { + /** * Returns a child object based on principal information * * @param array $principalInfo * @return User */ - public function getChildForPrincipal(array $principalInfo) - { + public function getChildForPrincipal(array $principalInfo) { + return new User($this->principalBackend, $principalInfo); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/IProxyRead.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/IProxyRead.php index c02679fb29..548411fa86 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/IProxyRead.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/IProxyRead.php @@ -10,10 +10,10 @@ * Any principal node implementing this interface will be picked up as a 'proxy * principal group'. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IProxyRead extends DAVACL\IPrincipal -{ +interface IProxyRead extends DAVACL\IPrincipal { + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/IProxyWrite.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/IProxyWrite.php index c719fa4a7b..f0e6e47cbf 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/IProxyWrite.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/IProxyWrite.php @@ -10,10 +10,10 @@ * Any principal node implementing this interface will be picked up as a 'proxy * principal group'. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IProxyWrite extends DAVACL\IPrincipal -{ +interface IProxyWrite extends DAVACL\IPrincipal { + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/ProxyRead.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/ProxyRead.php index bb10cdce2e..62f66b98c1 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/ProxyRead.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/ProxyRead.php @@ -11,12 +11,12 @@ * This is needed to implement 'Calendar delegation' support. This class is * instantiated by User. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ProxyRead implements IProxyRead -{ +class ProxyRead implements IProxyRead { + /** * Principal information from the parent principal. * @@ -39,8 +39,8 @@ class ProxyRead implements IProxyRead * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend * @param array $principalInfo */ - public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) - { + public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) { + $this->principalInfo = $principalInfo; $this->principalBackend = $principalBackend; @@ -51,8 +51,8 @@ public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalB * * @return string */ - public function getName() - { + public function getName() { + return 'calendar-proxy-read'; } @@ -62,8 +62,8 @@ public function getName() * * @return null */ - public function getLastModified() - { + public function getLastModified() { + return null; } @@ -74,8 +74,8 @@ public function getLastModified() * @throws DAV\Exception\Forbidden * @return void */ - public function delete() - { + public function delete() { + throw new DAV\Exception\Forbidden('Permission denied to delete node'); } @@ -87,8 +87,8 @@ public function delete() * @param string $name The new name * @return void */ - public function setName($name) - { + public function setName($name) { + throw new DAV\Exception\Forbidden('Permission denied to rename file'); } @@ -101,8 +101,8 @@ public function setName($name) * * @return array */ - public function getAlternateUriSet() - { + public function getAlternateUriSet() { + return array(); } @@ -112,8 +112,8 @@ public function getAlternateUriSet() * * @return string */ - public function getPrincipalUrl() - { + public function getPrincipalUrl() { + return $this->principalInfo['uri'] . '/' . $this->getName(); } @@ -126,8 +126,8 @@ public function getPrincipalUrl() * * @return array */ - public function getGroupMemberSet() - { + public function getGroupMemberSet() { + return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); } @@ -140,8 +140,8 @@ public function getGroupMemberSet() * * @return array */ - public function getGroupMembership() - { + public function getGroupMembership() { + return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); } @@ -157,8 +157,8 @@ public function getGroupMembership() * @param array $principals * @return void */ - public function setGroupMemberSet(array $principals) - { + public function setGroupMemberSet(array $principals) { + $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); } @@ -171,8 +171,8 @@ public function setGroupMemberSet(array $principals) * * @return string */ - public function getDisplayName() - { + public function getDisplayName() { + return $this->getName(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/ProxyWrite.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/ProxyWrite.php index cdf82344da..02cd81f709 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/ProxyWrite.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/ProxyWrite.php @@ -11,12 +11,12 @@ * This is needed to implement 'Calendar delegation' support. This class is * instantiated by User. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ProxyWrite implements IProxyWrite -{ +class ProxyWrite implements IProxyWrite { + /** * Parent principal information * @@ -39,8 +39,8 @@ class ProxyWrite implements IProxyWrite * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend * @param array $principalInfo */ - public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) - { + public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) { + $this->principalInfo = $principalInfo; $this->principalBackend = $principalBackend; @@ -51,8 +51,8 @@ public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalB * * @return string */ - public function getName() - { + public function getName() { + return 'calendar-proxy-write'; } @@ -62,8 +62,8 @@ public function getName() * * @return null */ - public function getLastModified() - { + public function getLastModified() { + return null; } @@ -74,8 +74,8 @@ public function getLastModified() * @throws DAV\Exception\Forbidden * @return void */ - public function delete() - { + public function delete() { + throw new DAV\Exception\Forbidden('Permission denied to delete node'); } @@ -87,8 +87,8 @@ public function delete() * @param string $name The new name * @return void */ - public function setName($name) - { + public function setName($name) { + throw new DAV\Exception\Forbidden('Permission denied to rename file'); } @@ -101,8 +101,8 @@ public function setName($name) * * @return array */ - public function getAlternateUriSet() - { + public function getAlternateUriSet() { + return array(); } @@ -112,8 +112,8 @@ public function getAlternateUriSet() * * @return string */ - public function getPrincipalUrl() - { + public function getPrincipalUrl() { + return $this->principalInfo['uri'] . '/' . $this->getName(); } @@ -126,8 +126,8 @@ public function getPrincipalUrl() * * @return array */ - public function getGroupMemberSet() - { + public function getGroupMemberSet() { + return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); } @@ -140,8 +140,8 @@ public function getGroupMemberSet() * * @return array */ - public function getGroupMembership() - { + public function getGroupMembership() { + return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); } @@ -157,8 +157,8 @@ public function getGroupMembership() * @param array $principals * @return void */ - public function setGroupMemberSet(array $principals) - { + public function setGroupMemberSet(array $principals) { + $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); } @@ -171,8 +171,8 @@ public function setGroupMemberSet(array $principals) * * @return string */ - public function getDisplayName() - { + public function getDisplayName() { + return $this->getName(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/User.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/User.php index b6536c3869..6f3ccb8689 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/User.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Principal/User.php @@ -11,12 +11,12 @@ * collection and returns the caldav-proxy-read and caldav-proxy-write child * principals. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class User extends DAVACL\Principal implements DAV\ICollection -{ +class User extends DAVACL\Principal implements DAV\ICollection { + /** * Creates a new file in the directory * @@ -25,8 +25,8 @@ class User extends DAVACL\Principal implements DAV\ICollection * @throws DAV\Exception\Forbidden * @return void */ - public function createFile($name, $data = null) - { + public function createFile($name, $data = null) { + throw new DAV\Exception\Forbidden('Permission denied to create file (filename ' . $name . ')'); } @@ -38,8 +38,8 @@ public function createFile($name, $data = null) * @throws DAV\Exception\Forbidden * @return void */ - public function createDirectory($name) - { + public function createDirectory($name) { + throw new DAV\Exception\Forbidden('Permission denied to create directory'); } @@ -50,8 +50,8 @@ public function createDirectory($name) * @param string $name * @return DAV\INode */ - public function getChild($name) - { + public function getChild($name) { + $principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name); if (!$principal) { throw new DAV\Exception\NotFound('Node with name ' . $name . ' was not found'); @@ -71,8 +71,8 @@ public function getChild($name) * * @return DAV\INode[] */ - public function getChildren() - { + public function getChildren() { + $r = array(); if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) { $r[] = new ProxyRead($this->principalBackend, $this->principalProperties); @@ -91,8 +91,8 @@ public function getChildren() * @param string $name * @return bool */ - public function childExists($name) - { + public function childExists($name) { + try { $this->getChild($name); return true; @@ -114,8 +114,8 @@ public function childExists($name) * * @return array */ - public function getACL() - { + public function getACL() { + $acl = parent::getACL(); $acl[] = array( 'privilege' => '{DAV:}read', diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/AllowedSharingModes.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/AllowedSharingModes.php index 4eb15a0c2b..ca8312d408 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/AllowedSharingModes.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/AllowedSharingModes.php @@ -16,12 +16,12 @@ * such as VEVENT, VTODO * * @see https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing-02.txt - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class AllowedSharingModes extends DAV\Property -{ +class AllowedSharingModes extends DAV\Property { + /** * Whether or not a calendar can be shared with another user * @@ -43,8 +43,8 @@ class AllowedSharingModes extends DAV\Property * @param bool $canBePublished * @return void */ - public function __construct($canBeShared, $canBePublished) - { + public function __construct($canBeShared, $canBePublished) { + $this->canBeShared = $canBeShared; $this->canBePublished = $canBePublished; @@ -57,8 +57,8 @@ public function __construct($canBeShared, $canBePublished) * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server, \DOMElement $node) - { + public function serialize(DAV\Server $server, \DOMElement $node) { + $doc = $node->ownerDocument; if ($this->canBeShared) { $xcomp = $doc->createElement('cs:can-be-shared'); diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/Invite.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/Invite.php index d0eb833b06..86ef69e803 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/Invite.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/Invite.php @@ -14,12 +14,12 @@ * namespace. * * @see https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing-02.txt - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Invite extends DAV\Property -{ +class Invite extends DAV\Property { + /** * The list of users a calendar has been shared to. * @@ -61,8 +61,8 @@ class Invite extends DAV\Property * * @param array $users */ - public function __construct(array $users, array $organizer = null) - { + public function __construct(array $users, array $organizer = null) { + $this->users = $users; $this->organizer = $organizer; @@ -73,8 +73,8 @@ public function __construct(array $users, array $organizer = null) * * @return array */ - public function getValue() - { + public function getValue() { + return $this->users; } @@ -86,8 +86,8 @@ public function getValue() * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; if (!is_null($this->organizer)) { @@ -119,7 +119,7 @@ public function serialize(DAV\Server $server,\DOMElement $node) } - foreach ($this->users as $user) { + foreach($this->users as $user) { $xuser = $doc->createElement('cs:user'); @@ -133,7 +133,7 @@ public function serialize(DAV\Server $server,\DOMElement $node) $xuser->appendChild($commonName); } - switch ($user['status']) { + switch($user['status']) { case SharingPlugin::STATUS_ACCEPTED : $status = $doc->createElement('cs:invite-accepted'); @@ -188,15 +188,15 @@ public function serialize(DAV\Server $server,\DOMElement $node) * @param \DOMElement $prop * @return DAV\IProperty */ - public static function unserialize(\DOMElement $prop) - { + static function unserialize(\DOMElement $prop) { + $xpath = new \DOMXPath($prop->ownerDocument); $xpath->registerNamespace('cs', CalDAV\Plugin::NS_CALENDARSERVER); $xpath->registerNamespace('d', 'urn:DAV'); $users = array(); - foreach ($xpath->query('cs:user', $prop) as $user) { + foreach($xpath->query('cs:user', $prop) as $user) { $status = null; if ($xpath->evaluate('boolean(cs:invite-accepted)', $user)) { diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/ScheduleCalendarTransp.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/ScheduleCalendarTransp.php index 051f6bfb22..7f12d75852 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/ScheduleCalendarTransp.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/ScheduleCalendarTransp.php @@ -15,12 +15,12 @@ * means that this calendar will not be taken into consideration when a * different user queries for free-busy information. If it's 'opaque', it will. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ScheduleCalendarTransp extends DAV\Property -{ +class ScheduleCalendarTransp extends DAV\Property { + const TRANSPARENT = 'transparent'; const OPAQUE = 'opaque'; @@ -31,8 +31,8 @@ class ScheduleCalendarTransp extends DAV\Property * * @param string $value */ - public function __construct($value) - { + public function __construct($value) { + if ($value !== self::TRANSPARENT && $value !== self::OPAQUE) { throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"'); } @@ -45,8 +45,8 @@ public function __construct($value) * * @return string */ - public function getValue() - { + public function getValue() { + return $this->value; } @@ -58,10 +58,10 @@ public function getValue() * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; - switch ($this->value) { + switch($this->value) { case self::TRANSPARENT : $xval = $doc->createElement('cal:transparent'); break; @@ -80,11 +80,11 @@ public function serialize(DAV\Server $server,\DOMElement $node) * @param \DOMElement $node * @return ScheduleCalendarTransp */ - public static function unserialize(\DOMElement $node) - { + static function unserialize(\DOMElement $node) { + $value = null; - foreach ($node->childNodes as $childNode) { - switch (DAV\XMLUtil::toClarkNotation($childNode)) { + foreach($node->childNodes as $childNode) { + switch(DAV\XMLUtil::toClarkNotation($childNode)) { case '{' . CalDAV\Plugin::NS_CALDAV . '}opaque' : $value = self::OPAQUE; break; diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php index 2b9dc45fc0..2538fa45d9 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php @@ -12,12 +12,12 @@ * property in the CalDAV namespace. It simply requires an array of components, * such as VEVENT, VTODO * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCalendarComponentSet extends DAV\Property -{ +class SupportedCalendarComponentSet extends DAV\Property { + /** * List of supported components, such as "VEVENT, VTODO" * @@ -30,8 +30,8 @@ class SupportedCalendarComponentSet extends DAV\Property * * @param array $components */ - public function __construct(array $components) - { + public function __construct(array $components) { + $this->components = $components; } @@ -41,8 +41,8 @@ public function __construct(array $components) * * @return array */ - public function getValue() - { + public function getValue() { + return $this->components; } @@ -54,10 +54,10 @@ public function getValue() * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; - foreach ($this->components as $component) { + foreach($this->components as $component) { $xcomp = $doc->createElement('cal:comp'); $xcomp->setAttribute('name',$component); @@ -73,10 +73,10 @@ public function serialize(DAV\Server $server,\DOMElement $node) * @param \DOMElement $node * @return Property_SupportedCalendarComponentSet */ - public static function unserialize(\DOMElement $node) - { + static function unserialize(\DOMElement $node) { + $components = array(); - foreach ($node->childNodes as $childNode) { + foreach($node->childNodes as $childNode) { if (DAV\XMLUtil::toClarkNotation($childNode)==='{' . CalDAV\Plugin::NS_CALDAV . '}comp') { $components[] = $childNode->getAttribute('name'); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCalendarData.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCalendarData.php index 0923cd832a..efab80a915 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCalendarData.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCalendarData.php @@ -11,12 +11,12 @@ * in the CalDAV namespace. SabreDAV only has support for text/calendar;2.0 * so the value is currently hardcoded. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCalendarData extends DAV\Property -{ +class SupportedCalendarData extends DAV\Property { + /** * Serializes the property in a DOMDocument * @@ -24,8 +24,8 @@ class SupportedCalendarData extends DAV\Property * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; $prefix = isset($server->xmlNamespaces[Plugin::NS_CALDAV])?$server->xmlNamespaces[Plugin::NS_CALDAV]:'cal'; diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCollationSet.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCollationSet.php index bb0caea506..63c37fe5ae 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCollationSet.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Property/SupportedCollationSet.php @@ -9,12 +9,12 @@ * This property is a representation of the supported-collation-set property * in the CalDAV namespace. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SupportedCollationSet extends DAV\Property -{ +class SupportedCollationSet extends DAV\Property { + /** * Serializes the property in a DOM document * @@ -22,8 +22,8 @@ class SupportedCollationSet extends DAV\Property * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; $prefix = $node->lookupPrefix('urn:ietf:params:xml:ns:caldav'); diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/IMip.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/IMip.php index c9d88b2fb3..b2b0d98b1b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/IMip.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/IMip.php @@ -15,12 +15,12 @@ * If you want to customize the email that gets sent out, you can do so by * extending this class and overriding the sendMessage method. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class IMip -{ +class IMip { + /** * Email address used in From: header. * @@ -36,8 +36,8 @@ class IMip * generally be some kind of no-reply email * address you own. */ - public function __construct($senderEmail) - { + public function __construct($senderEmail) { + $this->senderEmail = $senderEmail; } @@ -51,15 +51,15 @@ public function __construct($senderEmail) * @param string $principal Principal Url of the originator * @return void */ - public function sendMessage($originator, array $recipients, VObject\Component $vObject, $principal) - { - foreach ($recipients as $recipient) { + public function sendMessage($originator, array $recipients, VObject\Component $vObject, $principal) { + + foreach($recipients as $recipient) { $to = $recipient; $replyTo = $originator; $subject = 'SabreDAV iTIP message'; - switch (strtoupper($vObject->METHOD)) { + switch(strtoupper($vObject->METHOD)) { case 'REPLY' : $subject = 'Response for: ' . $vObject->VEVENT->SUMMARY; break; @@ -74,7 +74,7 @@ public function sendMessage($originator, array $recipients, VObject\Component $v $headers = array(); $headers[] = 'Reply-To: ' . $replyTo; $headers[] = 'From: ' . $this->senderEmail; - $headers[] = 'Content-Type: text/calendar; method=' . (string) $vObject->method . '; charset=utf-8'; + $headers[] = 'Content-Type: text/calendar; method=' . (string)$vObject->method . '; charset=utf-8'; if (DAV\Server::$exposeVersion) { $headers[] = 'X-Sabre-Version: ' . DAV\Version::VERSION . '-' . DAV\Version::STABILITY; } @@ -99,8 +99,9 @@ public function sendMessage($originator, array $recipients, VObject\Component $v * @param array $headers List of headers * @return void */ - protected function mail($to, $subject, $body, array $headers) - { + protected function mail($to, $subject, $body, array $headers) { + + mail($to, $subject, $body, implode("\r\n", $headers)); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/IOutbox.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/IOutbox.php index 7e1c02eaab..7341eaa85f 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/IOutbox.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/IOutbox.php @@ -6,10 +6,11 @@ * Implement this interface to have a node be recognized as a CalDAV scheduling * outbox. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IOutbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL -{ +interface IOutbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL { + + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/Outbox.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/Outbox.php index f6c77ebaeb..cf4500f699 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/Outbox.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Schedule/Outbox.php @@ -12,12 +12,12 @@ * free-busy requests. This functionality is completely handled by the * Scheduling plugin, so this object is actually mostly static. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Outbox extends DAV\Collection implements IOutbox -{ +class Outbox extends DAV\Collection implements IOutbox { + /** * The principal Uri * @@ -30,8 +30,8 @@ class Outbox extends DAV\Collection implements IOutbox * * @param string $principalUri */ - public function __construct($principalUri) - { + public function __construct($principalUri) { + $this->principalUri = $principalUri; } @@ -43,8 +43,8 @@ public function __construct($principalUri) * * @return string */ - public function getName() - { + public function getName() { + return 'outbox'; } @@ -54,8 +54,8 @@ public function getName() * * @return \Sabre\DAV\INode[] */ - public function getChildren() - { + public function getChildren() { + return array(); } @@ -67,8 +67,8 @@ public function getChildren() * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->principalUri; } @@ -80,8 +80,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -98,8 +98,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', @@ -128,8 +128,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\MethodNotAllowed('You\'re not allowed to update the ACL'); } @@ -146,8 +146,8 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet(); $default['aggregates'][] = array( 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy', diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ShareableCalendar.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ShareableCalendar.php index ba826adc8d..cabf7eb955 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ShareableCalendar.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/ShareableCalendar.php @@ -6,12 +6,12 @@ * This object represents a CalDAV calendar that can be shared with other * users. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ShareableCalendar extends Calendar implements IShareableCalendar -{ +class ShareableCalendar extends Calendar implements IShareableCalendar { + /** * Updates the list of shares. * @@ -30,8 +30,8 @@ class ShareableCalendar extends Calendar implements IShareableCalendar * @param array $remove * @return void */ - public function updateShares(array $add, array $remove) - { + public function updateShares(array $add, array $remove) { + $this->caldavBackend->updateShares($this->calendarInfo['id'], $add, $remove); } @@ -48,8 +48,8 @@ public function updateShares(array $add, array $remove) * * @return array */ - public function getShares() - { + public function getShares() { + return $this->caldavBackend->getShares($this->calendarInfo['id']); } @@ -63,8 +63,8 @@ public function getShares() * @param bool $value * @return void */ - public function setPublishStatus($value) - { + public function setPublishStatus($value) { + $this->caldavBackend->setPublishStatus($this->calendarInfo['id'], $value); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/SharedCalendar.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/SharedCalendar.php index 013ad36be6..79eda43abb 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/SharedCalendar.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/SharedCalendar.php @@ -7,26 +7,26 @@ /** * This object represents a CalDAV calendar that is shared by a different user. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SharedCalendar extends Calendar implements ISharedCalendar -{ +class SharedCalendar extends Calendar implements ISharedCalendar { + /** * Constructor * * @param Backend\BackendInterface $caldavBackend * @param array $calendarInfo */ - public function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) - { + public function __construct(Backend\BackendInterface $caldavBackend, $calendarInfo) { + $required = array( '{http://calendarserver.org/ns/}shared-url', '{http://sabredav.org/ns}owner-principal', '{http://sabredav.org/ns}read-only', ); - foreach ($required as $r) { + foreach($required as $r) { if (!isset($calendarInfo[$r])) { throw new \InvalidArgumentException('The ' . $r . ' property must be specified for SharedCalendar(s)'); } @@ -42,8 +42,8 @@ public function __construct(Backend\BackendInterface $caldavBackend, $calendarIn * * @return string */ - public function getSharedUrl() - { + public function getSharedUrl() { + return $this->calendarInfo['{http://calendarserver.org/ns/}shared-url']; } @@ -55,8 +55,8 @@ public function getSharedUrl() * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->calendarInfo['{http://sabredav.org/ns}owner-principal']; } @@ -73,8 +73,8 @@ public function getOwner() * * @return array */ - public function getACL() - { + public function getACL() { + // The top-level ACL only contains access information for the true // owner of the calendar, so we need to add the information for the // sharee. @@ -107,8 +107,8 @@ public function getACL() * * @return array */ - public function getShares() - { + public function getShares() { + return $this->caldavBackend->getShares($this->calendarInfo['id']); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/SharingPlugin.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/SharingPlugin.php index caab76c1b7..e869cb278b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/SharingPlugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/SharingPlugin.php @@ -16,12 +16,12 @@ * Note: This feature is experimental, and may change in between different * SabreDAV versions. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SharingPlugin extends DAV\ServerPlugin -{ +class SharingPlugin extends DAV\ServerPlugin { + /** * These are the various status constants used by sharing-messages. */ @@ -46,8 +46,8 @@ class SharingPlugin extends DAV\ServerPlugin * * @return array */ - public function getFeatures() - { + public function getFeatures() { + return array('calendarserver-sharing'); } @@ -60,8 +60,8 @@ public function getFeatures() * * @return string */ - public function getPluginName() - { + public function getPluginName() { + return 'caldav-sharing'; } @@ -77,8 +77,8 @@ public function getPluginName() * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $server->resourceTypeMapping['Sabre\\CalDAV\\ISharedCalendar'] = '{' . Plugin::NS_CALENDARSERVER . '}shared'; @@ -108,8 +108,8 @@ public function initialize(DAV\Server $server) * @param array $returnedProperties * @return void */ - public function beforeGetProperties($path, DAV\INode $node, &$requestedProperties, &$returnedProperties) - { + public function beforeGetProperties($path, DAV\INode $node, &$requestedProperties, &$returnedProperties) { + if ($node instanceof IShareableCalendar) { if (($index = array_search('{' . Plugin::NS_CALENDARSERVER . '}invite', $requestedProperties))!==false) { @@ -187,8 +187,8 @@ public function beforeGetProperties($path, DAV\INode $node, &$requestedPropertie * @param DAV\INode $node * @return void */ - public function afterGetProperties($path, &$properties, DAV\INode $node) - { + public function afterGetProperties($path, &$properties, DAV\INode $node) { + if ($node instanceof IShareableCalendar) { if (isset($properties[200]['{DAV:}resourcetype'])) { if (count($node->getShares())>0) { @@ -223,8 +223,8 @@ public function afterGetProperties($path, &$properties, DAV\INode $node) * @param DAV\INode $node * @return void */ - public function updateProperties(array &$mutations, array &$result, DAV\INode $node) - { + public function updateProperties(array &$mutations, array &$result, DAV\INode $node) { + if (!$node instanceof IShareableCalendar) return; @@ -237,7 +237,7 @@ public function updateProperties(array &$mutations, array &$result, DAV\INode $n $shares = $node->getShares(); $remove = array(); - foreach ($shares as $share) { + foreach($shares as $share) { $remove[] = $share['href']; } $node->updateShares(array(), $remove); @@ -260,8 +260,8 @@ public function updateProperties(array &$mutations, array &$result, DAV\INode $n * @param string $uri * @return null|bool */ - public function unknownMethod($method, $uri) - { + public function unknownMethod($method, $uri) { + if ($method!=='POST') { return; } @@ -293,7 +293,7 @@ public function unknownMethod($method, $uri) $documentType = DAV\XMLUtil::toClarkNotation($dom->firstChild); - switch ($documentType) { + switch($documentType) { // Dealing with the 'share' document, which modified invitees on a // calendar. @@ -361,7 +361,7 @@ public function unknownMethod($method, $uri) $dom->formatOutput = true; $root = $dom->createElement('cs:shared-as'); - foreach ($this->server->xmlNamespaces as $namespace => $prefix) { + foreach($this->server->xmlNamespaces as $namespace => $prefix) { $root->setAttribute('xmlns:' . $prefix, $namespace); } @@ -454,8 +454,8 @@ public function unknownMethod($method, $uri) * @param \DOMDocument $dom * @return array */ - protected function parseShareRequest(\DOMDocument $dom) - { + protected function parseShareRequest(\DOMDocument $dom) { + $xpath = new \DOMXPath($dom); $xpath->registerNamespace('cs', Plugin::NS_CALENDARSERVER); $xpath->registerNamespace('d', 'urn:DAV'); @@ -463,7 +463,7 @@ protected function parseShareRequest(\DOMDocument $dom) $set = array(); $elems = $xpath->query('cs:set'); - for ($i=0; $i < $elems->length; $i++) { + for($i=0; $i < $elems->length; $i++) { $xset = $elems->item($i); $set[] = array( @@ -478,7 +478,7 @@ protected function parseShareRequest(\DOMDocument $dom) $remove = array(); $elems = $xpath->query('cs:remove'); - for ($i=0; $i < $elems->length; $i++) { + for($i=0; $i < $elems->length; $i++) { $xremove = $elems->item($i); $remove[] = $xpath->evaluate('string(d:href)', $xremove); @@ -502,8 +502,8 @@ protected function parseShareRequest(\DOMDocument $dom) * @param \DOMDocument $dom * @return array */ - protected function parseInviteReplyRequest(\DOMDocument $dom) - { + protected function parseInviteReplyRequest(\DOMDocument $dom) { + $xpath = new \DOMXPath($dom); $xpath->registerNamespace('cs', Plugin::NS_CALENDARSERVER); $xpath->registerNamespace('d', 'urn:DAV'); diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/UserCalendars.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/UserCalendars.php index 02da425382..6e700eb048 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/UserCalendars.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/UserCalendars.php @@ -8,12 +8,12 @@ /** * The UserCalenders class contains all calendars associated to one user * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class UserCalendars implements DAV\IExtendedCollection, DAVACL\IACL -{ +class UserCalendars implements DAV\IExtendedCollection, DAVACL\IACL { + /** * CalDAV backend * @@ -34,8 +34,8 @@ class UserCalendars implements DAV\IExtendedCollection, DAVACL\IACL * @param Backend\BackendInterface $caldavBackend * @param mixed $userUri */ - public function __construct(Backend\BackendInterface $caldavBackend, $principalInfo) - { + public function __construct(Backend\BackendInterface $caldavBackend, $principalInfo) { + $this->caldavBackend = $caldavBackend; $this->principalInfo = $principalInfo; @@ -46,8 +46,8 @@ public function __construct(Backend\BackendInterface $caldavBackend, $principalI * * @return string */ - public function getName() - { + public function getName() { + list(,$name) = DAV\URLUtil::splitPath($this->principalInfo['uri']); return $name; @@ -59,8 +59,8 @@ public function getName() * @param string $name * @return void */ - public function setName($name) - { + public function setName($name) { + throw new DAV\Exception\Forbidden(); } @@ -70,8 +70,8 @@ public function setName($name) * * @return void */ - public function delete() - { + public function delete() { + throw new DAV\Exception\Forbidden(); } @@ -81,8 +81,8 @@ public function delete() * * @return int */ - public function getLastModified() - { + public function getLastModified() { + return null; } @@ -96,8 +96,8 @@ public function getLastModified() * @param resource $data * @return void */ - public function createFile($filename, $data=null) - { + public function createFile($filename, $data=null) { + throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported'); } @@ -110,8 +110,8 @@ public function createFile($filename, $data=null) * @param string $filename * @return void */ - public function createDirectory($filename) - { + public function createDirectory($filename) { + throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported'); } @@ -123,9 +123,9 @@ public function createDirectory($filename) * @todo needs optimizing * @return Calendar */ - public function getChild($name) - { - foreach ($this->getChildren() as $child) { + public function getChild($name) { + + foreach($this->getChildren() as $child) { if ($name==$child->getName()) return $child; @@ -141,9 +141,9 @@ public function getChild($name) * @todo needs optimizing * @return bool */ - public function childExists($name) - { - foreach ($this->getChildren() as $child) { + public function childExists($name) { + + foreach($this->getChildren() as $child) { if ($name==$child->getName()) return true; @@ -157,11 +157,11 @@ public function childExists($name) * * @return array */ - public function getChildren() - { + public function getChildren() { + $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); $objs = array(); - foreach ($calendars as $calendar) { + foreach($calendars as $calendar) { if ($this->caldavBackend instanceof Backend\SharingSupport) { if (isset($calendar['{http://calendarserver.org/ns/}shared-url'])) { $objs[] = new SharedCalendar($this->caldavBackend, $calendar); @@ -190,10 +190,10 @@ public function getChildren() * @param array $properties * @return void */ - public function createExtendedCollection($name, array $resourceType, array $properties) - { + public function createExtendedCollection($name, array $resourceType, array $properties) { + $isCalendar = false; - foreach ($resourceType as $rt) { + foreach($resourceType as $rt) { switch ($rt) { case '{DAV:}collection' : case '{http://calendarserver.org/ns/}shared-owner' : @@ -220,8 +220,8 @@ public function createExtendedCollection($name, array $resourceType, array $prop * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->principalInfo['uri']; } @@ -233,8 +233,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -251,8 +251,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'privilege' => '{DAV:}read', @@ -292,8 +292,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); } @@ -310,8 +310,8 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + return null; } @@ -329,8 +329,8 @@ public function getSupportedPrivilegeSet() * @param string $summary A description of the reply * @return null|string */ - public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null) - { + public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null) { + if (!$this->caldavBackend instanceof Backend\SharingSupport) { throw new DAV\Exception\NotImplemented('Sharing support is not implemented by this backend.'); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Version.php b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Version.php index cbac08f474..f30fc20ea3 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Version.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CalDAV/Version.php @@ -5,16 +5,16 @@ /** * This class contains the Sabre\CalDAV version constants. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Version -{ +class Version { + /** * Full version number */ - const VERSION = '1.8.3'; + const VERSION = '1.8.7'; /** * Stability : alpha, beta, stable diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBook.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBook.php index a8146c9043..399f38e8d9 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBook.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBook.php @@ -10,12 +10,12 @@ * * The AddressBook can contain multiple vcards * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL -{ +class AddressBook extends DAV\Collection implements IAddressBook, DAV\IProperties, DAVACL\IACL { + /** * This is an array with addressbook information * @@ -36,8 +36,8 @@ class AddressBook extends DAV\Collection implements IAddressBook, DAV\IPropertie * @param Backend\BackendInterface $carddavBackend * @param array $addressBookInfo */ - public function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo) - { + public function __construct(Backend\BackendInterface $carddavBackend, array $addressBookInfo) { + $this->carddavBackend = $carddavBackend; $this->addressBookInfo = $addressBookInfo; @@ -48,8 +48,8 @@ public function __construct(Backend\BackendInterface $carddavBackend, array $add * * @return string */ - public function getName() - { + public function getName() { + return $this->addressBookInfo['uri']; } @@ -60,8 +60,8 @@ public function getName() * @param string $name * @return \ICard */ - public function getChild($name) - { + public function getChild($name) { + $obj = $this->carddavBackend->getCard($this->addressBookInfo['id'],$name); if (!$obj) throw new DAV\Exception\NotFound('Card not found'); return new Card($this->carddavBackend,$this->addressBookInfo,$obj); @@ -73,11 +73,11 @@ public function getChild($name) * * @return array */ - public function getChildren() - { + public function getChildren() { + $objs = $this->carddavBackend->getCards($this->addressBookInfo['id']); $children = array(); - foreach ($objs as $obj) { + foreach($objs as $obj) { $children[] = new Card($this->carddavBackend,$this->addressBookInfo,$obj); } return $children; @@ -92,8 +92,8 @@ public function getChildren() * @param string $name * @return void */ - public function createDirectory($name) - { + public function createDirectory($name) { + throw new DAV\Exception\MethodNotAllowed('Creating collections in addressbooks is not allowed'); } @@ -109,8 +109,8 @@ public function createDirectory($name) * @param resource $vcardData * @return string|null */ - public function createFile($name,$vcardData = null) - { + public function createFile($name,$vcardData = null) { + if (is_resource($vcardData)) { $vcardData = stream_get_contents($vcardData); } @@ -126,8 +126,8 @@ public function createFile($name,$vcardData = null) * * @return void */ - public function delete() - { + public function delete() { + $this->carddavBackend->deleteAddressBook($this->addressBookInfo['id']); } @@ -138,8 +138,8 @@ public function delete() * @param string $newName * @return void */ - public function setName($newName) - { + public function setName($newName) { + throw new DAV\Exception\MethodNotAllowed('Renaming addressbooks is not yet supported'); } @@ -149,8 +149,8 @@ public function setName($newName) * * @return void */ - public function getLastModified() - { + public function getLastModified() { + return null; } @@ -190,8 +190,8 @@ public function getLastModified() * @param array $mutations * @return bool|array */ - public function updateProperties($mutations) - { + public function updateProperties($mutations) { + return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $mutations); } @@ -207,10 +207,10 @@ public function updateProperties($mutations) * @param array $properties * @return array */ - public function getProperties($properties) - { + public function getProperties($properties) { + $response = array(); - foreach ($properties as $propertyName) { + foreach($properties as $propertyName) { if (isset($this->addressBookInfo[$propertyName])) { @@ -231,8 +231,8 @@ public function getProperties($properties) * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->addressBookInfo['principaluri']; } @@ -244,8 +244,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -262,8 +262,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'privilege' => '{DAV:}read', @@ -288,8 +288,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); } @@ -306,8 +306,8 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + return null; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBookQueryParser.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBookQueryParser.php index cb448975a9..3277d98b09 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBookQueryParser.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBookQueryParser.php @@ -10,12 +10,12 @@ * Whoever designed this format, and the CalDAV equivalent even more so, * has no feel for design. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class AddressBookQueryParser -{ +class AddressBookQueryParser { + const TEST_ANYOF = 'anyof'; const TEST_ALLOF = 'allof'; @@ -68,8 +68,8 @@ class AddressBookQueryParser * * @param \DOMDocument $dom */ - public function __construct(\DOMDocument $dom) - { + public function __construct(\DOMDocument $dom) { + $this->dom = $dom; $this->xpath = new \DOMXPath($dom); @@ -82,8 +82,8 @@ public function __construct(\DOMDocument $dom) * * @return void */ - public function parse() - { + public function parse() { + $filterNode = null; $limit = $this->xpath->evaluate('number(/card:addressbook-query/card:limit/card:nresults)'); @@ -114,7 +114,7 @@ public function parse() $propFilters = array(); $propFilterNodes = $this->xpath->query('card:prop-filter', $filter); - for ($ii=0; $ii < $propFilterNodes->length; $ii++) { + for($ii=0; $ii < $propFilterNodes->length; $ii++) { $propFilters[] = $this->parsePropFilterNode($propFilterNodes->item($ii)); @@ -134,8 +134,8 @@ public function parse() * @param \DOMElement $propFilterNode * @return array */ - protected function parsePropFilterNode(\DOMElement $propFilterNode) - { + protected function parsePropFilterNode(\DOMElement $propFilterNode) { + $propFilter = array(); $propFilter['name'] = $propFilterNode->getAttribute('name'); $propFilter['test'] = $propFilterNode->getAttribute('test'); @@ -148,7 +148,7 @@ protected function parsePropFilterNode(\DOMElement $propFilterNode) $propFilter['param-filters'] = array(); - for ($ii=0;$ii<$paramFilterNodes->length;$ii++) { + for($ii=0;$ii<$paramFilterNodes->length;$ii++) { $propFilter['param-filters'][] = $this->parseParamFilterNode($paramFilterNodes->item($ii)); @@ -156,7 +156,7 @@ protected function parsePropFilterNode(\DOMElement $propFilterNode) $propFilter['text-matches'] = array(); $textMatchNodes = $this->xpath->query('card:text-match', $propFilterNode); - for ($ii=0;$ii<$textMatchNodes->length;$ii++) { + for($ii=0;$ii<$textMatchNodes->length;$ii++) { $propFilter['text-matches'][] = $this->parseTextMatchNode($textMatchNodes->item($ii)); @@ -172,8 +172,8 @@ protected function parsePropFilterNode(\DOMElement $propFilterNode) * @param \DOMElement $paramFilterNode * @return array */ - public function parseParamFilterNode(\DOMElement $paramFilterNode) - { + public function parseParamFilterNode(\DOMElement $paramFilterNode) { + $paramFilter = array(); $paramFilter['name'] = $paramFilterNode->getAttribute('name'); $paramFilter['is-not-defined'] = $this->xpath->query('card:is-not-defined', $paramFilterNode)->length>0; @@ -194,8 +194,8 @@ public function parseParamFilterNode(\DOMElement $paramFilterNode) * @param \DOMElement $textMatchNode * @return array */ - public function parseTextMatchNode(\DOMElement $textMatchNode) - { + public function parseTextMatchNode(\DOMElement $textMatchNode) { + $matchType = $textMatchNode->getAttribute('match-type'); if (!$matchType) $matchType = 'contains'; diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBookRoot.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBookRoot.php index b272e13887..789abbc5d8 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBookRoot.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/AddressBookRoot.php @@ -9,12 +9,12 @@ * * This object lists a collection of users, which can contain addressbooks. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class AddressBookRoot extends DAVACL\AbstractPrincipalCollection -{ +class AddressBookRoot extends DAVACL\AbstractPrincipalCollection { + /** * Principal Backend * @@ -43,8 +43,8 @@ class AddressBookRoot extends DAVACL\AbstractPrincipalCollection * @param Backend\BackendInterface $carddavBackend * @param string $principalPrefix */ - public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend,Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals') - { + public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend,Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals') { + $this->carddavBackend = $carddavBackend; parent::__construct($principalBackend, $principalPrefix); @@ -55,8 +55,8 @@ public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalB * * @return string */ - public function getName() - { + public function getName() { + return Plugin::ADDRESSBOOK_ROOT; } @@ -71,8 +71,8 @@ public function getName() * @param array $principal * @return \Sabre\DAV\INode */ - public function getChildForPrincipal(array $principal) - { + public function getChildForPrincipal(array $principal) { + return new UserAddressBooks($this->carddavBackend, $principal['uri']); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/AbstractBackend.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/AbstractBackend.php index 958eb92779..46909efef1 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/AbstractBackend.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/AbstractBackend.php @@ -9,10 +9,10 @@ * * This class doesn't do much, but it was added for consistency. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface -{ +abstract class AbstractBackend implements BackendInterface { + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/BackendInterface.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/BackendInterface.php index e197af29a8..982da3a0f6 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/BackendInterface.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/BackendInterface.php @@ -11,12 +11,12 @@ * class. The value of the addressBookId is completely up to you, it can be any * arbitrary value you can use as an unique identifier. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface -{ +interface BackendInterface { + /** * Returns the list of addressbooks for a specific user. * diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/PDO.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/PDO.php index 2620beac35..67e0ae3aa7 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/PDO.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Backend/PDO.php @@ -10,12 +10,12 @@ * * This CardDAV backend uses PDO to store addressbooks * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend -{ +class PDO extends AbstractBackend { + /** * PDO connection * @@ -40,8 +40,8 @@ class PDO extends AbstractBackend * @param string $addressBooksTableName * @param string $cardsTableName */ - public function __construct(\PDO $pdo, $addressBooksTableName = 'addressbooks', $cardsTableName = 'cards') - { + public function __construct(\PDO $pdo, $addressBooksTableName = 'addressbooks', $cardsTableName = 'cards') { + $this->pdo = $pdo; $this->addressBooksTableName = $addressBooksTableName; $this->cardsTableName = $cardsTableName; @@ -54,14 +54,14 @@ public function __construct(\PDO $pdo, $addressBooksTableName = 'addressbooks', * @param string $principalUri * @return array */ - public function getAddressBooksForUser($principalUri) - { + public function getAddressBooksForUser($principalUri) { + $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, ctag FROM '.$this->addressBooksTableName.' WHERE principaluri = ?'); $stmt->execute(array($principalUri)); $addressBooks = array(); - foreach ($stmt->fetchAll() as $row) { + foreach($stmt->fetchAll() as $row) { $addressBooks[] = array( 'id' => $row['id'], @@ -92,13 +92,13 @@ public function getAddressBooksForUser($principalUri) * @see Sabre\DAV\IProperties::updateProperties * @return bool|array */ - public function updateAddressBook($addressBookId, array $mutations) - { + public function updateAddressBook($addressBookId, array $mutations) { + $updates = array(); - foreach ($mutations as $property=>$newValue) { + foreach($mutations as $property=>$newValue) { - switch ($property) { + switch($property) { case '{DAV:}displayname' : $updates['displayname'] = $newValue; break; @@ -119,7 +119,7 @@ public function updateAddressBook($addressBookId, array $mutations) } $query = 'UPDATE ' . $this->addressBooksTableName . ' SET ctag = ctag + 1 '; - foreach ($updates as $key=>$value) { + foreach($updates as $key=>$value) { $query.=', `' . $key . '` = :' . $key . ' '; } $query.=' WHERE id = :addressbookid'; @@ -141,8 +141,8 @@ public function updateAddressBook($addressBookId, array $mutations) * @param array $properties * @return void */ - public function createAddressBook($principalUri, $url, array $properties) - { + public function createAddressBook($principalUri, $url, array $properties) { + $values = array( 'displayname' => null, 'description' => null, @@ -150,9 +150,9 @@ public function createAddressBook($principalUri, $url, array $properties) 'uri' => $url, ); - foreach ($properties as $property=>$newValue) { + foreach($properties as $property=>$newValue) { - switch ($property) { + switch($property) { case '{DAV:}displayname' : $values['displayname'] = $newValue; break; @@ -177,8 +177,8 @@ public function createAddressBook($principalUri, $url, array $properties) * @param int $addressBookId * @return void */ - public function deleteAddressBook($addressBookId) - { + public function deleteAddressBook($addressBookId) { + $stmt = $this->pdo->prepare('DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?'); $stmt->execute(array($addressBookId)); @@ -206,8 +206,8 @@ public function deleteAddressBook($addressBookId) * @param mixed $addressbookId * @return array */ - public function getCards($addressbookId) - { + public function getCards($addressbookId) { + $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?'); $stmt->execute(array($addressbookId)); @@ -226,8 +226,8 @@ public function getCards($addressbookId) * @param string $cardUri * @return array */ - public function getCard($addressBookId, $cardUri) - { + public function getCard($addressBookId, $cardUri) { + $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri = ? LIMIT 1'); $stmt->execute(array($addressBookId, $cardUri)); @@ -262,8 +262,8 @@ public function getCard($addressBookId, $cardUri) * @param string $cardData * @return string|null */ - public function createCard($addressBookId, $cardUri, $cardData) - { + public function createCard($addressBookId, $cardUri, $cardData) { + $stmt = $this->pdo->prepare('INSERT INTO ' . $this->cardsTableName . ' (carddata, uri, lastmodified, addressbookid) VALUES (?, ?, ?, ?)'); $result = $stmt->execute(array($cardData, $cardUri, time(), $addressBookId)); @@ -300,8 +300,8 @@ public function createCard($addressBookId, $cardUri, $cardData) * @param string $cardData * @return string|null */ - public function updateCard($addressBookId, $cardUri, $cardData) - { + public function updateCard($addressBookId, $cardUri, $cardData) { + $stmt = $this->pdo->prepare('UPDATE ' . $this->cardsTableName . ' SET carddata = ?, lastmodified = ? WHERE uri = ? AND addressbookid =?'); $stmt->execute(array($cardData, time(), $cardUri, $addressBookId)); @@ -319,8 +319,8 @@ public function updateCard($addressBookId, $cardUri, $cardData) * @param string $cardUri * @return bool */ - public function deleteCard($addressBookId, $cardUri) - { + public function deleteCard($addressBookId, $cardUri) { + $stmt = $this->pdo->prepare('DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri = ?'); $stmt->execute(array($addressBookId, $cardUri)); diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Card.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Card.php index 144df7738b..cc65f76008 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Card.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Card.php @@ -9,12 +9,12 @@ /** * The Card object represents a single Card from an addressbook * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Card extends DAV\File implements ICard, DAVACL\IACL -{ +class Card extends DAV\File implements ICard, DAVACL\IACL { + /** * CardDAV backend * @@ -43,8 +43,8 @@ class Card extends DAV\File implements ICard, DAVACL\IACL * @param array $addressBookInfo * @param array $cardData */ - public function __construct(Backend\BackendInterface $carddavBackend,array $addressBookInfo,array $cardData) - { + public function __construct(Backend\BackendInterface $carddavBackend,array $addressBookInfo,array $cardData) { + $this->carddavBackend = $carddavBackend; $this->addressBookInfo = $addressBookInfo; $this->cardData = $cardData; @@ -56,8 +56,8 @@ public function __construct(Backend\BackendInterface $carddavBackend,array $addr * * @return string */ - public function getName() - { + public function getName() { + return $this->cardData['uri']; } @@ -67,8 +67,8 @@ public function getName() * * @return string */ - public function get() - { + public function get() { + // Pre-populating 'carddata' is optional. If we don't yet have it // already, we fetch it from the backend. if (!isset($this->cardData['carddata'])) { @@ -84,8 +84,8 @@ public function get() * @param string $cardData * @return string|null */ - public function put($cardData) - { + public function put($cardData) { + if (is_resource($cardData)) $cardData = stream_get_contents($cardData); @@ -105,8 +105,8 @@ public function put($cardData) * * @return void */ - public function delete() - { + public function delete() { + $this->carddavBackend->deleteCard($this->addressBookInfo['id'],$this->cardData['uri']); } @@ -116,8 +116,8 @@ public function delete() * * @return string */ - public function getContentType() - { + public function getContentType() { + return 'text/x-vcard; charset=utf-8'; } @@ -127,8 +127,8 @@ public function getContentType() * * @return string */ - public function getETag() - { + public function getETag() { + if (isset($this->cardData['etag'])) { return $this->cardData['etag']; } else { @@ -148,8 +148,8 @@ public function getETag() * * @return int */ - public function getLastModified() - { + public function getLastModified() { + return isset($this->cardData['lastmodified'])?$this->cardData['lastmodified']:null; } @@ -159,8 +159,8 @@ public function getLastModified() * * @return int */ - public function getSize() - { + public function getSize() { + if (array_key_exists('size', $this->cardData)) { return $this->cardData['size']; } else { @@ -176,8 +176,8 @@ public function getSize() * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->addressBookInfo['principaluri']; } @@ -189,8 +189,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -207,8 +207,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'privilege' => '{DAV:}read', @@ -232,8 +232,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); } @@ -250,10 +250,11 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + return null; } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/IAddressBook.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/IAddressBook.php index dae7bb6f9c..e9e990cbdd 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/IAddressBook.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/IAddressBook.php @@ -9,10 +9,12 @@ * * Implement this interface to allow a node to be recognized as an addressbook. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IAddressBook extends DAV\ICollection -{ +interface IAddressBook extends DAV\ICollection { + + + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/ICard.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/ICard.php index c136ee02c1..e9a6331321 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/ICard.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/ICard.php @@ -10,10 +10,11 @@ * Extend the ICard interface to allow your custom nodes to be picked up as * 'Cards'. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface ICard extends DAV\IFile -{ +interface ICard extends DAV\IFile { + } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/IDirectory.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/IDirectory.php index a9ee710ad6..c2774cb45c 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/IDirectory.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/IDirectory.php @@ -11,10 +11,11 @@ * A full description can be found in the IETF draft: * - draft-daboo-carddav-directory-gateway * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IDirectory extends IAddressBook -{ +interface IDirectory extends IAddressBook { + + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Plugin.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Plugin.php index ada2447768..71a61fefc6 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Plugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Plugin.php @@ -11,12 +11,12 @@ * * The CardDAV plugin adds CardDAV functionality to the WebDAV server * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin -{ +class Plugin extends DAV\ServerPlugin { + /** * Url to the addressbooks */ @@ -48,8 +48,8 @@ class Plugin extends DAV\ServerPlugin * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + /* Events */ $server->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties')); $server->subscribeEvent('afterGetProperties', array($this, 'afterGetProperties')); @@ -86,8 +86,8 @@ public function initialize(DAV\Server $server) * * @return array */ - public function getFeatures() - { + public function getFeatures() { + return array('addressbook'); } @@ -102,8 +102,8 @@ public function getFeatures() * @param string $uri * @return array */ - public function getSupportedReportSet($uri) - { + public function getSupportedReportSet($uri) { + $node = $this->server->tree->getNodeForPath($uri); if ($node instanceof IAddressBook || $node instanceof ICard) { return array( @@ -125,8 +125,8 @@ public function getSupportedReportSet($uri) * @param array $returnedProperties * @return void */ - public function beforeGetProperties($path, DAV\INode $node, array &$requestedProperties, array &$returnedProperties) - { + public function beforeGetProperties($path, DAV\INode $node, array &$requestedProperties, array &$returnedProperties) { + if ($node instanceof DAVACL\IPrincipal) { // calendar-home-set property @@ -193,8 +193,8 @@ public function beforeGetProperties($path, DAV\INode $node, array &$requestedPro * @param DAV\INode $node * @return bool */ - public function updateProperties(&$mutations, &$result, DAV\INode $node) - { + public function updateProperties(&$mutations, &$result, DAV\INode $node) { + if (!$node instanceof UserAddressBooks) { return true; } @@ -224,7 +224,7 @@ public function updateProperties(&$mutations, &$result, DAV\INode $node) ); $closureResult = false; - foreach ($innerResult as $status => $props) { + foreach($innerResult as $status => $props) { if (is_array($props) && array_key_exists('{http://sabredav.org/ns}vcard-url', $props)) { $result[$status][$meCard] = null; $closureResult = ($status>=200 && $status<300); @@ -243,9 +243,9 @@ public function updateProperties(&$mutations, &$result, DAV\INode $node) * @param \DOMNode $dom * @return bool */ - public function report($reportName,$dom) - { - switch ($reportName) { + public function report($reportName,$dom) { + + switch($reportName) { case '{'.self::NS_CARDDAV.'}addressbook-multiget' : $this->addressbookMultiGetReport($dom); return false; @@ -269,14 +269,14 @@ public function report($reportName,$dom) * @param \DOMNode $dom * @return void */ - public function addressbookMultiGetReport($dom) - { + public function addressbookMultiGetReport($dom) { + $properties = array_keys(DAV\XMLUtil::parseProperties($dom->firstChild)); $hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href'); $propertyList = array(); - foreach ($hrefElems as $elem) { + foreach($hrefElems as $elem) { $uri = $this->server->calculateUri($elem->nodeValue); list($propertyList[]) = $this->server->getPropertiesForPath($uri,$properties); @@ -303,8 +303,8 @@ public function addressbookMultiGetReport($dom) * @param resource $data * @return void */ - public function beforeWriteContent($path, DAV\IFile $node, &$data) - { + public function beforeWriteContent($path, DAV\IFile $node, &$data) { + if (!$node instanceof ICard) return; @@ -323,8 +323,8 @@ public function beforeWriteContent($path, DAV\IFile $node, &$data) * @param DAV\ICollection $parentNode * @return void */ - public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode) - { + public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode) { + if (!$parentNode instanceof IAddressBook) return; @@ -340,8 +340,8 @@ public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode) * @param resource|string $data * @return void */ - protected function validateVCard(&$data) - { + protected function validateVCard(&$data) { + // If it's a stream, we convert it to a string first. if (is_resource($data)) { $data = stream_get_contents($data); @@ -365,7 +365,9 @@ protected function validateVCard(&$data) } if (!isset($vobj->UID)) { - throw new DAV\Exception\BadRequest('Every vcard must have a UID.'); + // No UID in vcards is invalid, but we'll just add it in anyway. + $vobj->add('UID', DAV\UUIDUtil::getUUID()); + $data = $vobj->serialize(); } } @@ -380,8 +382,8 @@ protected function validateVCard(&$data) * @param \DOMNode $dom * @return void */ - protected function addressbookQueryReport($dom) - { + protected function addressbookQueryReport($dom) { + $query = new AddressBookQueryParser($dom); $query->parse(); @@ -396,7 +398,7 @@ protected function addressbookQueryReport($dom) } $validNodes = array(); - foreach ($candidateNodes as $node) { + foreach($candidateNodes as $node) { if (!$node instanceof ICard) continue; @@ -420,7 +422,7 @@ protected function addressbookQueryReport($dom) } $result = array(); - foreach ($validNodes as $validNode) { + foreach($validNodes as $validNode) { if ($depth==0) { $href = $this->server->getRequestUri(); @@ -449,13 +451,13 @@ protected function addressbookQueryReport($dom) * @param string $test anyof or allof (which means OR or AND) * @return bool */ - public function validateFilters($vcardData, array $filters, $test) - { + public function validateFilters($vcardData, array $filters, $test) { + $vcard = VObject\Reader::read($vcardData); if (!$filters) return true; - foreach ($filters as $filter) { + foreach($filters as $filter) { $isDefined = isset($vcard->{$filter['name']}); if ($filter['is-not-defined']) { @@ -480,7 +482,7 @@ public function validateFilters($vcardData, array $filters, $test) if ($filter['text-matches']) { $texts = array(); foreach($vProperties as $vProperty) - $texts[] = $vProperty->value; + $texts[] = $vProperty->getValue(); $results[] = $this->validateTextMatches($texts, $filter['text-matches'], $filter['test']); } @@ -528,12 +530,12 @@ public function validateFilters($vcardData, array $filters, $test) * @param string $test * @return bool */ - protected function validateParamFilters(array $vProperties, array $filters, $test) - { - foreach ($filters as $filter) { + protected function validateParamFilters(array $vProperties, array $filters, $test) { + + foreach($filters as $filter) { $isDefined = false; - foreach ($vProperties as $vProperty) { + foreach($vProperties as $vProperty) { $isDefined = isset($vProperty[$filter['name']]); if ($isDefined) break; } @@ -553,10 +555,10 @@ protected function validateParamFilters(array $vProperties, array $filters, $tes } else { $success = false; - foreach ($vProperties as $vProperty) { + foreach($vProperties as $vProperty) { // If we got all the way here, we'll need to validate the // text-match filter. - $success = DAV\StringUtil::textMatch($vProperty[$filter['name']]->value, $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['match-type']); + $success = DAV\StringUtil::textMatch($vProperty[$filter['name']]->getValue(), $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['match-type']); if ($success) break; } if ($filter['text-match']['negate-condition']) { @@ -593,12 +595,12 @@ protected function validateParamFilters(array $vProperties, array $filters, $tes * @param string $test * @return bool */ - protected function validateTextMatches(array $texts, array $filters, $test) - { - foreach ($filters as $filter) { + protected function validateTextMatches(array $texts, array $filters, $test) { + + foreach($filters as $filter) { $success = false; - foreach ($texts as $haystack) { + foreach($texts as $haystack) { $success = DAV\StringUtil::textMatch($haystack, $filter['value'], $filter['collation'], $filter['match-type']); // Breaking on the first match @@ -631,8 +633,8 @@ protected function validateTextMatches(array $texts, array $filters, $test) * * @return bool */ - public function afterGetProperties($uri, &$properties) - { + public function afterGetProperties($uri, &$properties) { + // If the request was made using the SOGO connector, we must rewrite // the content-type property. By default SabreDAV will send back // text/x-vcard; charset=utf-8, but for SOGO we must strip that last @@ -659,8 +661,8 @@ public function afterGetProperties($uri, &$properties) * @param string $output * @return bool */ - public function htmlActionsPanel(DAV\INode $node, &$output) - { + public function htmlActionsPanel(DAV\INode $node, &$output) { + if (!$node instanceof UserAddressBooks) return; @@ -686,8 +688,8 @@ public function htmlActionsPanel(DAV\INode $node, &$output) * @param array $postVars * @return bool */ - public function browserPostAction($uri, $action, array $postVars) - { + public function browserPostAction($uri, $action, array $postVars) { + if ($action!=='mkaddressbook') return; diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Property/SupportedAddressData.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Property/SupportedAddressData.php index 65f061336a..9d8dd2e6de 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Property/SupportedAddressData.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Property/SupportedAddressData.php @@ -11,12 +11,12 @@ * This property is a representation of the supported-address-data property * in the CardDAV namespace. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SupportedAddressData extends DAV\Property -{ +class SupportedAddressData extends DAV\Property { + /** * supported versions * @@ -29,8 +29,8 @@ class SupportedAddressData extends DAV\Property * * @param array|null $supportedData */ - public function __construct(array $supportedData = null) - { + public function __construct(array $supportedData = null) { + if (is_null($supportedData)) { $supportedData = array( array('contentType' => 'text/vcard', 'version' => '3.0'), @@ -49,8 +49,8 @@ public function __construct(array $supportedData = null) * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; $prefix = @@ -58,7 +58,7 @@ public function serialize(DAV\Server $server,\DOMElement $node) $server->xmlNamespaces[CardDAV\Plugin::NS_CARDDAV] : 'card'; - foreach ($this->supportedData as $supported) { + foreach($this->supportedData as $supported) { $caldata = $doc->createElementNS(CardDAV\Plugin::NS_CARDDAV, $prefix . ':address-data-type'); $caldata->setAttribute('content-type',$supported['contentType']); diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/UserAddressBooks.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/UserAddressBooks.php index c6d156a0b7..b4af861474 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/UserAddressBooks.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/UserAddressBooks.php @@ -10,12 +10,12 @@ * * The UserAddressBooks collection contains a list of addressbooks associated with a user * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class UserAddressBooks extends DAV\Collection implements DAV\IExtendedCollection, DAVACL\IACL -{ +class UserAddressBooks extends DAV\Collection implements DAV\IExtendedCollection, DAVACL\IACL { + /** * Principal uri * @@ -36,8 +36,8 @@ class UserAddressBooks extends DAV\Collection implements DAV\IExtendedCollection * @param Backend\BackendInterface $carddavBackend * @param string $principalUri */ - public function __construct(Backend\BackendInterface $carddavBackend, $principalUri) - { + public function __construct(Backend\BackendInterface $carddavBackend, $principalUri) { + $this->carddavBackend = $carddavBackend; $this->principalUri = $principalUri; @@ -48,8 +48,8 @@ public function __construct(Backend\BackendInterface $carddavBackend, $principal * * @return string */ - public function getName() - { + public function getName() { + list(,$name) = DAV\URLUtil::splitPath($this->principalUri); return $name; @@ -61,8 +61,8 @@ public function getName() * @param string $name * @return void */ - public function setName($name) - { + public function setName($name) { + throw new DAV\Exception\MethodNotAllowed(); } @@ -72,8 +72,8 @@ public function setName($name) * * @return void */ - public function delete() - { + public function delete() { + throw new DAV\Exception\MethodNotAllowed(); } @@ -83,8 +83,8 @@ public function delete() * * @return int */ - public function getLastModified() - { + public function getLastModified() { + return null; } @@ -98,8 +98,8 @@ public function getLastModified() * @param resource $data * @return void */ - public function createFile($filename, $data=null) - { + public function createFile($filename, $data=null) { + throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported'); } @@ -112,8 +112,8 @@ public function createFile($filename, $data=null) * @param string $filename * @return void */ - public function createDirectory($filename) - { + public function createDirectory($filename) { + throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported'); } @@ -125,9 +125,9 @@ public function createDirectory($filename) * @todo needs optimizing * @return \AddressBook */ - public function getChild($name) - { - foreach ($this->getChildren() as $child) { + public function getChild($name) { + + foreach($this->getChildren() as $child) { if ($name==$child->getName()) return $child; @@ -141,11 +141,11 @@ public function getChild($name) * * @return array */ - public function getChildren() - { + public function getChildren() { + $addressbooks = $this->carddavBackend->getAddressbooksForUser($this->principalUri); $objs = array(); - foreach ($addressbooks as $addressbook) { + foreach($addressbooks as $addressbook) { $objs[] = new AddressBook($this->carddavBackend, $addressbook); } return $objs; @@ -160,8 +160,8 @@ public function getChildren() * @param array $properties * @return void */ - public function createExtendedCollection($name, array $resourceType, array $properties) - { + public function createExtendedCollection($name, array $resourceType, array $properties) { + if (!in_array('{'.Plugin::NS_CARDDAV.'}addressbook',$resourceType) || count($resourceType)!==2) { throw new DAV\Exception\InvalidResourceType('Unknown resourceType for this collection'); } @@ -176,8 +176,8 @@ public function createExtendedCollection($name, array $resourceType, array $prop * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->principalUri; } @@ -189,8 +189,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -207,8 +207,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'privilege' => '{DAV:}read', @@ -233,8 +233,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\MethodNotAllowed('Changing ACL is not yet supported'); } @@ -251,8 +251,8 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + return null; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/VCFExportPlugin.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/VCFExportPlugin.php index 9210377705..3f91a30127 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/VCFExportPlugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/VCFExportPlugin.php @@ -12,13 +12,13 @@ * This is useful for clients that don't support CardDAV yet. They often do * support vcf files. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) * @author Thomas Tanghus (http://tanghus.net/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ -class VCFExportPlugin extends DAV\ServerPlugin -{ +class VCFExportPlugin extends DAV\ServerPlugin { + /** * Reference to Server class * @@ -32,8 +32,8 @@ class VCFExportPlugin extends DAV\ServerPlugin * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90); @@ -47,8 +47,8 @@ public function initialize(DAV\Server $server) * @param string $uri * @return bool */ - public function beforeMethod($method, $uri) - { + public function beforeMethod($method, $uri) { + if ($method!='GET') return; if ($this->server->httpRequest->getQueryString()!='export') return; @@ -84,11 +84,11 @@ public function beforeMethod($method, $uri) * @param array $nodes * @return string */ - public function generateVCF(array $nodes) - { + public function generateVCF(array $nodes) { + $output = ""; - foreach ($nodes as $node) { + foreach($nodes as $node) { if (!isset($node[200]['{' . Plugin::NS_CARDDAV . '}address-data'])) { continue; diff --git a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Version.php b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Version.php index e6311eac84..00221941b3 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Version.php +++ b/core/src/core/classes/sabredav/lib/Sabre/CardDAV/Version.php @@ -7,16 +7,16 @@ * * This class contains the Sabre\CardDAV version information * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Version -{ +class Version { + /** * Full version number */ - const VERSION = '1.8.3'; + const VERSION = '1.8.7'; /** * Stability : alpha, beta, stable diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/AbstractBasic.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/AbstractBasic.php index e7f99021c2..599f932d4e 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/AbstractBasic.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/AbstractBasic.php @@ -12,13 +12,13 @@ * Most of the digest logic is handled, implementors just need to worry about * the validateUserPass method. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). * @author James David Low (http://jameslow.com/) - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBasic implements BackendInterface -{ +abstract class AbstractBasic implements BackendInterface { + /** * This variable holds the currently logged in username. * @@ -45,8 +45,7 @@ abstract protected function validateUserPass($username, $password); * * @return string|null */ - public function getCurrentUser() - { + public function getCurrentUser() { return $this->currentUser; } @@ -62,8 +61,8 @@ public function getCurrentUser() * @throws DAV\Exception\NotAuthenticated * @return bool */ - public function authenticate(DAV\Server $server, $realm) - { + public function authenticate(DAV\Server $server, $realm) { + $auth = new HTTP\BasicAuth(); $auth->setHTTPRequest($server->httpRequest); $auth->setHTTPResponse($server->httpResponse); @@ -85,3 +84,4 @@ public function authenticate(DAV\Server $server, $realm) } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/AbstractDigest.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/AbstractDigest.php index da4e7419d5..dc00438c95 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/AbstractDigest.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/AbstractDigest.php @@ -12,12 +12,12 @@ * Most of the digest logic is handled, implementors just need to worry about * the getDigestHash method * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractDigest implements BackendInterface -{ +abstract class AbstractDigest implements BackendInterface { + /** * This variable holds the currently logged in username. * @@ -47,8 +47,8 @@ abstract public function getDigestHash($realm, $username); * @throws DAV\Exception\NotAuthenticated * @return bool */ - public function authenticate(DAV\Server $server, $realm) - { + public function authenticate(DAV\Server $server, $realm) { + $digest = new HTTP\DigestAuth(); // Hooking up request and response objects @@ -92,8 +92,8 @@ public function authenticate(DAV\Server $server, $realm) * * @return string|null */ - public function getCurrentUser() - { + public function getCurrentUser() { + return $this->currentUser; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/Apache.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/Apache.php index e3992adedc..66fdd91e1e 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/Apache.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/Apache.php @@ -11,12 +11,12 @@ * * Make sure apache is properly configured for this to work. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Apache implements BackendInterface -{ +class Apache implements BackendInterface { + /** * Current apache user * @@ -34,8 +34,8 @@ class Apache implements BackendInterface * @param string $realm * @return bool */ - public function authenticate(DAV\Server $server, $realm) - { + public function authenticate(DAV\Server $server, $realm) { + $remoteUser = $server->httpRequest->getRawServerValue('REMOTE_USER'); if (is_null($remoteUser)) { throw new DAV\Exception('We did not receive the $_SERVER[REMOTE_USER] property. This means that apache might have been misconfigured'); @@ -53,10 +53,11 @@ public function authenticate(DAV\Server $server, $realm) * * @return array|null */ - public function getCurrentUser() - { + public function getCurrentUser() { + return $this->remoteUser; } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/BackendInterface.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/BackendInterface.php index c944c4cba3..b8d04e2e11 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/BackendInterface.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/BackendInterface.php @@ -5,12 +5,12 @@ /** * This is the base class for any authentication object. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface -{ +interface BackendInterface { + /** * Authenticates the user based on the current request. * @@ -21,7 +21,7 @@ interface BackendInterface * @param string $realm * @return bool */ - public function authenticate(\Sabre\DAV\Server $server,$realm); + function authenticate(\Sabre\DAV\Server $server,$realm); /** * Returns information about the currently logged in username. @@ -30,6 +30,7 @@ public function authenticate(\Sabre\DAV\Server $server,$realm); * * @return string|null */ - public function getCurrentUser(); + function getCurrentUser(); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/File.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/File.php index d86e2bc9e7..a8e9136144 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/File.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/File.php @@ -9,12 +9,12 @@ * * The backend file must conform to Apache's htdigest format * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class File extends AbstractDigest -{ +class File extends AbstractDigest { + /** * List of users * @@ -29,8 +29,8 @@ class File extends AbstractDigest * * @param string|null $filename */ - public function __construct($filename=null) - { + public function __construct($filename=null) { + if (!is_null($filename)) $this->loadFile($filename); @@ -43,9 +43,9 @@ public function __construct($filename=null) * @param string $filename * @return void */ - public function loadFile($filename) - { - foreach (file($filename,FILE_IGNORE_NEW_LINES) as $line) { + public function loadFile($filename) { + + foreach(file($filename,FILE_IGNORE_NEW_LINES) as $line) { if (substr_count($line, ":") !== 2) throw new DAV\Exception('Malformed htdigest file. Every line should contain 2 colons'); @@ -68,8 +68,8 @@ public function loadFile($filename) * @param string $username * @return string */ - public function getDigestHash($realm, $username) - { + public function getDigestHash($realm, $username) { + return isset($this->users[$realm . ':' . $username])?$this->users[$realm . ':' . $username]:false; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/PDO.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/PDO.php index f86e93dd8f..f153d8429b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/PDO.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Backend/PDO.php @@ -7,12 +7,12 @@ * * The backend file must conform to Apache's htdigest format * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractDigest -{ +class PDO extends AbstractDigest { + /** * Reference to PDO connection * @@ -36,8 +36,8 @@ class PDO extends AbstractDigest * @param PDO $pdo * @param string $tableName The PDO table name to use */ - public function __construct(\PDO $pdo, $tableName = 'users') - { + public function __construct(\PDO $pdo, $tableName = 'users') { + $this->pdo = $pdo; $this->tableName = $tableName; @@ -50,8 +50,8 @@ public function __construct(\PDO $pdo, $tableName = 'users') * @param string $username * @return string|null */ - public function getDigestHash($realm,$username) - { + public function getDigestHash($realm,$username) { + $stmt = $this->pdo->prepare('SELECT username, digesta1 FROM '.$this->tableName.' WHERE username = ?'); $stmt->execute(array($username)); $result = $stmt->fetchAll(); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Plugin.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Plugin.php index 5b725a30f2..dbebc20f05 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Plugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Auth/Plugin.php @@ -12,12 +12,12 @@ * * {DAV:}current-user-principal property from RFC5397 * * {DAV:}principal-collection-set property from RFC3744 * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin -{ +class Plugin extends DAV\ServerPlugin { + /** * Reference to main server object * @@ -45,8 +45,8 @@ class Plugin extends DAV\ServerPlugin * @param Backend\BackendInterface $authBackend * @param string $realm */ - public function __construct(Backend\BackendInterface $authBackend, $realm) - { + public function __construct(Backend\BackendInterface $authBackend, $realm) { + $this->authBackend = $authBackend; $this->realm = $realm; @@ -58,8 +58,8 @@ public function __construct(Backend\BackendInterface $authBackend, $realm) * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'),10); @@ -73,8 +73,8 @@ public function initialize(DAV\Server $server) * * @return string */ - public function getPluginName() - { + public function getPluginName() { + return 'auth'; } @@ -86,8 +86,8 @@ public function getPluginName() * * @return string|null */ - public function getCurrentUser() - { + public function getCurrentUser() { + $userInfo = $this->authBackend->getCurrentUser(); if (!$userInfo) return null; @@ -103,8 +103,8 @@ public function getCurrentUser() * @throws Sabre\DAV\Exception\NotAuthenticated * @return bool */ - public function beforeMethod($method, $uri) - { + public function beforeMethod($method, $uri) { + $this->authBackend->authenticate($this->server,$this->realm); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/GuessContentType.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/GuessContentType.php index 02ae19b3d1..9fd47b9304 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/GuessContentType.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/GuessContentType.php @@ -15,12 +15,12 @@ * so this extension does what the rest of the world does, and guesses it based * on the file extension. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class GuessContentType extends DAV\ServerPlugin -{ +class GuessContentType extends DAV\ServerPlugin { + /** * List of recognized file extensions * @@ -50,8 +50,8 @@ class GuessContentType extends DAV\ServerPlugin * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + // Using a relatively low priority (200) to allow other extensions // to set the content-type first. $server->subscribeEvent('afterGetProperties',array($this,'afterGetProperties'),200); @@ -65,8 +65,8 @@ public function initialize(DAV\Server $server) * @param array $properties * @return void */ - public function afterGetProperties($path, &$properties) - { + public function afterGetProperties($path, &$properties) { + if (array_key_exists('{DAV:}getcontenttype', $properties[404])) { list(, $fileName) = DAV\URLUtil::splitPath($path); @@ -87,8 +87,8 @@ public function afterGetProperties($path, &$properties) * @param string $fileName * @return string */ - protected function getContentType($fileName) - { + protected function getContentType($fileName) { + // Just grabbing the extension $extension = strtolower(substr($fileName,strrpos($fileName,'.')+1)); if (isset($this->extensionMap[$extension])) diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/MapGetToPropFind.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/MapGetToPropFind.php index 70ec574faa..881c063b90 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/MapGetToPropFind.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/MapGetToPropFind.php @@ -10,12 +10,12 @@ * * This should allow easy debugging of PROPFIND * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class MapGetToPropFind extends DAV\ServerPlugin -{ +class MapGetToPropFind extends DAV\ServerPlugin { + /** * reference to server class * @@ -29,8 +29,8 @@ class MapGetToPropFind extends DAV\ServerPlugin * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $this->server->subscribeEvent('beforeMethod',array($this,'httpGetInterceptor')); } @@ -42,8 +42,8 @@ public function initialize(DAV\Server $server) * @param string $uri * @return bool */ - public function httpGetInterceptor($method, $uri) - { + public function httpGetInterceptor($method, $uri) { + if ($method!='GET') return true; $node = $this->server->tree->getNodeForPath($uri); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/Plugin.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/Plugin.php index 8a89030304..751c229654 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/Plugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/Plugin.php @@ -13,12 +13,12 @@ * The class intercepts GET requests to collection resources and generates a simple * html index. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin -{ +class Plugin extends DAV\ServerPlugin { + /** * List of default icons for nodes. * @@ -78,8 +78,8 @@ class Plugin extends DAV\ServerPlugin * @param bool $enablePost * @param bool $enableAssets */ - public function __construct($enablePost=true, $enableAssets = true) - { + public function __construct($enablePost=true, $enableAssets = true) { + $this->enablePost = $enablePost; $this->enableAssets = $enableAssets; @@ -91,8 +91,8 @@ public function __construct($enablePost=true, $enableAssets = true) * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $this->server->subscribeEvent('beforeMethod',array($this,'httpGetInterceptor')); $this->server->subscribeEvent('onHTMLActionsPanel', array($this, 'htmlActionsPanel'),200); @@ -106,8 +106,8 @@ public function initialize(DAV\Server $server) * @param string $uri * @return bool */ - public function httpGetInterceptor($method, $uri) - { + public function httpGetInterceptor($method, $uri) { + if ($method !== 'GET') return true; // We're not using straight-up $_GET, because we want everything to be @@ -148,8 +148,8 @@ public function httpGetInterceptor($method, $uri) * @param string $uri * @return bool */ - public function httpPOSTHandler($method, $uri) - { + public function httpPOSTHandler($method, $uri) { + if ($method!='POST') return; $contentType = $this->server->httpRequest->getHeader('Content-Type'); list($contentType) = explode(';', $contentType); @@ -164,7 +164,7 @@ public function httpPOSTHandler($method, $uri) if ($this->server->broadcastEvent('onBrowserPostAction', array($uri, $postVars['sabreAction'], $postVars))) { - switch ($postVars['sabreAction']) { + switch($postVars['sabreAction']) { case 'mkcol' : if (isset($postVars['name']) && trim($postVars['name'])) { @@ -204,8 +204,8 @@ public function httpPOSTHandler($method, $uri) * @param string $value * @return string */ - public function escapeHTML($value) - { + public function escapeHTML($value) { + return htmlspecialchars($value,ENT_QUOTES,'UTF-8'); } @@ -216,8 +216,8 @@ public function escapeHTML($value) * @param string $path * @return string */ - public function generateDirectoryIndex($path) - { + public function generateDirectoryIndex($path) { + $version = ''; if (DAV\Server::$exposeVersion) { $version = DAV\Version::VERSION ."-". DAV\Version::STABILITY; @@ -270,7 +270,7 @@ public function generateDirectoryIndex($path) } - foreach ($files as $file) { + foreach($files as $file) { // This is the current directory, we can skip it if (rtrim($file['href'],'/')==$path) continue; @@ -286,10 +286,10 @@ public function generateDirectoryIndex($path) // resourcetype can have multiple values if (!is_array($type)) $type = array($type); - foreach ($type as $k=>$v) { + foreach($type as $k=>$v) { // Some name mapping is preferred - switch ($v) { + switch($v) { case '{DAV:}collection' : $type[$k] = 'Collection'; break; @@ -327,7 +327,7 @@ public function generateDirectoryIndex($path) } if (!$type) $type = 'Unknown'; - $size = isset($file[200]['{DAV:}getcontentlength'])?(int) $file[200]['{DAV:}getcontentlength']:''; + $size = isset($file[200]['{DAV:}getcontentlength'])?(int)$file[200]['{DAV:}getcontentlength']:''; $lastmodified = isset($file[200]['{DAV:}getlastmodified'])?$file[200]['{DAV:}getlastmodified']->getTime()->format(\DateTime::ATOM):''; $fullPath = DAV\URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path?$path . '/':'') . $name,'/')); @@ -341,7 +341,7 @@ public function generateDirectoryIndex($path) if ($this->enableAssets) { $node = $this->server->tree->getNodeForPath(($path?$path.'/':'') . $name); - foreach (array_reverse($this->iconMap) as $class=>$iconName) { + foreach(array_reverse($this->iconMap) as $class=>$iconName) { if ($node instanceof $class) { $icon = ''; @@ -374,7 +374,7 @@ public function generateDirectoryIndex($path) $html.=$output; $html.= " -
Generated by SabreDAV " . $version . " (c)2007-2013 http://code.google.com/p/sabredav/
+
Generated by SabreDAV " . $version . " (c)2007-2014 http://sabre.io/
"; @@ -393,8 +393,8 @@ public function generateDirectoryIndex($path) * @param mixed $output * @return void */ - public function htmlActionsPanel(DAV\INode $node, &$output) - { + public function htmlActionsPanel(DAV\INode $node, &$output) { + if (!$node instanceof DAV\ICollection) return; @@ -427,8 +427,8 @@ public function htmlActionsPanel(DAV\INode $node, &$output) * @param string $assetName * @return string */ - protected function getAssetUrl($assetName) - { + protected function getAssetUrl($assetName) { + return $this->server->getBaseUri() . '?sabreAction=asset&assetName=' . urlencode($assetName); } @@ -439,8 +439,8 @@ protected function getAssetUrl($assetName) * @param string $assetName * @return string */ - protected function getLocalAssetPath($assetName) - { + protected function getLocalAssetPath($assetName) { + $assetDir = __DIR__ . '/assets/'; $path = $assetDir . $assetName; @@ -457,14 +457,14 @@ protected function getLocalAssetPath($assetName) * @param string $assetName * @return void */ - protected function serveAsset($assetName) - { + protected function serveAsset($assetName) { + $assetPath = $this->getLocalAssetPath($assetName); if (!file_exists($assetPath)) { throw new DAV\Exception\NotFound('Could not find an asset with this name'); } // Rudimentary mime type detection - switch (strtolower(substr($assetPath,strpos($assetPath,'.')+1))) { + switch(strtolower(substr($assetPath,strpos($assetPath,'.')+1))) { case 'ico' : $mime = 'image/vnd.microsoft.icon'; diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/addressbook.png b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/addressbook.png index bcc3582854..c9acc84172 100644 Binary files a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/addressbook.png and b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/addressbook.png differ diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/calendar.png b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/calendar.png index 2d61f645b7..3ecd6a800a 100644 Binary files a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/calendar.png and b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/calendar.png differ diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/card.png b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/card.png index 2ee655c30f..2ce954866d 100644 Binary files a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/card.png and b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/card.png differ diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/collection.png b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/collection.png index 933a620c8d..156fa64fd5 100644 Binary files a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/collection.png and b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/collection.png differ diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/file.png b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/file.png index ffaa995025..3b98551cec 100644 Binary files a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/file.png and b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/file.png differ diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/parent.png b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/parent.png index 933a620c8d..156fa64fd5 100644 Binary files a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/parent.png and b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/parent.png differ diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/principal.png b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/principal.png index 8a9149bdc1..f8988f828e 100644 Binary files a/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/principal.png and b/core/src/core/classes/sabredav/lib/Sabre/DAV/Browser/assets/icons/principal.png differ diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Client.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Client.php index dcd8ab1dbe..705b321955 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Client.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Client.php @@ -10,12 +10,12 @@ * * NOTE: This class is experimental, it's api will likely change in the future. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Client -{ +class Client { + /** * The propertyMap is a key-value array. * @@ -63,7 +63,7 @@ class Client * * @var boolean */ - private $verifyPeer; + protected $verifyPeer; /** * Constructor @@ -78,8 +78,8 @@ class Client * * @param array $settings */ - public function __construct(array $settings) - { + public function __construct(array $settings) { + if (!isset($settings['baseUri'])) { throw new \InvalidArgumentException('A baseUri must be provided'); } @@ -91,7 +91,7 @@ public function __construct(array $settings) 'proxy', ); - foreach ($validSettings as $validSetting) { + foreach($validSettings as $validSetting) { if (isset($settings[$validSetting])) { $this->$validSetting = $settings[$validSetting]; } @@ -115,8 +115,7 @@ public function __construct(array $settings) * * @param string $certificates */ - public function addTrustedCertificates($certificates) - { + public function addTrustedCertificates($certificates) { $this->trustedCertificates = $certificates; } @@ -125,8 +124,7 @@ public function addTrustedCertificates($certificates) * * @param boolean $value */ - public function setVerifyPeer($value) - { + public function setVerifyPeer($value) { $this->verifyPeer = $value; } @@ -151,13 +149,13 @@ public function setVerifyPeer($value) * @param int $depth * @return array */ - public function propFind($url, array $properties, $depth = 0) - { + public function propFind($url, array $properties, $depth = 0) { + $body = '' . "\n"; $body.= '' . "\n"; $body.= ' ' . "\n"; - foreach ($properties as $property) { + foreach($properties as $property) { list( $namespace, @@ -190,7 +188,7 @@ public function propFind($url, array $properties, $depth = 0) } $newResult = array(); - foreach ($result as $href => $statusList) { + foreach($result as $href => $statusList) { $newResult[$href] = isset($statusList[200])?$statusList[200]:array(); @@ -213,12 +211,12 @@ public function propFind($url, array $properties, $depth = 0) * @param array $properties * @return void */ - public function propPatch($url, array $properties) - { + public function propPatch($url, array $properties) { + $body = '' . "\n"; $body.= '' . "\n"; - foreach ($properties as $propName => $propValue) { + foreach($properties as $propName => $propValue) { list( $namespace, @@ -275,15 +273,15 @@ public function propPatch($url, array $properties) * * @return array */ - public function options() - { + public function options() { + $result = $this->request('OPTIONS'); if (!isset($result['headers']['dav'])) { return array(); } $features = explode(',', $result['headers']['dav']); - foreach ($features as &$v) { + foreach($features as &$v) { $v = trim($v); } return $features; @@ -308,25 +306,29 @@ public function options() * @param array $headers * @return array */ - public function request($method, $url = '', $body = null, $headers = array()) - { + public function request($method, $url = '', $body = null, $headers = array()) { + $url = $this->getAbsoluteUrl($url); $curlSettings = array( CURLOPT_RETURNTRANSFER => true, // Return headers as part of the response CURLOPT_HEADER => true, - CURLOPT_POSTFIELDS => $body, + + // For security we cast this to a string. If somehow an array could + // be passed here, it would be possible for an attacker to use @ to + // post local files. + CURLOPT_POSTFIELDS => (string)$body, // Automatically follow redirects CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, ); - if ($this->verifyPeer !== null) { + if($this->verifyPeer !== null) { $curlSettings[CURLOPT_SSL_VERIFYPEER] = $this->verifyPeer; } - if ($this->trustedCertificates) { + if($this->trustedCertificates) { $curlSettings[CURLOPT_CAINFO] = $this->trustedCertificates; } @@ -350,7 +352,7 @@ public function request($method, $url = '', $body = null, $headers = array()) // Adding HTTP headers $nHeaders = array(); - foreach ($headers as $key=>$value) { + foreach($headers as $key=>$value) { $nHeaders[] = $key . ': ' . $value; @@ -395,7 +397,7 @@ public function request($method, $url = '', $body = null, $headers = array()) $headerBlob = explode("\r\n", $headerBlob); $headers = array(); - foreach ($headerBlob as $header) { + foreach($headerBlob as $header) { $parts = explode(':', $header, 2); if (count($parts)==2) { $headers[strtolower(trim($parts[0]))] = trim($parts[1]); @@ -458,8 +460,8 @@ public function request($method, $url = '', $body = null, $headers = array()) * @return array */ // @codeCoverageIgnoreStart - protected function curlRequest($url, $settings) - { + protected function curlRequest($url, $settings) { + $curl = curl_init($url); curl_setopt_array($curl, $settings); @@ -480,8 +482,8 @@ protected function curlRequest($url, $settings) * @param string $url * @return string */ - protected function getAbsoluteUrl($url) - { + protected function getAbsoluteUrl($url) { + // If the url starts with http:// or https://, the url is already absolute. if (preg_match('/^http(s?):\/\//', $url)) { return $url; @@ -524,11 +526,16 @@ protected function getAbsoluteUrl($url) * @param string $body xml body * @return array */ - public function parseMultiStatus($body) - { + public function parseMultiStatus($body) { + $body = XMLUtil::convertDAVNamespace($body); + // Fixes an XXE vulnerability on PHP versions older than 5.3.23 or + // 5.4.13. + $previous = libxml_disable_entity_loader(true); $responseXML = simplexml_load_string($body, null, LIBXML_NOBLANKS | LIBXML_NOCDATA); + libxml_disable_entity_loader($previous); + if ($responseXML===false) { throw new \InvalidArgumentException('The passed data is not valid XML'); } @@ -537,20 +544,23 @@ public function parseMultiStatus($body) $propResult = array(); - foreach ($responseXML->xpath('d:response') as $response) { + foreach($responseXML->xpath('d:response') as $response) { $response->registerXPathNamespace('d', 'urn:DAV'); $href = $response->xpath('d:href'); - $href = (string) $href[0]; + $href = (string)$href[0]; $properties = array(); - foreach ($response->xpath('d:propstat') as $propStat) { + foreach($response->xpath('d:propstat') as $propStat) { $propStat->registerXPathNamespace('d', 'urn:DAV'); $status = $propStat->xpath('d:status'); - list($httpVersion, $statusCode, $message) = explode(' ', (string) $status[0],3); + list($httpVersion, $statusCode, $message) = explode(' ', (string)$status[0],3); + + // Only using the propertymap for results with status 200. + $propertyMap = $statusCode==='200' ? $this->propertyMap : array(); - $properties[$statusCode] = XMLUtil::parseProperties(dom_import_simplexml($propStat), $this->propertyMap); + $properties[$statusCode] = XMLUtil::parseProperties(dom_import_simplexml($propStat), $propertyMap); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Collection.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Collection.php index 1388b4cffa..0090a4d6ed 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Collection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Collection.php @@ -8,12 +8,12 @@ * This is a helper class, that should aid in getting collections classes setup. * Most of its methods are implemented, and throw permission denied exceptions * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class Collection extends Node implements ICollection -{ +abstract class Collection extends Node implements ICollection { + /** * Returns a child object, by its name. * @@ -28,9 +28,9 @@ abstract class Collection extends Node implements ICollection * @throws Exception\NotFound * @return INode */ - public function getChild($name) - { - foreach ($this->getChildren() as $child) { + public function getChild($name) { + + foreach($this->getChildren() as $child) { if ($child->getName()==$name) return $child; @@ -47,14 +47,14 @@ public function getChild($name) * @param string $name * @return bool */ - public function childExists($name) - { + public function childExists($name) { + try { $this->getChild($name); return true; - } catch (Exception\NotFound $e) { + } catch(Exception\NotFound $e) { return false; @@ -86,8 +86,8 @@ public function childExists($name) * @param resource|string $data Initial payload * @return null|string */ - public function createFile($name, $data = null) - { + public function createFile($name, $data = null) { + throw new Exception\Forbidden('Permission denied to create file (filename ' . $name . ')'); } @@ -99,11 +99,12 @@ public function createFile($name, $data = null) * @throws Exception\Forbidden * @return void */ - public function createDirectory($name) - { + public function createDirectory($name) { + throw new Exception\Forbidden('Permission denied to create directory'); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception.php index fcdb1c077a..22a319e9f7 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception.php @@ -5,9 +5,9 @@ * * This is SabreDAV's base exception file, use this to implement your own exception. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ namespace Sabre\DAV; @@ -21,15 +21,15 @@ * This class also allows you to generate custom xml data for your exceptions. This will be displayed * in the 'error' element in the failing response. */ -class Exception extends \Exception -{ +class Exception extends \Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 500; } @@ -41,8 +41,9 @@ public function getHTTPCode() * @param \DOMElement $errorNode * @return void */ - public function serialize(Server $server,\DOMElement $errorNode) - { + public function serialize(Server $server,\DOMElement $errorNode) { + + } /** @@ -53,10 +54,11 @@ public function serialize(Server $server,\DOMElement $errorNode) * @param Server $server * @return array */ - public function getHTTPHeaders(Server $server) - { + public function getHTTPHeaders(Server $server) { + return array(); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/BadRequest.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/BadRequest.php index 7c2d14e666..d59727e3a2 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/BadRequest.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/BadRequest.php @@ -8,19 +8,19 @@ * The BadRequest is thrown when the user submitted an invalid HTTP request * BadRequest * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class BadRequest extends \Sabre\DAV\Exception -{ +class BadRequest extends \Sabre\DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 400; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Conflict.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Conflict.php index 00cf016743..cbb8fcf1ac 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Conflict.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Conflict.php @@ -8,19 +8,19 @@ * A 409 Conflict is thrown when a user tried to make a directory over an existing * file or in a parent directory that doesn't exist. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Conflict extends \Sabre\DAV\Exception -{ +class Conflict extends \Sabre\DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 409; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ConflictingLock.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ConflictingLock.php index bede6e1c01..715870f465 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ConflictingLock.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ConflictingLock.php @@ -10,12 +10,12 @@ * Similar to the Locked exception, this exception thrown when a LOCK request * was made, on a resource which was already locked * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ConflictingLock extends Locked -{ +class ConflictingLock extends Locked { + /** * This method allows the exception to include additional information into the WebDAV error response * @@ -23,8 +23,8 @@ class ConflictingLock extends Locked * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server, \DOMElement $errorNode) - { + public function serialize(DAV\Server $server, \DOMElement $errorNode) { + if ($this->lock) { $error = $errorNode->ownerDocument->createElementNS('DAV:','d:no-conflicting-lock'); $errorNode->appendChild($error); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/FileNotFound.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/FileNotFound.php index db1cc43542..aa4844cb9b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/FileNotFound.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/FileNotFound.php @@ -8,11 +8,12 @@ * Deprecated: Warning, this class is deprecated and will be removed in a * future version of SabreDAV. Please use Sabre\DAV\Exception\NotFound instead. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) * @deprecated Use Sabre\DAV\Exception\NotFound instead - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ -class FileNotFound extends NotFound -{ +class FileNotFound extends NotFound { + } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Forbidden.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Forbidden.php index b5f8b6b3ae..2dc620612d 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Forbidden.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Forbidden.php @@ -7,19 +7,19 @@ * * This exception is thrown whenever a user tries to do an operation he's not allowed to * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Forbidden extends \Sabre\DAV\Exception -{ +class Forbidden extends \Sabre\DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 403; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/InsufficientStorage.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/InsufficientStorage.php index 84b791f17b..f7e382c5a7 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/InsufficientStorage.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/InsufficientStorage.php @@ -7,19 +7,19 @@ * * This Exception can be thrown, when for example a harddisk is full or a quota is exceeded * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class InsufficientStorage extends \Sabre\DAV\Exception -{ +class InsufficientStorage extends \Sabre\DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 507; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/InvalidResourceType.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/InvalidResourceType.php index ec09a3ed6c..847ed47861 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/InvalidResourceType.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/InvalidResourceType.php @@ -10,12 +10,12 @@ * * See RFC5689 section 3.3 * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class InvalidResourceType extends Forbidden -{ +class InvalidResourceType extends Forbidden { + /** * This method allows the exception to include additional information into the WebDAV error response * @@ -23,8 +23,8 @@ class InvalidResourceType extends Forbidden * @param \DOMElement $errorNode * @return void */ - public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) { + $error = $errorNode->ownerDocument->createElementNS('DAV:','d:valid-resourcetype'); $errorNode->appendChild($error); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/LengthRequired.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/LengthRequired.php new file mode 100644 index 0000000000..9487686dc4 --- /dev/null +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/LengthRequired.php @@ -0,0 +1,30 @@ +message = 'The locktoken supplied does not match any locks on this entity'; } @@ -31,8 +31,8 @@ public function __construct() * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + $error = $errorNode->ownerDocument->createElementNS('DAV:','d:lock-token-matches-request-uri'); $errorNode->appendChild($error); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Locked.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Locked.php index 2d68690933..2bee1b02f1 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Locked.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/Locked.php @@ -9,12 +9,12 @@ * * The 423 is thrown when a client tried to access a resource that was locked, without supplying a valid lock token * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Locked extends DAV\Exception -{ +class Locked extends DAV\Exception { + /** * Lock information * @@ -30,8 +30,8 @@ class Locked extends DAV\Exception * * @param DAV\Locks\LockInfo $lock */ - public function __construct(DAV\Locks\LockInfo $lock = null) - { + public function __construct(DAV\Locks\LockInfo $lock = null) { + $this->lock = $lock; } @@ -41,8 +41,8 @@ public function __construct(DAV\Locks\LockInfo $lock = null) * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 423; } @@ -54,15 +54,20 @@ public function getHTTPCode() * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + if ($this->lock) { $error = $errorNode->ownerDocument->createElementNS('DAV:','d:lock-token-submitted'); $errorNode->appendChild($error); - if (!is_object($this->lock)) var_dump($this->lock); - $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:','d:href',$this->lock->uri)); + + $href = $errorNode->ownerDocument->createElementNS('DAV:','d:href'); + $href->appendChild($errorNode->ownerDocument->createTextNode($this->lock->uri)); + $error->appendChild( + $href + ); } } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/MethodNotAllowed.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/MethodNotAllowed.php index 337627064d..05970cfa85 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/MethodNotAllowed.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/MethodNotAllowed.php @@ -7,19 +7,19 @@ * * The 405 is thrown when a client tried to create a directory on an already existing directory * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class MethodNotAllowed extends \Sabre\DAV\Exception -{ +class MethodNotAllowed extends \Sabre\DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 405; } @@ -32,8 +32,8 @@ public function getHTTPCode() * @param \Sabre\DAV\Server $server * @return array */ - public function getHTTPHeaders(\Sabre\DAV\Server $server) - { + public function getHTTPHeaders(\Sabre\DAV\Server $server) { + $methods = $server->getAllowedMethods($server->getRequestUri()); return array( diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotAuthenticated.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotAuthenticated.php index ca7e7fbb57..c082d489bb 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotAuthenticated.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotAuthenticated.php @@ -10,19 +10,19 @@ * This exception is thrown when the client did not provide valid * authentication credentials. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class NotAuthenticated extends DAV\Exception -{ +class NotAuthenticated extends DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 401; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotFound.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotFound.php index 173658a152..83e699cb2b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotFound.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotFound.php @@ -7,21 +7,22 @@ * * This Exception is thrown when a Node couldn't be found. It returns HTTP error code 404 * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class NotFound extends \Sabre\DAV\Exception -{ +class NotFound extends \Sabre\DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 404; } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotImplemented.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotImplemented.php index a6625fbaad..5f031cb7f4 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotImplemented.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/NotImplemented.php @@ -7,19 +7,19 @@ * * This exception is thrown when the client tried to call an unsupported HTTP method or other feature * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class NotImplemented extends \Sabre\DAV\Exception -{ +class NotImplemented extends \Sabre\DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 501; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/PaymentRequired.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/PaymentRequired.php index e4acfe31aa..3c256a0649 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/PaymentRequired.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/PaymentRequired.php @@ -10,19 +10,19 @@ * The PaymentRequired exception may be thrown in a case where a user must pay * to access a certain resource or operation. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class PaymentRequired extends DAV\Exception -{ +class PaymentRequired extends DAV\Exception { + /** * Returns the HTTP statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 402; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/PreconditionFailed.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/PreconditionFailed.php index 25889b9c54..deb8a5bea5 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/PreconditionFailed.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/PreconditionFailed.php @@ -11,12 +11,12 @@ * like for example an If, If-None-Match or If-Match header, which caused the HTTP * request to not execute (the condition of the header failed) * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class PreconditionFailed extends DAV\Exception -{ +class PreconditionFailed extends DAV\Exception { + /** * When this exception is thrown, the header-name might be set. * @@ -33,8 +33,8 @@ class PreconditionFailed extends DAV\Exception * @param string $message * @param string $header */ - public function __construct($message, $header=null) - { + public function __construct($message, $header=null) { + parent::__construct($message); $this->header = $header; @@ -45,8 +45,8 @@ public function __construct($message, $header=null) * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 412; } @@ -58,8 +58,8 @@ public function getHTTPCode() * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + if ($this->header) { $prop = $errorNode->ownerDocument->createElement('s:header'); $prop->nodeValue = $this->header; diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ReportNotSupported.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ReportNotSupported.php index fe3aa843e7..8e32096e0f 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ReportNotSupported.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ReportNotSupported.php @@ -9,12 +9,12 @@ * * This exception is thrown when the client requested an unknown report through the REPORT method * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ReportNotSupported extends Forbidden -{ +class ReportNotSupported extends Forbidden { + /** * This method allows the exception to include additional information into the WebDAV error response * @@ -22,8 +22,8 @@ class ReportNotSupported extends Forbidden * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + $error = $errorNode->ownerDocument->createElementNS('DAV:','d:supported-report'); $errorNode->appendChild($error); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php index 4aecdae553..25002be6ae 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php @@ -10,21 +10,22 @@ * This exception is normally thrown when the user * request a range that is out of the entity bounds. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class RequestedRangeNotSatisfiable extends DAV\Exception -{ +class RequestedRangeNotSatisfiable extends DAV\Exception { + /** * returns the http statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 416; } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ServiceUnavailable.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ServiceUnavailable.php index a1e3ccd29e..59e433954b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ServiceUnavailable.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/ServiceUnavailable.php @@ -11,20 +11,20 @@ * is currently not available (e.g. down for maintenance). * * @author Thomas Müller - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @license http://sabre.io/license/ Modified BSD License */ -class ServiceUnavailable extends DAV\Exception -{ - /** - * Returns the HTTP statuscode for this exception - * - * @return int - */ - public function getHTTPCode() - { - return 503; +class ServiceUnavailable extends DAV\Exception { - } + /** + * Returns the HTTP statuscode for this exception + * + * @return int + */ + public function getHTTPCode() { + + return 503; + + } } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/UnsupportedMediaType.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/UnsupportedMediaType.php index 07dbb9d847..46eea60df6 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/UnsupportedMediaType.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Exception/UnsupportedMediaType.php @@ -8,19 +8,19 @@ * The 415 Unsupported Media Type status code is generally sent back when the client * tried to call an HTTP method, with a body the server didn't understand * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class UnsupportedMediaType extends \Sabre\DAV\Exception -{ +class UnsupportedMediaType extends \Sabre\DAV\Exception { + /** * returns the http statuscode for this exception * * @return int */ - public function getHTTPCode() - { + public function getHTTPCode() { + return 415; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/Directory.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/Directory.php index e55ebc44d5..6fdd2aecf0 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/Directory.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/Directory.php @@ -6,12 +6,12 @@ /** * Directory class * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Directory extends Node implements DAV\ICollection, DAV\IQuota -{ +class Directory extends Node implements DAV\ICollection, DAV\IQuota { + /** * Creates a new file in the directory * @@ -36,8 +36,8 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota * @param resource|string $data Initial payload * @return null|string */ - public function createFile($name, $data = null) - { + public function createFile($name, $data = null) { + $newPath = $this->path . '/' . $name; file_put_contents($newPath,$data); @@ -49,8 +49,8 @@ public function createFile($name, $data = null) * @param string $name * @return void */ - public function createDirectory($name) - { + public function createDirectory($name) { + $newPath = $this->path . '/' . $name; mkdir($newPath); @@ -66,8 +66,8 @@ public function createDirectory($name) * @throws DAV\Exception\NotFound * @return DAV\INode */ - public function getChild($name) - { + public function getChild($name) { + $path = $this->path . '/' . $name; if (!file_exists($path)) throw new DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); @@ -89,8 +89,8 @@ public function getChild($name) * * @return DAV\INode[] */ - public function getChildren() - { + public function getChildren() { + $nodes = array(); foreach(scandir($this->path) as $node) if($node!='.' && $node!='..') $nodes[] = $this->getChild($node); return $nodes; @@ -103,8 +103,8 @@ public function getChildren() * @param string $name * @return bool */ - public function childExists($name) - { + public function childExists($name) { + $path = $this->path . '/' . $name; return file_exists($path); @@ -115,8 +115,8 @@ public function childExists($name) * * @return void */ - public function delete() - { + public function delete() { + foreach($this->getChildren() as $child) $child->delete(); rmdir($this->path); @@ -127,8 +127,8 @@ public function delete() * * @return array */ - public function getQuotaInfo() - { + public function getQuotaInfo() { + return array( disk_total_space($this->path)-disk_free_space($this->path), disk_free_space($this->path) @@ -137,3 +137,4 @@ public function getQuotaInfo() } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/File.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/File.php index 600100e0da..d10370fae0 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/File.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/File.php @@ -7,20 +7,20 @@ /** * File class * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class File extends Node implements DAV\IFile -{ +class File extends Node implements DAV\IFile { + /** * Updates the data * * @param resource $data * @return void */ - public function put($data) - { + public function put($data) { + file_put_contents($this->path,$data); } @@ -30,8 +30,8 @@ public function put($data) * * @return string */ - public function get() - { + public function get() { + return fopen($this->path,'r'); } @@ -41,8 +41,8 @@ public function get() * * @return void */ - public function delete() - { + public function delete() { + unlink($this->path); } @@ -52,8 +52,8 @@ public function delete() * * @return int */ - public function getSize() - { + public function getSize() { + return filesize($this->path); } @@ -68,8 +68,8 @@ public function getSize() * * @return mixed */ - public function getETag() - { + public function getETag() { + return null; } @@ -81,10 +81,11 @@ public function getETag() * * @return mixed */ - public function getContentType() - { + public function getContentType() { + return null; } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/Node.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/Node.php index 4a1dc0e4f9..605fa3c826 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/Node.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/FS/Node.php @@ -9,12 +9,12 @@ * * The node class implements the method used by both the File and the Directory classes * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements DAV\INode -{ +abstract class Node implements DAV\INode { + /** * The path to the current node * @@ -27,8 +27,8 @@ abstract class Node implements DAV\INode * * @param string $path */ - public function __construct($path) - { + public function __construct($path) { + $this->path = $path; } @@ -40,8 +40,8 @@ public function __construct($path) * * @return string */ - public function getName() - { + public function getName() { + list(, $name) = DAV\URLUtil::splitPath($this->path); return $name; @@ -53,8 +53,8 @@ public function getName() * @param string $name The new name * @return void */ - public function setName($name) - { + public function setName($name) { + list($parentPath, ) = DAV\URLUtil::splitPath($this->path); list(, $newName) = DAV\URLUtil::splitPath($name); @@ -72,10 +72,11 @@ public function setName($name) * * @return int */ - public function getLastModified() - { + public function getLastModified() { + return filemtime($this->path); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/Directory.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/Directory.php index b324be1c66..da3d2cc69b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/Directory.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/Directory.php @@ -7,12 +7,12 @@ /** * Directory class * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Directory extends Node implements DAV\ICollection, DAV\IQuota -{ +class Directory extends Node implements DAV\ICollection, DAV\IQuota { + /** * Creates a new file in the directory * @@ -37,8 +37,8 @@ class Directory extends Node implements DAV\ICollection, DAV\IQuota * @param resource|string $data Initial payload * @return null|string */ - public function createFile($name, $data = null) - { + public function createFile($name, $data = null) { + // We're not allowing dots if ($name=='.' || $name=='..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); $newPath = $this->path . '/' . $name; @@ -54,8 +54,8 @@ public function createFile($name, $data = null) * @param string $name * @return void */ - public function createDirectory($name) - { + public function createDirectory($name) { + // We're not allowing dots if ($name=='.' || $name=='..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); $newPath = $this->path . '/' . $name; @@ -73,8 +73,8 @@ public function createDirectory($name) * @throws DAV\Exception\NotFound * @return DAV\INode */ - public function getChild($name) - { + public function getChild($name) { + $path = $this->path . '/' . $name; if (!file_exists($path)) throw new DAV\Exception\NotFound('File could not be located'); @@ -98,8 +98,8 @@ public function getChild($name) * @param string $name * @return bool */ - public function childExists($name) - { + public function childExists($name) { + if ($name=='.' || $name=='..') throw new DAV\Exception\Forbidden('Permission denied to . and ..'); @@ -113,8 +113,8 @@ public function childExists($name) * * @return DAV\INode[] */ - public function getChildren() - { + public function getChildren() { + $nodes = array(); foreach(scandir($this->path) as $node) if($node!='.' && $node!='..' && $node!='.sabredav') $nodes[] = $this->getChild($node); return $nodes; @@ -126,8 +126,8 @@ public function getChildren() * * @return bool */ - public function delete() - { + public function delete() { + // Deleting all children foreach($this->getChildren() as $child) $child->delete(); @@ -146,8 +146,8 @@ public function delete() * * @return array */ - public function getQuotaInfo() - { + public function getQuotaInfo() { + return array( disk_total_space($this->path)-disk_free_space($this->path), disk_free_space($this->path) @@ -156,3 +156,4 @@ public function getQuotaInfo() } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/File.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/File.php index 548d51f6d3..6588fad7eb 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/File.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/File.php @@ -6,12 +6,12 @@ /** * File class * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class File extends Node implements DAV\PartialUpdate\IFile -{ +class File extends Node implements DAV\PartialUpdate\IPatchSupport { + /** * Updates the data * @@ -20,27 +20,55 @@ class File extends Node implements DAV\PartialUpdate\IFile * @param resource|string $data * @return string */ - public function put($data) - { + public function put($data) { + file_put_contents($this->path,$data); return '"' . md5_file($this->path) . '"'; } /** - * Updates the data at a given offset + * Updates the file based on a range specification. + * + * The first argument is the data, which is either a readable stream + * resource or a string. + * + * The second argument is the type of update we're doing. + * This is either: + * * 1. append + * * 2. update based on a start byte + * * 3. update based on an end byte + *; + * The third argument is the start or end byte. * - * The data argument is a readable stream resource. - * The offset argument is a 0-based offset where the data should be - * written. + * After a successful put operation, you may choose to return an ETag. The + * etag must always be surrounded by double-quotes. These quotes must + * appear in the actual string you're returning. * - * param resource|string $data - * @return void + * Clients may use the ETag from a PUT request to later on make sure that + * when they update the file, the contents haven't changed in the mean + * time. + * + * @param resource|string $data + * @param int $rangeType + * @param int $offset + * @return string|null */ - public function putRange($data, $offset) - { - $f = fopen($this->path, 'c'); - fseek($f,$offset-1); + public function patch($data, $rangeType, $offset = null) { + + switch($rangeType) { + case 1 : + $f = fopen($this->path, 'a'); + break; + case 2 : + $f = fopen($this->path, 'c'); + fseek($f,$offset); + break; + case 3 : + $f = fopen($this->path, 'c'); + fseek($f, $offset, SEEK_END); + break; + } if (is_string($data)) { fwrite($f, $data); } else { @@ -56,8 +84,8 @@ public function putRange($data, $offset) * * @return resource */ - public function get() - { + public function get() { + return fopen($this->path,'r'); } @@ -67,8 +95,8 @@ public function get() * * @return bool */ - public function delete() - { + public function delete() { + unlink($this->path); return parent::delete(); @@ -84,8 +112,8 @@ public function delete() * * @return string|null */ - public function getETag() - { + public function getETag() { + return '"' . md5_file($this->path). '"'; } @@ -97,8 +125,8 @@ public function getETag() * * @return string|null */ - public function getContentType() - { + public function getContentType() { + return null; } @@ -108,10 +136,11 @@ public function getContentType() * * @return int */ - public function getSize() - { + public function getSize() { + return filesize($this->path); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/Node.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/Node.php index e1bfad882e..0e11582f34 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/Node.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/FSExt/Node.php @@ -9,12 +9,12 @@ * * The node class implements the method used by both the File and the Directory classes * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node extends DAV\FS\Node implements DAV\IProperties -{ +abstract class Node extends DAV\FS\Node implements DAV\IProperties { + /** * Updates properties on this node, * @@ -22,11 +22,11 @@ abstract class Node extends DAV\FS\Node implements DAV\IProperties * @see Sabre\DAV\IProperties::updateProperties * @return bool|array */ - public function updateProperties($properties) - { + public function updateProperties($properties) { + $resourceData = $this->getResourceData(); - foreach ($properties as $propertyName=>$propertyValue) { + foreach($properties as $propertyName=>$propertyValue) { // If it was null, we need to delete the property if (is_null($propertyValue)) { @@ -52,15 +52,15 @@ public function updateProperties($properties) * @param array $properties * @return array */ - public function getProperties($properties) - { + function getProperties($properties) { + $resourceData = $this->getResourceData(); // if the array was empty, we need to return everything if (!$properties) return $resourceData['properties']; $props = array(); - foreach ($properties as $property) { + foreach($properties as $property) { if (isset($resourceData['properties'][$property])) $props[$property] = $resourceData['properties'][$property]; } @@ -73,8 +73,8 @@ public function getProperties($properties) * * @return string */ - protected function getResourceInfoPath() - { + protected function getResourceInfoPath() { + list($parentDir) = DAV\URLUtil::splitPath($this->path); return $parentDir . '/.sabredav'; @@ -85,8 +85,8 @@ protected function getResourceInfoPath() * * @return array */ - protected function getResourceData() - { + protected function getResourceData() { + $path = $this->getResourceInfoPath(); if (!file_exists($path)) return array('properties' => array()); @@ -96,7 +96,7 @@ protected function getResourceData() $data = ''; // Reading data until the eof - while (!feof($handle)) { + while(!feof($handle)) { $data.=fread($handle,8192); } @@ -121,8 +121,8 @@ protected function getResourceData() * @param array $newData * @return void */ - protected function putResourceData(array $newData) - { + protected function putResourceData(array $newData) { + $path = $this->getResourceInfoPath(); // opening up the file, and creating a shared lock @@ -133,7 +133,7 @@ protected function putResourceData(array $newData) rewind($handle); // Reading data until the eof - while (!feof($handle)) { + while(!feof($handle)) { $data.=fread($handle,8192); } @@ -154,8 +154,8 @@ protected function putResourceData(array $newData) * @param string $name The new name * @return void */ - public function setName($name) - { + public function setName($name) { + list($parentPath, ) = DAV\URLUtil::splitPath($this->path); list(, $newName) = DAV\URLUtil::splitPath($name); $newPath = $parentPath . '/' . $newName; @@ -175,8 +175,8 @@ public function setName($name) /** * @return bool */ - public function deleteResourceData() - { + public function deleteResourceData() { + // When we're deleting this node, we also need to delete any resource information $path = $this->getResourceInfoPath(); if (!file_exists($path)) return true; @@ -189,7 +189,7 @@ public function deleteResourceData() rewind($handle); // Reading data until the eof - while (!feof($handle)) { + while(!feof($handle)) { $data.=fread($handle,8192); } @@ -204,10 +204,11 @@ public function deleteResourceData() return true; } - public function delete() - { + public function delete() { + return $this->deleteResourceData(); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/File.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/File.php index bb04c4aed7..af8ce735fd 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/File.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/File.php @@ -8,12 +8,12 @@ * This is a helper class, that should aid in getting file classes setup. * Most of its methods are implemented, and throw permission denied exceptions * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class File extends Node implements IFile -{ +abstract class File extends Node implements IFile { + /** * Updates the data * @@ -22,8 +22,8 @@ abstract class File extends Node implements IFile * @param resource $data * @return void */ - public function put($data) - { + public function put($data) { + throw new Exception\Forbidden('Permission denied to change data'); } @@ -35,8 +35,8 @@ public function put($data) * * @return mixed */ - public function get() - { + public function get() { + throw new Exception\Forbidden('Permission denied to read this file'); } @@ -46,8 +46,8 @@ public function get() * * @return int */ - public function getSize() - { + public function getSize() { + return 0; } @@ -62,8 +62,8 @@ public function getSize() * * @return string|null */ - public function getETag() - { + public function getETag() { + return null; } @@ -75,10 +75,11 @@ public function getETag() * * @return string|null */ - public function getContentType() - { + public function getContentType() { + return null; } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/ICollection.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/ICollection.php index 1c5d098cde..c38d5e5531 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/ICollection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/ICollection.php @@ -7,12 +7,12 @@ * * This interface should be implemented by each class that represents a collection * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface ICollection extends INode -{ +interface ICollection extends INode { + /** * Creates a new file in the directory * @@ -37,7 +37,7 @@ interface ICollection extends INode * @param resource|string $data Initial payload * @return null|string */ - public function createFile($name, $data = null); + function createFile($name, $data = null); /** * Creates a new subdirectory @@ -45,7 +45,7 @@ public function createFile($name, $data = null); * @param string $name * @return void */ - public function createDirectory($name); + function createDirectory($name); /** * Returns a specific child node, referenced by its name @@ -56,14 +56,14 @@ public function createDirectory($name); * @param string $name * @return DAV\INode */ - public function getChild($name); + function getChild($name); /** * Returns an array with all the child nodes * * @return DAV\INode[] */ - public function getChildren(); + function getChildren(); /** * Checks if a child-node with the specified name exists @@ -71,6 +71,7 @@ public function getChildren(); * @param string $name * @return bool */ - public function childExists($name); + function childExists($name); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/IExtendedCollection.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/IExtendedCollection.php index 9974526bac..8d37484676 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/IExtendedCollection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/IExtendedCollection.php @@ -8,12 +8,12 @@ * This interface can be used to create special-type of collection-resources * as defined by RFC 5689. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IExtendedCollection extends ICollection -{ +interface IExtendedCollection extends ICollection { + /** * Creates a new collection * @@ -22,6 +22,7 @@ interface IExtendedCollection extends ICollection * @param array $properties * @return void */ - public function createExtendedCollection($name, array $resourceType, array $properties); + function createExtendedCollection($name, array $resourceType, array $properties); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/IFile.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/IFile.php index 3a872cb96a..6245d3fad5 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/IFile.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/IFile.php @@ -9,12 +9,12 @@ * this specific node a PUT or GET method may be performed, to either update, * or retrieve the contents of the file. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IFile extends INode -{ +interface IFile extends INode { + /** * Updates the data * @@ -35,7 +35,7 @@ interface IFile extends INode * @param resource $data * @return string|null */ - public function put($data); + function put($data); /** * Returns the data @@ -44,7 +44,7 @@ public function put($data); * * @return mixed */ - public function get(); + function get(); /** * Returns the mime-type for a file @@ -53,7 +53,7 @@ public function get(); * * @return string|null */ - public function getContentType(); + function getContentType(); /** * Returns the ETag for a file @@ -64,13 +64,14 @@ public function getContentType(); * * @return void */ - public function getETag(); + function getETag(); /** * Returns the size of the node, in bytes * * @return int */ - public function getSize(); + function getSize(); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/INode.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/INode.php index ec97cd7de0..e183c84be4 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/INode.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/INode.php @@ -5,18 +5,18 @@ /** * The INode interface is the base interface, and the parent class of both ICollection and IFile * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface INode -{ +interface INode { + /** * Deleted the current node * * @return void */ - public function delete(); + function delete(); /** * Returns the name of the node. @@ -25,7 +25,7 @@ public function delete(); * * @return string */ - public function getName(); + function getName(); /** * Renames the node @@ -33,13 +33,14 @@ public function getName(); * @param string $name The new name * @return void */ - public function setName($name); + function setName($name); /** * Returns the last modification time, as a unix timestamp * * @return int */ - public function getLastModified(); + function getLastModified(); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/IProperties.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/IProperties.php index 01f05c4468..f3601575b5 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/IProperties.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/IProperties.php @@ -7,12 +7,12 @@ * * Implement this interface to support custom WebDAV properties requested and sent from clients. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IProperties extends INode -{ +interface IProperties extends INode { + /** * Updates properties on this node, * @@ -48,7 +48,7 @@ interface IProperties extends INode * @param array $mutations * @return bool|array */ - public function updateProperties($mutations); + function updateProperties($mutations); /** * Returns a list of properties for this nodes. @@ -65,6 +65,7 @@ public function updateProperties($mutations); * @param array $properties * @return void */ - public function getProperties($properties); + function getProperties($properties); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/IQuota.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/IQuota.php index 5395a31885..988df3d062 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/IQuota.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/IQuota.php @@ -9,18 +9,19 @@ * will check for quota information on any given node. If the information is not available it will * attempt to fetch the information from the root node. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IQuota extends ICollection -{ +interface IQuota extends ICollection { + /** * Returns the quota information * * This method MUST return an array with 2 values, the first being the total used space, * the second the available space (in bytes) */ - public function getQuotaInfo(); + function getQuotaInfo(); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/AbstractBackend.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/AbstractBackend.php index b7c53c13b9..b2c7b983ad 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/AbstractBackend.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/AbstractBackend.php @@ -11,10 +11,11 @@ * to ensure that if default code is required in the backend, there will be a * non-bc-breaking way to do so. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface -{ +abstract class AbstractBackend implements BackendInterface { + } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/BackendInterface.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/BackendInterface.php index 7d5abf6a02..bae666b2f7 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/BackendInterface.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/BackendInterface.php @@ -8,12 +8,12 @@ * If you are defining your own Locks backend, you must implement this * interface. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface -{ +interface BackendInterface { + /** * Returns a list of Sabre\DAV\Locks\LockInfo objects * @@ -48,3 +48,4 @@ public function lock($uri,Locks\LockInfo $lockInfo); public function unlock($uri,Locks\LockInfo $lockInfo); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/FS.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/FS.php index f356acbdb3..a9b0aaaaf6 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/FS.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/FS.php @@ -17,12 +17,12 @@ * You are recommended to use either the PDO or the File backend instead. * * @deprecated - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class FS extends AbstractBackend -{ +class FS extends AbstractBackend { + /** * The default data directory * @@ -30,14 +30,14 @@ class FS extends AbstractBackend */ private $dataDir; - public function __construct($dataDir) - { + public function __construct($dataDir) { + $this->dataDir = $dataDir; } - protected function getFileNameForUri($uri) - { + protected function getFileNameForUri($uri) { + return $this->dataDir . '/sabredav_' . md5($uri) . '.locks'; } @@ -56,12 +56,12 @@ protected function getFileNameForUri($uri) * @param bool $returnChildLocks * @return array */ - public function getLocks($uri, $returnChildLocks) - { + public function getLocks($uri, $returnChildLocks) { + $lockList = array(); $currentPath = ''; - foreach (explode('/',$uri) as $uriPart) { + foreach(explode('/',$uri) as $uriPart) { // weird algorithm that can probably be improved, but we're traversing the path top down if ($currentPath) $currentPath.='/'; @@ -69,10 +69,10 @@ public function getLocks($uri, $returnChildLocks) $uriLocks = $this->getData($currentPath); - foreach ($uriLocks as $uriLock) { + foreach($uriLocks as $uriLock) { // Unless we're on the leaf of the uri-tree we should ignore locks with depth 0 - if ($uri==$currentPath || $uriLock->depth!=0) { + if($uri==$currentPath || $uriLock->depth!=0) { $uriLock->uri = $currentPath; $lockList[] = $uriLock; } @@ -82,7 +82,7 @@ public function getLocks($uri, $returnChildLocks) } // Checking if we can remove any of these locks - foreach ($lockList as $k=>$lock) { + foreach($lockList as $k=>$lock) { if (time() > $lock->timeout + $lock->created) unset($lockList[$k]); } return $lockList; @@ -96,14 +96,14 @@ public function getLocks($uri, $returnChildLocks) * @param LockInfo $lockInfo * @return bool */ - public function lock($uri, LockInfo $lockInfo) - { + public function lock($uri, LockInfo $lockInfo) { + // We're making the lock timeout 30 minutes $lockInfo->timeout = 1800; $lockInfo->created = time(); $locks = $this->getLocks($uri,false); - foreach ($locks as $k=>$lock) { + foreach($locks as $k=>$lock) { if ($lock->token == $lockInfo->token) unset($locks[$k]); } $locks[] = $lockInfo; @@ -119,10 +119,10 @@ public function lock($uri, LockInfo $lockInfo) * @param LockInfo $lockInfo * @return bool */ - public function unlock($uri, LockInfo $lockInfo) - { + public function unlock($uri, LockInfo $lockInfo) { + $locks = $this->getLocks($uri,false); - foreach ($locks as $k=>$lock) { + foreach($locks as $k=>$lock) { if ($lock->token == $lockInfo->token) { @@ -142,8 +142,8 @@ public function unlock($uri, LockInfo $lockInfo) * @param string $uri * @return array */ - protected function getData($uri) - { + protected function getData($uri) { + $path = $this->getFilenameForUri($uri); if (!file_exists($path)) return array(); @@ -153,7 +153,7 @@ protected function getData($uri) $data = ''; // Reading data until the eof - while (!feof($handle)) { + while(!feof($handle)) { $data.=fread($handle,8192); } @@ -174,8 +174,8 @@ protected function getData($uri) * @param array $newData * @return void */ - protected function putData($uri,array $newData) - { + protected function putData($uri,array $newData) { + $path = $this->getFileNameForUri($uri); // opening up the file, and creating a shared lock @@ -190,3 +190,4 @@ protected function putData($uri,array $newData) } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/File.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/File.php index eb59c6e19a..9ac7e06b29 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/File.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/File.php @@ -12,12 +12,12 @@ * Note that this is not nearly as robust as a database, you are encouraged * to use the PDO backend instead. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class File extends AbstractBackend -{ +class File extends AbstractBackend { + /** * The storage file * @@ -30,8 +30,8 @@ class File extends AbstractBackend * * @param string $locksFile path to file */ - public function __construct($locksFile) - { + public function __construct($locksFile) { + $this->locksFile = $locksFile; } @@ -49,13 +49,13 @@ public function __construct($locksFile) * @param bool $returnChildLocks * @return array */ - public function getLocks($uri, $returnChildLocks) - { + public function getLocks($uri, $returnChildLocks) { + $newLocks = array(); $locks = $this->getData(); - foreach ($locks as $lock) { + foreach($locks as $lock) { if ($lock->uri === $uri || //deep locks on parents @@ -71,7 +71,7 @@ public function getLocks($uri, $returnChildLocks) } // Checking if we can remove any of these locks - foreach ($newLocks as $k=>$lock) { + foreach($newLocks as $k=>$lock) { if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]); } return $newLocks; @@ -85,8 +85,8 @@ public function getLocks($uri, $returnChildLocks) * @param LockInfo $lockInfo * @return bool */ - public function lock($uri, LockInfo $lockInfo) - { + public function lock($uri, LockInfo $lockInfo) { + // We're making the lock timeout 30 minutes $lockInfo->timeout = 1800; $lockInfo->created = time(); @@ -94,7 +94,7 @@ public function lock($uri, LockInfo $lockInfo) $locks = $this->getData(); - foreach ($locks as $k=>$lock) { + foreach($locks as $k=>$lock) { if ( ($lock->token == $lockInfo->token) || (time() > $lock->timeout + $lock->created) @@ -115,10 +115,10 @@ public function lock($uri, LockInfo $lockInfo) * @param LockInfo $lockInfo * @return bool */ - public function unlock($uri, LockInfo $lockInfo) - { + public function unlock($uri, LockInfo $lockInfo) { + $locks = $this->getData(); - foreach ($locks as $k=>$lock) { + foreach($locks as $k=>$lock) { if ($lock->token == $lockInfo->token) { @@ -137,8 +137,8 @@ public function unlock($uri, LockInfo $lockInfo) * * @return array */ - protected function getData() - { + protected function getData() { + if (!file_exists($this->locksFile)) return array(); // opening up the file, and creating a shared lock @@ -164,8 +164,8 @@ protected function getData() * @param array $newData * @return void */ - protected function putData(array $newData) - { + protected function putData(array $newData) { + // opening up the file, and creating an exclusive lock $handle = fopen($this->locksFile,'a+'); flock($handle,LOCK_EX); @@ -180,3 +180,4 @@ protected function putData(array $newData) } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/PDO.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/PDO.php index e649abaf6a..ebaeef860c 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/PDO.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Backend/PDO.php @@ -10,12 +10,12 @@ * This Lock Manager stores all its data in a database. You must pass a PDO * connection object in the constructor. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend -{ +class PDO extends AbstractBackend { + /** * The PDO connection object * @@ -36,8 +36,8 @@ class PDO extends AbstractBackend * @param PDO $pdo * @param string $tableName */ - public function __construct(\PDO $pdo, $tableName = 'locks') - { + public function __construct(\PDO $pdo, $tableName = 'locks') { + $this->pdo = $pdo; $this->tableName = $tableName; @@ -56,8 +56,8 @@ public function __construct(\PDO $pdo, $tableName = 'locks') * @param bool $returnChildLocks * @return array */ - public function getLocks($uri, $returnChildLocks) - { + public function getLocks($uri, $returnChildLocks) { + // NOTE: the following 10 lines or so could be easily replaced by // pure sql. MySQL's non-standard string concatenation prevents us // from doing this though. @@ -72,7 +72,7 @@ public function getLocks($uri, $returnChildLocks) $currentPath=''; - foreach ($uriParts as $part) { + foreach($uriParts as $part) { if ($currentPath) $currentPath.='/'; $currentPath.=$part; @@ -95,7 +95,7 @@ public function getLocks($uri, $returnChildLocks) $result = $stmt->fetchAll(); $lockList = array(); - foreach ($result as $row) { + foreach($result as $row) { $lockInfo = new LockInfo(); $lockInfo->owner = $row['owner']; @@ -120,8 +120,8 @@ public function getLocks($uri, $returnChildLocks) * @param LockInfo $lockInfo * @return bool */ - public function lock($uri, LockInfo $lockInfo) - { + public function lock($uri, LockInfo $lockInfo) { + // We're making the lock timeout 30 minutes $lockInfo->timeout = 30*60; $lockInfo->created = time(); @@ -129,7 +129,7 @@ public function lock($uri, LockInfo $lockInfo) $locks = $this->getLocks($uri,false); $exists = false; - foreach ($locks as $lock) { + foreach($locks as $lock) { if ($lock->token == $lockInfo->token) $exists = true; } @@ -154,8 +154,8 @@ public function lock($uri, LockInfo $lockInfo) * @param LockInfo $lockInfo * @return bool */ - public function unlock($uri, LockInfo $lockInfo) - { + public function unlock($uri, LockInfo $lockInfo) { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE uri = ? AND token = ?'); $stmt->execute(array($uri,$lockInfo->token)); @@ -164,3 +164,4 @@ public function unlock($uri, LockInfo $lockInfo) } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/LockInfo.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/LockInfo.php index bc136d49ec..74bdb0f9c7 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/LockInfo.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/LockInfo.php @@ -8,12 +8,12 @@ * An object of the LockInfo class holds all the information relevant to a * single lock. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class LockInfo -{ +class LockInfo { + /** * A shared lock */ @@ -78,3 +78,4 @@ class LockInfo public $uri; } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Plugin.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Plugin.php index 9459431225..001f8175df 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Plugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Locks/Plugin.php @@ -14,12 +14,12 @@ * $lockPlugin = new Sabre\DAV\Locks\Plugin($lockBackend); * $server->addPlugin($lockPlugin); * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin -{ +class Plugin extends DAV\ServerPlugin { + /** * locksBackend * @@ -39,8 +39,8 @@ class Plugin extends DAV\ServerPlugin * * @param Backend\BackendInterface $locksBackend */ - public function __construct(Backend\BackendInterface $locksBackend = null) - { + public function __construct(Backend\BackendInterface $locksBackend = null) { + $this->locksBackend = $locksBackend; } @@ -53,8 +53,8 @@ public function __construct(Backend\BackendInterface $locksBackend = null) * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $server->subscribeEvent('unknownMethod',array($this,'unknownMethod')); $server->subscribeEvent('beforeMethod',array($this,'beforeMethod'),50); @@ -70,8 +70,8 @@ public function initialize(DAV\Server $server) * * @return string */ - public function getPluginName() - { + public function getPluginName() { + return 'locks'; } @@ -86,9 +86,9 @@ public function getPluginName() * @param string $uri * @return bool */ - public function unknownMethod($method, $uri) - { - switch ($method) { + public function unknownMethod($method, $uri) { + + switch($method) { case 'LOCK' : $this->httpLock($uri); return false; case 'UNLOCK' : $this->httpUnlock($uri); return false; @@ -105,11 +105,11 @@ public function unknownMethod($method, $uri) * @param array $newProperties * @return bool */ - public function afterGetProperties($path, &$newProperties) - { - foreach ($newProperties[404] as $propName=>$discard) { + public function afterGetProperties($path, &$newProperties) { + + foreach($newProperties[404] as $propName=>$discard) { - switch ($propName) { + switch($propName) { case '{DAV:}supportedlock' : $val = false; @@ -142,9 +142,9 @@ public function afterGetProperties($path, &$newProperties) * @param string $uri * @return bool */ - public function beforeMethod($method, $uri) - { - switch ($method) { + public function beforeMethod($method, $uri) { + + switch($method) { case 'DELETE' : $lastLock = null; @@ -190,8 +190,8 @@ public function beforeMethod($method, $uri) * @param string $uri * @return array */ - public function getHTTPMethods($uri) - { + public function getHTTPMethods($uri) { + if ($this->locksBackend) return array('LOCK','UNLOCK'); @@ -207,8 +207,8 @@ public function getHTTPMethods($uri) * * @return array */ - public function getFeatures() - { + public function getFeatures() { + return array(2); } @@ -226,8 +226,8 @@ public function getFeatures() * @param bool $returnChildLocks * @return array */ - public function getLocks($uri, $returnChildLocks = false) - { + public function getLocks($uri, $returnChildLocks = false) { + $lockList = array(); if ($this->locksBackend) @@ -251,8 +251,8 @@ public function getLocks($uri, $returnChildLocks = false) * @param string $uri * @return void */ - protected function httpLock($uri) - { + protected function httpLock($uri) { + $lastLock = null; if (!$this->validateLock($uri,$lastLock)) { @@ -326,8 +326,8 @@ protected function httpLock($uri) * @param string $uri * @return void */ - protected function httpUnlock($uri) - { + protected function httpUnlock($uri) { + $lockToken = $this->server->httpRequest->getHeader('Lock-Token'); // If the locktoken header is not supplied, we need to throw a bad request exception @@ -339,7 +339,7 @@ protected function httpUnlock($uri) // header if ($lockToken[0]!=='<') $lockToken = '<' . $lockToken . '>'; - foreach ($locks as $lock) { + foreach($locks as $lock) { if ('token . '>' == $lockToken) { @@ -367,8 +367,8 @@ protected function httpUnlock($uri) * @param LockInfo $lockInfo * @return bool */ - public function lockNode($uri,LockInfo $lockInfo) - { + public function lockNode($uri,LockInfo $lockInfo) { + if (!$this->server->broadcastEvent('beforeLock',array($uri,$lockInfo))) return; if ($this->locksBackend) return $this->locksBackend->lock($uri,$lockInfo); @@ -385,8 +385,8 @@ public function lockNode($uri,LockInfo $lockInfo) * @param LockInfo $lockInfo * @return bool */ - public function unlockNode($uri, LockInfo $lockInfo) - { + public function unlockNode($uri, LockInfo $lockInfo) { + if (!$this->server->broadcastEvent('beforeUnlock',array($uri,$lockInfo))) return; if ($this->locksBackend) return $this->locksBackend->unlock($uri,$lockInfo); @@ -400,13 +400,13 @@ public function unlockNode($uri, LockInfo $lockInfo) * * @return int */ - public function getTimeoutHeader() - { + public function getTimeoutHeader() { + $header = $this->server->httpRequest->getHeader('Timeout'); if ($header) { - if (stripos($header,'second-')===0) $header = (int) (substr($header,7)); + if (stripos($header,'second-')===0) $header = (int)(substr($header,7)); else if (strtolower($header)=='infinite') $header = LockInfo::TIMEOUT_INFINITE; else throw new DAV\Exception\BadRequest('Invalid HTTP timeout header'); @@ -426,8 +426,8 @@ public function getTimeoutHeader() * @param LockInfo $lockInfo * @return string */ - protected function generateLockResponse(LockInfo $lockInfo) - { + protected function generateLockResponse(LockInfo $lockInfo) { + $dom = new \DOMDocument('1.0','utf-8'); $dom->formatOutput = true; @@ -453,8 +453,8 @@ protected function generateLockResponse(LockInfo $lockInfo) * @param bool $checkChildLocks If set to true, this function will also look for any locks set on child resources of the supplied urls. This is needed for for example deletion of entire trees. * @return bool */ - protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks = false) - { + protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks = false) { + if (is_null($urls)) { $urls = array($this->server->getRequestUri()); } elseif (is_string($urls)) { @@ -466,7 +466,7 @@ protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks $conditions = $this->getIfConditions(); // We're going to loop through the urls and make sure all lock conditions are satisfied - foreach ($urls as $url) { + foreach($urls as $url) { $locks = $this->getLocks($url, $checkChildLocks); @@ -480,7 +480,7 @@ protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks // If there were no locks or conditions, we go to the next url if (!$locks && !$conditions) continue; - foreach ($conditions as $condition) { + foreach($conditions as $condition) { if (!$condition['uri']) { $conditionUri = $this->server->getRequestUri(); @@ -493,7 +493,7 @@ protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks // The tokens array contians arrays with 2 elements. 0=true/false for normal/not condition, 1=locktoken // At least 1 condition has to be satisfied - foreach ($condition['tokens'] as $conditionToken) { + foreach($condition['tokens'] as $conditionToken) { $etagValid = true; $lockValid = true; @@ -503,7 +503,7 @@ protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks $uri = $conditionUri?$conditionUri:$this->server->getRequestUri(); $node = $this->server->tree->getNodeForPath($uri); - $etagValid = $node->getETag()==$conditionToken[2]; + $etagValid = $node instanceof DAV\IFile && $node->getETag()==$conditionToken[2]; } @@ -512,7 +512,7 @@ protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks $lockValid = false; // Match all the locks - foreach ($locks as $lockIndex=>$lock) { + foreach($locks as $lockIndex=>$lock) { $lockToken = 'opaquelocktoken:' . $lock->token; @@ -577,8 +577,8 @@ protected function validateLock($urls = null,&$lastLock = null, $checkChildLocks * * @return array */ - public function getIfConditions() - { + public function getIfConditions() { + $header = $this->server->httpRequest->getHeader('If'); if (!$header) return array(); @@ -589,7 +589,7 @@ public function getIfConditions() $conditions = array(); - foreach ($matches as $match) { + foreach($matches as $match) { $condition = array( 'uri' => $match['uri'], @@ -619,17 +619,24 @@ public function getIfConditions() * @param string $body * @return DAV\Locks\LockInfo */ - protected function parseLockRequest($body) - { + protected function parseLockRequest($body) { + + // Fixes an XXE vulnerability on PHP versions older than 5.3.23 or + // 5.4.13. + $previous = libxml_disable_entity_loader(true); + + $xml = simplexml_load_string( DAV\XMLUtil::convertDAVNamespace($body), null, LIBXML_NOWARNING); + libxml_disable_entity_loader($previous); + $xml->registerXPathNamespace('d','urn:DAV'); $lockInfo = new LockInfo(); $children = $xml->children("urn:DAV"); - $lockInfo->owner = (string) $children->owner; + $lockInfo->owner = (string)$children->owner; $lockInfo->token = DAV\UUIDUtil::getUUID(); $lockInfo->scope = count($xml->xpath('d:lockscope/d:exclusive'))>0 ? LockInfo::EXCLUSIVE : LockInfo::SHARED; diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Mount/Plugin.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Mount/Plugin.php index 0a779196df..8376b03b06 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Mount/Plugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Mount/Plugin.php @@ -9,12 +9,12 @@ * * Simply append ?mount to any collection to generate the davmount response. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin -{ +class Plugin extends DAV\ServerPlugin { + /** * Reference to Server class * @@ -28,8 +28,8 @@ class Plugin extends DAV\ServerPlugin * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $this->server->subscribeEvent('beforeMethod',array($this,'beforeMethod'), 90); @@ -43,8 +43,8 @@ public function initialize(DAV\Server $server) * @param string $uri * @return bool */ - public function beforeMethod($method, $uri) - { + public function beforeMethod($method, $uri) { + if ($method!='GET') return; if ($this->server->httpRequest->getQueryString()!='mount') return; @@ -66,8 +66,8 @@ public function beforeMethod($method, $uri) * @param string $uri absolute uri * @return void */ - public function davMount($uri) - { + public function davMount($uri) { + $this->server->httpResponse->sendStatus(200); $this->server->httpResponse->setHeader('Content-Type','application/davmount+xml'); ob_start(); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Node.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Node.php index 48ce08425b..44e47be68f 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Node.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Node.php @@ -7,12 +7,12 @@ * * This is a helper class, that should aid in getting nodes setup. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class Node implements INode -{ +abstract class Node implements INode { + /** * Returns the last modification time * @@ -20,8 +20,8 @@ abstract class Node implements INode * * @return int */ - public function getLastModified() - { + public function getLastModified() { + return time(); } @@ -32,8 +32,8 @@ public function getLastModified() * @throws Sabre\DAV\Exception\Forbidden * @return void */ - public function delete() - { + public function delete() { + throw new Exception\Forbidden('Permission denied to delete node'); } @@ -45,10 +45,11 @@ public function delete() * @param string $name The new name * @return void */ - public function setName($name) - { + public function setName($name) { + throw new Exception\Forbidden('Permission denied to rename file'); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/ObjectTree.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/ObjectTree.php index b3feb44e4e..3e7c0fcf83 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/ObjectTree.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/ObjectTree.php @@ -7,12 +7,12 @@ * * This implementation of the Tree class makes use of the INode, IFile and ICollection API's * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ObjectTree extends Tree -{ +class ObjectTree extends Tree { + /** * The root node * @@ -34,8 +34,8 @@ class ObjectTree extends Tree * * @param ICollection $rootNode */ - public function __construct(ICollection $rootNode) - { + public function __construct(ICollection $rootNode) { + $this->rootNode = $rootNode; } @@ -46,8 +46,8 @@ public function __construct(ICollection $rootNode) * @param string $path * @return INode */ - public function getNodeForPath($path) - { + public function getNodeForPath($path) { + $path = trim($path,'/'); if (isset($this->cache[$path])) return $this->cache[$path]; @@ -84,8 +84,8 @@ public function getNodeForPath($path) * @param string $path * @return bool */ - public function nodeExists($path) - { + public function nodeExists($path) { + try { // The root always exists @@ -111,11 +111,11 @@ public function nodeExists($path) * @param string $path * @return array */ - public function getChildren($path) - { + public function getChildren($path) { + $node = $this->getNodeForPath($path); $children = $node->getChildren(); - foreach ($children as $child) { + foreach($children as $child) { $this->cache[trim($path,'/') . '/' . $child->getName()] = $child; @@ -142,12 +142,12 @@ public function getChildren($path) * @param string $path * @return void */ - public function markDirty($path) - { + public function markDirty($path) { + // We don't care enough about sub-paths // flushing the entire cache $path = trim($path,'/'); - foreach ($this->cache as $nodePath=>$node) { + foreach($this->cache as $nodePath=>$node) { if ($nodePath == $path || strpos($nodePath,$path.'/')===0) unset($this->cache[$nodePath]); @@ -156,3 +156,4 @@ public function markDirty($path) } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/PartialUpdate/IFile.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/PartialUpdate/IFile.php index dd4f1ddb94..9cfb47377b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/PartialUpdate/IFile.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/PartialUpdate/IFile.php @@ -5,16 +5,15 @@ use Sabre\DAV; /** - * This interface provides a way to modify only part of a target resource - * It may be used to update a file chunk, upload big a file into smaller - * chunks or resume an upload + * This interface is deprecated. Use IPatchSupport instead. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License + * @deprecated */ -interface IFile extends DAV\IFile -{ +interface IFile extends DAV\IFile { + /** * Updates the data at a given offset * @@ -34,6 +33,7 @@ interface IFile extends DAV\IFile * @param integer $offset * @return string|null */ - public function putRange($data, $offset); + function putRange($data, $offset); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/PartialUpdate/IPatchSupport.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/PartialUpdate/IPatchSupport.php new file mode 100644 index 0000000000..aff1d320fa --- /dev/null +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/PartialUpdate/IPatchSupport.php @@ -0,0 +1,48 @@ +addPlugin($patchPlugin); * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin -{ +class Plugin extends DAV\ServerPlugin { + + const RANGE_APPEND = 1; + const RANGE_START = 2; + const RANGE_END = 3; + /** * Reference to server * @@ -35,8 +39,8 @@ class Plugin extends DAV\ServerPlugin * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $server->subscribeEvent('unknownMethod',array($this,'unknownMethod')); @@ -50,8 +54,8 @@ public function initialize(DAV\Server $server) * * @return string */ - public function getPluginName() - { + public function getPluginName() { + return 'partialupdate'; } @@ -66,9 +70,9 @@ public function getPluginName() * @param string $uri * @return bool|null */ - public function unknownMethod($method, $uri) - { - switch ($method) { + public function unknownMethod($method, $uri) { + + switch($method) { case 'PATCH': return $this->httpPatch($uri); @@ -91,16 +95,16 @@ public function unknownMethod($method, $uri) * @param string $uri * @return array */ - public function getHTTPMethods($uri) - { - $tree = $this->server->tree; + public function getHTTPMethods($uri) { - if ($tree->nodeExists($uri) && - $tree->getNodeForPath($uri) instanceof IFile) { - return array('PATCH'); - } - - return array(); + $tree = $this->server->tree; + if ($tree->nodeExists($uri)) { + $node = $tree->getNodeForPath($uri); + if ($node instanceof IFile || $node instanceof IPatchSupport) { + return array('PATCH'); + } + } + return array(); } @@ -109,8 +113,8 @@ public function getHTTPMethods($uri) * * @return array */ - public function getFeatures() - { + public function getFeatures() { + return array('sabredav-partialupdate'); } @@ -125,11 +129,11 @@ public function getFeatures() * @param string $uri * @return void */ - protected function httpPatch($uri) - { + protected function httpPatch($uri) { + // Get the node. Will throw a 404 if not found $node = $this->server->tree->getNodeForPath($uri); - if (!($node instanceof IFile)) { + if (!$node instanceof IFile && !$node instanceof IPatchSupport) { throw new DAV\Exception\MethodNotAllowed('The target resource does not support the PATCH method.'); } @@ -148,17 +152,23 @@ protected function httpPatch($uri) } $len = $this->server->httpRequest->getHeader('Content-Length'); - - // Load the begin and end data - $start = ($range[0])?$range[0]:0; - $end = ($range[1])?$range[1]:$len-1; - - // Check consistency - if($end < $start) - throw new DAV\Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[1] . ') is lower than the start offset (' . $range[0] . ')'); - if($end - $start + 1 != $len) - throw new DAV\Exception\RequestedRangeNotSatisfiable('Actual data length (' . $len . ') is not consistent with begin (' . $range[0] . ') and end (' . $range[1] . ') offsets'); - + if (!$len) throw new DAV\Exception\LengthRequired('A Content-Length header is required'); + + switch($range[0]) { + case self::RANGE_START : + // Calculate the end-range if it doesn't exist. + if (!$range[2]) { + $range[2] = $range[1] + $len - 1; + } else { + if ($range[2] < $range[1]) { + throw new DAV\Exception\RequestedRangeNotSatisfiable('The end offset (' . $range[2] . ') is lower than the start offset (' . $range[1] . ')'); + } + if($range[2] - $range[1] + 1 != $len) { + throw new DAV\Exception\RequestedRangeNotSatisfiable('Actual data length (' . $len . ') is not consistent with begin (' . $range[1] . ') and end (' . $range[2] . ') offsets'); + } + } + break; + } // Checking If-None-Match and related headers. if (!$this->server->checkPreconditions()) return; @@ -166,7 +176,23 @@ protected function httpPatch($uri) return; $body = $this->server->httpRequest->getBody(); - $etag = $node->putRange($body, $start-1); + + + if ($node instanceof IPatchSupport) { + $etag = $node->patch($body, $range[0], isset($range[1])?$range[1]:null); + } else { + // The old interface + switch($range[0]) { + case self::RANGE_APPEND : + throw new DAV\Exception\NotImplemented('This node does not support the append syntax. Please upgrade it to IPatchSupport'); + case self::RANGE_START : + $etag = $node->putRange($body, $range[1]); + break; + case self::RANGE_END : + throw new DAV\Exception\NotImplemented('This node does not support the end-range syntax. Please upgrade it to IPatchSupport'); + break; + } + } $this->server->broadcastEvent('afterWriteContent',array($uri, $node)); @@ -182,31 +208,39 @@ protected function httpPatch($uri) * Returns the HTTP custom range update header * * This method returns null if there is no well-formed HTTP range request - * header or array($start, $end). + * header. It returns array(1) if it was an append request, array(2, + * $start, $end) if it's a start and end range, lastly it's array(3, + * $endoffset) if the offset was negative, and should be calculated from + * the end of the file. * - * The first number is the offset of the first byte in the range. - * The second number is the offset of the last byte in the range. + * Examples: * - * If the second offset is null, it should be treated as the offset of the last byte of the entity - * If the first offset is null, the second offset should be used to retrieve the last x bytes of the entity + * null - invalid + * array(1) - append + * array(2,10,15) - update bytes 10, 11, 12, 13, 14, 15 + * array(2,10,null) - update bytes 10 until the end of the patch body + * array(3,-5) - update from 5 bytes from the end of the file. * * @return array|null */ - public function getHTTPUpdateRange() - { + public function getHTTPUpdateRange() { + $range = $this->server->httpRequest->getHeader('X-Update-Range'); if (is_null($range)) return null; // Matching "Range: bytes=1234-5678: both numbers are optional - if (!preg_match('/^bytes=([0-9]*)-([0-9]*)$/i',$range,$matches)) return null; - - if ($matches[1]==='' && $matches[2]==='') return null; + if (!preg_match('/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i',$range,$matches)) return null; - return array( - $matches[1]!==''?$matches[1]:null, - $matches[2]!==''?$matches[2]:null, - ); + if ($matches[1]==='append') { + return array(self::RANGE_APPEND); + } elseif (strlen($matches[2])>0) { + return array(self::RANGE_START, $matches[2], $matches[3]?:null); + } elseif ($matches[4]) { + return array(self::RANGE_END, $matches[4]); + } else { + return null; + } } } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property.php index e13266ebc6..d0c265907c 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property.php @@ -7,12 +7,12 @@ * * Extend this class to create custom complex properties * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class Property implements PropertyInterface -{ +abstract class Property implements PropertyInterface { + /** * Unserializes the property. * @@ -21,10 +21,11 @@ abstract class Property implements PropertyInterface * @param \DOMElement $prop * @return DAV\IProperty */ - public static function unserialize(\DOMElement $prop) - { + static function unserialize(\DOMElement $prop) { + throw new Exception('Unserialize has not been implemented for this class'); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/GetLastModified.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/GetLastModified.php index cd84856b5e..987e3fc024 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/GetLastModified.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/GetLastModified.php @@ -14,12 +14,12 @@ * This class uses unix timestamps internally, and converts them to RFC 1123 times for * serialization * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class GetLastModified extends DAV\Property -{ +class GetLastModified extends DAV\Property { + /** * time * @@ -32,8 +32,8 @@ class GetLastModified extends DAV\Property * * @param int|DateTime $time */ - public function __construct($time) - { + public function __construct($time) { + if ($time instanceof \DateTime) { $this->time = $time; } elseif (is_int($time) || ctype_digit($time)) { @@ -54,8 +54,8 @@ public function __construct($time) * @param \DOMElement $prop * @return void */ - public function serialize(DAV\Server $server, \DOMElement $prop) - { + public function serialize(DAV\Server $server, \DOMElement $prop) { + $doc = $prop->ownerDocument; //$prop->setAttribute('xmlns:b','urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/'); //$prop->setAttribute('b:dt','dateTime.rfc1123'); @@ -68,10 +68,11 @@ public function serialize(DAV\Server $server, \DOMElement $prop) * * @return \DateTime */ - public function getTime() - { + public function getTime() { + return $this->time; } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/Href.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/Href.php index 41e1d504b4..f0c162706c 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/Href.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/Href.php @@ -10,12 +10,12 @@ * The href property represents a url within a {DAV:}href element. * This is used by many WebDAV extensions, but not really within the WebDAV core spec * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Href extends DAV\Property implements IHref -{ +class Href extends DAV\Property implements IHref { + /** * href * @@ -36,8 +36,8 @@ class Href extends DAV\Property implements IHref * @param string $href * @param bool $autoPrefix */ - public function __construct($href, $autoPrefix = true) - { + public function __construct($href, $autoPrefix = true) { + $this->href = $href; $this->autoPrefix = $autoPrefix; @@ -48,8 +48,8 @@ public function __construct($href, $autoPrefix = true) * * @return string */ - public function getHref() - { + public function getHref() { + return $this->href; } @@ -63,12 +63,18 @@ public function getHref() * @param \DOMElement $dom * @return void */ - public function serialize(DAV\Server $server, \DOMElement $dom) - { - $prefix = $server->xmlNamespaces['DAV:']; + public function serialize(DAV\Server $server, \DOMElement $dom) { + $prefix = $server->xmlNamespaces['DAV:']; $elem = $dom->ownerDocument->createElement($prefix . ':href'); - $elem->nodeValue = ($this->autoPrefix?$server->getBaseUri():'') . $this->href; + + if ($this->autoPrefix) { + $value = $server->getBaseUri() . DAV\URLUtil::encodePath($this->href); + } else { + $value = $this->href; + } + $elem->appendChild($dom->ownerDocument->createTextNode($value)); + $dom->appendChild($elem); } @@ -82,8 +88,8 @@ public function serialize(DAV\Server $server, \DOMElement $dom) * @param \DOMElement $dom * @return DAV\Property\Href */ - public static function unserialize(\DOMElement $dom) - { + static function unserialize(\DOMElement $dom) { + if ($dom->firstChild && DAV\XMLUtil::toClarkNotation($dom->firstChild)==='{DAV:}href') { return new self($dom->firstChild->textContent,false); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/HrefList.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/HrefList.php index a93aae3696..a5bad4ace3 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/HrefList.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/HrefList.php @@ -9,12 +9,12 @@ * * This property contains multiple {DAV:}href elements, each containing a url. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class HrefList extends DAV\Property -{ +class HrefList extends DAV\Property { + /** * hrefs * @@ -35,8 +35,8 @@ class HrefList extends DAV\Property * @param array $hrefs * @param bool $autoPrefix */ - public function __construct(array $hrefs, $autoPrefix = true) - { + public function __construct(array $hrefs, $autoPrefix = true) { + $this->hrefs = $hrefs; $this->autoPrefix = $autoPrefix; @@ -47,8 +47,8 @@ public function __construct(array $hrefs, $autoPrefix = true) * * @return array */ - public function getHrefs() - { + public function getHrefs() { + return $this->hrefs; } @@ -62,13 +62,20 @@ public function getHrefs() * @param \DOMElement $dom * @return void */ - public function serialize(DAV\Server $server,\DOMElement $dom) - { + public function serialize(DAV\Server $server,\DOMElement $dom) { + $prefix = $server->xmlNamespaces['DAV:']; - foreach ($this->hrefs as $href) { + foreach($this->hrefs as $href) { + $elem = $dom->ownerDocument->createElement($prefix . ':href'); - $elem->nodeValue = ($this->autoPrefix?$server->getBaseUri():'') . $href; + if ($this->autoPrefix) { + $value = $server->getBaseUri() . DAV\URLUtil::encodePath($href); + } else { + $value = $href; + } + $elem->appendChild($dom->ownerDocument->createTextNode($value)); + $dom->appendChild($elem); } @@ -83,10 +90,10 @@ public function serialize(DAV\Server $server,\DOMElement $dom) * @param \DOMElement $dom * @return DAV\Property\HrefList */ - public static function unserialize(\DOMElement $dom) - { + static function unserialize(\DOMElement $dom) { + $hrefs = array(); - foreach ($dom->childNodes as $child) { + foreach($dom->childNodes as $child) { if (DAV\XMLUtil::toClarkNotation($child)==='{DAV:}href') { $hrefs[] = $child->textContent; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/IHref.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/IHref.php index 1f549db654..268ab8d517 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/IHref.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/IHref.php @@ -9,17 +9,17 @@ * This is used by certain subsystems to aquire more information about for example * the owner of a file * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IHref -{ +interface IHref { + /** * getHref * * @return string */ - public function getHref(); + function getHref(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/LockDiscovery.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/LockDiscovery.php index a24fd114be..6b47935af4 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/LockDiscovery.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/LockDiscovery.php @@ -9,12 +9,12 @@ * * This property contains all the open locks on a given resource * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class LockDiscovery extends DAV\Property -{ +class LockDiscovery extends DAV\Property { + /** * locks * @@ -35,7 +35,7 @@ class LockDiscovery extends DAV\Property * It was reported that showing the lockroot in the response can break * Office 2000 compatibility. */ - public static $hideLockRoot = false; + static public $hideLockRoot = false; /** * __construct @@ -43,8 +43,8 @@ class LockDiscovery extends DAV\Property * @param array $locks * @param bool $revealLockToken */ - public function __construct($locks, $revealLockToken = false) - { + public function __construct($locks, $revealLockToken = false) { + $this->locks = $locks; $this->revealLockToken = $revealLockToken; @@ -57,11 +57,11 @@ public function __construct($locks, $revealLockToken = false) * @param \DOMElement $prop * @return void */ - public function serialize(DAV\Server $server, \DOMElement $prop) - { + public function serialize(DAV\Server $server, \DOMElement $prop) { + $doc = $prop->ownerDocument; - foreach ($this->locks as $lock) { + foreach($this->locks as $lock) { $activeLock = $doc->createElementNS('DAV:','d:activelock'); $prop->appendChild($activeLock); @@ -101,3 +101,4 @@ public function serialize(DAV\Server $server, \DOMElement $prop) } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/ResourceType.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/ResourceType.php index 5752c3a5e3..68134f3f91 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/ResourceType.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/ResourceType.php @@ -10,12 +10,12 @@ * Normally for files this is empty, and for collection {DAV:}collection. * However, other specs define different values for this. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ResourceType extends DAV\Property -{ +class ResourceType extends DAV\Property { + /** * resourceType * @@ -28,8 +28,8 @@ class ResourceType extends DAV\Property * * @param mixed $resourceType */ - public function __construct($resourceType = array()) - { + public function __construct($resourceType = array()) { + if ($resourceType === DAV\Server::NODE_FILE) $this->resourceType = array(); elseif ($resourceType === DAV\Server::NODE_DIRECTORY) @@ -48,12 +48,12 @@ public function __construct($resourceType = array()) * @param \DOMElement $prop * @return void */ - public function serialize(DAV\Server $server, \DOMElement $prop) - { + public function serialize(DAV\Server $server, \DOMElement $prop) { + $propName = null; $rt = $this->resourceType; - foreach ($rt as $resourceType) { + foreach($rt as $resourceType) { if (preg_match('/^{([^}]*)}(.*)$/',$resourceType,$propName)) { if (isset($server->xmlNamespaces[$propName[1]])) { @@ -74,8 +74,8 @@ public function serialize(DAV\Server $server, \DOMElement $prop) * * @return array */ - public function getValue() - { + public function getValue() { + return $this->resourceType; } @@ -86,8 +86,8 @@ public function getValue() * @param string $type * @return bool */ - public function is($type) - { + public function is($type) { + return in_array($type, $this->resourceType); } @@ -98,8 +98,8 @@ public function is($type) * @param string $type * @return void */ - public function add($type) - { + public function add($type) { + $this->resourceType[] = $type; $this->resourceType = array_unique($this->resourceType); @@ -111,10 +111,10 @@ public function add($type) * @param \DOMElement $dom * @return DAV\Property\ResourceType */ - public static function unserialize(\DOMElement $dom) - { + static public function unserialize(\DOMElement $dom) { + $value = array(); - foreach ($dom->childNodes as $child) { + foreach($dom->childNodes as $child) { $value[] = DAV\XMLUtil::toClarkNotation($child); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/Response.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/Response.php index 01bce38bb7..370abc26be 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/Response.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/Response.php @@ -11,12 +11,12 @@ * This is used by the Server class to encode individual items within a multistatus * response. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Response extends DAV\Property implements IHref -{ +class Response extends DAV\Property implements IHref { + /** * Url for the response * @@ -38,8 +38,8 @@ class Response extends DAV\Property implements IHref * @param string $href * @param array $responseProperties */ - public function __construct($href, array $responseProperties) - { + public function __construct($href, array $responseProperties) { + $this->href = $href; $this->responseProperties = $responseProperties; @@ -50,8 +50,8 @@ public function __construct($href, array $responseProperties) * * @return string */ - public function getHref() - { + public function getHref() { + return $this->href; } @@ -61,8 +61,8 @@ public function getHref() * * @return array */ - public function getResponseProperties() - { + public function getResponseProperties() { + return $this->responseProperties; } @@ -74,8 +74,8 @@ public function getResponseProperties() * @param \DOMElement $dom * @return void */ - public function serialize(DAV\Server $server, \DOMElement $dom) - { + public function serialize(DAV\Server $server, \DOMElement $dom) { + $document = $dom->ownerDocument; $properties = $this->responseProperties; @@ -91,7 +91,7 @@ public function serialize(DAV\Server $server, \DOMElement $dom) // The properties variable is an array containing properties, grouped by // HTTP status - foreach ($properties as $httpStatus=>$propertyGroup) { + foreach($properties as $httpStatus=>$propertyGroup) { // The 'href' is also in this array, and it's special cased. // We will ignore it @@ -108,7 +108,7 @@ public function serialize(DAV\Server $server, \DOMElement $dom) $nsList = $server->xmlNamespaces; - foreach ($propertyGroup as $propertyName=>$propertyValue) { + foreach($propertyGroup as $propertyName=>$propertyValue) { $propName = null; preg_match('/^{([^}]*)}(.*)$/',$propertyName,$propName); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/ResponseList.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/ResponseList.php index f946e838e9..9db6cbbf59 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/ResponseList.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/ResponseList.php @@ -11,12 +11,12 @@ * This is used by the Server class to encode items within a multistatus * response. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class ResponseList extends DAV\Property -{ +class ResponseList extends DAV\Property { + /** * Response objects. * @@ -30,9 +30,9 @@ class ResponseList extends DAV\Property * * @param array $responses; */ - public function __construct($responses) - { - foreach ($responses as $response) { + public function __construct($responses) { + + foreach($responses as $response) { if (!($response instanceof Response)) { throw new \InvalidArgumentException('You must pass an array of Sabre\DAV\Property\Response objects'); } @@ -48,9 +48,9 @@ public function __construct($responses) * @param \DOMElement $dom * @return void */ - public function serialize(DAV\Server $server,\DOMElement $dom) - { - foreach ($this->responses as $response) { + public function serialize(DAV\Server $server,\DOMElement $dom) { + + foreach($this->responses as $response) { $response->serialize($server, $dom); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/SupportedLock.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/SupportedLock.php index 74be3d95d5..035c2f3301 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/SupportedLock.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/SupportedLock.php @@ -10,12 +10,12 @@ * This property contains information about what kind of locks * this server supports. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SupportedLock extends DAV\Property -{ +class SupportedLock extends DAV\Property { + /** * supportsLocks * @@ -28,8 +28,8 @@ class SupportedLock extends DAV\Property * * @param mixed $supportsLocks */ - public function __construct($supportsLocks) - { + public function __construct($supportsLocks) { + $this->supportsLocks = $supportsLocks; } @@ -41,8 +41,8 @@ public function __construct($supportsLocks) * @param \DOMElement $prop * @return void */ - public function serialize(DAV\Server $server,\DOMElement $prop) - { + public function serialize(DAV\Server $server,\DOMElement $prop) { + $doc = $prop->ownerDocument; if (!$this->supportsLocks) return null; @@ -75,3 +75,4 @@ public function serialize(DAV\Server $server,\DOMElement $prop) } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/SupportedReportSet.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/SupportedReportSet.php index 3c1baa051c..a8a90bb189 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/SupportedReportSet.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Property/SupportedReportSet.php @@ -10,12 +10,12 @@ * This property is defined in RFC3253, but since it's * so common in other webdav-related specs, it is part of the core server. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SupportedReportSet extends DAV\Property -{ +class SupportedReportSet extends DAV\Property { + /** * List of reports * @@ -33,8 +33,8 @@ class SupportedReportSet extends DAV\Property * * @param mixed $reports */ - public function __construct($reports = null) - { + public function __construct($reports = null) { + if (!is_null($reports)) $this->addReport($reports); @@ -49,11 +49,11 @@ public function __construct($reports = null) * @param mixed $report * @return void */ - public function addReport($report) - { + public function addReport($report) { + if (!is_array($report)) $report = array($report); - foreach ($report as $r) { + foreach($report as $r) { if (!preg_match('/^{([^}]*)}(.*)$/',$r)) throw new DAV\Exception('Reportname must be in clark-notation'); @@ -69,8 +69,8 @@ public function addReport($report) * * @return array */ - public function getValue() - { + public function getValue() { + return $this->reports; } @@ -82,9 +82,9 @@ public function getValue() * @param \DOMElement $prop * @return void */ - public function serialize(DAV\Server $server, \DOMElement $prop) - { - foreach ($this->reports as $reportName) { + public function serialize(DAV\Server $server, \DOMElement $prop) { + + foreach($this->reports as $reportName) { $supportedReport = $prop->ownerDocument->createElement('d:supported-report'); $prop->appendChild($supportedReport); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/PropertyInterface.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/PropertyInterface.php index c8b1ce15aa..2fb0d7db6b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/PropertyInterface.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/PropertyInterface.php @@ -7,14 +7,15 @@ * * Implement this interface to create new complex properties * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface PropertyInterface -{ +interface PropertyInterface { + public function serialize(Server $server, \DOMElement $prop); - public static function unserialize(\DOMElement $prop); + static function unserialize(\DOMElement $prop); } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Server.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Server.php index d6631e698c..e0a68ab50b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Server.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Server.php @@ -6,12 +6,12 @@ /** * Main DAV server class * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Server -{ +class Server { + /** * Infinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree */ @@ -147,7 +147,7 @@ class Server * * @var bool */ - public static $exposeVersion = true; + static public $exposeVersion = true; /** * Sets up the server @@ -164,8 +164,8 @@ class Server * * @param Tree|INode|array|null $treeOrNode The tree object */ - public function __construct($treeOrNode = null) - { + public function __construct($treeOrNode = null) { + if ($treeOrNode instanceof Tree) { $this->tree = $treeOrNode; } elseif ($treeOrNode instanceof INode) { @@ -174,7 +174,7 @@ public function __construct($treeOrNode = null) // If it's an array, a list of nodes was passed, and we need to // create the root node. - foreach ($treeOrNode as $node) { + foreach($treeOrNode as $node) { if (!($node instanceof INode)) { throw new Exception('Invalid argument passed to constructor. If you\'re passing an array, all the values must implement Sabre\\DAV\\INode'); } @@ -199,8 +199,8 @@ public function __construct($treeOrNode = null) * * @return void */ - public function exec() - { + public function exec() { + try { // If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an @@ -245,7 +245,7 @@ public function exec() $error->appendChild($DOM->createElement('s:sabredav-version',$h(Version::VERSION))); } - if ($e instanceof Exception) { + if($e instanceof Exception) { $httpCode = $e->getHTTPCode(); $e->serialize($this,$error); @@ -273,8 +273,8 @@ public function exec() * @param string $uri * @return void */ - public function setBaseUri($uri) - { + public function setBaseUri($uri) { + // If the baseUri does not end with a slash, we must add it if ($uri[strlen($uri)-1]!=='/') $uri.='/'; @@ -288,8 +288,8 @@ public function setBaseUri($uri) * * @return string */ - public function getBaseUri() - { + public function getBaseUri() { + if (is_null($this->baseUri)) $this->baseUri = $this->guessBaseUri(); return $this->baseUri; @@ -303,8 +303,8 @@ public function getBaseUri() * * @return string */ - public function guessBaseUri() - { + public function guessBaseUri() { + $pathInfo = $this->httpRequest->getRawServerValue('PATH_INFO'); $uri = $this->httpRequest->getRawServerValue('REQUEST_URI'); @@ -323,7 +323,7 @@ public function guessBaseUri() $decodedUri = URLUtil::decodePath($uri); // A simple sanity check: - if (substr($decodedUri,strlen($decodedUri)-strlen($pathInfo))===$pathInfo) { + if(substr($decodedUri,strlen($decodedUri)-strlen($pathInfo))===$pathInfo) { $baseUri = substr($decodedUri,0,strlen($decodedUri)-strlen($pathInfo)); return rtrim($baseUri,'/') . '/'; } @@ -345,8 +345,8 @@ public function guessBaseUri() * @param ServerPlugin $plugin * @return void */ - public function addPlugin(ServerPlugin $plugin) - { + public function addPlugin(ServerPlugin $plugin) { + $this->plugins[$plugin->getPluginName()] = $plugin; $plugin->initialize($this); @@ -360,13 +360,13 @@ public function addPlugin(ServerPlugin $plugin) * @param string $name * @return ServerPlugin */ - public function getPlugin($name) - { + public function getPlugin($name) { + if (isset($this->plugins[$name])) return $this->plugins[$name]; // This is a fallback and deprecated. - foreach ($this->plugins as $plugin) { + foreach($this->plugins as $plugin) { if (get_class($plugin)===$name) return $plugin; } @@ -379,8 +379,8 @@ public function getPlugin($name) * * @return array */ - public function getPlugins() - { + public function getPlugins() { + return $this->plugins; } @@ -402,8 +402,8 @@ public function getPlugins() * @param int $priority * @return void */ - public function subscribeEvent($event, $callback, $priority = 100) - { + public function subscribeEvent($event, $callback, $priority = 100) { + if (!isset($this->eventSubscriptions[$event])) { $this->eventSubscriptions[$event] = array(); } @@ -424,11 +424,11 @@ public function subscribeEvent($event, $callback, $priority = 100) * @param array $arguments * @return bool */ - public function broadcastEvent($eventName,$arguments = array()) - { + public function broadcastEvent($eventName,$arguments = array()) { + if (isset($this->eventSubscriptions[$eventName])) { - foreach ($this->eventSubscriptions[$eventName] as $subscriber) { + foreach($this->eventSubscriptions[$eventName] as $subscriber) { $result = call_user_func_array($subscriber,$arguments); if ($result===false) return false; @@ -448,8 +448,8 @@ public function broadcastEvent($eventName,$arguments = array()) * @param string $uri * @return void */ - public function invokeMethod($method, $uri) - { + public function invokeMethod($method, $uri) { + $method = strtoupper($method); if (!$this->broadcastEvent('beforeMethod',array($method, $uri))) return; @@ -492,8 +492,8 @@ public function invokeMethod($method, $uri) * @param string $uri * @return void */ - protected function httpOptions($uri) - { + protected function httpOptions($uri) { + $methods = $this->getAllowedMethods($uri); $this->httpResponse->setHeader('Allow',strtoupper(implode(', ',$methods))); @@ -520,8 +520,8 @@ protected function httpOptions($uri) * @param string $uri * @return bool */ - protected function httpGet($uri) - { + protected function httpGet($uri) { + $node = $this->tree->getNodeForPath($uri,0); if (!$this->checkPreconditions(true)) return false; @@ -644,8 +644,6 @@ protected function httpGet($uri) $this->httpResponse->sendBody($body); } - $repositories = \ConfService::getRepositoriesList("user"); - \AJXP_Logger::info(__CLASS__,"Download", array("files"=>$repositories[\ConfService::getCurrentRepositoryId()]->getSlug()."/".$uri)); } @@ -658,8 +656,8 @@ protected function httpGet($uri) * @param string $uri * @return void */ - protected function httpHead($uri) - { + protected function httpHead($uri) { + $node = $this->tree->getNodeForPath($uri); /* This information is only collection for File objects. * Ideally we want to throw 405 Method Not Allowed for every @@ -684,8 +682,11 @@ protected function httpHead($uri) * @param string $uri * @return void */ - protected function httpDelete($uri) - { + protected function httpDelete($uri) { + + // Checking If-None-Match and related headers. + if (!$this->checkPreconditions()) return; + if (!$this->broadcastEvent('beforeUnbind',array($uri))) return; $this->tree->delete($uri); $this->broadcastEvent('afterUnbind',array($uri)); @@ -711,8 +712,8 @@ protected function httpDelete($uri) * @param string $uri * @return void */ - protected function httpPropfind($uri) - { + protected function httpPropfind($uri) { + $requestedProperties = $this->parsePropFindRequest($this->httpRequest->getBody(true)); $depth = $this->getHTTPDepth(1); @@ -750,8 +751,8 @@ protected function httpPropfind($uri) * @param string $uri * @return void */ - protected function httpPropPatch($uri) - { + protected function httpPropPatch($uri) { + $newProperties = $this->parsePropPatchRequest($this->httpRequest->getBody(true)); $result = $this->updateProperties($uri, $newProperties); @@ -765,8 +766,8 @@ protected function httpPropPatch($uri) // request was succesful, and don't need to return the // multi-status. $ok = true; - foreach ($result as $code=>$prop) { - if ((int) $code > 299) { + foreach($result as $code=>$prop) { + if ((int)$code > 299) { $ok = false; } } @@ -799,8 +800,8 @@ protected function httpPropPatch($uri) * @param string $uri * @return bool */ - protected function httpPut($uri) - { + protected function httpPut($uri) { + $body = $this->httpRequest->getBody(); // Intercepting Content-Range @@ -873,13 +874,13 @@ protected function httpPut($uri) } + // Checking If-None-Match and related headers. + if (!$this->checkPreconditions()) return; + if ($this->tree->nodeExists($uri)) { $node = $this->tree->getNodeForPath($uri); - // Checking If-None-Match and related headers. - if (!$this->checkPreconditions()) return; - // If the node is a collection, we'll deny it if (!($node instanceof IFile)) throw new Exception\Conflict('PUT is not allowed on non-files.'); if (!$this->broadcastEvent('beforeWriteContent',array($uri, $node, &$body))) return false; @@ -906,8 +907,6 @@ protected function httpPut($uri) $this->httpResponse->sendStatus(201); } - $repositories = \ConfService::getRepositoriesList("user"); - \AJXP_Logger::info(__CLASS__,"Upload", array("files"=>$repositories[\ConfService::getCurrentRepositoryId()]->getSlug()."/".$uri)); } @@ -920,8 +919,8 @@ protected function httpPut($uri) * @param string $uri * @return void */ - protected function httpMkcol($uri) - { + protected function httpMkcol($uri) { + $requestBody = $this->httpRequest->getBody(true); if ($requestBody) { @@ -943,7 +942,7 @@ protected function httpMkcol($uri) } $properties = array(); - foreach ($dom->firstChild->childNodes as $childNode) { + foreach($dom->firstChild->childNodes as $childNode) { if (XMLUtil::toClarkNotation($childNode)!=='{DAV:}set') continue; $properties = array_merge($properties, XMLUtil::parseProperties($childNode, $this->propertyMap)); @@ -987,8 +986,8 @@ protected function httpMkcol($uri) * @param string $uri * @return bool */ - protected function httpMove($uri) - { + protected function httpMove($uri) { + $moveInfo = $this->getCopyAndMoveInfo(); // If the destination is part of the source tree, we must fail @@ -1024,8 +1023,8 @@ protected function httpMove($uri) * @param string $uri * @return bool */ - protected function httpCopy($uri) - { + protected function httpCopy($uri) { + $copyInfo = $this->getCopyAndMoveInfo(); // If the destination is part of the source tree, we must fail if ($copyInfo['destination']==$uri) @@ -1057,8 +1056,8 @@ protected function httpCopy($uri) * @param string $uri * @return void */ - protected function httpReport($uri) - { + protected function httpReport($uri) { + $body = $this->httpRequest->getBody(true); $dom = XMLUtil::loadDOMDocument($body); @@ -1082,8 +1081,8 @@ protected function httpReport($uri) * @param string $uri * @return array */ - public function getAllowedMethods($uri) - { + public function getAllowedMethods($uri) { + $methods = array( 'OPTIONS', 'GET', @@ -1117,8 +1116,8 @@ public function getAllowedMethods($uri) * * @return string */ - public function getRequestUri() - { + public function getRequestUri() { + return $this->calculateUri($this->httpRequest->getUri()); } @@ -1130,8 +1129,8 @@ public function getRequestUri() * @throws Exception\Forbidden A permission denied exception is thrown whenever there was an attempt to supply a uri outside of the base uri * @return string */ - public function calculateUri($uri) - { + public function calculateUri($uri) { + if ($uri[0]!='/' && strpos($uri,'://')) { $uri = parse_url($uri,PHP_URL_PATH); @@ -1167,8 +1166,8 @@ public function calculateUri($uri) * @param mixed $default * @return int */ - public function getHTTPDepth($default = self::DEPTH_INFINITY) - { + public function getHTTPDepth($default = self::DEPTH_INFINITY) { + // If its not set, we'll grab the default $depth = $this->httpRequest->getHeader('Depth'); @@ -1180,7 +1179,7 @@ public function getHTTPDepth($default = self::DEPTH_INFINITY) // If its an unknown value. we'll grab the default if (!ctype_digit($depth)) return $default; - return (int) $depth; + return (int)$depth; } @@ -1198,8 +1197,8 @@ public function getHTTPDepth($default = self::DEPTH_INFINITY) * * @return array|null */ - public function getHTTPRange() - { + public function getHTTPRange() { + $range = $this->httpRequest->getHeader('range'); if (is_null($range)) return null; @@ -1242,8 +1241,8 @@ public function getHTTPRange() * * @return array */ - public function getHTTPPrefer() - { + public function getHTTPPrefer() { + $result = array( 'return-asynch' => false, 'return-minimal' => false, @@ -1259,16 +1258,16 @@ public function getHTTPPrefer() explode(',', $prefer) ); - foreach ($parameters as $parameter) { + foreach($parameters as $parameter) { // Right now our regex only supports the tokens actually // specified in the draft. We may need to expand this if new // tokens get registered. - if (!preg_match('/^(?P[a-z0-9-]+)(?:=(?P[0-9]+))?$/', $parameter, $matches)) { + if(!preg_match('/^(?P[a-z0-9-]+)(?:=(?P[0-9]+))?$/', $parameter, $matches)) { continue; } - switch ($matches['token']) { + switch($matches['token']) { case 'return-asynch' : case 'return-minimal' : @@ -1308,8 +1307,8 @@ public function getHTTPPrefer() * * @return array */ - public function getCopyAndMoveInfo() - { + public function getCopyAndMoveInfo() { + // Collecting the relevant HTTP headers if (!$this->httpRequest->getHeader('Destination')) throw new Exception\BadRequest('The destination header was not supplied'); $destination = $this->calculateUri($this->httpRequest->getHeader('Destination')); @@ -1367,8 +1366,8 @@ public function getCopyAndMoveInfo() * @param string $path * @param array $propertyNames */ - public function getProperties($path, $propertyNames) - { + public function getProperties($path, $propertyNames) { + $result = $this->getPropertiesForPath($path,$propertyNames,0); return $result[0][200]; @@ -1386,10 +1385,10 @@ public function getProperties($path, $propertyNames) * @param array $propertyNames * @return array */ - public function getPropertiesForChildren($path, $propertyNames) - { + public function getPropertiesForChildren($path, $propertyNames) { + $result = array(); - foreach ($this->getPropertiesForPath($path,$propertyNames,1) as $k=>$row) { + foreach($this->getPropertiesForPath($path,$propertyNames,1) as $k=>$row) { // Skipping the parent path if ($k === 0) continue; @@ -1413,8 +1412,8 @@ public function getPropertiesForChildren($path, $propertyNames) * @param string $path * @return array */ - public function getHTTPHeaders($path) - { + public function getHTTPHeaders($path) { + $propertyMap = array( '{DAV:}getcontenttype' => 'Content-Type', '{DAV:}getcontentlength' => 'Content-Length', @@ -1425,7 +1424,7 @@ public function getHTTPHeaders($path) $properties = $this->getProperties($path,array_keys($propertyMap)); $headers = array(); - foreach ($propertyMap as $property=>$header) { + foreach($propertyMap as $property=>$header) { if (!isset($properties[$property])) continue; if (is_scalar($properties[$property])) { @@ -1456,12 +1455,19 @@ public function getHTTPHeaders($path) * @param int $depth * @return array */ - public function getPropertiesForPath($path, $propertyNames = array(), $depth = 0) - { + public function getPropertiesForPath($path, $propertyNames = array(), $depth = 0) { + if ($depth!=0) $depth = 1; $path = rtrim($path,'/'); + // This event allows people to intercept these requests early on in the + // process. + // + // We're not doing anything with the result, but this can be helpful to + // pre-fetch certain expensive live properties. + $this->broadCastEvent('beforeGetPropertiesForPath', array($path, $propertyNames, $depth)); + $returnPropertyList = array(); $parentNode = $this->tree->getNodeForPath($path); @@ -1478,7 +1484,7 @@ public function getPropertiesForPath($path, $propertyNames = array(), $depth = 0 // sensible list. $allProperties = count($propertyNames)==0; - foreach ($nodes as $myPath=>$node) { + foreach($nodes as $myPath=>$node) { $currentPropertyNames = $propertyNames; @@ -1526,7 +1532,7 @@ public function getPropertiesForPath($path, $propertyNames = array(), $depth = 0 // So as we loop through this list, we will only take the // properties that were actually requested and discard the // rest. - foreach ($currentPropertyNames as $k=>$currentPropertyName) { + foreach($currentPropertyNames as $k=>$currentPropertyName) { if (isset($nodeProperties[$currentPropertyName])) { unset($currentPropertyNames[$k]); $newProperties[200][$currentPropertyName] = $nodeProperties[$currentPropertyName]; @@ -1537,17 +1543,17 @@ public function getPropertiesForPath($path, $propertyNames = array(), $depth = 0 } - foreach ($currentPropertyNames as $prop) { + foreach($currentPropertyNames as $prop) { if (isset($newProperties[200][$prop])) continue; - switch ($prop) { + switch($prop) { case '{DAV:}getlastmodified' : if ($node->getLastModified()) $newProperties[200][$prop] = new Property\GetLastModified($node->getLastModified()); break; case '{DAV:}getcontentlength' : if ($node instanceof IFile) { $size = $node->getSize(); if (!is_null($size)) { - $newProperties[200][$prop] = (int) $node->getSize(); + $newProperties[200][$prop] = (int)$node->getSize(); } } break; @@ -1567,14 +1573,14 @@ public function getPropertiesForPath($path, $propertyNames = array(), $depth = 0 case '{DAV:}getcontenttype' : if ($node instanceof IFile && $ct = $node->getContentType()) $newProperties[200][$prop] = $ct; break; case '{DAV:}supported-report-set' : $reports = array(); - foreach ($this->plugins as $plugin) { + foreach($this->plugins as $plugin) { $reports = array_merge($reports, $plugin->getSupportedReportSet($myPath)); } $newProperties[200][$prop] = new Property\SupportedReportSet($reports); break; case '{DAV:}resourcetype' : $newProperties[200]['{DAV:}resourcetype'] = new Property\ResourceType(); - foreach ($this->resourceTypeMapping as $className => $resourceType) { + foreach($this->resourceTypeMapping as $className => $resourceType) { if ($node instanceof $className) $newProperties[200]['{DAV:}resourcetype']->add($resourceType); } break; @@ -1625,8 +1631,8 @@ public function getPropertiesForPath($path, $propertyNames = array(), $depth = 0 * @param string $etag * @return bool */ - public function createFile($uri,$data, &$etag = null) - { + public function createFile($uri,$data, &$etag = null) { + list($dir,$name) = URLUtil::splitPath($uri); if (!$this->broadcastEvent('beforeBind',array($uri))) return false; @@ -1653,8 +1659,8 @@ public function createFile($uri,$data, &$etag = null) * @param string $uri * @return void */ - public function createDirectory($uri) - { + public function createDirectory($uri) { + $this->createCollection($uri,array('{DAV:}collection'),array()); } @@ -1672,8 +1678,8 @@ public function createDirectory($uri) * @param array $properties A list of properties * @return array|null */ - public function createCollection($uri, array $resourceType, array $properties) - { + public function createCollection($uri, array $resourceType, array $properties) { + list($parentUri,$newName) = URLUtil::splitPath($uri); // Making sure {DAV:}collection was specified as resourceType @@ -1785,8 +1791,8 @@ public function createCollection($uri, array $resourceType, array $properties) * @param array $properties * @return array */ - public function updateProperties($uri, array $properties) - { + public function updateProperties($uri, array $properties) { + // we'll start by grabbing the node, this will throw the appropriate // exceptions if it doesn't. $node = $this->tree->getNodeForPath($uri); @@ -1800,8 +1806,8 @@ public function updateProperties($uri, array $properties) $hasError = false; // Running through all properties to make sure none of them are protected - if (!$hasError) foreach ($properties as $propertyName => $value) { - if (in_array($propertyName, $this->protectedProperties)) { + if (!$hasError) foreach($properties as $propertyName => $value) { + if(in_array($propertyName, $this->protectedProperties)) { $result[403][$propertyName] = null; unset($remainingProperties[$propertyName]); $hasError = true; @@ -1821,7 +1827,7 @@ public function updateProperties($uri, array $properties) // property is 403 Forbidden if (!$hasError && count($remainingProperties) && !($node instanceof IProperties)) { $hasError = true; - foreach ($properties as $propertyName=> $value) { + foreach($properties as $propertyName=> $value) { $result[403][$propertyName] = null; } $remainingProperties = array(); @@ -1836,14 +1842,14 @@ public function updateProperties($uri, array $properties) if ($updateResult===true) { // success - foreach ($remainingProperties as $propertyName=>$value) { + foreach($remainingProperties as $propertyName=>$value) { $result[200][$propertyName] = null; } } elseif ($updateResult===false) { // The node failed to update the properties for an // unknown reason - foreach ($remainingProperties as $propertyName=>$value) { + foreach($remainingProperties as $propertyName=>$value) { $result[403][$propertyName] = null; } @@ -1851,7 +1857,7 @@ public function updateProperties($uri, array $properties) // The node has detailed update information // We need to merge the results with the earlier results. - foreach ($updateResult as $status => $props) { + foreach($updateResult as $status => $props) { if (is_array($props)) { if (!isset($result[$status])) $result[$status] = array(); @@ -1868,14 +1874,14 @@ public function updateProperties($uri, array $properties) } - foreach ($remainingProperties as $propertyName=>$value) { + foreach($remainingProperties as $propertyName=>$value) { // if there are remaining properties, it must mean // there's a dependency failure $result[424][$propertyName] = null; } // Removing empty array values - foreach ($result as $status=>$props) { + foreach($result as $status=>$props) { if (count($props)===0) unset($result[$status]); @@ -1910,8 +1916,8 @@ public function updateProperties($uri, array $properties) * @param bool $handleAsGET * @return bool */ - public function checkPreconditions($handleAsGET = false) - { + public function checkPreconditions($handleAsGET = false) { + $uri = $this->getRequestUri(); $node = null; $lastMod = null; @@ -1935,7 +1941,7 @@ public function checkPreconditions($handleAsGET = false) // There can be multiple etags $ifMatch = explode(',',$ifMatch); $haveMatch = false; - foreach ($ifMatch as $ifMatchItem) { + foreach($ifMatch as $ifMatchItem) { // Stripping any extra spaces $ifMatchItem = trim($ifMatchItem,' '); @@ -1981,7 +1987,7 @@ public function checkPreconditions($handleAsGET = false) $ifNoneMatch = explode(',', $ifNoneMatch); $etag = $node->getETag(); - foreach ($ifNoneMatch as $ifNoneMatchItem) { + foreach($ifNoneMatch as $ifNoneMatchItem) { // Stripping any extra spaces $ifNoneMatchItem = trim($ifNoneMatchItem,' '); @@ -2068,21 +2074,21 @@ public function checkPreconditions($handleAsGET = false) * @param bool strip404s * @return string */ - public function generateMultiStatus(array $fileProperties, $strip404s = false) - { + public function generateMultiStatus(array $fileProperties, $strip404s = false) { + $dom = new \DOMDocument('1.0','utf-8'); //$dom->formatOutput = true; $multiStatus = $dom->createElement('d:multistatus'); $dom->appendChild($multiStatus); // Adding in default namespaces - foreach ($this->xmlNamespaces as $namespace=>$prefix) { + foreach($this->xmlNamespaces as $namespace=>$prefix) { $multiStatus->setAttribute('xmlns:' . $prefix,$namespace); } - foreach ($fileProperties as $entry) { + foreach($fileProperties as $entry) { $href = $entry['href']; unset($entry['href']); @@ -2113,14 +2119,14 @@ public function generateMultiStatus(array $fileProperties, $strip404s = false) * @param string $body xml body * @return array list of properties in need of updating or deletion */ - public function parsePropPatchRequest($body) - { + public function parsePropPatchRequest($body) { + //We'll need to change the DAV namespace declaration to something else in order to make it parsable $dom = XMLUtil::loadDOMDocument($body); $newProperties = array(); - foreach ($dom->firstChild->childNodes as $child) { + foreach($dom->firstChild->childNodes as $child) { if ($child->nodeType !== XML_ELEMENT_NODE) continue; @@ -2130,7 +2136,7 @@ public function parsePropPatchRequest($body) $innerProperties = XMLUtil::parseProperties($child, $this->propertyMap); - foreach ($innerProperties as $propertyName=>$propertyValue) { + foreach($innerProperties as $propertyName=>$propertyValue) { if ($operation==='{DAV:}remove') { $propertyValue = null; @@ -2155,8 +2161,8 @@ public function parsePropPatchRequest($body) * @param string $body * @return array */ - public function parsePropFindRequest($body) - { + public function parsePropFindRequest($body) { + // If the propfind body was empty, it means IE is requesting 'all' properties if (!$body) return array(); @@ -2169,3 +2175,4 @@ public function parsePropFindRequest($body) // }}} } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/ServerPlugin.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/ServerPlugin.php index de2ece3eb0..c393f43fbd 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/ServerPlugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/ServerPlugin.php @@ -7,12 +7,12 @@ * * Plugins can modify or extend the servers behaviour. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class ServerPlugin -{ +abstract class ServerPlugin { + /** * This initializes the plugin. * @@ -34,8 +34,8 @@ abstract public function initialize(Server $server); * * @return array */ - public function getFeatures() - { + public function getFeatures() { + return array(); } @@ -50,8 +50,8 @@ public function getFeatures() * @param string $uri * @return array */ - public function getHTTPMethods($uri) - { + public function getHTTPMethods($uri) { + return array(); } @@ -64,8 +64,8 @@ public function getHTTPMethods($uri) * * @return string */ - public function getPluginName() - { + public function getPluginName() { + return get_class($this); } @@ -80,10 +80,11 @@ public function getPluginName() * @param string $uri * @return array */ - public function getSupportedReportSet($uri) - { + public function getSupportedReportSet($uri) { + return array(); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/SimpleCollection.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/SimpleCollection.php index f1388cee2a..1bdb166c7f 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/SimpleCollection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/SimpleCollection.php @@ -8,12 +8,12 @@ * The SimpleCollection is used to quickly setup static directory structures. * Just create the object with a proper name, and add children to use it. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SimpleCollection extends Collection -{ +class SimpleCollection extends Collection { + /** * List of childnodes * @@ -37,10 +37,10 @@ class SimpleCollection extends Collection * @param string $name * @param array $children */ - public function __construct($name,array $children = array()) - { + public function __construct($name,array $children = array()) { + $this->name = $name; - foreach ($children as $child) { + foreach($children as $child) { if (!($child instanceof INode)) throw new Exception('Only instances of Sabre\DAV\INode are allowed to be passed in the children argument'); $this->addChild($child); @@ -55,8 +55,8 @@ public function __construct($name,array $children = array()) * @param INode $child * @return void */ - public function addChild(INode $child) - { + public function addChild(INode $child) { + $this->children[$child->getName()] = $child; } @@ -66,8 +66,8 @@ public function addChild(INode $child) * * @return string */ - public function getName() - { + public function getName() { + return $this->name; } @@ -85,8 +85,8 @@ public function getName() * @throws Exception\NotFound * @return INode */ - public function getChild($name) - { + public function getChild($name) { + if (isset($this->children[$name])) return $this->children[$name]; throw new Exception\NotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\''); @@ -97,11 +97,12 @@ public function getChild($name) * * @return array */ - public function getChildren() - { + public function getChildren() { + return array_values($this->children); } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/SimpleFile.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/SimpleFile.php index 4aeb7d03bc..b7413fdded 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/SimpleFile.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/SimpleFile.php @@ -9,12 +9,12 @@ * the directory structure. One usecase would be to add a 'readme.txt' to a * root of a webserver with some standard content. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SimpleFile extends File -{ +class SimpleFile extends File { + /** * File contents * @@ -46,8 +46,8 @@ class SimpleFile extends File * @param string $contents * @param string|null $mimeType */ - public function __construct($name, $contents, $mimeType = null) - { + public function __construct($name, $contents, $mimeType = null) { + $this->name = $name; $this->contents = $contents; $this->mimeType = $mimeType; @@ -61,8 +61,8 @@ public function __construct($name, $contents, $mimeType = null) * * @return string */ - public function getName() - { + public function getName() { + return $this->name; } @@ -74,8 +74,8 @@ public function getName() * * @return mixed */ - public function get() - { + public function get() { + return $this->contents; } @@ -85,8 +85,8 @@ public function get() * * @return int */ - public function getSize() - { + public function getSize() { + return strlen($this->contents); } @@ -100,8 +100,8 @@ public function getSize() * Return null if the ETag can not effectively be determined * @return string */ - public function getETag() - { + public function getETag() { + return '"' . md5($this->contents) . '"'; } @@ -112,8 +112,8 @@ public function getETag() * If null is returned, we'll assume application/octet-stream * @return string */ - public function getContentType() - { + public function getContentType() { + return $this->mimeType; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/StringUtil.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/StringUtil.php index c68f0b5b61..c71575f490 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/StringUtil.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/StringUtil.php @@ -9,12 +9,12 @@ * the CalDAV calendar-query REPORT, and CardDAV addressbook-query REPORT. * Because they both need it, it was decided to put it in Sabre\DAV instead. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class StringUtil -{ +class StringUtil { + /** * Checks if a needle occurs in a haystack ;) * @@ -24,9 +24,9 @@ class StringUtil * @param string $matchType * @return bool */ - public static function textMatch($haystack, $needle, $collation, $matchType = 'contains') - { - switch ($collation) { + static public function textMatch($haystack, $needle, $collation, $matchType = 'contains') { + + switch($collation) { case 'i;ascii-casemap' : // default strtolower takes locale into consideration @@ -49,7 +49,7 @@ public static function textMatch($haystack, $needle, $collation, $matchType = 'c } - switch ($matchType) { + switch($matchType) { case 'contains' : return strpos($haystack, $needle)!==false; @@ -76,8 +76,8 @@ public static function textMatch($haystack, $needle, $collation, $matchType = 'c * @param string $input * @return string */ - public static function ensureUTF8($input) - { + static public function ensureUTF8($input) { + $encoding = mb_detect_encoding($input , array('UTF-8','ISO-8859-1'), true); if ($encoding === 'ISO-8859-1') { diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/TemporaryFileFilterPlugin.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/TemporaryFileFilterPlugin.php index 49acc8291e..37f976b7b4 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/TemporaryFileFilterPlugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/TemporaryFileFilterPlugin.php @@ -22,12 +22,12 @@ * Additional patterns can be added, by adding on to the * temporaryFilePatterns property. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class TemporaryFileFilterPlugin extends ServerPlugin -{ +class TemporaryFileFilterPlugin extends ServerPlugin { + /** * This is the list of patterns we intercept. * If new patterns are added, they must be valid patterns for preg_match. @@ -68,8 +68,8 @@ class TemporaryFileFilterPlugin extends ServerPlugin * * @param string|null $dataDir */ - public function __construct($dataDir = null) - { + public function __construct($dataDir = null) { + if (!$dataDir) $dataDir = ini_get('session.save_path').'/sabredav/'; if (!is_dir($dataDir)) mkdir($dataDir); $this->dataDir = $dataDir; @@ -85,8 +85,8 @@ public function __construct($dataDir = null) * @param Server $server * @return void */ - public function initialize(Server $server) - { + public function initialize(Server $server) { + $this->server = $server; $server->subscribeEvent('beforeMethod',array($this,'beforeMethod')); $server->subscribeEvent('beforeCreateFile',array($this,'beforeCreateFile')); @@ -103,12 +103,12 @@ public function initialize(Server $server) * @param string $uri * @return bool */ - public function beforeMethod($method, $uri) - { + public function beforeMethod($method, $uri) { + if (!$tempLocation = $this->isTempFile($uri)) return true; - switch ($method) { + switch($method) { case 'GET' : return $this->httpGet($tempLocation); case 'PUT' : @@ -132,8 +132,8 @@ public function beforeMethod($method, $uri) * @param resource $data * @return bool */ - public function beforeCreateFile($uri,$data) - { + public function beforeCreateFile($uri,$data) { + if ($tempPath = $this->isTempFile($uri)) { $hR = $this->server->httpResponse; @@ -153,12 +153,12 @@ public function beforeCreateFile($uri,$data) * @param string $path * @return boolean|string */ - protected function isTempFile($path) - { + protected function isTempFile($path) { + // We're only interested in the basename. list(, $tempPath) = URLUtil::splitPath($path); - foreach ($this->temporaryFilePatterns as $tempFile) { + foreach($this->temporaryFilePatterns as $tempFile) { if (preg_match($tempFile,$tempPath)) { return $this->getDataDir() . '/sabredav_' . md5($path) . '.tempfile'; @@ -179,8 +179,8 @@ protected function isTempFile($path) * @param string $tempLocation * @return bool */ - public function httpGet($tempLocation) - { + public function httpGet($tempLocation) { + if (!file_exists($tempLocation)) return true; $hR = $this->server->httpResponse; @@ -199,8 +199,8 @@ public function httpGet($tempLocation) * @param string $tempLocation * @return bool */ - public function httpPut($tempLocation) - { + public function httpPut($tempLocation) { + $hR = $this->server->httpResponse; $hR->setHeader('X-Sabre-Temp','true'); @@ -225,8 +225,8 @@ public function httpPut($tempLocation) * @param string $tempLocation * @return bool */ - public function httpDelete($tempLocation) - { + public function httpDelete($tempLocation) { + if (!file_exists($tempLocation)) return true; unlink($tempLocation); @@ -248,8 +248,8 @@ public function httpDelete($tempLocation) * @param string $uri * @return bool */ - public function httpPropfind($tempLocation, $uri) - { + public function httpPropfind($tempLocation, $uri) { + if (!file_exists($tempLocation)) return true; $hR = $this->server->httpResponse; diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Tree.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Tree.php index 17846a2442..ab94168b29 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Tree.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Tree.php @@ -5,12 +5,12 @@ /** * Abstract tree object * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class Tree -{ +abstract class Tree { + /** * This function must return an INode object for a path * If a Path doesn't exist, thrown a Exception_NotFound @@ -19,7 +19,7 @@ abstract class Tree * @throws Exception\NotFound * @return INode */ - abstract public function getNodeForPath($path); + abstract function getNodeForPath($path); /** * This function allows you to check if a node exists. @@ -30,8 +30,8 @@ abstract public function getNodeForPath($path); * @param string $path * @return bool */ - public function nodeExists($path) - { + public function nodeExists($path) { + try { $this->getNodeForPath($path); @@ -52,8 +52,8 @@ public function nodeExists($path) * @param string $destinationPath The full destination path * @return void */ - public function copy($sourcePath, $destinationPath) - { + public function copy($sourcePath, $destinationPath) { + $sourceNode = $this->getNodeForPath($sourcePath); // grab the dirname and basename components @@ -73,8 +73,8 @@ public function copy($sourcePath, $destinationPath) * @param string $destinationPath The full destination path, so not just the destination parent node * @return int */ - public function move($sourcePath, $destinationPath) - { + public function move($sourcePath, $destinationPath) { + list($sourceDir, $sourceName) = URLUtil::splitPath($sourcePath); list($destinationDir, $destinationName) = URLUtil::splitPath($destinationPath); @@ -96,8 +96,8 @@ public function move($sourcePath, $destinationPath) * @param string $path * @return void */ - public function delete($path) - { + public function delete($path) { + $node = $this->getNodeForPath($path); $node->delete(); @@ -112,8 +112,8 @@ public function delete($path) * @param string $path * @return array */ - public function getChildren($path) - { + public function getChildren($path) { + $node = $this->getNodeForPath($path); return $node->getChildren(); @@ -137,8 +137,9 @@ public function getChildren($path) * @param string $path * @return void */ - public function markDirty($path) - { + public function markDirty($path) { + + } /** @@ -149,8 +150,8 @@ public function markDirty($path) * @param string $destinationName * @return void */ - protected function copyNode(INode $source,ICollection $destinationParent,$destinationName = null) - { + protected function copyNode(INode $source,ICollection $destinationParent,$destinationName = null) { + if (!$destinationName) $destinationName = $source->getName(); if ($source instanceof IFile) { @@ -172,7 +173,7 @@ protected function copyNode(INode $source,ICollection $destinationParent,$destin $destinationParent->createDirectory($destinationName); $destination = $destinationParent->getChild($destinationName); - foreach ($source->getChildren() as $child) { + foreach($source->getChildren() as $child) { $this->copyNode($child,$destination); @@ -189,3 +190,4 @@ protected function copyNode(INode $source,ICollection $destinationParent,$destin } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Tree/Filesystem.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Tree/Filesystem.php index 03cccee3f9..a477725a5c 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Tree/Filesystem.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Tree/Filesystem.php @@ -13,12 +13,12 @@ * * Specifically copying and moving are much, much faster. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Filesystem extends DAV\Tree -{ +class Filesystem extends DAV\Tree { + /** * Base url on the filesystem. * @@ -33,8 +33,8 @@ class Filesystem extends DAV\Tree * * @param string $basePath */ - public function __construct($basePath) - { + public function __construct($basePath) { + $this->basePath = $basePath; } @@ -45,10 +45,10 @@ public function __construct($basePath) * @param string $path * @return DAV\FS\Node */ - public function getNodeForPath($path) - { + public function getNodeForPath($path) { + $realPath = $this->getRealPath($path); - if (!file_exists($realPath)) { + if (!file_exists($realPath)) { throw new DAV\Exception\NotFound('File at location ' . $realPath . ' not found'); } if (is_dir($realPath)) { @@ -65,8 +65,8 @@ public function getNodeForPath($path) * @param string $publicPath * @return string */ - protected function getRealPath($publicPath) - { + protected function getRealPath($publicPath) { + return rtrim($this->basePath,'/') . '/' . trim($publicPath,'/'); } @@ -81,8 +81,8 @@ protected function getRealPath($publicPath) * @param string $destination * @return void */ - public function copy($source,$destination) - { + public function copy($source,$destination) { + $source = $this->getRealPath($source); $destination = $this->getRealPath($destination); $this->realCopy($source,$destination); @@ -96,13 +96,13 @@ public function copy($source,$destination) * @param string $destination * @return void */ - protected function realCopy($source,$destination) - { + protected function realCopy($source,$destination) { + if (is_file($source)) { copy($source,$destination); } else { mkdir($destination); - foreach (scandir($source) as $subnode) { + foreach(scandir($source) as $subnode) { if ($subnode=='.' || $subnode=='..') continue; $this->realCopy($source.'/'.$subnode,$destination.'/'.$subnode); @@ -121,8 +121,8 @@ protected function realCopy($source,$destination) * @param string $destination * @return void */ - public function move($source,$destination) - { + public function move($source,$destination) { + $source = $this->getRealPath($source); $destination = $this->getRealPath($destination); rename($source,$destination); @@ -130,3 +130,4 @@ public function move($source,$destination) } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/URLUtil.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/URLUtil.php index 8c8e846da6..b7254e9a17 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/URLUtil.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/URLUtil.php @@ -14,12 +14,15 @@ * ). Since these are reserved, but don't have a reserved meaning in url, these characters are * kept as-is. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * It was also discovered that versions of the SOGO connector for thunderbird + * has issues with urlencoded colons. + * + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class URLUtil -{ +class URLUtil { + /** * Encodes the path of a url. * @@ -28,9 +31,9 @@ class URLUtil * @param string $path * @return string */ - public static function encodePath($path) - { - return preg_replace_callback('/([^A-Za-z0-9_\-\.~\(\)\/])/',function($match) { + static function encodePath($path) { + + return preg_replace_callback('/([^A-Za-z0-9_\-\.~\(\)\/:])/',function($match) { return '%'.sprintf('%02x',ord($match[0])); @@ -46,9 +49,9 @@ public static function encodePath($path) * @param string $pathSegment * @return string */ - public static function encodePathSegment($pathSegment) - { - return preg_replace_callback('/([^A-Za-z0-9_\-\.~\(\)])/',function($match) { + static function encodePathSegment($pathSegment) { + + return preg_replace_callback('/([^A-Za-z0-9_\-\.~\(\):])/',function($match) { return '%'.sprintf('%02x',ord($match[0])); @@ -61,8 +64,8 @@ public static function encodePathSegment($pathSegment) * @param string $path * @return string */ - public static function decodePath($path) - { + static function decodePath($path) { + return self::decodePathSegment($path); } @@ -73,12 +76,12 @@ public static function decodePath($path) * @param string $path * @return string */ - public static function decodePathSegment($path) - { + static function decodePathSegment($path) { + $path = rawurldecode($path); $encoding = mb_detect_encoding($path, array('UTF-8','ISO-8859-1')); - switch ($encoding) { + switch($encoding) { case 'ISO-8859-1' : $path = utf8_encode($path); @@ -107,10 +110,10 @@ public static function decodePathSegment($path) * @param string $path * @return array */ - public static function splitPath($path) - { + static function splitPath($path) { + $matches = array(); - if (preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u',$path,$matches)) { + if(preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u',$path,$matches)) { return array($matches[1],$matches[2]); } else { return array(null,null); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/UUIDUtil.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/UUIDUtil.php index cb570beea0..6a904a7bc2 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/UUIDUtil.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/UUIDUtil.php @@ -9,12 +9,12 @@ * UUIDs are used a decent amount within various *DAV standards, so it made * sense to include it. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class UUIDUtil -{ +class UUIDUtil { + /** * Returns a pseudo-random v4 UUID * @@ -23,8 +23,8 @@ class UUIDUtil * @see http://www.php.net/manual/en/function.uniqid.php#94959 * @return string */ - public static function getUUID() - { + static function getUUID() { + return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), @@ -52,8 +52,8 @@ public static function getUUID() * @param string $uuid * @return bool */ - public static function validateUUID($uuid) - { + static function validateUUID($uuid) { + return preg_match( '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $uuid diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/Version.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/Version.php index a68d61d91d..afe603c3cd 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/Version.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/Version.php @@ -5,16 +5,16 @@ /** * This class contains the SabreDAV version constants. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Version -{ +class Version { + /** * Full version number */ - const VERSION = '1.8.5'; + const VERSION = '1.8.10'; /** * Stability : alpha, beta, stable diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAV/XMLUtil.php b/core/src/core/classes/sabredav/lib/Sabre/DAV/XMLUtil.php index b0236fefd1..2bf81b3b86 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAV/XMLUtil.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAV/XMLUtil.php @@ -5,12 +5,12 @@ /** * XML utilities for WebDAV * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class XMLUtil -{ +class XMLUtil { + /** * Returns the 'clark notation' for an element. * @@ -29,8 +29,8 @@ class XMLUtil * @param \DOMNode $dom * @return string */ - public static function toClarkNotation(\DOMNode $dom) - { + static function toClarkNotation(\DOMNode $dom) { + if ($dom->nodeType !== XML_ELEMENT_NODE) return null; // Mapping back to the real namespace, in case it was dav @@ -51,8 +51,8 @@ public static function toClarkNotation(\DOMNode $dom) * @throws InvalidArgumentException * @return array */ - public static function parseClarkNotation($str) - { + static function parseClarkNotation($str) { + if (!preg_match('/^{([^}]*)}(.*)$/',$str,$matches)) { throw new \InvalidArgumentException('\'' . $str . '\' is not a valid clark-notation formatted string'); } @@ -74,8 +74,8 @@ public static function parseClarkNotation($str) * @param string $xmlDocument * @return array|string|null */ - public static function convertDAVNamespace($xmlDocument) - { + static function convertDAVNamespace($xmlDocument) { + // This is used to map the DAV: namespace to urn:DAV. This is needed, because the DAV: // namespace is actually a violation of the XML namespaces specification, and will cause errors return preg_replace("/xmlns(:[A-Za-z0-9_]*)?=(\"|\')DAV:(\\2)/","xmlns\\1=\\2urn:DAV\\2",$xmlDocument); @@ -92,8 +92,8 @@ public static function convertDAVNamespace($xmlDocument) * @throws Sabre\DAV\Exception\BadRequest * @return DOMDocument */ - public static function loadDOMDocument($xml) - { + static function loadDOMDocument($xml) { + if (empty($xml)) throw new Exception\BadRequest('Empty XML document sent'); @@ -113,6 +113,9 @@ public static function loadDOMDocument($xml) // Retaining old error setting $oldErrorSetting = libxml_use_internal_errors(true); + // Fixes an XXE vulnerability on PHP versions older than 5.3.23 or + // 5.4.13. + $oldEntityLoaderSetting = libxml_disable_entity_loader(true); // Clearing any previous errors libxml_clear_errors(); @@ -131,6 +134,7 @@ public static function loadDOMDocument($xml) // Restoring old mechanism for error handling if ($oldErrorSetting===false) libxml_use_internal_errors(false); + if ($oldEntityLoaderSetting===false) libxml_disable_entity_loader(false); return $dom; @@ -158,14 +162,14 @@ public static function loadDOMDocument($xml) * @param array $propertyMap * @return array */ - public static function parseProperties(\DOMElement $parentNode, array $propertyMap = array()) - { + static function parseProperties(\DOMElement $parentNode, array $propertyMap = array()) { + $propList = array(); - foreach ($parentNode->childNodes as $propNode) { + foreach($parentNode->childNodes as $propNode) { if (self::toClarkNotation($propNode)!=='{DAV:}prop') continue; - foreach ($propNode->childNodes as $propNodeData) { + foreach($propNode->childNodes as $propNodeData) { /* If there are no elements in here, we actually get 1 text node, this special case is dedicated to netdrive */ if ($propNodeData->nodeType != XML_ELEMENT_NODE) continue; diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/AbstractPrincipalCollection.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/AbstractPrincipalCollection.php index ed3a51f673..a116236f31 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/AbstractPrincipalCollection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/AbstractPrincipalCollection.php @@ -11,12 +11,12 @@ * * To use this class, simply implement the getChildForPrincipal method. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection -{ +abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection { + /** * Node or 'directory' name. * @@ -51,8 +51,8 @@ abstract class AbstractPrincipalCollection extends DAV\Collection implements IPr * @param PrincipalBackend\BackendInterface $principalBackend * @param string $principalPrefix */ - public function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') - { + public function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') { + $this->principalPrefix = $principalPrefix; $this->principalBackend = $principalBackend; @@ -68,15 +68,15 @@ public function __construct(PrincipalBackend\BackendInterface $principalBackend, * @param array $principalInfo * @return IPrincipal */ - abstract public function getChildForPrincipal(array $principalInfo); + abstract function getChildForPrincipal(array $principalInfo); /** * Returns the name of this collection. * * @return string */ - public function getName() - { + public function getName() { + list(,$name) = DAV\URLUtil::splitPath($this->principalPrefix); return $name; @@ -87,13 +87,13 @@ public function getName() * * @return array */ - public function getChildren() - { + public function getChildren() { + if ($this->disableListing) throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled'); $children = array(); - foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { + foreach($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) { $children[] = $this->getChildForPrincipal($principalInfo); @@ -110,8 +110,8 @@ public function getChildren() * @throws DAV\Exception\NotFound * @return IPrincipal */ - public function getChild($name) - { + public function getChild($name) { + $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name); if (!$principalInfo) throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found'); return $this->getChildForPrincipal($principalInfo); @@ -139,12 +139,12 @@ public function getChild($name) * @param array $searchProperties * @return array */ - public function searchPrincipals(array $searchProperties) - { + public function searchPrincipals(array $searchProperties) { + $result = $this->principalBackend->searchPrincipals($this->principalPrefix, $searchProperties); $r = array(); - foreach ($result as $row) { + foreach($result as $row) { list(, $r[]) = DAV\URLUtil::splitPath($row); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/AceConflict.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/AceConflict.php index 721c3f2083..6ee9afd73b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/AceConflict.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/AceConflict.php @@ -8,12 +8,12 @@ * This exception is thrown when a client attempts to set conflicting * permissions. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class AceConflict extends DAV\Exception\Conflict -{ +class AceConflict extends DAV\Exception\Conflict { + /** * Adds in extra information in the xml response. * @@ -23,8 +23,8 @@ class AceConflict extends DAV\Exception\Conflict * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:','d:no-ace-conflict'); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NeedPrivileges.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NeedPrivileges.php index 94bc423309..f7e4358839 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NeedPrivileges.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NeedPrivileges.php @@ -10,12 +10,12 @@ * The 403-need privileges is thrown when a user didn't have the appropriate * permissions to perform an operation * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class NeedPrivileges extends DAV\Exception\Forbidden -{ +class NeedPrivileges extends DAV\Exception\Forbidden { + /** * The relevant uri * @@ -36,8 +36,8 @@ class NeedPrivileges extends DAV\Exception\Forbidden * @param string $uri * @param array $privileges */ - public function __construct($uri,array $privileges) - { + public function __construct($uri,array $privileges) { + $this->uri = $uri; $this->privileges = $privileges; @@ -54,14 +54,14 @@ public function __construct($uri,array $privileges) * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:','d:need-privileges'); $errorNode->appendChild($np); - foreach ($this->privileges as $privilege) { + foreach($this->privileges as $privilege) { $resource = $doc->createElementNS('DAV:','d:resource'); $np->appendChild($resource); @@ -80,3 +80,4 @@ public function serialize(DAV\Server $server,\DOMElement $errorNode) } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NoAbstract.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NoAbstract.php index 83955f8586..ba6f76cdb5 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NoAbstract.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NoAbstract.php @@ -8,12 +8,12 @@ * This exception is thrown when a user tries to set a privilege that's marked * as abstract. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class NoAbstract extends DAV\Exception\PreconditionFailed -{ +class NoAbstract extends DAV\Exception\PreconditionFailed { + /** * Adds in extra information in the xml response. * @@ -23,8 +23,8 @@ class NoAbstract extends DAV\Exception\PreconditionFailed * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:','d:no-abstract'); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php index f03052decd..f61edef073 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NotRecognizedPrincipal.php @@ -8,12 +8,12 @@ * If a client tried to set a privilege assigned to a non-existant principal, * this exception will be thrown. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed -{ +class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed { + /** * Adds in extra information in the xml response. * @@ -23,8 +23,8 @@ class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:','d:recognized-principal'); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NotSupportedPrivilege.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NotSupportedPrivilege.php index b2ad741857..6d30698cd7 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NotSupportedPrivilege.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Exception/NotSupportedPrivilege.php @@ -8,12 +8,12 @@ * If a client tried to set a privilege that doesn't exist, this exception will * be thrown. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed -{ +class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed { + /** * Adds in extra information in the xml response. * @@ -23,8 +23,8 @@ class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed * @param \DOMElement $errorNode * @return void */ - public function serialize(DAV\Server $server,\DOMElement $errorNode) - { + public function serialize(DAV\Server $server,\DOMElement $errorNode) { + $doc = $errorNode->ownerDocument; $np = $doc->createElementNS('DAV:','d:not-supported-privilege'); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IACL.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IACL.php index 9a5bd037eb..088ca3eec8 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IACL.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IACL.php @@ -8,12 +8,12 @@ * * If you want to add WebDAV ACL to a node, you must implement this class * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IACL extends DAV\INode -{ +interface IACL extends DAV\INode { + /** * Returns the owner principal * @@ -21,7 +21,7 @@ interface IACL extends DAV\INode * * @return string|null */ - public function getOwner(); + function getOwner(); /** * Returns a group principal @@ -30,7 +30,7 @@ public function getOwner(); * * @return string|null */ - public function getGroup(); + function getGroup(); /** * Returns a list of ACE's for this node. @@ -44,7 +44,7 @@ public function getGroup(); * * @return array */ - public function getACL(); + function getACL(); /** * Updates the ACL @@ -54,7 +54,7 @@ public function getACL(); * @param array $acl * @return void */ - public function setACL(array $acl); + function setACL(array $acl); /** * Returns the list of supported privileges for this node. @@ -68,7 +68,7 @@ public function setACL(array $acl); * * @return array|null */ - public function getSupportedPrivilegeSet(); + function getSupportedPrivilegeSet(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IPrincipal.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IPrincipal.php index 6209b67b4d..d88a0289bd 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IPrincipal.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IPrincipal.php @@ -9,12 +9,12 @@ * * Implement this interface to define your own principals * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IPrincipal extends DAV\INode -{ +interface IPrincipal extends DAV\INode { + /** * Returns a list of alternative urls for a principal * @@ -22,14 +22,14 @@ interface IPrincipal extends DAV\INode * * @return array */ - public function getAlternateUriSet(); + function getAlternateUriSet(); /** * Returns the full principal url * * @return string */ - public function getPrincipalUrl(); + function getPrincipalUrl(); /** * Returns the list of group members @@ -39,7 +39,7 @@ public function getPrincipalUrl(); * * @return array */ - public function getGroupMemberSet(); + function getGroupMemberSet(); /** * Returns the list of groups this principal is member of @@ -49,7 +49,7 @@ public function getGroupMemberSet(); * * @return array */ - public function getGroupMembership(); + function getGroupMembership(); /** * Sets a list of group members @@ -62,7 +62,7 @@ public function getGroupMembership(); * @param array $principals * @return void */ - public function setGroupMemberSet(array $principals); + function setGroupMemberSet(array $principals); /** * Returns the displayname @@ -72,6 +72,6 @@ public function setGroupMemberSet(array $principals); * * @return string */ - public function getDisplayName(); + function getDisplayName(); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IPrincipalCollection.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IPrincipalCollection.php index a16672d40e..2c097f9d7c 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IPrincipalCollection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/IPrincipalCollection.php @@ -10,12 +10,12 @@ * Implement this interface to ensure that your principal collection can be * searched using the principal-property-search REPORT. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface IPrincipalCollection extends DAV\INode -{ +interface IPrincipalCollection extends DAV\INode { + /** * This method is used to search for principals matching a set of * properties. @@ -37,6 +37,6 @@ interface IPrincipalCollection extends DAV\INode * @param array $searchProperties * @return array */ - public function searchPrincipals(array $searchProperties); + function searchPrincipals(array $searchProperties); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Plugin.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Plugin.php index afb37cff5d..f9bf4bb441 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Plugin.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Plugin.php @@ -13,12 +13,12 @@ * property, defined in RFC5397 and the {DAV:}expand-property report, as * defined in RFC3253. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Plugin extends DAV\ServerPlugin -{ +class Plugin extends DAV\ServerPlugin { + /** * Recursion constants * @@ -118,8 +118,8 @@ class Plugin extends DAV\ServerPlugin * * @return array */ - public function getFeatures() - { + public function getFeatures() { + return array('access-control', 'calendarserver-principal-property-search'); } @@ -130,8 +130,8 @@ public function getFeatures() * @param string $uri * @return array */ - public function getMethods($uri) - { + public function getMethods($uri) { + return array('ACL'); } @@ -144,8 +144,8 @@ public function getMethods($uri) * * @return string */ - public function getPluginName() - { + public function getPluginName() { + return 'acl'; } @@ -160,8 +160,8 @@ public function getPluginName() * @param string $uri * @return array */ - public function getSupportedReportSet($uri) - { + public function getSupportedReportSet($uri) { + return array( '{DAV:}expand-property', '{DAV:}principal-property-search', @@ -185,8 +185,8 @@ public function getSupportedReportSet($uri) * @throws Sabre\DAVACL\Exception\NeedPrivileges * @return bool */ - public function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) - { + public function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true) { + if (!is_array($privileges)) $privileges = array($privileges); $acl = $this->getCurrentUserPrivilegeSet($uri); @@ -204,7 +204,7 @@ public function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, } $failed = array(); - foreach ($privileges as $priv) { + foreach($privileges as $priv) { if (!in_array($priv, $acl)) { $failed[] = $priv; @@ -230,8 +230,8 @@ public function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, * * @return string|null */ - public function getCurrentUserPrincipal() - { + public function getCurrentUserPrincipal() { + $authPlugin = $this->server->getPlugin('auth'); if (is_null($authPlugin)) return null; /** @var $authPlugin Sabre\DAV\Auth\Plugin */ @@ -239,7 +239,7 @@ public function getCurrentUserPrincipal() $userName = $authPlugin->getCurrentUser(); if (!$userName) return null; - return $this->defaultUsernamePath . '/' . $userName; + return $this->defaultUsernamePath . '/' . $userName; } @@ -250,8 +250,8 @@ public function getCurrentUserPrincipal() * * @return array */ - public function getCurrentUserPrincipals() - { + public function getCurrentUserPrincipals() { + $currentUser = $this->getCurrentUserPrincipal(); if (is_null($currentUser)) return array(); @@ -278,8 +278,8 @@ public function getCurrentUserPrincipals() * @param string $principal * @return array */ - public function getPrincipalMembership($mainPrincipal) - { + public function getPrincipalMembership($mainPrincipal) { + // First check our cache if (isset($this->principalMembershipCache[$mainPrincipal])) { return $this->principalMembershipCache[$mainPrincipal]; @@ -288,13 +288,13 @@ public function getPrincipalMembership($mainPrincipal) $check = array($mainPrincipal); $principals = array(); - while (count($check)) { + while(count($check)) { $principal = array_shift($check); $node = $this->server->tree->getNodeForPath($principal); if ($node instanceof IPrincipal) { - foreach ($node->getGroupMembership() as $groupMember) { + foreach($node->getGroupMembership() as $groupMember) { if (!in_array($groupMember, $principals)) { @@ -328,8 +328,8 @@ public function getPrincipalMembership($mainPrincipal) * @param string|DAV\INode $node * @return array */ - public function getSupportedPrivilegeSet($node) - { + public function getSupportedPrivilegeSet($node) { + if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -351,8 +351,8 @@ public function getSupportedPrivilegeSet($node) * * @return array */ - public static function getDefaultSupportedPrivilegeSet() - { + static function getDefaultSupportedPrivilegeSet() { + return array( 'privilege' => '{DAV:}all', 'abstract' => true, @@ -418,8 +418,8 @@ public static function getDefaultSupportedPrivilegeSet() * @param string|DAV\INode $node * @return array */ - final public function getFlatPrivilegeSet($node) - { + final public function getFlatPrivilegeSet($node) { + $privs = $this->getSupportedPrivilegeSet($node); $flat = array(); @@ -440,8 +440,8 @@ final public function getFlatPrivilegeSet($node) * @param array $flat * @return void */ - final private function getFPSTraverse($priv, $concrete, &$flat) - { + final private function getFPSTraverse($priv, $concrete, &$flat) { + $myPriv = array( 'privilege' => $priv['privilege'], 'abstract' => isset($priv['abstract']) && $priv['abstract'], @@ -456,7 +456,7 @@ final private function getFPSTraverse($priv, $concrete, &$flat) if (isset($priv['aggregates'])) { - foreach ($priv['aggregates'] as $subPriv) { + foreach($priv['aggregates'] as $subPriv) { $this->getFPSTraverse($subPriv, $myPriv['concrete'], $flat); @@ -476,8 +476,8 @@ final private function getFPSTraverse($priv, $concrete, &$flat) * @param string|DAV\INode $node * @return array */ - public function getACL($node) - { + public function getACL($node) { + if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -485,7 +485,7 @@ public function getACL($node) return null; } $acl = $node->getACL(); - foreach ($this->adminPrincipals as $adminPrincipal) { + foreach($this->adminPrincipals as $adminPrincipal) { $acl[] = array( 'principal' => $adminPrincipal, 'privilege' => '{DAV:}all', @@ -507,8 +507,8 @@ public function getACL($node) * @param string|DAV\INode $node * @return array */ - public function getCurrentUserPrivilegeSet($node) - { + public function getCurrentUserPrivilegeSet($node) { + if (is_string($node)) { $node = $this->server->tree->getNodeForPath($node); } @@ -521,11 +521,11 @@ public function getCurrentUserPrivilegeSet($node) $collected = array(); - foreach ($acl as $ace) { + foreach($acl as $ace) { $principal = $ace['principal']; - switch ($principal) { + switch($principal) { case '{DAV:}owner' : $owner = $node->getOwner(); @@ -565,12 +565,12 @@ public function getCurrentUserPrivilegeSet($node) $flat = $this->getFlatPrivilegeSet($node); $collected2 = array(); - while (count($collected)) { + while(count($collected)) { $current = array_pop($collected); $collected2[] = $current['privilege']; - foreach ($flat[$current['privilege']]['aggregates'] as $subPriv) { + foreach($flat[$current['privilege']]['aggregates'] as $subPriv) { $collected2[] = $subPriv; $collected[] = $flat[$subPriv]; } @@ -603,8 +603,8 @@ public function getCurrentUserPrivilegeSet($node) * properties are index by a HTTP status code. * */ - public function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null) - { + public function principalSearch(array $searchProperties, array $requestedProperties, $collectionUri = null) { + if (!is_null($collectionUri)) { $uris = array($collectionUri); } else { @@ -612,7 +612,7 @@ public function principalSearch(array $searchProperties, array $requestedPropert } $lookupResults = array(); - foreach ($uris as $uri) { + foreach($uris as $uri) { $principalCollection = $this->server->tree->getNodeForPath($uri); if (!$principalCollection instanceof IPrincipalCollection) { @@ -622,7 +622,7 @@ public function principalSearch(array $searchProperties, array $requestedPropert } $results = $principalCollection->searchPrincipals($searchProperties); - foreach ($results as $result) { + foreach($results as $result) { $lookupResults[] = rtrim($uri,'/') . '/' . $result; } @@ -630,7 +630,7 @@ public function principalSearch(array $searchProperties, array $requestedPropert $matches = array(); - foreach ($lookupResults as $lookupResult) { + foreach($lookupResults as $lookupResult) { list($matches[]) = $this->server->getPropertiesForPath($lookupResult, $requestedProperties, 0); @@ -648,8 +648,8 @@ public function principalSearch(array $searchProperties, array $requestedPropert * @param DAV\Server $server * @return void */ - public function initialize(DAV\Server $server) - { + public function initialize(DAV\Server $server) { + $this->server = $server; $server->subscribeEvent('beforeGetProperties',array($this,'beforeGetProperties')); @@ -696,14 +696,14 @@ public function initialize(DAV\Server $server) * @param string $uri * @return void */ - public function beforeMethod($method, $uri) - { + public function beforeMethod($method, $uri) { + $exists = $this->server->tree->nodeExists($uri); // If the node doesn't exists, none of these checks apply if (!$exists) return; - switch ($method) { + switch($method) { case 'GET' : case 'HEAD' : @@ -761,8 +761,8 @@ public function beforeMethod($method, $uri) * @param string $uri * @return void */ - public function beforeBind($uri) - { + public function beforeBind($uri) { + list($parentUri,$nodeName) = DAV\URLUtil::splitPath($uri); $this->checkPrivileges($parentUri,'{DAV:}bind'); @@ -777,8 +777,8 @@ public function beforeBind($uri) * @param string $uri * @return void */ - public function beforeUnbind($uri) - { + public function beforeUnbind($uri) { + list($parentUri,$nodeName) = DAV\URLUtil::splitPath($uri); $this->checkPrivileges($parentUri,'{DAV:}unbind',self::R_RECURSIVEPARENTS); @@ -792,8 +792,9 @@ public function beforeUnbind($uri) * @TODO: not yet implemented * @return void */ - public function beforeUnlock($uri, DAV\Locks\LockInfo $lock) - { + public function beforeUnlock($uri, DAV\Locks\LockInfo $lock) { + + } /** @@ -806,8 +807,8 @@ public function beforeUnlock($uri, DAV\Locks\LockInfo $lock) * @TODO really should be broken into multiple methods, or even a class. * @return bool */ - public function beforeGetProperties($uri, DAV\INode $node, &$requestedProperties, &$returnedProperties) - { + public function beforeGetProperties($uri, DAV\INode $node, &$requestedProperties, &$returnedProperties) { + // Checking the read permission if (!$this->checkPrivileges($uri,'{DAV:}read',self::R_PARENT,false)) { @@ -817,7 +818,7 @@ public function beforeGetProperties($uri, DAV\INode $node, &$requestedProperties } // Marking all requested properties as '403'. - foreach ($requestedProperties as $key=>$requestedProperty) { + foreach($requestedProperties as $key=>$requestedProperty) { unset($requestedProperties[$key]); $returnedProperties[403][$requestedProperty] = null; } @@ -951,8 +952,8 @@ public function beforeGetProperties($uri, DAV\INode $node, &$requestedProperties * @param DAV\INode $node * @return bool */ - public function updateProperties(&$propertyDelta, &$result, DAV\INode $node) - { + public function updateProperties(&$propertyDelta, &$result, DAV\INode $node) { + if (!array_key_exists('{DAV:}group-member-set', $propertyDelta)) return; @@ -992,9 +993,9 @@ public function updateProperties(&$propertyDelta, &$result, DAV\INode $node) * @param \DOMNode $dom * @return bool */ - public function report($reportName, $dom) - { - switch ($reportName) { + public function report($reportName, $dom) { + + switch($reportName) { case '{DAV:}principal-property-search' : $this->principalPropertySearchReport($dom); @@ -1018,8 +1019,8 @@ public function report($reportName, $dom) * @param string $uri * @return bool */ - public function unknownMethod($method, $uri) - { + public function unknownMethod($method, $uri) { + if ($method!=='ACL') return; $this->httpACL($uri); @@ -1033,8 +1034,8 @@ public function unknownMethod($method, $uri) * @param string $uri * @return void */ - public function httpACL($uri) - { + public function httpACL($uri) { + $body = $this->server->httpRequest->getBody(true); $dom = DAV\XMLUtil::loadDOMDocument($body); @@ -1043,7 +1044,7 @@ public function httpACL($uri) ->getPrivileges(); // Normalizing urls - foreach ($newAcl as $k=>$newAce) { + foreach($newAcl as $k=>$newAce) { $newAcl[$k]['principal'] = $this->server->calculateUri($newAce['principal']); } @@ -1059,12 +1060,12 @@ public function httpACL($uri) /* Checking if protected principals from the existing principal set are not overwritten. */ - foreach ($oldAcl as $oldAce) { + foreach($oldAcl as $oldAce) { if (!isset($oldAce['protected']) || !$oldAce['protected']) continue; $found = false; - foreach ($newAcl as $newAce) { + foreach($newAcl as $newAce) { if ( $newAce['privilege'] === $oldAce['privilege'] && $newAce['principal'] === $oldAce['principal'] && @@ -1078,7 +1079,7 @@ public function httpACL($uri) } - foreach ($newAcl as $newAce) { + foreach($newAcl as $newAce) { // Do we recognize the privilege if (!isset($supportedPrivileges[$newAce['privilege']])) { @@ -1122,8 +1123,8 @@ public function httpACL($uri) * @param \DOMElement $dom * @return void */ - protected function expandPropertyReport($dom) - { + protected function expandPropertyReport($dom) { + $requestedProperties = $this->parseExpandPropertyReportRequest($dom->firstChild->firstChild); $depth = $this->server->getHTTPDepth(0); $requestUri = $this->server->getRequestUri(); @@ -1136,13 +1137,13 @@ protected function expandPropertyReport($dom) $dom->appendChild($multiStatus); // Adding in default namespaces - foreach ($this->server->xmlNamespaces as $namespace=>$prefix) { + foreach($this->server->xmlNamespaces as $namespace=>$prefix) { $multiStatus->setAttribute('xmlns:' . $prefix,$namespace); } - foreach ($result as $response) { + foreach($result as $response) { $response->serialize($this->server, $multiStatus); } @@ -1160,8 +1161,8 @@ protected function expandPropertyReport($dom) * @param \DOMElement $node * @return array */ - protected function parseExpandPropertyReportRequest($node) - { + protected function parseExpandPropertyReportRequest($node) { + $requestedProperties = array(); do { @@ -1198,15 +1199,15 @@ protected function parseExpandPropertyReportRequest($node) * @param int $depth * @return array */ - protected function expandProperties($path, array $requestedProperties, $depth) - { + protected function expandProperties($path, array $requestedProperties, $depth) { + $foundProperties = $this->server->getPropertiesForPath($path, array_keys($requestedProperties), $depth); $result = array(); - foreach ($foundProperties as $node) { + foreach($foundProperties as $node) { - foreach ($requestedProperties as $propertyName=>$childRequestedProperties) { + foreach($requestedProperties as $propertyName=>$childRequestedProperties) { // We're only traversing if sub-properties were requested if(count($childRequestedProperties)===0) continue; @@ -1222,7 +1223,7 @@ protected function expandProperties($path, array $requestedProperties, $depth) } $childProps = array(); - foreach ($hrefs as $href) { + foreach($hrefs as $href) { $childProps = array_merge($childProps, $this->expandProperties($href, $childRequestedProperties, 0)); } $node[200][$propertyName] = new DAV\Property\ResponseList($childProps); @@ -1247,8 +1248,8 @@ protected function expandProperties($path, array $requestedProperties, $depth) * @param \DOMDocument $dom * @return void */ - protected function principalSearchPropertySetReport(\DOMDocument $dom) - { + protected function principalSearchPropertySetReport(\DOMDocument $dom) { + $httpDepth = $this->server->getHTTPDepth(0); if ($httpDepth!==0) { throw new DAV\Exception\BadRequest('This report is only defined when Depth: 0'); @@ -1262,7 +1263,7 @@ protected function principalSearchPropertySetReport(\DOMDocument $dom) $root = $dom->createElement('d:principal-search-property-set'); $dom->appendChild($root); // Adding in default namespaces - foreach ($this->server->xmlNamespaces as $namespace=>$prefix) { + foreach($this->server->xmlNamespaces as $namespace=>$prefix) { $root->setAttribute('xmlns:' . $prefix,$namespace); @@ -1270,7 +1271,7 @@ protected function principalSearchPropertySetReport(\DOMDocument $dom) $nsList = $this->server->xmlNamespaces; - foreach ($this->principalSearchPropertySet as $propertyName=>$description) { + foreach($this->principalSearchPropertySet as $propertyName=>$description) { $psp = $dom->createElement('d:principal-search-property'); $root->appendChild($psp); @@ -1309,8 +1310,8 @@ protected function principalSearchPropertySetReport(\DOMDocument $dom) * @param \DOMDocument $dom * @return void */ - protected function principalPropertySearchReport(\DOMDocument $dom) - { + protected function principalPropertySearchReport(\DOMDocument $dom) { + list($searchProperties, $requestedProperties, $applyToPrincipalCollectionSet) = $this->parsePrincipalPropertySearchReportRequest($dom); $uri = null; @@ -1341,8 +1342,8 @@ protected function principalPropertySearchReport(\DOMDocument $dom) * @param \DOMDocument $dom * @return array */ - protected function parsePrincipalPropertySearchReportRequest($dom) - { + protected function parsePrincipalPropertySearchReportRequest($dom) { + $httpDepth = $this->server->getHTTPDepth(0); if ($httpDepth!==0) { throw new DAV\Exception\BadRequest('This report is only defined when Depth: 0'); @@ -1353,7 +1354,7 @@ protected function parsePrincipalPropertySearchReportRequest($dom) $applyToPrincipalCollectionSet = false; // Parsing the search request - foreach ($dom->firstChild->childNodes as $searchNode) { + foreach($dom->firstChild->childNodes as $searchNode) { if (DAV\XMLUtil::toClarkNotation($searchNode) == '{DAV:}apply-to-principal-collection-set') { $applyToPrincipalCollectionSet = true; @@ -1365,9 +1366,9 @@ protected function parsePrincipalPropertySearchReportRequest($dom) $propertyName = null; $propertyValue = null; - foreach ($searchNode->childNodes as $childNode) { + foreach($searchNode->childNodes as $childNode) { - switch (DAV\XMLUtil::toClarkNotation($childNode)) { + switch(DAV\XMLUtil::toClarkNotation($childNode)) { case '{DAV:}prop' : $property = DAV\XMLUtil::parseProperties($searchNode); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Principal.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Principal.php index cd7b5e151f..89277f8508 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Principal.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Principal.php @@ -15,12 +15,12 @@ * This principal also has basic ACL settings, only allowing the principal * access it's own principal. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL -{ +class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL { + /** * Struct with principal information. * @@ -41,8 +41,8 @@ class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL * @param IPrincipalBackend $principalBackend * @param array $principalProperties */ - public function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = array()) - { + public function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = array()) { + if (!isset($principalProperties['uri'])) { throw new DAV\Exception('The principal properties must at least contain the \'uri\' key'); } @@ -56,8 +56,8 @@ public function __construct(PrincipalBackend\BackendInterface $principalBackend, * * @return string */ - public function getPrincipalUrl() - { + public function getPrincipalUrl() { + return $this->principalProperties['uri']; } @@ -69,8 +69,8 @@ public function getPrincipalUrl() * * @return array */ - public function getAlternateUriSet() - { + public function getAlternateUriSet() { + $uris = array(); if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) { @@ -94,8 +94,8 @@ public function getAlternateUriSet() * * @return array */ - public function getGroupMemberSet() - { + public function getGroupMemberSet() { + return $this->principalBackend->getGroupMemberSet($this->principalProperties['uri']); } @@ -108,8 +108,8 @@ public function getGroupMemberSet() * * @return array */ - public function getGroupMembership() - { + public function getGroupMembership() { + return $this->principalBackend->getGroupMemberShip($this->principalProperties['uri']); } @@ -126,8 +126,8 @@ public function getGroupMembership() * @param array $groupMembers * @return void */ - public function setGroupMemberSet(array $groupMembers) - { + public function setGroupMemberSet(array $groupMembers) { + $this->principalBackend->setGroupMemberSet($this->principalProperties['uri'], $groupMembers); } @@ -138,8 +138,8 @@ public function setGroupMemberSet(array $groupMembers) * * @return string */ - public function getName() - { + public function getName() { + $uri = $this->principalProperties['uri']; list(, $name) = DAV\URLUtil::splitPath($uri); return $name; @@ -151,8 +151,8 @@ public function getName() * * @return string */ - public function getDisplayName() - { + public function getDisplayName() { + if (isset($this->principalProperties['{DAV:}displayname'])) { return $this->principalProperties['{DAV:}displayname']; } else { @@ -167,10 +167,10 @@ public function getDisplayName() * @param array $requestedProperties * @return array */ - public function getProperties($requestedProperties) - { + public function getProperties($requestedProperties) { + $newProperties = array(); - foreach ($requestedProperties as $propName) { + foreach($requestedProperties as $propName) { if (isset($this->principalProperties[$propName])) { $newProperties[$propName] = $this->principalProperties[$propName]; @@ -184,13 +184,13 @@ public function getProperties($requestedProperties) /** * Updates this principals properties. - * + * * @param array $mutations * @see Sabre\DAV\IProperties::updateProperties * @return bool|array */ - public function updateProperties($mutations) - { + public function updateProperties($mutations) { + return $this->principalBackend->updatePrincipal($this->principalProperties['uri'], $mutations); } @@ -202,8 +202,8 @@ public function updateProperties($mutations) * * @return string|null */ - public function getOwner() - { + public function getOwner() { + return $this->principalProperties['uri']; @@ -216,8 +216,8 @@ public function getOwner() * * @return string|null */ - public function getGroup() - { + public function getGroup() { + return null; } @@ -234,8 +234,8 @@ public function getGroup() * * @return array */ - public function getACL() - { + public function getACL() { + return array( array( 'privilege' => '{DAV:}read', @@ -254,8 +254,8 @@ public function getACL() * @param array $acl * @return void */ - public function setACL(array $acl) - { + public function setACL(array $acl) { + throw new DAV\Exception\MethodNotAllowed('Updating ACLs is not allowed here'); } @@ -272,8 +272,8 @@ public function setACL(array $acl) * * @return array|null */ - public function getSupportedPrivilegeSet() - { + public function getSupportedPrivilegeSet() { + return null; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/AbstractBackend.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/AbstractBackend.php index a524f2eea4..984f9ad82f 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/AbstractBackend.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/AbstractBackend.php @@ -9,10 +9,10 @@ * have a non-bc-breaking way to add a default generic implementation to * functions we may add in the future. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractBackend implements BackendInterface -{ +abstract class AbstractBackend implements BackendInterface { + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/BackendInterface.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/BackendInterface.php index dcba71cfd2..d0416ac9cc 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/BackendInterface.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/BackendInterface.php @@ -9,12 +9,12 @@ * implement Sabre\DAVACL\IPrincipal directly. This interface is used solely by * Sabre\DAVACL\AbstractPrincipalCollection. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface -{ +interface BackendInterface { + /** * Returns a list of principals based on a prefix. * @@ -31,7 +31,7 @@ interface BackendInterface * @param string $prefixPath * @return array */ - public function getPrincipalsByPrefix($prefixPath); + function getPrincipalsByPrefix($prefixPath); /** * Returns a specific principal, specified by it's path. @@ -41,7 +41,7 @@ public function getPrincipalsByPrefix($prefixPath); * @param string $path * @return array */ - public function getPrincipalByPath($path); + function getPrincipalByPath($path); /** * Updates one ore more webdav properties on a principal. @@ -91,7 +91,7 @@ public function getPrincipalByPath($path); * @param array $mutations * @return array|bool */ - public function updatePrincipal($path, $mutations); + function updatePrincipal($path, $mutations); /** * This method is used to search for principals matching a set of @@ -121,7 +121,7 @@ public function updatePrincipal($path, $mutations); * @param array $searchProperties * @return array */ - public function searchPrincipals($prefixPath, array $searchProperties); + function searchPrincipals($prefixPath, array $searchProperties); /** * Returns the list of members for a group-principal @@ -129,7 +129,7 @@ public function searchPrincipals($prefixPath, array $searchProperties); * @param string $principal * @return array */ - public function getGroupMemberSet($principal); + function getGroupMemberSet($principal); /** * Returns the list of groups a principal is a member of @@ -137,7 +137,7 @@ public function getGroupMemberSet($principal); * @param string $principal * @return array */ - public function getGroupMembership($principal); + function getGroupMembership($principal); /** * Updates the list of group members for a group principal. @@ -148,6 +148,6 @@ public function getGroupMembership($principal); * @param array $members * @return void */ - public function setGroupMemberSet($principal, array $members); + function setGroupMemberSet($principal, array $members); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/PDO.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/PDO.php index 8590165bb4..0921768c37 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/PDO.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalBackend/PDO.php @@ -12,12 +12,12 @@ * This backend assumes all principals are in a single collection. The default collection * is 'principals/', but this can be overriden. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class PDO extends AbstractBackend -{ +class PDO extends AbstractBackend { + /** * pdo * @@ -79,8 +79,8 @@ class PDO extends AbstractBackend * @param string $tableName * @param string $groupMembersTableName */ - public function __construct(\PDO $pdo, $tableName = 'principals', $groupMembersTableName = 'groupmembers') - { + public function __construct(\PDO $pdo, $tableName = 'principals', $groupMembersTableName = 'groupmembers') { + $this->pdo = $pdo; $this->tableName = $tableName; $this->groupMembersTableName = $groupMembersTableName; @@ -104,20 +104,20 @@ public function __construct(\PDO $pdo, $tableName = 'principals', $groupMembersT * @param string $prefixPath * @return array */ - public function getPrincipalsByPrefix($prefixPath) - { + public function getPrincipalsByPrefix($prefixPath) { + $fields = array( 'uri', ); - foreach ($this->fieldMap as $key=>$value) { + foreach($this->fieldMap as $key=>$value) { $fields[] = $value['dbField']; } $result = $this->pdo->query('SELECT '.implode(',', $fields).' FROM '. $this->tableName); $principals = array(); - while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { + while($row = $result->fetch(\PDO::FETCH_ASSOC)) { // Checking if the principal is in the prefix list($rowPrefix) = DAV\URLUtil::splitPath($row['uri']); @@ -126,7 +126,7 @@ public function getPrincipalsByPrefix($prefixPath) $principal = array( 'uri' => $row['uri'], ); - foreach ($this->fieldMap as $key=>$value) { + foreach($this->fieldMap as $key=>$value) { if ($row[$value['dbField']]) { $principal[$key] = $row[$value['dbField']]; } @@ -147,14 +147,14 @@ public function getPrincipalsByPrefix($prefixPath) * @param string $path * @return array */ - public function getPrincipalByPath($path) - { + public function getPrincipalByPath($path) { + $fields = array( 'id', 'uri', ); - foreach ($this->fieldMap as $key=>$value) { + foreach($this->fieldMap as $key=>$value) { $fields[] = $value['dbField']; } $stmt = $this->pdo->prepare('SELECT '.implode(',', $fields).' FROM '. $this->tableName . ' WHERE uri = ?'); @@ -167,7 +167,7 @@ public function getPrincipalByPath($path) 'id' => $row['id'], 'uri' => $row['uri'], ); - foreach ($this->fieldMap as $key=>$value) { + foreach($this->fieldMap as $key=>$value) { if ($row[$value['dbField']]) { $principal[$key] = $row[$value['dbField']]; } @@ -224,10 +224,10 @@ public function getPrincipalByPath($path) * @param array $mutations * @return array|bool */ - public function updatePrincipal($path, $mutations) - { + public function updatePrincipal($path, $mutations) { + $updateAble = array(); - foreach ($mutations as $key=>$value) { + foreach($mutations as $key=>$value) { // We are not aware of this field, we must fail. if (!isset($this->fieldMap[$key])) { @@ -240,7 +240,7 @@ public function updatePrincipal($path, $mutations) ); // Adding the rest to the response as a 424 - foreach ($mutations as $subKey=>$subValue) { + foreach($mutations as $subKey=>$subValue) { if ($subKey !== $key) { $response[424][$subKey] = null; } @@ -256,7 +256,7 @@ public function updatePrincipal($path, $mutations) $query = "UPDATE " . $this->tableName . " SET "; $first = true; - foreach ($updateAble as $key => $value) { + foreach($updateAble as $key => $value) { if (!$first) { $query.= ', '; } @@ -300,13 +300,13 @@ public function updatePrincipal($path, $mutations) * @param array $searchProperties * @return array */ - public function searchPrincipals($prefixPath, array $searchProperties) - { + public function searchPrincipals($prefixPath, array $searchProperties) { + $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE 1=1 '; $values = array(); - foreach ($searchProperties as $property => $value) { + foreach($searchProperties as $property => $value) { - switch ($property) { + switch($property) { case '{DAV:}displayname' : $query.=' AND displayname LIKE ?'; @@ -327,7 +327,7 @@ public function searchPrincipals($prefixPath, array $searchProperties) $stmt->execute($values); $principals = array(); - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { // Checking if the principal is in the prefix list($rowPrefix) = DAV\URLUtil::splitPath($row['uri']); @@ -347,8 +347,8 @@ public function searchPrincipals($prefixPath, array $searchProperties) * @param string $principal * @return array */ - public function getGroupMemberSet($principal) - { + public function getGroupMemberSet($principal) { + $principal = $this->getPrincipalByPath($principal); if (!$principal) throw new DAV\Exception('Principal not found'); @@ -369,8 +369,8 @@ public function getGroupMemberSet($principal) * @param string $principal * @return array */ - public function getGroupMembership($principal) - { + public function getGroupMembership($principal) { + $principal = $this->getPrincipalByPath($principal); if (!$principal) throw new DAV\Exception('Principal not found'); @@ -394,8 +394,8 @@ public function getGroupMembership($principal) * @param array $members * @return void */ - public function setGroupMemberSet($principal, array $members) - { + public function setGroupMemberSet($principal, array $members) { + // Grabbing the list of principal id's. $stmt = $this->pdo->prepare('SELECT id, uri FROM '.$this->tableName.' WHERE uri IN (? ' . str_repeat(', ? ', count($members)) . ');'); $stmt->execute(array_merge(array($principal), $members)); @@ -403,7 +403,7 @@ public function setGroupMemberSet($principal, array $members) $memberIds = array(); $principalId = null; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { if ($row['uri'] == $principal) { $principalId = $row['id']; } else { @@ -416,7 +416,7 @@ public function setGroupMemberSet($principal, array $members) $stmt = $this->pdo->prepare('DELETE FROM '.$this->groupMembersTableName.' WHERE principal_id = ?;'); $stmt->execute(array($principalId)); - foreach ($memberIds as $memberId) { + foreach($memberIds as $memberId) { $stmt = $this->pdo->prepare('INSERT INTO '.$this->groupMembersTableName.' (principal_id, member_id) VALUES (?, ?);'); $stmt->execute(array($principalId, $memberId)); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalCollection.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalCollection.php index 29bc904959..3aadf399d3 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalCollection.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/PrincipalCollection.php @@ -8,12 +8,12 @@ * This collection represents a list of users. * The users are instances of Sabre\DAVACL\Principal * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class PrincipalCollection extends AbstractPrincipalCollection -{ +class PrincipalCollection extends AbstractPrincipalCollection { + /** * This method returns a node for a principal. * @@ -24,8 +24,8 @@ class PrincipalCollection extends AbstractPrincipalCollection * @param array $principal * @return \Sabre\DAV\INode */ - public function getChildForPrincipal(array $principal) - { + public function getChildForPrincipal(array $principal) { + return new Principal($this->principalBackend, $principal); } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/Acl.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/Acl.php index 58d4368602..e6a70ce911 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/Acl.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/Acl.php @@ -7,12 +7,12 @@ /** * This class represents the {DAV:}acl property * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Acl extends DAV\Property -{ +class Acl extends DAV\Property { + /** * List of privileges * @@ -45,8 +45,8 @@ class Acl extends DAV\Property * @param bool $prefixBaseUrl * @param array $privileges */ - public function __construct(array $privileges, $prefixBaseUrl = true) - { + public function __construct(array $privileges, $prefixBaseUrl = true) { + $this->privileges = $privileges; $this->prefixBaseUrl = $prefixBaseUrl; @@ -57,8 +57,8 @@ public function __construct(array $privileges, $prefixBaseUrl = true) * * @return array */ - public function getPrivileges() - { + public function getPrivileges() { + return $this->privileges; } @@ -70,10 +70,10 @@ public function getPrivileges() * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; - foreach ($this->privileges as $ace) { + foreach($this->privileges as $ace) { $this->serializeAce($doc, $node, $ace, $server); @@ -87,11 +87,11 @@ public function serialize(DAV\Server $server,\DOMElement $node) * @param \DOMElement $dom * @return Acl */ - public static function unserialize(\DOMElement $dom) - { + static public function unserialize(\DOMElement $dom) { + $privileges = array(); $xaces = $dom->getElementsByTagNameNS('urn:DAV','ace'); - for ($ii=0; $ii < $xaces->length; $ii++) { + for($ii=0; $ii < $xaces->length; $ii++) { $xace = $xaces->item($ii); $principal = $xace->getElementsByTagNameNS('urn:DAV','principal'); @@ -100,7 +100,7 @@ public static function unserialize(\DOMElement $dom) } $principal = Principal::unserialize($principal->item(0)); - switch ($principal->getType()) { + switch($principal->getType()) { case Principal::HREF : $principal = $principal->getHref(); break; @@ -129,7 +129,7 @@ public static function unserialize(\DOMElement $dom) $grant = $grants->item(0); $xprivs = $grant->getElementsByTagNameNS('urn:DAV','privilege'); - for ($jj=0; $jj<$xprivs->length; $jj++) { + for($jj=0; $jj<$xprivs->length; $jj++) { $xpriv = $xprivs->item($jj); @@ -170,14 +170,14 @@ public static function unserialize(\DOMElement $dom) * @param DAV\Server $server * @return void */ - private function serializeAce($doc,$node,$ace, DAV\Server $server) - { + private function serializeAce($doc,$node,$ace, DAV\Server $server) { + $xace = $doc->createElementNS('DAV:','d:ace'); $node->appendChild($xace); $principal = $doc->createElementNS('DAV:','d:principal'); $xace->appendChild($principal); - switch ($ace['principal']) { + switch($ace['principal']) { case '{DAV:}authenticated' : $principal->appendChild($doc->createElementNS('DAV:','d:authenticated')); break; diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/AclRestrictions.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/AclRestrictions.php index c9ae9d290f..aa6fd17d6b 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/AclRestrictions.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/AclRestrictions.php @@ -9,12 +9,12 @@ * * This property represents {DAV:}acl-restrictions, as defined in RFC3744. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class AclRestrictions extends DAV\Property -{ +class AclRestrictions extends DAV\Property { + /** * Serializes the property into a DOMElement * @@ -22,8 +22,8 @@ class AclRestrictions extends DAV\Property * @param \DOMElement $elem * @return void */ - public function serialize(DAV\Server $server,\DOMElement $elem) - { + public function serialize(DAV\Server $server,\DOMElement $elem) { + $doc = $elem->ownerDocument; $elem->appendChild($doc->createElementNS('DAV:','d:grant-only')); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php index 13d3ce24ad..e0501dbd60 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/CurrentUserPrivilegeSet.php @@ -10,12 +10,12 @@ * This class represents the current-user-privilege-set property. When * requested, it contain all the privileges a user has on a specific node. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class CurrentUserPrivilegeSet extends DAV\Property -{ +class CurrentUserPrivilegeSet extends DAV\Property { + /** * List of privileges * @@ -30,8 +30,8 @@ class CurrentUserPrivilegeSet extends DAV\Property * * @param array $privileges */ - public function __construct(array $privileges) - { + public function __construct(array $privileges) { + $this->privileges = $privileges; } @@ -43,10 +43,10 @@ public function __construct(array $privileges) * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; - foreach ($this->privileges as $privName) { + foreach($this->privileges as $privName) { $this->serializePriv($doc,$node,$privName); @@ -54,6 +54,18 @@ public function serialize(DAV\Server $server,\DOMElement $node) } + /** + * Returns true or false, whether the specified principal appears in the + * list. + * + * @return bool + */ + public function has($privilegeName) { + + return in_array($privilegeName, $this->privileges); + + } + /** * Serializes one privilege * @@ -62,8 +74,8 @@ public function serialize(DAV\Server $server,\DOMElement $node) * @param string $privName * @return void */ - protected function serializePriv($doc,$node,$privName) - { + protected function serializePriv($doc,$node,$privName) { + $xp = $doc->createElementNS('DAV:','d:privilege'); $node->appendChild($xp); @@ -74,4 +86,39 @@ protected function serializePriv($doc,$node,$privName) } + /** + * Unserializes the {DAV:}current-user-privilege-set element. + * + * @param DOMElement $node + * @return CurrentUserPrivilegeSet + */ + static public function unserialize(\DOMElement $node) { + + $result = array(); + + $xprivs = $node->getElementsByTagNameNS('urn:DAV','privilege'); + + for($jj=0; $jj<$xprivs->length; $jj++) { + + $xpriv = $xprivs->item($jj); + + $privilegeName = null; + + for ($kk=0;$kk<$xpriv->childNodes->length;$kk++) { + + $childNode = $xpriv->childNodes->item($kk); + if ($t = DAV\XMLUtil::toClarkNotation($childNode)) { + $privilegeName = $t; + break; + } + } + + $result[] = $privilegeName; + + } + + return new self($result); + + } + } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/Principal.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/Principal.php index 7cc183ab85..6c644b024a 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/Principal.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/Principal.php @@ -9,12 +9,12 @@ * The principal property represents a principal from RFC3744 (ACL). * The property can be used to specify a principal or pseudo principals. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Principal extends DAV\Property implements DAV\Property\IHref -{ +class Principal extends DAV\Property implements DAV\Property\IHref { + /** * To specify a not-logged-in user, use the UNAUTHENTICATED principal */ @@ -63,8 +63,8 @@ class Principal extends DAV\Property implements DAV\Property\IHref * @param int $type * @param string|null $href */ - public function __construct($type, $href = null) - { + public function __construct($type, $href = null) { + $this->type = $type; if ($type===self::HREF && is_null($href)) { @@ -79,8 +79,8 @@ public function __construct($type, $href = null) * * @return int */ - public function getType() - { + public function getType() { + return $this->type; } @@ -90,8 +90,8 @@ public function getType() * * @return string */ - public function getHref() - { + public function getHref() { + return $this->href; } @@ -103,10 +103,10 @@ public function getHref() * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server, \DOMElement $node) - { + public function serialize(DAV\Server $server, \DOMElement $node) { + $prefix = $server->xmlNamespaces['DAV:']; - switch ($this->type) { + switch($this->type) { case self::UNAUTHENTICATED : $node->appendChild( @@ -120,7 +120,7 @@ public function serialize(DAV\Server $server, \DOMElement $node) break; case self::HREF : $href = $node->ownerDocument->createElement($prefix . ':href'); - $href->nodeValue = $server->getBaseUri() . $this->href; + $href->nodeValue = $server->getBaseUri() . DAV\URLUtil::encodePath($this->href); $node->appendChild($href); break; @@ -134,14 +134,14 @@ public function serialize(DAV\Server $server, \DOMElement $node) * @param \DOMElement $dom * @return Principal */ - public static function unserialize(\DOMElement $dom) - { + static public function unserialize(\DOMElement $dom) { + $parent = $dom->firstChild; - while (!DAV\XMLUtil::toClarkNotation($parent)) { + while(!DAV\XMLUtil::toClarkNotation($parent)) { $parent = $parent->nextSibling; } - switch (DAV\XMLUtil::toClarkNotation($parent)) { + switch(DAV\XMLUtil::toClarkNotation($parent)) { case '{DAV:}unauthenticated' : return new self(self::UNAUTHENTICATED); diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/SupportedPrivilegeSet.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/SupportedPrivilegeSet.php index fc6a19a278..5f152d9e5e 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/SupportedPrivilegeSet.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Property/SupportedPrivilegeSet.php @@ -14,12 +14,12 @@ * Sabre\DAVACL\Plugin::getSupportedPrivilegeSet as the argument in its * constructor. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class SupportedPrivilegeSet extends DAV\Property -{ +class SupportedPrivilegeSet extends DAV\Property { + /** * privileges * @@ -32,8 +32,8 @@ class SupportedPrivilegeSet extends DAV\Property * * @param array $privileges */ - public function __construct(array $privileges) - { + public function __construct(array $privileges) { + $this->privileges = $privileges; } @@ -45,8 +45,8 @@ public function __construct(array $privileges) * @param \DOMElement $node * @return void */ - public function serialize(DAV\Server $server,\DOMElement $node) - { + public function serialize(DAV\Server $server,\DOMElement $node) { + $doc = $node->ownerDocument; $this->serializePriv($doc, $node, $this->privileges); @@ -62,8 +62,8 @@ public function serialize(DAV\Server $server,\DOMElement $node) * @param array $privilege * @return void */ - private function serializePriv($doc,$node,$privilege) - { + private function serializePriv($doc,$node,$privilege) { + $xsp = $doc->createElementNS('DAV:','d:supported-privilege'); $node->appendChild($xsp); @@ -84,7 +84,7 @@ private function serializePriv($doc,$node,$privilege) } if (isset($privilege['aggregates'])) { - foreach ($privilege['aggregates'] as $subPrivilege) { + foreach($privilege['aggregates'] as $subPrivilege) { $this->serializePriv($doc,$xsp,$subPrivilege); } } diff --git a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Version.php b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Version.php index 3486b8e4e4..344e22d7bd 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Version.php +++ b/core/src/core/classes/sabredav/lib/Sabre/DAVACL/Version.php @@ -5,16 +5,16 @@ /** * This class contains the SabreDAV version constants. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Version -{ +class Version { + /** * Full version number */ - const VERSION = '1.8.4'; + const VERSION = '1.8.7'; /** * Stability : alpha, beta, stable diff --git a/core/src/core/classes/sabredav/lib/Sabre/HTTP/AWSAuth.php b/core/src/core/classes/sabredav/lib/Sabre/HTTP/AWSAuth.php index d50c466421..603470fb40 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/HTTP/AWSAuth.php +++ b/core/src/core/classes/sabredav/lib/Sabre/HTTP/AWSAuth.php @@ -7,12 +7,12 @@ * * Use this class to leverage amazon's AWS authentication header * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class AWSAuth extends AbstractAuth -{ +class AWSAuth extends AbstractAuth { + /** * The signature supplied by the HTTP client * @@ -49,8 +49,8 @@ class AWSAuth extends AbstractAuth * * @return bool */ - public function init() - { + public function init() { + $authHeader = $this->httpRequest->getHeader('Authorization'); $authHeader = explode(' ',$authHeader); @@ -70,8 +70,8 @@ public function init() * * @return string */ - public function getAccessKey() - { + public function getAccessKey() { + return $this->accessKey; } @@ -82,8 +82,8 @@ public function getAccessKey() * @param string $secretKey * @return bool */ - public function validate($secretKey) - { + public function validate($secretKey) { + $contentMD5 = $this->httpRequest->getHeader('Content-MD5'); if ($contentMD5) { @@ -137,8 +137,8 @@ public function validate($secretKey) * * @return void */ - public function requireLogin() - { + public function requireLogin() { + $this->httpResponse->setHeader('WWW-Authenticate','AWS'); $this->httpResponse->sendStatus(401); @@ -156,8 +156,8 @@ public function requireLogin() * @param string $dateHeader * @return bool */ - protected function validateRFC2616Date($dateHeader) - { + protected function validateRFC2616Date($dateHeader) { + $date = Util::parseHTTPDate($dateHeader); // Unknown format @@ -184,11 +184,11 @@ protected function validateRFC2616Date($dateHeader) * * @return string */ - protected function getAmzHeaders() - { + protected function getAmzHeaders() { + $amzHeaders = array(); $headers = $this->httpRequest->getHeaders(); - foreach ($headers as $headerName => $headerValue) { + foreach($headers as $headerName => $headerValue) { if (strpos(strtolower($headerName),'x-amz-')===0) { $amzHeaders[strtolower($headerName)] = str_replace(array("\r\n"),array(' '),$headerValue) . "\n"; } @@ -196,7 +196,7 @@ protected function getAmzHeaders() ksort($amzHeaders); $headerStr = ''; - foreach ($amzHeaders as $h=>$v) { + foreach($amzHeaders as $h=>$v) { $headerStr.=$h.':'.$v; } @@ -211,8 +211,8 @@ protected function getAmzHeaders() * @param string $message * @return string */ - private function hmacsha1($key, $message) - { + private function hmacsha1($key, $message) { + $blocksize=64; if (strlen($key)>$blocksize) $key=pack('H*', sha1($key)); diff --git a/core/src/core/classes/sabredav/lib/Sabre/HTTP/AbstractAuth.php b/core/src/core/classes/sabredav/lib/Sabre/HTTP/AbstractAuth.php index f3509d3ff9..1ddf412b7e 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/HTTP/AbstractAuth.php +++ b/core/src/core/classes/sabredav/lib/Sabre/HTTP/AbstractAuth.php @@ -7,12 +7,12 @@ * * This class has the common functionality for BasicAuth and DigestAuth * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -abstract class AbstractAuth -{ +abstract class AbstractAuth { + /** * The realm will be displayed in the dialog boxes * @@ -41,8 +41,8 @@ abstract class AbstractAuth * __construct * */ - public function __construct() - { + public function __construct() { + $this->httpResponse = new Response(); $this->httpRequest = new Request(); @@ -54,8 +54,8 @@ public function __construct() * @param Response $response * @return void */ - public function setHTTPResponse(Response $response) - { + public function setHTTPResponse(Response $response) { + $this->httpResponse = $response; } @@ -66,8 +66,8 @@ public function setHTTPResponse(Response $response) * @param Request $request * @return void */ - public function setHTTPRequest(Request $request) - { + public function setHTTPRequest(Request $request) { + $this->httpRequest = $request; } @@ -82,8 +82,8 @@ public function setHTTPRequest(Request $request) * @param string $realm * @return void */ - public function setRealm($realm) - { + public function setRealm($realm) { + $this->realm = $realm; } @@ -93,8 +93,8 @@ public function setRealm($realm) * * @return string */ - public function getRealm() - { + public function getRealm() { + return $this->realm; } diff --git a/core/src/core/classes/sabredav/lib/Sabre/HTTP/BasicAuth.php b/core/src/core/classes/sabredav/lib/Sabre/HTTP/BasicAuth.php index 326bbc3039..659964faa1 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/HTTP/BasicAuth.php +++ b/core/src/core/classes/sabredav/lib/Sabre/HTTP/BasicAuth.php @@ -7,12 +7,12 @@ * * Use this class for easy http authentication setup * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class BasicAuth extends AbstractAuth -{ +class BasicAuth extends AbstractAuth { + /** * Returns the supplied username and password. * @@ -24,8 +24,8 @@ class BasicAuth extends AbstractAuth * * @return mixed */ - public function getUserPass() - { + public function getUserPass() { + // Apache and mod_php if (($user = $this->httpRequest->getRawServerValue('PHP_AUTH_USER')) && ($pass = $this->httpRequest->getRawServerValue('PHP_AUTH_PW'))) { @@ -57,8 +57,8 @@ public function getUserPass() * * @return void */ - public function requireLogin() - { + public function requireLogin() { + $this->httpResponse->setHeader('WWW-Authenticate','Basic realm="' . $this->realm . '"'); $this->httpResponse->sendStatus(401); diff --git a/core/src/core/classes/sabredav/lib/Sabre/HTTP/DigestAuth.php b/core/src/core/classes/sabredav/lib/Sabre/HTTP/DigestAuth.php index e6d323ab54..aae6d84d61 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/HTTP/DigestAuth.php +++ b/core/src/core/classes/sabredav/lib/Sabre/HTTP/DigestAuth.php @@ -21,12 +21,12 @@ * requireLogin() method. * * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class DigestAuth extends AbstractAuth -{ +class DigestAuth extends AbstractAuth { + /** * These constants are used in setQOP(); */ @@ -42,8 +42,8 @@ class DigestAuth extends AbstractAuth /** * Initializes the object */ - public function __construct() - { + public function __construct() { + $this->nonce = uniqid(); $this->opaque = md5($this->realm); parent::__construct(); @@ -57,8 +57,8 @@ public function __construct() * * @return void */ - public function init() - { + public function init() { + $digest = $this->getDigest(); $this->digestParts = $this->parseDigest($digest); @@ -80,8 +80,8 @@ public function init() * @param int $qop * @return void */ - public function setQOP($qop) - { + public function setQOP($qop) { + $this->qop = $qop; } @@ -94,8 +94,8 @@ public function setQOP($qop) * @param string $A1 * @return bool */ - public function validateA1($A1) - { + public function validateA1($A1) { + $this->A1 = $A1; return $this->validate(); @@ -108,8 +108,8 @@ public function validateA1($A1) * @param string $password * @return bool */ - public function validatePassword($password) - { + public function validatePassword($password) { + $this->A1 = md5($this->digestParts['username'] . ':' . $this->realm . ':' . $password); return $this->validate(); @@ -120,8 +120,8 @@ public function validatePassword($password) * * @return string */ - public function getUsername() - { + public function getUsername() { + return $this->digestParts['username']; } @@ -131,8 +131,8 @@ public function getUsername() * * @return bool */ - protected function validate() - { + protected function validate() { + $A2 = $this->httpRequest->getMethod() . ':' . $this->digestParts['uri']; if ($this->digestParts['qop']=='auth-int') { @@ -164,10 +164,10 @@ protected function validate() * * @return void */ - public function requireLogin() - { + public function requireLogin() { + $qop = ''; - switch ($this->qop) { + switch($this->qop) { case self::QOP_AUTH : $qop = 'auth'; break; case self::QOP_AUTHINT : $qop = 'auth-int'; break; case self::QOP_AUTH | self::QOP_AUTHINT : $qop = 'auth,auth-int'; break; @@ -188,8 +188,8 @@ public function requireLogin() * * @return mixed */ - public function getDigest() - { + public function getDigest() { + // mod_php $digest = $this->httpRequest->getRawServerValue('PHP_AUTH_DIGEST'); if ($digest) return $digest; @@ -220,8 +220,8 @@ public function getDigest() * @param string $digest * @return mixed */ - protected function parseDigest($digest) - { + protected function parseDigest($digest) { + // protect against missing data $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); $data = array(); diff --git a/core/src/core/classes/sabredav/lib/Sabre/HTTP/Request.php b/core/src/core/classes/sabredav/lib/Sabre/HTTP/Request.php index 76ac3102ef..a71a52b421 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/HTTP/Request.php +++ b/core/src/core/classes/sabredav/lib/Sabre/HTTP/Request.php @@ -12,12 +12,12 @@ * request per run it can operate as a singleton. For more information check out * the behaviour around 'defaultInputStream'. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Request -{ +class Request { + /** * PHP's $_SERVER data * @@ -48,7 +48,7 @@ class Request * * @var resource */ - public static $defaultInputStream=null; + static $defaultInputStream=null; /** * Sets up the object @@ -59,8 +59,8 @@ class Request * @param array $serverData * @param array $postData */ - public function __construct(array $serverData = null, array $postData = null) - { + public function __construct(array $serverData = null, array $postData = null) { + if ($serverData) $this->_SERVER = $serverData; else $this->_SERVER =& $_SERVER; @@ -77,8 +77,8 @@ public function __construct(array $serverData = null, array $postData = null) * @param string $name * @return string */ - public function getHeader($name) - { + public function getHeader($name) { + $name = strtoupper(str_replace(array('-'),array('_'),$name)); if (isset($this->_SERVER['HTTP_' . $name])) { return $this->_SERVER['HTTP_' . $name]; @@ -86,7 +86,7 @@ public function getHeader($name) // There's a few headers that seem to end up in the top-level // server array. - switch ($name) { + switch($name) { case 'CONTENT_TYPE' : case 'CONTENT_LENGTH' : if (isset($this->_SERVER[$name])) { @@ -107,12 +107,12 @@ public function getHeader($name) * * @return array */ - public function getHeaders() - { + public function getHeaders() { + $hdrs = array(); - foreach ($this->_SERVER as $key=>$value) { + foreach($this->_SERVER as $key=>$value) { - switch ($key) { + switch($key) { case 'CONTENT_LENGTH' : case 'CONTENT_TYPE' : $hdrs[strtolower(str_replace('_','-',$key))] = $value; @@ -137,8 +137,8 @@ public function getHeaders() * * @return string */ - public function getMethod() - { + public function getMethod() { + return $this->_SERVER['REQUEST_METHOD']; } @@ -148,8 +148,8 @@ public function getMethod() * * @return string */ - public function getUri() - { + public function getUri() { + return $this->_SERVER['REQUEST_URI']; } @@ -159,8 +159,8 @@ public function getUri() * * @return string */ - public function getAbsoluteUri() - { + public function getAbsoluteUri() { + // Checking if the request was made through HTTPS. The last in line is for IIS $protocol = isset($this->_SERVER['HTTPS']) && ($this->_SERVER['HTTPS']) && ($this->_SERVER['HTTPS']!='off'); return ($protocol?'https':'http') . '://' . $this->getHeader('Host') . $this->getUri(); @@ -172,8 +172,8 @@ public function getAbsoluteUri() * * @return string */ - public function getQueryString() - { + public function getQueryString() { + return isset($this->_SERVER['QUERY_STRING'])?$this->_SERVER['QUERY_STRING']:''; } @@ -187,8 +187,8 @@ public function getQueryString() * @param bool $asString * @return resource */ - public function getBody($asString = false) - { + public function getBody($asString = false) { + if (is_null($this->body)) { if (!is_null(self::$defaultInputStream)) { $this->body = self::$defaultInputStream; @@ -218,9 +218,9 @@ public function getBody($asString = false) * @param bool $setAsDefaultInputStream * @return void */ - public function setBody($body,$setAsDefaultInputStream = false) - { - if (is_resource($body)) { + public function setBody($body,$setAsDefaultInputStream = false) { + + if(is_resource($body)) { $this->body = $body; } else { @@ -244,8 +244,8 @@ public function setBody($body,$setAsDefaultInputStream = false) * * @return array */ - public function getPostVars() - { + public function getPostVars() { + return $this->_POST; } @@ -258,8 +258,8 @@ public function getPostVars() * @param string $field * @return string */ - public function getRawServerValue($field) - { + public function getRawServerValue($field) { + return isset($this->_SERVER[$field])?$this->_SERVER[$field]:null; } @@ -269,8 +269,8 @@ public function getRawServerValue($field) * * @return string */ - public function getHTTPVersion() - { + public function getHTTPVersion() { + $protocol = $this->getRawServerValue('SERVER_PROTOCOL'); if ($protocol==='HTTP/1.0') { return '1.0'; @@ -281,3 +281,4 @@ public function getHTTPVersion() } } + diff --git a/core/src/core/classes/sabredav/lib/Sabre/HTTP/Response.php b/core/src/core/classes/sabredav/lib/Sabre/HTTP/Response.php index 3d2615c7b0..a7fc0da126 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/HTTP/Response.php +++ b/core/src/core/classes/sabredav/lib/Sabre/HTTP/Response.php @@ -7,12 +7,12 @@ * * It contains the HTTP status code, response headers and a message body. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Response -{ +class Response { + /** * The HTTP version to return in the header() line. * @@ -30,8 +30,8 @@ class Response * @param int $code * @return string */ - public function getStatusMessage($code, $httpVersion = '1.1') - { + public function getStatusMessage($code, $httpVersion = '1.1') { + $msg = array( 100 => 'Continue', 101 => 'Switching Protocols', @@ -107,8 +107,8 @@ public function getStatusMessage($code, $httpVersion = '1.1') * @param int $code HTTP status code * @return bool */ - public function sendStatus($code) - { + public function sendStatus($code) { + if (!headers_sent()) return header($this->getStatusMessage($code, $this->defaultHttpVersion)); else return false; @@ -123,8 +123,8 @@ public function sendStatus($code) * @param bool $replace * @return bool */ - public function setHeader($name, $value, $replace = true) - { + public function setHeader($name, $value, $replace = true) { + $value = str_replace(array("\r","\n"),array('\r','\n'),$value); if (!headers_sent()) return header($name . ': ' . $value, $replace); @@ -142,8 +142,8 @@ public function setHeader($name, $value, $replace = true) * @param array $headers * @return void */ - public function setHeaders(array $headers) - { + public function setHeaders(array $headers) { + foreach($headers as $key=>$value) $this->setHeader($key, $value); @@ -157,11 +157,11 @@ public function setHeaders(array $headers) * @param mixed $body * @return void */ - public function sendBody($body) - { + public function sendBody($body) { + if (is_resource($body)) { - fpassthru($body); + file_put_contents('php://output', $body); } else { diff --git a/core/src/core/classes/sabredav/lib/Sabre/HTTP/Util.php b/core/src/core/classes/sabredav/lib/Sabre/HTTP/Util.php index a1df16a89a..1472462538 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/HTTP/Util.php +++ b/core/src/core/classes/sabredav/lib/Sabre/HTTP/Util.php @@ -5,13 +5,13 @@ /** * HTTP utility methods * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) * @author Paul Voegler - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ -class Util -{ +class Util { + /** * Parses a RFC2616-compatible date string * @@ -20,8 +20,8 @@ class Util * @param string $dateHeader * @return bool|DateTime */ - public static function parseHTTPDate($dateHeader) - { + static function parseHTTPDate($dateHeader) { + //RFC 2616 section 3.3.1 Full Date //Only the format is checked, valid ranges are checked by strtotime below $month = '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'; @@ -69,8 +69,8 @@ public static function parseHTTPDate($dateHeader) * @param \DateTime $dateTime * @return string */ - public static function toHTTPDate(\DateTime $dateTime) - { + static function toHTTPDate(\DateTime $dateTime) { + // We need to clone it, as we don't want to affect the existing // DateTime. $dateTime = clone $dateTime; diff --git a/core/src/core/classes/sabredav/lib/Sabre/HTTP/Version.php b/core/src/core/classes/sabredav/lib/Sabre/HTTP/Version.php index 20e006b0dd..0e913835ce 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/HTTP/Version.php +++ b/core/src/core/classes/sabredav/lib/Sabre/HTTP/Version.php @@ -5,16 +5,16 @@ /** * This class contains the Sabre\HTTP version constants. * - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ -class Version -{ +class Version { + /** * Full version number */ - const VERSION = '1.8.1'; + const VERSION = '1.8.9'; /** * Stability : alpha, beta, stable diff --git a/core/src/core/classes/sabredav/lib/Sabre/autoload.php b/core/src/core/classes/sabredav/lib/Sabre/autoload.php index cdd096f724..c5945ee1d4 100644 --- a/core/src/core/classes/sabredav/lib/Sabre/autoload.php +++ b/core/src/core/classes/sabredav/lib/Sabre/autoload.php @@ -10,9 +10,9 @@ * instead. * * @deprecated Will be removed in a future version! - * @copyright Copyright (C) 2007-2013 Rooftop Solutions. All rights reserved. - * @author Evert Pot (http://www.rooftopsolutions.nl/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License */ /** diff --git a/core/src/core/doc/LICENSE-SABREDAV.txt b/core/src/core/doc/LICENSE-SABREDAV.txt new file mode 100644 index 0000000000..7435c19fdd --- /dev/null +++ b/core/src/core/doc/LICENSE-SABREDAV.txt @@ -0,0 +1,27 @@ +Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of SabreDAV nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE.