Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Update SabreDAV to 1.8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Sep 30, 2014
1 parent 86e9fc7 commit bbc1137
Show file tree
Hide file tree
Showing 181 changed files with 3,093 additions and 2,753 deletions.
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;

}
Expand Down Expand Up @@ -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'];
Expand All @@ -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.
Expand Down
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);

Expand Down
Expand Up @@ -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.
*
Expand Down
96 changes: 49 additions & 47 deletions core/src/core/classes/sabredav/lib/Sabre/CalDAV/Backend/PDO.php
Expand Up @@ -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*
*
Expand Down Expand Up @@ -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;
Expand All @@ -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';
Expand All @@ -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']) {
Expand All @@ -130,7 +130,7 @@ public function getCalendarsForUser($principalUri)
);


foreach ($this->propertyMap as $xmlName=>$dbName) {
foreach($this->propertyMap as $xmlName=>$dbName) {
$calendar[$xmlName] = $row[$dbName];
}

Expand All @@ -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',
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand All @@ -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';
Expand All @@ -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]);
}

Expand All @@ -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';
Expand All @@ -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));

Expand Down Expand Up @@ -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'],
);
}

Expand All @@ -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);
Expand All @@ -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'],
);

Expand All @@ -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 (?,?,?,?,?,?,?,?,?)');
Expand Down Expand Up @@ -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 = ?');
Expand All @@ -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;
Expand All @@ -505,23 +507,23 @@ 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();
} else {
$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();

Expand Down Expand Up @@ -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 = ?');
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bbc1137

Please sign in to comment.