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/