fix merge conflicts
|
@ -3,125 +3,24 @@
|
|||
/**
|
||||
* Library include file
|
||||
*
|
||||
* This file is deprecated, don't use it!
|
||||
* Instead, use the specific includes files that are in the sub-packages.
|
||||
*
|
||||
* Sabre/DAV/includes.php
|
||||
* Sabre/HTTP/includes.php
|
||||
*
|
||||
* etc..
|
||||
*
|
||||
* This file contains all includes to the rest of the SabreDAV library
|
||||
* Make sure the lib/ directory is in PHP's include_path
|
||||
* Make sure the lib/ directory is in PHP's include_path.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @deprecated Don't use this file, it will be remove in a future version
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
||||
/* Utilities */
|
||||
include 'Sabre/HTTP/Util.php';
|
||||
include 'Sabre/HTTP/Response.php';
|
||||
include 'Sabre/HTTP/Request.php';
|
||||
include 'Sabre/HTTP/AbstractAuth.php';
|
||||
include 'Sabre/HTTP/BasicAuth.php';
|
||||
include 'Sabre/HTTP/DigestAuth.php';
|
||||
include 'Sabre/HTTP/AWSAuth.php';
|
||||
|
||||
/* Version */
|
||||
include 'Sabre/DAV/Version.php';
|
||||
include 'Sabre/HTTP/Version.php';
|
||||
|
||||
/* Exceptions */
|
||||
include 'Sabre/DAV/Exception.php';
|
||||
include 'Sabre/DAV/Exception/BadRequest.php';
|
||||
include 'Sabre/DAV/Exception/Conflict.php';
|
||||
include 'Sabre/DAV/Exception/FileNotFound.php';
|
||||
include 'Sabre/DAV/Exception/InsufficientStorage.php';
|
||||
include 'Sabre/DAV/Exception/Locked.php';
|
||||
include 'Sabre/DAV/Exception/LockTokenMatchesRequestUri.php';
|
||||
include 'Sabre/DAV/Exception/MethodNotAllowed.php';
|
||||
include 'Sabre/DAV/Exception/NotImplemented.php';
|
||||
include 'Sabre/DAV/Exception/Forbidden.php';
|
||||
include 'Sabre/DAV/Exception/PreconditionFailed.php';
|
||||
include 'Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php';
|
||||
include 'Sabre/DAV/Exception/UnsupportedMediaType.php';
|
||||
include 'Sabre/DAV/Exception/NotAuthenticated.php';
|
||||
|
||||
include 'Sabre/DAV/Exception/ConflictingLock.php';
|
||||
include 'Sabre/DAV/Exception/ReportNotImplemented.php';
|
||||
include 'Sabre/DAV/Exception/InvalidResourceType.php';
|
||||
|
||||
/* Properties */
|
||||
include 'Sabre/DAV/Property.php';
|
||||
include 'Sabre/DAV/Property/GetLastModified.php';
|
||||
include 'Sabre/DAV/Property/ResourceType.php';
|
||||
include 'Sabre/DAV/Property/SupportedLock.php';
|
||||
include 'Sabre/DAV/Property/LockDiscovery.php';
|
||||
include 'Sabre/DAV/Property/IHref.php';
|
||||
include 'Sabre/DAV/Property/Href.php';
|
||||
include 'Sabre/DAV/Property/HrefList.php';
|
||||
include 'Sabre/DAV/Property/SupportedReportSet.php';
|
||||
include 'Sabre/DAV/Property/Response.php';
|
||||
include 'Sabre/DAV/Property/ResponseList.php';
|
||||
|
||||
/* Node interfaces */
|
||||
include 'Sabre/DAV/INode.php';
|
||||
include 'Sabre/DAV/IFile.php';
|
||||
include 'Sabre/DAV/ICollection.php';
|
||||
include 'Sabre/DAV/IProperties.php';
|
||||
include 'Sabre/DAV/ILockable.php';
|
||||
include 'Sabre/DAV/IQuota.php';
|
||||
include 'Sabre/DAV/IExtendedCollection.php';
|
||||
|
||||
/* Node abstract implementations */
|
||||
include 'Sabre/DAV/Node.php';
|
||||
include 'Sabre/DAV/File.php';
|
||||
include 'Sabre/DAV/Collection.php';
|
||||
include 'Sabre/DAV/Directory.php';
|
||||
|
||||
/* Utilities */
|
||||
include 'Sabre/DAV/SimpleCollection.php';
|
||||
include 'Sabre/DAV/SimpleDirectory.php';
|
||||
include 'Sabre/DAV/XMLUtil.php';
|
||||
include 'Sabre/DAV/URLUtil.php';
|
||||
|
||||
/* Filesystem implementation */
|
||||
include 'Sabre/DAV/FS/Node.php';
|
||||
include 'Sabre/DAV/FS/File.php';
|
||||
include 'Sabre/DAV/FS/Directory.php';
|
||||
|
||||
/* Advanced filesystem implementation */
|
||||
include 'Sabre/DAV/FSExt/Node.php';
|
||||
include 'Sabre/DAV/FSExt/File.php';
|
||||
include 'Sabre/DAV/FSExt/Directory.php';
|
||||
|
||||
/* Trees */
|
||||
include 'Sabre/DAV/Tree.php';
|
||||
include 'Sabre/DAV/ObjectTree.php';
|
||||
include 'Sabre/DAV/Tree/Filesystem.php';
|
||||
|
||||
/* Server */
|
||||
include 'Sabre/DAV/Server.php';
|
||||
include 'Sabre/DAV/ServerPlugin.php';
|
||||
|
||||
/* Browser */
|
||||
include 'Sabre/DAV/Browser/Plugin.php';
|
||||
include 'Sabre/DAV/Browser/MapGetToPropFind.php';
|
||||
include 'Sabre/DAV/Browser/GuessContentType.php';
|
||||
|
||||
/* Locks */
|
||||
include 'Sabre/DAV/Locks/LockInfo.php';
|
||||
include 'Sabre/DAV/Locks/Plugin.php';
|
||||
include 'Sabre/DAV/Locks/Backend/Abstract.php';
|
||||
include 'Sabre/DAV/Locks/Backend/FS.php';
|
||||
include 'Sabre/DAV/Locks/Backend/PDO.php';
|
||||
|
||||
/* Temporary File Filter plugin */
|
||||
include 'Sabre/DAV/TemporaryFileFilterPlugin.php';
|
||||
|
||||
/* Authentication plugin */
|
||||
include 'Sabre/DAV/Auth/Plugin.php';
|
||||
include 'Sabre/DAV/Auth/IBackend.php';
|
||||
include 'Sabre/DAV/Auth/Backend/AbstractDigest.php';
|
||||
include 'Sabre/DAV/Auth/Backend/AbstractBasic.php';
|
||||
include 'Sabre/DAV/Auth/Backend/File.php';
|
||||
include 'Sabre/DAV/Auth/Backend/PDO.php';
|
||||
|
||||
/* DavMount plugin */
|
||||
include 'Sabre/DAV/Mount/Plugin.php';
|
||||
include 'Sabre/HTTP/includes.php';
|
||||
include 'Sabre/DAV/includes.php';
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* Abstract Calendaring backend. Extend this class to create your own backends.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -17,16 +17,16 @@ abstract class Sabre_CalDAV_Backend_Abstract {
|
|||
* Every project is an array with the following keys:
|
||||
* * id, a unique id that will be used by other functions to modify the
|
||||
* calendar. This can be the same as the uri or a database key.
|
||||
* * uri, which the basename of the uri with which the calendar is
|
||||
* * uri, which the basename of the uri with which the calendar is
|
||||
* accessed.
|
||||
* * principalUri. The owner of the calendar. Almost always the same as
|
||||
* * principaluri. The owner of the calendar. Almost always the same as
|
||||
* principalUri passed to this method.
|
||||
*
|
||||
* Furthermore it can contain webdav properties in clark notation. A very
|
||||
* common one is '{DAV:}displayname'.
|
||||
* common one is '{DAV:}displayname'.
|
||||
*
|
||||
* @param string $principalUri
|
||||
* @return array
|
||||
* @param string $principalUri
|
||||
* @return array
|
||||
*/
|
||||
abstract function getCalendarsForUser($principalUri);
|
||||
|
||||
|
@ -39,9 +39,9 @@ abstract class Sabre_CalDAV_Backend_Abstract {
|
|||
* @param string $principalUri
|
||||
* @param string $calendarUri
|
||||
* @param array $properties
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
abstract function createCalendar($principalUri,$calendarUri,array $properties);
|
||||
abstract function createCalendar($principalUri,$calendarUri,array $properties);
|
||||
|
||||
/**
|
||||
* Updates properties for a calendar.
|
||||
|
@ -56,7 +56,7 @@ abstract class Sabre_CalDAV_Backend_Abstract {
|
|||
* If the operation was successful, true can be returned.
|
||||
* If the operation failed, false can be returned.
|
||||
*
|
||||
* Deletion of a non-existant property is always succesful.
|
||||
* Deletion of a non-existent property is always successful.
|
||||
*
|
||||
* Lastly, it is optional to return detailed information about any
|
||||
* failures. In this case an array should be returned with the following
|
||||
|
@ -71,24 +71,24 @@ abstract class Sabre_CalDAV_Backend_Abstract {
|
|||
* )
|
||||
* )
|
||||
*
|
||||
* In this example it was forbidden to update {DAV:}displayname.
|
||||
* In this example it was forbidden to update {DAV:}displayname.
|
||||
* (403 Forbidden), which in turn also caused {DAV:}owner to fail
|
||||
* (424 Failed Dependency) because the request needs to be atomic.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param array $mutations
|
||||
* @return bool|array
|
||||
* @return bool|array
|
||||
*/
|
||||
public function updateCalendar($calendarId, array $mutations) {
|
||||
|
||||
return false;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a calendar and all it's objects
|
||||
*
|
||||
* @param string $calendarId
|
||||
* Delete a calendar and all it's objects
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @return void
|
||||
*/
|
||||
abstract function deleteCalendar($calendarId);
|
||||
|
@ -98,22 +98,27 @@ abstract class Sabre_CalDAV_Backend_Abstract {
|
|||
*
|
||||
* Every item contains an array with the following keys:
|
||||
* * id - unique identifier which will be used for subsequent updates
|
||||
* * calendardata - The iCalendar-compatible calnedar data
|
||||
* * calendardata - The iCalendar-compatible calendar data
|
||||
* * uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
|
||||
* * lastmodified - a timestamp of the last modification time
|
||||
* * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
|
||||
* * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
|
||||
* ' "abcdef"')
|
||||
* * calendarid - The calendarid as it was passed to this function.
|
||||
* * size - The size of the calendar objects, in bytes.
|
||||
*
|
||||
* Note that the etag is optional, but it's highly encouraged to return for
|
||||
* Note that the etag is optional, but it's highly encouraged to return for
|
||||
* speed reasons.
|
||||
*
|
||||
* The calendardata is also optional. If it's not returned
|
||||
* 'getCalendarObject' will be called later, which *is* expected to return
|
||||
* The calendardata is also optional. If it's not returned
|
||||
* 'getCalendarObject' will be called later, which *is* expected to return
|
||||
* calendardata.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @return array
|
||||
*
|
||||
* If neither etag or size are specified, the calendardata will be
|
||||
* used/fetched to determine these numbers. If both are specified the
|
||||
* amount of times this is needed is reduced by a great degree.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @return array
|
||||
*/
|
||||
abstract function getCalendarObjects($calendarId);
|
||||
|
||||
|
@ -121,41 +126,41 @@ abstract class Sabre_CalDAV_Backend_Abstract {
|
|||
* Returns information from a single calendar object, based on it's object
|
||||
* uri.
|
||||
*
|
||||
* The returned array must have the same keys as getCalendarObjects. The
|
||||
* 'calendardata' object is required here though, while it's not required
|
||||
* The returned array must have the same keys as getCalendarObjects. The
|
||||
* 'calendardata' object is required here though, while it's not required
|
||||
* for getCalendarObjects.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @return array
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @return array
|
||||
*/
|
||||
abstract function getCalendarObject($calendarId,$objectUri);
|
||||
|
||||
/**
|
||||
* Creates a new calendar object.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @param string $calendarData
|
||||
* Creates a new calendar object.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @param string $calendarData
|
||||
* @return void
|
||||
*/
|
||||
abstract function createCalendarObject($calendarId,$objectUri,$calendarData);
|
||||
|
||||
/**
|
||||
* Updates an existing calendarobject, based on it's uri.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @param string $calendarData
|
||||
* Updates an existing calendarobject, based on it's uri.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @param string $calendarData
|
||||
* @return void
|
||||
*/
|
||||
abstract function updateCalendarObject($calendarId,$objectUri,$calendarData);
|
||||
|
||||
/**
|
||||
* Deletes an existing calendar object.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* Deletes an existing calendar object.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @return void
|
||||
*/
|
||||
abstract function deleteCalendarObject($calendarId,$objectUri);
|
||||
|
|
|
@ -3,35 +3,35 @@
|
|||
/**
|
||||
* PDO CalDAV backend
|
||||
*
|
||||
* This backend is used to store calendar-data in a PDO database, such as
|
||||
* This backend is used to store calendar-data in a PDO database, such as
|
||||
* sqlite or MySQL
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
||||
|
||||
/**
|
||||
* pdo
|
||||
*
|
||||
* pdo
|
||||
*
|
||||
* @var PDO
|
||||
*/
|
||||
protected $pdo;
|
||||
|
||||
/**
|
||||
* The table name that will be used for calendars
|
||||
*
|
||||
* @var string
|
||||
* The table name that will be used for calendars
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $calendarTableName;
|
||||
|
||||
/**
|
||||
* The table name that will be used for calendar objects
|
||||
*
|
||||
* @var string
|
||||
* The table name that will be used for calendar objects
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $calendarObjectTableName;
|
||||
|
||||
|
@ -39,7 +39,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
* List of CalDAV properties, and how they map to database fieldnames
|
||||
*
|
||||
* Add your own properties by simply adding on to this array
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $propertyMap = array(
|
||||
|
@ -51,9 +51,11 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
);
|
||||
|
||||
/**
|
||||
* Creates the backend
|
||||
*
|
||||
* @param PDO $pdo
|
||||
* Creates the backend
|
||||
*
|
||||
* @param PDO $pdo
|
||||
* @param string $calendarTableName
|
||||
* @param string $calendarObjectTableName
|
||||
*/
|
||||
public function __construct(PDO $pdo, $calendarTableName = 'calendars', $calendarObjectTableName = 'calendarobjects') {
|
||||
|
||||
|
@ -69,16 +71,16 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
* Every project is an array with the following keys:
|
||||
* * id, a unique id that will be used by other functions to modify the
|
||||
* calendar. This can be the same as the uri or a database key.
|
||||
* * uri, which the basename of the uri with which the calendar is
|
||||
* * uri, which the basename of the uri with which the calendar is
|
||||
* accessed.
|
||||
* * principalUri. The owner of the calendar. Almost always the same as
|
||||
* * principaluri. The owner of the calendar. Almost always the same as
|
||||
* principalUri passed to this method.
|
||||
*
|
||||
* Furthermore it can contain webdav properties in clark notation. A very
|
||||
* common one is '{DAV:}displayname'.
|
||||
* common one is '{DAV:}displayname'.
|
||||
*
|
||||
* @param string $principalUri
|
||||
* @return array
|
||||
* @param string $principalUri
|
||||
* @return array
|
||||
*/
|
||||
public function getCalendarsForUser($principalUri) {
|
||||
|
||||
|
@ -89,15 +91,18 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
$fields[] = 'components';
|
||||
$fields[] = 'principaluri';
|
||||
|
||||
// Making fields a comma-delimited list
|
||||
// Making fields a comma-delimited list
|
||||
$fields = implode(', ', $fields);
|
||||
$stmt = $this->pdo->prepare("SELECT " . $fields . " FROM `".$this->calendarTableName."` WHERE principaluri = ?");
|
||||
$stmt = $this->pdo->prepare("SELECT " . $fields . " FROM ".$this->calendarTableName." WHERE principaluri = ? ORDER BY calendarorder ASC");
|
||||
$stmt->execute(array($principalUri));
|
||||
|
||||
$calendars = array();
|
||||
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
$components = explode(',',$row['components']);
|
||||
$components = array();
|
||||
if ($row['components']) {
|
||||
$components = explode(',',$row['components']);
|
||||
}
|
||||
|
||||
$calendar = array(
|
||||
'id' => $row['id'],
|
||||
|
@ -106,7 +111,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
'{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => $row['ctag']?$row['ctag']:'0',
|
||||
'{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet($components),
|
||||
);
|
||||
|
||||
|
||||
|
||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
||||
$calendar[$xmlName] = $row[$dbName];
|
||||
|
@ -129,8 +134,9 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
* @param string $principalUri
|
||||
* @param string $calendarUri
|
||||
* @param array $properties
|
||||
* @return string
|
||||
*/
|
||||
public function createCalendar($principalUri,$calendarUri, array $properties) {
|
||||
public function createCalendar($principalUri, $calendarUri, array $properties) {
|
||||
|
||||
$fieldNames = array(
|
||||
'principaluri',
|
||||
|
@ -158,13 +164,12 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
||||
if (isset($properties[$xmlName])) {
|
||||
|
||||
$myValue = $properties[$xmlName];
|
||||
$values[':' . $dbName] = $properties[$xmlName];
|
||||
$fieldNames[] = $dbName;
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = $this->pdo->prepare("INSERT INTO `".$this->calendarTableName."` (".implode(', ', $fieldNames).") VALUES (".implode(', ',array_keys($values)).")");
|
||||
$stmt = $this->pdo->prepare("INSERT INTO ".$this->calendarTableName." (".implode(', ', $fieldNames).") VALUES (".implode(', ',array_keys($values)).")");
|
||||
$stmt->execute($values);
|
||||
|
||||
return $this->pdo->lastInsertId();
|
||||
|
@ -184,7 +189,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
* If the operation was successful, true can be returned.
|
||||
* If the operation failed, false can be returned.
|
||||
*
|
||||
* Deletion of a non-existant property is always succesful.
|
||||
* Deletion of a non-existent property is always successful.
|
||||
*
|
||||
* Lastly, it is optional to return detailed information about any
|
||||
* failures. In this case an array should be returned with the following
|
||||
|
@ -199,13 +204,13 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
* )
|
||||
* )
|
||||
*
|
||||
* In this example it was forbidden to update {DAV:}displayname.
|
||||
* In this example it was forbidden to update {DAV:}displayname.
|
||||
* (403 Forbidden), which in turn also caused {DAV:}owner to fail
|
||||
* (424 Failed Dependency) because the request needs to be atomic.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param array $mutations
|
||||
* @return bool|array
|
||||
* @param array $mutations
|
||||
* @return bool|array
|
||||
*/
|
||||
public function updateCalendar($calendarId, array $mutations) {
|
||||
|
||||
|
@ -220,7 +225,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
|
||||
foreach($mutations as $propertyName=>$propertyValue) {
|
||||
|
||||
// We don't know about this property.
|
||||
// We don't know about this property.
|
||||
if (!isset($this->propertyMap[$propertyName])) {
|
||||
$hasError = true;
|
||||
$result[403][$propertyName] = null;
|
||||
|
@ -230,7 +235,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
|
||||
$fieldName = $this->propertyMap[$propertyName];
|
||||
$newValues[$fieldName] = $propertyValue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// If there were any errors we need to fail the request
|
||||
|
@ -258,55 +263,60 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
}
|
||||
$valuesSql[] = 'ctag = ctag + 1';
|
||||
|
||||
$stmt = $this->pdo->prepare("UPDATE `" . $this->calendarTableName . "` SET " . implode(', ',$valuesSql) . " WHERE id = ?");
|
||||
$newValues['id'] = $calendarId;
|
||||
$stmt = $this->pdo->prepare("UPDATE " . $this->calendarTableName . " SET " . implode(', ',$valuesSql) . " WHERE id = ?");
|
||||
$newValues['id'] = $calendarId;
|
||||
$stmt->execute(array_values($newValues));
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a calendar and all it's objects
|
||||
*
|
||||
* @param string $calendarId
|
||||
* Delete a calendar and all it's objects
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @return void
|
||||
*/
|
||||
public function deleteCalendar($calendarId) {
|
||||
|
||||
$stmt = $this->pdo->prepare('DELETE FROM `'.$this->calendarObjectTableName.'` WHERE calendarid = ?');
|
||||
$stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?');
|
||||
$stmt->execute(array($calendarId));
|
||||
|
||||
$stmt = $this->pdo->prepare('DELETE FROM `'.$this->calendarTableName.'` WHERE id = ?');
|
||||
$stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarTableName.' WHERE id = ?');
|
||||
$stmt->execute(array($calendarId));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all calendar objects within a calendar.
|
||||
* Returns all calendar objects within a calendar.
|
||||
*
|
||||
* Every item contains an array with the following keys:
|
||||
* * id - unique identifier which will be used for subsequent updates
|
||||
* * calendardata - The iCalendar-compatible calnedar data
|
||||
* * calendardata - The iCalendar-compatible calendar data
|
||||
* * uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
|
||||
* * lastmodified - a timestamp of the last modification time
|
||||
* * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
|
||||
* * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
|
||||
* ' "abcdef"')
|
||||
* * calendarid - The calendarid as it was passed to this function.
|
||||
* * size - The size of the calendar objects, in bytes.
|
||||
*
|
||||
* Note that the etag is optional, but it's highly encouraged to return for
|
||||
* Note that the etag is optional, but it's highly encouraged to return for
|
||||
* speed reasons.
|
||||
*
|
||||
* The calendardata is also optional. If it's not returned
|
||||
* 'getCalendarObject' will be called later, which *is* expected to return
|
||||
* The calendardata is also optional. If it's not returned
|
||||
* 'getCalendarObject' will be called later, which *is* expected to return
|
||||
* calendardata.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @return array
|
||||
*
|
||||
* If neither etag or size are specified, the calendardata will be
|
||||
* used/fetched to determine these numbers. If both are specified the
|
||||
* amount of times this is needed is reduced by a great degree.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @return array
|
||||
*/
|
||||
public function getCalendarObjects($calendarId) {
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT * FROM `'.$this->calendarObjectTableName.'` WHERE calendarid = ?');
|
||||
$stmt = $this->pdo->prepare('SELECT * FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?');
|
||||
$stmt->execute(array($calendarId));
|
||||
return $stmt->fetchAll();
|
||||
|
||||
|
@ -316,68 +326,68 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract {
|
|||
* Returns information from a single calendar object, based on it's object
|
||||
* uri.
|
||||
*
|
||||
* The returned array must have the same keys as getCalendarObjects. The
|
||||
* 'calendardata' object is required here though, while it's not required
|
||||
* The returned array must have the same keys as getCalendarObjects. The
|
||||
* 'calendardata' object is required here though, while it's not required
|
||||
* for getCalendarObjects.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @return array
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @return array
|
||||
*/
|
||||
public function getCalendarObject($calendarId,$objectUri) {
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT * FROM `'.$this->calendarObjectTableName.'` WHERE calendarid = ? AND uri = ?');
|
||||
$stmt = $this->pdo->prepare('SELECT * FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?');
|
||||
$stmt->execute(array($calendarId, $objectUri));
|
||||
return $stmt->fetch();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new calendar object.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @param string $calendarData
|
||||
* Creates a new calendar object.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @param string $calendarData
|
||||
* @return void
|
||||
*/
|
||||
public function createCalendarObject($calendarId,$objectUri,$calendarData) {
|
||||
|
||||
$stmt = $this->pdo->prepare('INSERT INTO `'.$this->calendarObjectTableName.'` (calendarid, uri, calendardata, lastmodified) VALUES (?,?,?,?)');
|
||||
$stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarObjectTableName.' (calendarid, uri, calendardata, lastmodified) VALUES (?,?,?,?)');
|
||||
$stmt->execute(array($calendarId,$objectUri,$calendarData,time()));
|
||||
$stmt = $this->pdo->prepare('UPDATE `'.$this->calendarTableName.'` SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt = $this->pdo->prepare('UPDATE '.$this->calendarTableName.' SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt->execute(array($calendarId));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing calendarobject, based on it's uri.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @param string $calendarData
|
||||
* Updates an existing calendarobject, based on it's uri.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @param string $calendarData
|
||||
* @return void
|
||||
*/
|
||||
public function updateCalendarObject($calendarId,$objectUri,$calendarData) {
|
||||
|
||||
$stmt = $this->pdo->prepare('UPDATE `'.$this->calendarObjectTableName.'` SET calendardata = ?, lastmodified = ? WHERE calendarid = ? AND uri = ?');
|
||||
$stmt = $this->pdo->prepare('UPDATE '.$this->calendarObjectTableName.' SET calendardata = ?, lastmodified = ? WHERE calendarid = ? AND uri = ?');
|
||||
$stmt->execute(array($calendarData,time(),$calendarId,$objectUri));
|
||||
$stmt = $this->pdo->prepare('UPDATE `'.$this->calendarTableName.'` SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt = $this->pdo->prepare('UPDATE '.$this->calendarTableName.' SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt->execute(array($calendarId));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing calendar object.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* Deletes an existing calendar object.
|
||||
*
|
||||
* @param string $calendarId
|
||||
* @param string $objectUri
|
||||
* @return void
|
||||
*/
|
||||
public function deleteCalendarObject($calendarId,$objectUri) {
|
||||
|
||||
$stmt = $this->pdo->prepare('DELETE FROM `'.$this->calendarObjectTableName.'` WHERE calendarid = ? AND uri = ?');
|
||||
$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 = ?');
|
||||
$stmt = $this->pdo->prepare('UPDATE '. $this->calendarTableName .' SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt->execute(array($calendarId));
|
||||
|
||||
}
|
||||
|
|
|
@ -5,42 +5,42 @@
|
|||
*
|
||||
* A calendar can contain multiple TODO and or Events. These are represented
|
||||
* as Sabre_CalDAV_CalendarObject objects.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProperties, Sabre_DAVACL_IACL {
|
||||
|
||||
/**
|
||||
* This is an array with calendar information
|
||||
*
|
||||
* @var array
|
||||
* This is an array with calendar information
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $calendarInfo;
|
||||
|
||||
/**
|
||||
* CalDAV backend
|
||||
*
|
||||
* @var Sabre_CalDAV_Backend_Abstract
|
||||
* CalDAV backend
|
||||
*
|
||||
* @var Sabre_CalDAV_Backend_Abstract
|
||||
*/
|
||||
protected $caldavBackend;
|
||||
|
||||
/**
|
||||
* Principal backend
|
||||
*
|
||||
*
|
||||
* @var Sabre_DAVACL_IPrincipalBackend
|
||||
*/
|
||||
protected $principalBackend;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_CalDAV_Backend_Abstract $caldavBackend
|
||||
* @param array $calendarInfo
|
||||
* @return void
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param Sabre_CalDAV_Backend_Abstract $caldavBackend
|
||||
* @param array $calendarInfo
|
||||
*/
|
||||
public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend, Sabre_CalDAV_Backend_Abstract $caldavBackend, $calendarInfo) {
|
||||
|
||||
|
@ -52,9 +52,9 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the calendar
|
||||
*
|
||||
* @return string
|
||||
* Returns the name of the calendar
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -63,10 +63,10 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates properties such as the display name and description
|
||||
*
|
||||
* @param array $mutations
|
||||
* @return array
|
||||
* Updates properties such as the display name and description
|
||||
*
|
||||
* @param array $mutations
|
||||
* @return array
|
||||
*/
|
||||
public function updateProperties($mutations) {
|
||||
|
||||
|
@ -75,10 +75,10 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the list of properties
|
||||
*
|
||||
* @param array $properties
|
||||
* @return array
|
||||
* Returns the list of properties
|
||||
*
|
||||
* @param array $requestedProperties
|
||||
* @return array
|
||||
*/
|
||||
public function getProperties($requestedProperties) {
|
||||
|
||||
|
@ -86,16 +86,16 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
|
||||
foreach($requestedProperties as $prop) switch($prop) {
|
||||
|
||||
case '{urn:ietf:params:xml:ns:caldav}supported-calendar-data' :
|
||||
$response[$prop] = new Sabre_CalDAV_Property_SupportedCalendarData();
|
||||
case '{urn:ietf:params:xml:ns:caldav}supported-calendar-data' :
|
||||
$response[$prop] = new Sabre_CalDAV_Property_SupportedCalendarData();
|
||||
break;
|
||||
case '{urn:ietf:params:xml:ns:caldav}supported-collation-set' :
|
||||
$response[$prop] = new Sabre_CalDAV_Property_SupportedCollationSet();
|
||||
case '{urn:ietf:params:xml:ns:caldav}supported-collation-set' :
|
||||
$response[$prop] = new Sabre_CalDAV_Property_SupportedCollationSet();
|
||||
break;
|
||||
case '{DAV:}owner' :
|
||||
$response[$prop] = new Sabre_DAVACL_Property_Principal(Sabre_DAVACL_Property_Principal::HREF,$this->calendarInfo['principaluri']);
|
||||
break;
|
||||
default :
|
||||
default :
|
||||
if (isset($this->calendarInfo[$prop])) $response[$prop] = $this->calendarInfo[$prop];
|
||||
break;
|
||||
|
||||
|
@ -108,22 +108,22 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
* Returns a calendar object
|
||||
*
|
||||
* The contained calendar objects are for example Events or Todo's.
|
||||
*
|
||||
* @param string $name
|
||||
* @return Sabre_DAV_ICalendarObject
|
||||
*
|
||||
* @param string $name
|
||||
* @return Sabre_DAV_ICalendarObject
|
||||
*/
|
||||
public function getChild($name) {
|
||||
|
||||
$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'],$name);
|
||||
if (!$obj) throw new Sabre_DAV_Exception_FileNotFound('Calendar object not found');
|
||||
if (!$obj) throw new Sabre_DAV_Exception_NotFound('Calendar object not found');
|
||||
return new Sabre_CalDAV_CalendarObject($this->caldavBackend,$this->calendarInfo,$obj);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full list of calendar objects
|
||||
*
|
||||
* @return array
|
||||
* Returns the full list of calendar objects
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getChildren() {
|
||||
|
||||
|
@ -137,17 +137,17 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if a child-node exists.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* Checks if a child-node exists.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function childExists($name) {
|
||||
|
||||
$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'],$name);
|
||||
if (!$obj)
|
||||
if (!$obj)
|
||||
return false;
|
||||
else
|
||||
else
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -156,8 +156,8 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
* Creates a new directory
|
||||
*
|
||||
* We actually block this, as subdirectories are not allowed in calendars.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function createDirectory($name) {
|
||||
|
@ -170,32 +170,23 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
* Creates a new file
|
||||
*
|
||||
* The contents of the new file must be a valid ICalendar string.
|
||||
*
|
||||
* @param string $name
|
||||
* @param resource $calendarData
|
||||
* @return void
|
||||
*
|
||||
* @param string $name
|
||||
* @param resource $calendarData
|
||||
* @return string|null
|
||||
*/
|
||||
public function createFile($name,$calendarData = null) {
|
||||
|
||||
$calendarData = stream_get_contents($calendarData);
|
||||
// Converting to UTF-8, if needed
|
||||
$calendarData = Sabre_DAV_StringUtil::ensureUTF8($calendarData);
|
||||
|
||||
$supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set'];
|
||||
if ($supportedComponents) {
|
||||
$supportedComponents = $supportedComponents->getValue();
|
||||
} else {
|
||||
$supportedComponents = null;
|
||||
if (is_resource($calendarData)) {
|
||||
$calendarData = stream_get_contents($calendarData);
|
||||
}
|
||||
Sabre_CalDAV_ICalendarUtil::validateICalendarObject($calendarData, $supportedComponents);
|
||||
|
||||
$this->caldavBackend->createCalendarObject($this->calendarInfo['id'],$name,$calendarData);
|
||||
return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'],$name,$calendarData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the calendar.
|
||||
*
|
||||
* Deletes the calendar.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
@ -205,10 +196,10 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
}
|
||||
|
||||
/**
|
||||
* Renames the calendar. Note that most calendars use the
|
||||
* {DAV:}displayname to display a name to display a name.
|
||||
*
|
||||
* @param string $newName
|
||||
* Renames the calendar. Note that most calendars use the
|
||||
* {DAV:}displayname to display a name to display a name.
|
||||
*
|
||||
* @param string $newName
|
||||
* @return void
|
||||
*/
|
||||
public function setName($newName) {
|
||||
|
@ -219,7 +210,7 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
|
||||
/**
|
||||
* Returns the last modification date as a unix timestamp.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
@ -231,8 +222,8 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
/**
|
||||
* Returns the owner principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner() {
|
||||
|
@ -245,8 +236,8 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
* Returns a group principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup() {
|
||||
|
||||
|
@ -258,13 +249,13 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL() {
|
||||
|
||||
|
@ -294,6 +285,11 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
'principal' => $this->calendarInfo['principaluri'] . '/calendar-proxy-read',
|
||||
'protected' => true,
|
||||
),
|
||||
array(
|
||||
'privilege' => '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}read-free-busy',
|
||||
'principal' => '{DAV:}authenticated',
|
||||
'protected' => true,
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
|
@ -302,9 +298,9 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
/**
|
||||
* Updates the ACL
|
||||
*
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* @return void
|
||||
*/
|
||||
public function setACL(array $acl) {
|
||||
|
@ -313,6 +309,35 @@ class Sabre_CalDAV_Calendar implements Sabre_CalDAV_ICalendar, Sabre_DAV_IProper
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet() {
|
||||
|
||||
$default = Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet();
|
||||
|
||||
// We need to inject 'read-free-busy' in the tree, aggregated under
|
||||
// {DAV:}read.
|
||||
foreach($default['aggregates'] as &$agg) {
|
||||
|
||||
if ($agg['privilege'] !== '{DAV:}read') continue;
|
||||
|
||||
$agg['aggregates'][] = array(
|
||||
'privilege' => '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}read-free-busy',
|
||||
);
|
||||
|
||||
}
|
||||
return $default;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The CalendarObject represents a single VEVENT or VTODO within a Calendar.
|
||||
*
|
||||
* The CalendarObject represents a single VEVENT or VTODO within a Calendar.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV_ICalendarObject, Sabre_DAVACL_IACL {
|
||||
|
||||
/**
|
||||
* Sabre_CalDAV_Backend_Abstract
|
||||
*
|
||||
* @var array
|
||||
* Sabre_CalDAV_Backend_Abstract
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $caldavBackend;
|
||||
|
||||
/**
|
||||
* Array with information about this CalendarObject
|
||||
*
|
||||
* @var array
|
||||
* Array with information about this CalendarObject
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $objectData;
|
||||
|
||||
/**
|
||||
* Array with information about the containing calendar
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $calendarInfo;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_CalDAV_Backend_Abstract $caldavBackend
|
||||
* @param array $calendarInfo
|
||||
* @param array $objectData
|
||||
* @param array $objectData
|
||||
*/
|
||||
public function __construct(Sabre_CalDAV_Backend_Abstract $caldavBackend,array $calendarInfo,array $objectData) {
|
||||
|
||||
|
@ -56,9 +56,9 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the uri for this object
|
||||
*
|
||||
* @return string
|
||||
* Returns the uri for this object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -67,9 +67,9 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the ICalendar-formatted object
|
||||
*
|
||||
* @return string
|
||||
* Returns the ICalendar-formatted object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get() {
|
||||
|
||||
|
@ -83,35 +83,27 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates the ICalendar-formatted object
|
||||
*
|
||||
* @param string $calendarData
|
||||
* @return void
|
||||
* Updates the ICalendar-formatted object
|
||||
*
|
||||
* @param string $calendarData
|
||||
* @return void
|
||||
*/
|
||||
public function put($calendarData) {
|
||||
|
||||
if (is_resource($calendarData))
|
||||
if (is_resource($calendarData)) {
|
||||
$calendarData = stream_get_contents($calendarData);
|
||||
|
||||
// Converting to UTF-8, if needed
|
||||
$calendarData = Sabre_DAV_StringUtil::ensureUTF8($calendarData);
|
||||
|
||||
$supportedComponents = $this->calendarInfo['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set'];
|
||||
if ($supportedComponents) {
|
||||
$supportedComponents = $supportedComponents->getValue();
|
||||
} else {
|
||||
$supportedComponents = null;
|
||||
}
|
||||
Sabre_CalDAV_ICalendarUtil::validateICalendarObject($calendarData, $supportedComponents);
|
||||
|
||||
$this->caldavBackend->updateCalendarObject($this->calendarInfo['id'],$this->objectData['uri'],$calendarData);
|
||||
$etag = $this->caldavBackend->updateCalendarObject($this->calendarInfo['id'],$this->objectData['uri'],$calendarData);
|
||||
$this->objectData['calendardata'] = $calendarData;
|
||||
$this->objectData['etag'] = $etag;
|
||||
|
||||
return $etag;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the calendar object
|
||||
*
|
||||
* Deletes the calendar object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
@ -121,9 +113,9 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the mime content-type
|
||||
*
|
||||
* @return string
|
||||
* Returns the mime content-type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContentType() {
|
||||
|
||||
|
@ -134,9 +126,9 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
/**
|
||||
* Returns an ETag for this object.
|
||||
*
|
||||
* The ETag is an arbritrary string, but MUST be surrounded by double-quotes.
|
||||
*
|
||||
* @return string
|
||||
* The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getETag() {
|
||||
|
||||
|
@ -150,8 +142,8 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
|
||||
/**
|
||||
* Returns the last modification date as a unix timestamp
|
||||
*
|
||||
* @return time
|
||||
*
|
||||
* @return time
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
||||
|
@ -160,21 +152,25 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the size of this object in bytes
|
||||
*
|
||||
* Returns the size of this object in bytes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSize() {
|
||||
|
||||
return strlen($this->objectData['calendardata']);
|
||||
if (array_key_exists('size',$this->objectData)) {
|
||||
return $this->objectData['size'];
|
||||
} else {
|
||||
return strlen($this->get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner() {
|
||||
|
@ -187,8 +183,8 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
* Returns a group principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup() {
|
||||
|
||||
|
@ -200,13 +196,13 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL() {
|
||||
|
||||
|
@ -244,9 +240,9 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
/**
|
||||
* Updates the ACL
|
||||
*
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* @return void
|
||||
*/
|
||||
public function setACL(array $acl) {
|
||||
|
@ -255,6 +251,23 @@ class Sabre_CalDAV_CalendarObject extends Sabre_DAV_File implements Sabre_CalDAV
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,296 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Parses the calendar-query report request body.
|
||||
*
|
||||
* Whoever designed this format, and the CalDAV equivalent even more so,
|
||||
* has no feel for design.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_CalendarQueryParser {
|
||||
|
||||
/**
|
||||
* List of requested properties the client wanted
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $requestedProperties;
|
||||
|
||||
/**
|
||||
* List of property/component filters.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $filters;
|
||||
|
||||
/**
|
||||
* This property will contain null if CALDAV:expand was not specified,
|
||||
* otherwise it will contain an array with 2 elements (start, end). Each
|
||||
* contain a DateTime object.
|
||||
*
|
||||
* If expand is specified, recurring calendar objects are to be expanded
|
||||
* into their individual components, and only the components that fall
|
||||
* within the specified time-range are to be returned.
|
||||
*
|
||||
* For more details, see rfc4791, section 9.6.5.
|
||||
*
|
||||
* @var null|array
|
||||
*/
|
||||
public $expand;
|
||||
|
||||
/**
|
||||
* DOM Document
|
||||
*
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $dom;
|
||||
|
||||
/**
|
||||
* DOM XPath object
|
||||
*
|
||||
* @var DOMXPath
|
||||
*/
|
||||
protected $xpath;
|
||||
|
||||
/**
|
||||
* Creates the parser
|
||||
*
|
||||
* @param DOMDocument $dom
|
||||
*/
|
||||
public function __construct(DOMDocument $dom) {
|
||||
|
||||
$this->dom = $dom;
|
||||
|
||||
$this->xpath = new DOMXPath($dom);
|
||||
$this->xpath->registerNameSpace('cal',Sabre_CalDAV_Plugin::NS_CALDAV);
|
||||
$this->xpath->registerNameSpace('dav','urn:DAV');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function parse() {
|
||||
|
||||
$filterNode = null;
|
||||
|
||||
$filter = $this->xpath->query('/cal:calendar-query/cal:filter');
|
||||
if ($filter->length !== 1) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed');
|
||||
}
|
||||
|
||||
$compFilters = $this->parseCompFilters($filter->item(0));
|
||||
if (count($compFilters)!==1) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('There must be exactly 1 top-level comp-filter.');
|
||||
}
|
||||
|
||||
$this->filters = $compFilters[0];
|
||||
$this->requestedProperties = array_keys(Sabre_DAV_XMLUtil::parseProperties($this->dom->firstChild));
|
||||
|
||||
$expand = $this->xpath->query('/cal:calendar-query/dav:prop/cal:calendar-data/cal:expand');
|
||||
if ($expand->length>0) {
|
||||
$this->expand = $this->parseExpand($expand->item(0));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses all the 'comp-filter' elements from a node
|
||||
*
|
||||
* @param DOMElement $parentNode
|
||||
* @return array
|
||||
*/
|
||||
protected function parseCompFilters(DOMElement $parentNode) {
|
||||
|
||||
$compFilterNodes = $this->xpath->query('cal:comp-filter', $parentNode);
|
||||
$result = array();
|
||||
|
||||
for($ii=0; $ii < $compFilterNodes->length; $ii++) {
|
||||
|
||||
$compFilterNode = $compFilterNodes->item($ii);
|
||||
|
||||
$compFilter = array();
|
||||
$compFilter['name'] = $compFilterNode->getAttribute('name');
|
||||
$compFilter['is-not-defined'] = $this->xpath->query('cal:is-not-defined', $compFilterNode)->length>0;
|
||||
$compFilter['comp-filters'] = $this->parseCompFilters($compFilterNode);
|
||||
$compFilter['prop-filters'] = $this->parsePropFilters($compFilterNode);
|
||||
$compFilter['time-range'] = $this->parseTimeRange($compFilterNode);
|
||||
|
||||
if ($compFilter['time-range'] && !in_array($compFilter['name'],array(
|
||||
'VEVENT',
|
||||
'VTODO',
|
||||
'VJOURNAL',
|
||||
'VFREEBUSY',
|
||||
'VALARM',
|
||||
))) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The time-range filter is not defined for the ' . $compFilter['name'] . ' component');
|
||||
};
|
||||
|
||||
$result[] = $compFilter;
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses all the prop-filter elements from a node
|
||||
*
|
||||
* @param DOMElement $parentNode
|
||||
* @return array
|
||||
*/
|
||||
protected function parsePropFilters(DOMElement $parentNode) {
|
||||
|
||||
$propFilterNodes = $this->xpath->query('cal:prop-filter', $parentNode);
|
||||
$result = array();
|
||||
|
||||
for ($ii=0; $ii < $propFilterNodes->length; $ii++) {
|
||||
|
||||
$propFilterNode = $propFilterNodes->item($ii);
|
||||
$propFilter = array();
|
||||
$propFilter['name'] = $propFilterNode->getAttribute('name');
|
||||
$propFilter['is-not-defined'] = $this->xpath->query('cal:is-not-defined', $propFilterNode)->length>0;
|
||||
$propFilter['param-filters'] = $this->parseParamFilters($propFilterNode);
|
||||
$propFilter['text-match'] = $this->parseTextMatch($propFilterNode);
|
||||
$propFilter['time-range'] = $this->parseTimeRange($propFilterNode);
|
||||
|
||||
$result[] = $propFilter;
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the param-filter element
|
||||
*
|
||||
* @param DOMElement $parentNode
|
||||
* @return array
|
||||
*/
|
||||
protected function parseParamFilters(DOMElement $parentNode) {
|
||||
|
||||
$paramFilterNodes = $this->xpath->query('cal:param-filter', $parentNode);
|
||||
$result = array();
|
||||
|
||||
for($ii=0;$ii<$paramFilterNodes->length;$ii++) {
|
||||
|
||||
$paramFilterNode = $paramFilterNodes->item($ii);
|
||||
$paramFilter = array();
|
||||
$paramFilter['name'] = $paramFilterNode->getAttribute('name');
|
||||
$paramFilter['is-not-defined'] = $this->xpath->query('cal:is-not-defined', $paramFilterNode)->length>0;
|
||||
$paramFilter['text-match'] = $this->parseTextMatch($paramFilterNode);
|
||||
|
||||
$result[] = $paramFilter;
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the text-match element
|
||||
*
|
||||
* @param DOMElement $parentNode
|
||||
* @return array|null
|
||||
*/
|
||||
protected function parseTextMatch(DOMElement $parentNode) {
|
||||
|
||||
$textMatchNodes = $this->xpath->query('cal:text-match', $parentNode);
|
||||
|
||||
if ($textMatchNodes->length === 0)
|
||||
return null;
|
||||
|
||||
$textMatchNode = $textMatchNodes->item(0);
|
||||
$negateCondition = $textMatchNode->getAttribute('negate-condition');
|
||||
$negateCondition = $negateCondition==='yes';
|
||||
$collation = $textMatchNode->getAttribute('collation');
|
||||
if (!$collation) $collation = 'i;ascii-casemap';
|
||||
|
||||
return array(
|
||||
'negate-condition' => $negateCondition,
|
||||
'collation' => $collation,
|
||||
'value' => $textMatchNode->nodeValue
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the time-range element
|
||||
*
|
||||
* @param DOMElement $parentNode
|
||||
* @return array|null
|
||||
*/
|
||||
protected function parseTimeRange(DOMElement $parentNode) {
|
||||
|
||||
$timeRangeNodes = $this->xpath->query('cal:time-range', $parentNode);
|
||||
if ($timeRangeNodes->length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$timeRangeNode = $timeRangeNodes->item(0);
|
||||
|
||||
if ($start = $timeRangeNode->getAttribute('start')) {
|
||||
$start = Sabre_VObject_DateTimeParser::parseDateTime($start);
|
||||
} else {
|
||||
$start = null;
|
||||
}
|
||||
if ($end = $timeRangeNode->getAttribute('end')) {
|
||||
$end = Sabre_VObject_DateTimeParser::parseDateTime($end);
|
||||
} else {
|
||||
$end = null;
|
||||
}
|
||||
|
||||
if (!is_null($start) && !is_null($end) && $end <= $start) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The end-date must be larger than the start-date in the time-range filter');
|
||||
}
|
||||
|
||||
return array(
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the CALDAV:expand element
|
||||
*
|
||||
* @param DOMElement $parentNode
|
||||
* @return void
|
||||
*/
|
||||
protected function parseExpand(DOMElement $parentNode) {
|
||||
|
||||
$start = $parentNode->getAttribute('start');
|
||||
if(!$start) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The "start" attribute is required for the CALDAV:expand element');
|
||||
}
|
||||
$start = Sabre_VObject_DateTimeParser::parseDateTime($start);
|
||||
|
||||
$end = $parentNode->getAttribute('end');
|
||||
if(!$end) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The "end" attribute is required for the CALDAV:expand element');
|
||||
}
|
||||
$end = Sabre_VObject_DateTimeParser::parseDateTime($end);
|
||||
|
||||
if ($end <= $start) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The end-date must be larger than the start-date in the expand element.');
|
||||
}
|
||||
|
||||
return array(
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,347 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* CalendarQuery Validator
|
||||
*
|
||||
* This class is responsible for checking if an iCalendar object matches a set
|
||||
* of filters. The main function to do this is 'validate'.
|
||||
*
|
||||
* This is used to determine which icalendar objects should be returned for a
|
||||
* calendar-query REPORT request.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_CalendarQueryValidator {
|
||||
|
||||
/**
|
||||
* Verify if a list of filters applies to the calendar data object
|
||||
*
|
||||
* The list of filters must be formatted as parsed by Sabre_CalDAV_CalendarQueryParser
|
||||
*
|
||||
* @param Sabre_VObject_Component $vObject
|
||||
* @param array $filters
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(Sabre_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']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return
|
||||
$this->validateCompFilters($vObject, $filters['comp-filters']) &&
|
||||
$this->validatePropFilters($vObject, $filters['prop-filters']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks the validity of comp-filters.
|
||||
*
|
||||
* A list of comp-filters needs to be specified. Also the parent of the
|
||||
* component we're checking should be specified, not the component to check
|
||||
* itself.
|
||||
*
|
||||
* @param Sabre_VObject_Component $parent
|
||||
* @param array $filters
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateCompFilters(Sabre_VObject_Component $parent, array $filters) {
|
||||
|
||||
foreach($filters as $filter) {
|
||||
|
||||
$isDefined = isset($parent->$filter['name']);
|
||||
|
||||
if ($filter['is-not-defined']) {
|
||||
|
||||
if ($isDefined) {
|
||||
return false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
if (!$isDefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filter['time-range']) {
|
||||
foreach($parent->$filter['name'] as $subComponent) {
|
||||
if ($this->validateTimeRange($subComponent, $filter['time-range']['start'], $filter['time-range']['end'])) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$filter['comp-filters'] && !$filter['prop-filters']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
||||
if (
|
||||
$this->validateCompFilters($subComponent, $filter['comp-filters']) &&
|
||||
$this->validatePropFilters($subComponent, $filter['prop-filters'])) {
|
||||
// We had a match, so this comp-filter succeeds
|
||||
continue 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If we got here it means there were sub-comp-filters or
|
||||
// sub-prop-filters and there was no match. This means this filter
|
||||
// needs to return false.
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// If we got here it means we got through all comp-filters alive so the
|
||||
// filters were all true.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks the validity of prop-filters.
|
||||
*
|
||||
* A list of prop-filters needs to be specified. Also the parent of the
|
||||
* property we're checking should be specified, not the property to check
|
||||
* itself.
|
||||
*
|
||||
* @param Sabre_VObject_Component $parent
|
||||
* @param array $filters
|
||||
* @return bool
|
||||
*/
|
||||
protected function validatePropFilters(Sabre_VObject_Component $parent, array $filters) {
|
||||
|
||||
foreach($filters as $filter) {
|
||||
|
||||
$isDefined = isset($parent->$filter['name']);
|
||||
|
||||
if ($filter['is-not-defined']) {
|
||||
|
||||
if ($isDefined) {
|
||||
return false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
if (!$isDefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filter['time-range']) {
|
||||
foreach($parent->$filter['name'] as $subComponent) {
|
||||
if ($this->validateTimeRange($subComponent, $filter['time-range']['start'], $filter['time-range']['end'])) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$filter['param-filters'] && !$filter['text-match']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
||||
if(
|
||||
$this->validateParamFilters($subComponent, $filter['param-filters']) &&
|
||||
(!$filter['text-match'] || $this->validateTextMatch($subComponent, $filter['text-match']))
|
||||
) {
|
||||
// We had a match, so this prop-filter succeeds
|
||||
continue 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If we got here it means there were sub-param-filters or
|
||||
// text-match filters and there was no match. This means the
|
||||
// filter needs to return false.
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// If we got here it means we got through all prop-filters alive so the
|
||||
// filters were all true.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks the validity of param-filters.
|
||||
*
|
||||
* A list of param-filters needs to be specified. Also the parent of the
|
||||
* parameter we're checking should be specified, not the parameter to check
|
||||
* itself.
|
||||
*
|
||||
* @param Sabre_VObject_Property $parent
|
||||
* @param array $filters
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateParamFilters(Sabre_VObject_Property $parent, array $filters) {
|
||||
|
||||
foreach($filters as $filter) {
|
||||
|
||||
$isDefined = isset($parent[$filter['name']]);
|
||||
|
||||
if ($filter['is-not-defined']) {
|
||||
|
||||
if ($isDefined) {
|
||||
return false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
if (!$isDefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$filter['text-match']) {
|
||||
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($this->validateTextMatch($subParam,$filter['text-match'])) {
|
||||
// We had a match, so this param-filter succeeds
|
||||
continue 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If we got here it means there was a text-match filter and there
|
||||
// were no matches. This means the filter needs to return false.
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// If we got here it means we got through all param-filters alive so the
|
||||
// filters were all true.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks the validity of a text-match.
|
||||
*
|
||||
* A single text-match should be specified as well as the specific property
|
||||
* or parameter we need to validate.
|
||||
*
|
||||
* @param Sabre_VObject_Node $parent
|
||||
* @param array $textMatch
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateTextMatch(Sabre_VObject_Node $parent, array $textMatch) {
|
||||
|
||||
$value = (string)$parent;
|
||||
|
||||
$isMatching = Sabre_DAV_StringUtil::textMatch($value, $textMatch['value'], $textMatch['collation']);
|
||||
|
||||
return ($textMatch['negate-condition'] xor $isMatching);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if a component matches the given time range.
|
||||
*
|
||||
* This is all based on the rules specified in rfc4791, which are quite
|
||||
* complex.
|
||||
*
|
||||
* @param Sabre_VObject_Node $component
|
||||
* @param DateTime $start
|
||||
* @param DateTime $end
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateTimeRange(Sabre_VObject_Node $component, $start, $end) {
|
||||
|
||||
if (is_null($start)) {
|
||||
$start = new DateTime('1900-01-01');
|
||||
}
|
||||
if (is_null($end)) {
|
||||
$end = new DateTime('3000-01-01');
|
||||
}
|
||||
|
||||
switch($component->name) {
|
||||
|
||||
case 'VEVENT' :
|
||||
case 'VTODO' :
|
||||
case 'VJOURNAL' :
|
||||
|
||||
return $component->isInTimeRange($start, $end);
|
||||
|
||||
case 'VALARM' :
|
||||
|
||||
// If the valarm is wrapped in a recurring event, we need to
|
||||
// expand the recursions, and validate each.
|
||||
//
|
||||
// Our datamodel doesn't easily allow us to do this straight
|
||||
// in the VALARM component code, so this is a hack, and an
|
||||
// expensive one too.
|
||||
if ($component->parent->name === 'VEVENT' && $component->parent->RRULE) {
|
||||
// Fire up the iterator!
|
||||
$it = new Sabre_VObject_RecurrenceIterator($component->parent->parent, (string)$component->parent->UID);
|
||||
while($it->valid()) {
|
||||
$expandedEvent = $it->getEventObject();
|
||||
|
||||
// We need to check from these expanded alarms, which
|
||||
// one is the first to trigger. Based on this, we can
|
||||
// determine if we can 'give up' expanding events.
|
||||
$firstAlarm = null;
|
||||
foreach($expandedEvent->VALARM as $expandedAlarm) {
|
||||
$effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime();
|
||||
if (!$firstAlarm || $effectiveTrigger < $firstAlarm) {
|
||||
$firstAlarm = $effectiveTrigger;
|
||||
}
|
||||
if ($expandedAlarm->isInTimeRange($start, $end)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
if ($firstAlarm > $end) {
|
||||
return false;
|
||||
}
|
||||
$it->next();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return $component->isInTimeRange($start, $end);
|
||||
}
|
||||
|
||||
case 'VFREEBUSY' :
|
||||
throw new Sabre_DAV_Exception_NotImplemented('time-range filters are currently not supported on ' . $component->name . ' components');
|
||||
|
||||
case 'COMPLETED' :
|
||||
case 'CREATED' :
|
||||
case 'DTEND' :
|
||||
case 'DTSTAMP' :
|
||||
case 'DTSTART' :
|
||||
case 'DUE' :
|
||||
case 'LAST-MODIFIED' :
|
||||
return ($start <= $component->getDateTime() && $end >= $component->getDateTime());
|
||||
|
||||
|
||||
|
||||
default :
|
||||
throw new Sabre_DAV_Exception_BadRequest('You cannot create a time-range filter on a ' . $component->name . ' component');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Users collection
|
||||
* Users collection
|
||||
*
|
||||
* This object is responsible for generating a collection of users.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_CalendarRootNode extends Sabre_DAVACL_AbstractPrincipalCollection {
|
||||
|
||||
/**
|
||||
* CalDAV backend
|
||||
*
|
||||
* @var Sabre_CalDAV_Backend_Abstract
|
||||
* CalDAV backend
|
||||
*
|
||||
* @var Sabre_CalDAV_Backend_Abstract
|
||||
*/
|
||||
protected $caldavBackend;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor
|
||||
*
|
||||
* This constructor needs both an authentication and a caldav backend.
|
||||
*
|
||||
* By default this class will show a list of calendar collections for
|
||||
* principals in the 'principals' collection. If your main principals are
|
||||
* actually located in a different path, use the $principalPrefix argument
|
||||
* By default this class will show a list of calendar collections for
|
||||
* principals in the 'principals' collection. If your main principals are
|
||||
* actually located in a different path, use the $principalPrefix argument
|
||||
* to override this.
|
||||
*
|
||||
*
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param Sabre_CalDAV_Backend_Abstract $caldavBackend
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param Sabre_CalDAV_Backend_Abstract $caldavBackend
|
||||
* @param string $principalPrefix
|
||||
*/
|
||||
public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend,Sabre_CalDAV_Backend_Abstract $caldavBackend, $principalPrefix = 'principals') {
|
||||
|
@ -46,9 +46,9 @@ class Sabre_CalDAV_CalendarRootNode extends Sabre_DAVACL_AbstractPrincipalCollec
|
|||
* Returns the nodename
|
||||
*
|
||||
* We're overriding this, because the default will be the 'principalPrefix',
|
||||
* and we want it to be Sabre_CalDAV_Plugin::CALENDAR_ROOT
|
||||
*
|
||||
* @return void
|
||||
* and we want it to be Sabre_CalDAV_Plugin::CALENDAR_ROOT
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -62,9 +62,9 @@ class Sabre_CalDAV_CalendarRootNode extends Sabre_DAVACL_AbstractPrincipalCollec
|
|||
* The passed array contains principal information, and is guaranteed to
|
||||
* at least contain a uri item. Other properties may or may not be
|
||||
* supplied by the authentication backend.
|
||||
*
|
||||
* @param array $principal
|
||||
* @return Sabre_DAV_INode
|
||||
*
|
||||
* @param array $principal
|
||||
* @return Sabre_DAV_INode
|
||||
*/
|
||||
public function getChildForPrincipal(array $principal) {
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* InvalidICalendarObject
|
||||
*
|
||||
* This exception is thrown when an attempt is made to create or update
|
||||
* an invalid ICalendar object
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Exception_InvalidICalendarObject extends Sabre_DAV_Exception_PreconditionFailed {
|
||||
|
||||
|
||||
}
|
|
@ -4,28 +4,28 @@
|
|||
* ICS Exporter
|
||||
*
|
||||
* This plugin adds the ability to export entire calendars as .ics files.
|
||||
* This is useful for clients that don't support CalDAV yet. They often do
|
||||
* This is useful for clients that don't support CalDAV yet. They often do
|
||||
* support ics files.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin {
|
||||
|
||||
/**
|
||||
* Reference to Server class
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
* Reference to Server class
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
*/
|
||||
private $server;
|
||||
|
||||
/**
|
||||
* Initializes the plugin and registers event handlers
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* Initializes the plugin and registers event handlers
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(Sabre_DAV_Server $server) {
|
||||
|
@ -38,10 +38,10 @@ class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin {
|
|||
/**
|
||||
* 'beforeMethod' event handles. This event handles intercepts GET requests ending
|
||||
* with ?export
|
||||
*
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $uri
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function beforeMethod($method, $uri) {
|
||||
|
||||
|
@ -55,9 +55,19 @@ class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
if (!($node instanceof Sabre_CalDAV_Calendar)) return;
|
||||
|
||||
// Checking ACL, if available.
|
||||
if ($aclPlugin = $this->server->getPlugin('acl')) {
|
||||
$aclPlugin->checkPrivileges($uri, '{DAV:}read');
|
||||
}
|
||||
|
||||
$this->server->httpResponse->setHeader('Content-Type','text/calendar');
|
||||
$this->server->httpResponse->sendStatus(200);
|
||||
$this->server->httpResponse->sendBody($this->generateICS($this->server->tree->getChildren($uri)));
|
||||
|
||||
$nodes = $this->server->getPropertiesForPath($uri, array(
|
||||
'{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data',
|
||||
),1);
|
||||
|
||||
$this->server->httpResponse->sendBody($this->generateICS($nodes));
|
||||
|
||||
// Returning false to break the event chain
|
||||
return false;
|
||||
|
@ -65,16 +75,20 @@ class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* Merges all calendar objects, and builds one big ics export
|
||||
*
|
||||
* @param array $nodes
|
||||
* @return void
|
||||
* Merges all calendar objects, and builds one big ics export
|
||||
*
|
||||
* @param array $nodes
|
||||
* @return string
|
||||
*/
|
||||
public function generateICS(array $nodes) {
|
||||
|
||||
$calendar = new Sabre_VObject_Component('vcalendar');
|
||||
$calendar->version = '2.0';
|
||||
$calendar->prodid = '-//SabreDAV//SabreDAV ' . Sabre_DAV_Version::VERSION . '//EN';
|
||||
if (Sabre_DAV_Server::$exposeVersion) {
|
||||
$calendar->prodid = '-//SabreDAV//SabreDAV ' . Sabre_DAV_Version::VERSION . '//EN';
|
||||
} else {
|
||||
$calendar->prodid = '-//SabreDAV//SabreDAV//EN';
|
||||
}
|
||||
$calendar->calscale = 'GREGORIAN';
|
||||
|
||||
$collectedTimezones = array();
|
||||
|
@ -84,7 +98,11 @@ class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
foreach($nodes as $node) {
|
||||
|
||||
$nodeData = $node->get();
|
||||
if (!isset($node[200]['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data'])) {
|
||||
continue;
|
||||
}
|
||||
$nodeData = $node[200]['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data'];
|
||||
|
||||
$nodeComp = Sabre_VObject_Reader::read($nodeData);
|
||||
|
||||
foreach($nodeComp->children() as $child) {
|
||||
|
@ -105,13 +123,10 @@ class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin {
|
|||
$collectedTimezones[] = $child->TZID;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
foreach($timezones as $tz) $calendar->add($tz);
|
||||
|
@ -119,6 +134,6 @@ class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
return $calendar->serialize();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
* Calendar interface
|
||||
*
|
||||
* Implement this interface to allow a node to be recognized as an calendar.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_CalDAV_ICalendar extends Sabre_DAV_ICollection {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* CalendarObject interface
|
||||
* CalendarObject interface
|
||||
/**
|
||||
* Extend the ICalendarObject interface to allow your custom nodes to be picked up as
|
||||
* Extend the ICalendarObject interface to allow your custom nodes to be picked up as
|
||||
* CalendarObjects.
|
||||
*
|
||||
* Calendar objects are resources such as Events, Todo's or Journals.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_CalDAV_ICalendarObject extends Sabre_DAV_IFile {
|
||||
interface Sabre_CalDAV_ICalendarObject extends Sabre_DAV_IFile {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This class contains several utilities related to the ICalendar (rfc2445) format
|
||||
*
|
||||
* This class is now deprecated, and won't be further maintained. Please use
|
||||
* the Sabre_VObject package for your ics parsing needs.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
* @deprecated Use Sabre_VObject instead.
|
||||
*/
|
||||
class Sabre_CalDAV_ICalendarUtil {
|
||||
|
||||
/**
|
||||
* Validates an ICalendar object
|
||||
*
|
||||
* This method makes sure this ICalendar object is properly formatted.
|
||||
* If we can't parse it, we'll throw exceptions.
|
||||
*
|
||||
* @param string $icalData
|
||||
* @param array $allowedComponents
|
||||
* @return bool
|
||||
*/
|
||||
static function validateICalendarObject($icalData, array $allowedComponents = null) {
|
||||
|
||||
$xcal = simplexml_load_string(self::toXCal($icalData));
|
||||
if (!$xcal) throw new Sabre_CalDAV_Exception_InvalidICalendarObject('Invalid calendarobject format');
|
||||
|
||||
$xcal->registerXPathNameSpace('cal','urn:ietf:params:xml:ns:xcal');
|
||||
|
||||
// Check if there's only 1 component
|
||||
$components = array('vevent','vtodo','vjournal','vfreebusy');
|
||||
$componentsFound = array();
|
||||
|
||||
foreach($components as $component) {
|
||||
$test = $xcal->xpath('/cal:iCalendar/cal:vcalendar/cal:' . $component);
|
||||
if (is_array($test)) $componentsFound = array_merge($componentsFound, $test);
|
||||
}
|
||||
if (count($componentsFound)<1) {
|
||||
throw new Sabre_CalDAV_Exception_InvalidICalendarObject('One VEVENT, VTODO, VJOURNAL or VFREEBUSY must be specified. 0 found.');
|
||||
}
|
||||
$component = $componentsFound[0];
|
||||
|
||||
if (is_null($allowedComponents)) return true;
|
||||
|
||||
// Check if the component is allowed
|
||||
$name = $component->getName();
|
||||
if (!in_array(strtoupper($name),$allowedComponents)) {
|
||||
throw new Sabre_CalDAV_Exception_InvalidICalendarObject(strtoupper($name) . ' is not allowed in this calendar.');
|
||||
}
|
||||
|
||||
if (count($xcal->xpath('/cal:iCalendar/cal:vcalendar/cal:method'))>0) {
|
||||
throw new Sabre_CalDAV_Exception_InvalidICalendarObject('The METHOD property is not allowed in calendar objects');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts ICalendar data to XML.
|
||||
*
|
||||
* Properties are converted to lowercase xml elements. Parameters are;
|
||||
* converted to attributes. BEGIN:VEVENT is converted to <vevent> and
|
||||
* END:VEVENT </vevent> as well as other components.
|
||||
*
|
||||
* It's a very loose parser. If any line does not conform to the spec, it
|
||||
* will simply be ignored. It will try to detect if \r\n or \n line endings
|
||||
* are used.
|
||||
*
|
||||
* @todo Currently quoted attributes are not parsed correctly.
|
||||
* @see http://tools.ietf.org/html/draft-royer-calsch-xcal-03
|
||||
* @param string $icalData
|
||||
* @return string.
|
||||
*/
|
||||
static function toXCAL($icalData) {
|
||||
|
||||
// Detecting line endings
|
||||
$lb="\r\n";
|
||||
if (strpos($icalData,"\r\n")!==false) $lb = "\r\n";
|
||||
elseif (strpos($icalData,"\n")!==false) $lb = "\n";
|
||||
|
||||
// Splitting up items per line
|
||||
$lines = explode($lb,$icalData);
|
||||
|
||||
// Properties can be folded over 2 lines. In this case the second
|
||||
// line will be preceeded by a space or tab.
|
||||
$lines2 = array();
|
||||
foreach($lines as $line) {
|
||||
|
||||
if (!$line) continue;
|
||||
if ($line[0]===" " || $line[0]==="\t") {
|
||||
$lines2[count($lines2)-1].=substr($line,1);
|
||||
continue;
|
||||
}
|
||||
|
||||
$lines2[]=$line;
|
||||
|
||||
}
|
||||
|
||||
$xml = '<?xml version="1.0"?>' . "\n";
|
||||
$xml.= "<iCalendar xmlns=\"urn:ietf:params:xml:ns:xcal\">\n";
|
||||
|
||||
$spaces = 2;
|
||||
foreach($lines2 as $line) {
|
||||
|
||||
$matches = array();
|
||||
// This matches PROPERTYNAME;ATTRIBUTES:VALUE
|
||||
if (!preg_match('/^([^:^;]*)(?:;([^:]*))?:(.*)$/',$line,$matches))
|
||||
continue;
|
||||
|
||||
$propertyName = strtolower($matches[1]);
|
||||
$attributes = $matches[2];
|
||||
$value = $matches[3];
|
||||
|
||||
// If the line was in the format BEGIN:COMPONENT or END:COMPONENT, we need to special case it.
|
||||
if ($propertyName === 'begin') {
|
||||
$xml.=str_repeat(" ",$spaces);
|
||||
$xml.='<' . strtolower($value) . ">\n";
|
||||
$spaces+=2;
|
||||
continue;
|
||||
} elseif ($propertyName === 'end') {
|
||||
$spaces-=2;
|
||||
$xml.=str_repeat(" ",$spaces);
|
||||
$xml.='</' . strtolower($value) . ">\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$xml.=str_repeat(" ",$spaces);
|
||||
$xml.='<' . $propertyName;
|
||||
if ($attributes) {
|
||||
// There can be multiple attributes
|
||||
$attributes = explode(';',$attributes);
|
||||
foreach($attributes as $att) {
|
||||
|
||||
list($attName,$attValue) = explode('=',$att,2);
|
||||
$attName = strtolower($attName);
|
||||
if ($attName === 'language') $attName='xml:lang';
|
||||
$xml.=' ' . $attName . '="' . htmlspecialchars($attValue) . '"';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$xml.='>'. htmlspecialchars(trim($value)) . '</' . $propertyName . ">\n";
|
||||
|
||||
}
|
||||
$xml.="</iCalendar>";
|
||||
return $xml;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,23 +4,23 @@
|
|||
* Principal collection
|
||||
*
|
||||
* This is an alternative collection to the standard ACL principal collection.
|
||||
* This collection adds support for the calendar-proxy-read and
|
||||
* calendar-proxy-write sub-principals, as defined by the caldav-proxy
|
||||
* This collection adds support for the calendar-proxy-read and
|
||||
* calendar-proxy-write sub-principals, as defined by the caldav-proxy
|
||||
* specification.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Principal_Collection extends Sabre_DAVACL_AbstractPrincipalCollection {
|
||||
|
||||
/**
|
||||
* Returns a child object based on principal information
|
||||
*
|
||||
* @param array $principalInfo
|
||||
* @return Sabre_CalDAV_Principal_User
|
||||
* Returns a child object based on principal information
|
||||
*
|
||||
* @param array $principalInfo
|
||||
* @return Sabre_CalDAV_Principal_User
|
||||
*/
|
||||
public function getChildForPrincipal(array $principalInfo) {
|
||||
|
||||
|
|
|
@ -4,38 +4,38 @@
|
|||
* ProxyRead principal
|
||||
*
|
||||
* This class represents a principal group, hosted under the main principal.
|
||||
* This is needed to implement 'Calendar delegation' support. This class is
|
||||
* This is needed to implement 'Calendar delegation' support. This class is
|
||||
* instantiated by Sabre_CalDAV_Principal_User.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
||||
|
||||
/**
|
||||
* Principal information from the parent principal.
|
||||
*
|
||||
* @var array
|
||||
* Principal information from the parent principal.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $principalInfo;
|
||||
|
||||
/**
|
||||
* Principal backend
|
||||
*
|
||||
* @var Sabre_DAVACL_IPrincipalBackend
|
||||
* Principal backend
|
||||
*
|
||||
* @var Sabre_DAVACL_IPrincipalBackend
|
||||
*/
|
||||
protected $principalBackend;
|
||||
|
||||
/**
|
||||
* Creates the object.
|
||||
*
|
||||
* Note that you MUST supply the parent principal information.
|
||||
*
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param array $principalInfo
|
||||
* Note that you MUST supply the parent principal information.
|
||||
*
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param array $principalInfo
|
||||
*/
|
||||
public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend, array $principalInfo) {
|
||||
|
||||
|
@ -46,8 +46,8 @@ class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
|||
|
||||
/**
|
||||
* Returns this principals name.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -56,13 +56,13 @@ class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the last modification time
|
||||
* Returns the last modification time
|
||||
*
|
||||
* @return null
|
||||
* @return null
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
||||
return null;
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
|||
* Deletes the current node
|
||||
*
|
||||
* @throws Sabre_DAV_Exception_Forbidden
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
||||
|
@ -80,7 +80,7 @@ class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
|||
|
||||
/**
|
||||
* Renames the node
|
||||
*
|
||||
*
|
||||
* @throws Sabre_DAV_Exception_Forbidden
|
||||
* @param string $name The new name
|
||||
* @return void
|
||||
|
@ -93,11 +93,11 @@ class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
|||
|
||||
|
||||
/**
|
||||
* Returns a list of altenative urls for a principal
|
||||
*
|
||||
* Returns a list of alternative urls for a principal
|
||||
*
|
||||
* This can for example be an email address, or ldap url.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAlternateUriSet() {
|
||||
|
||||
|
@ -106,41 +106,41 @@ class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the full principal url
|
||||
*
|
||||
* @return string
|
||||
* Returns the full principal url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrincipalUrl() {
|
||||
|
||||
return $this->principalInfo['uri'] . '/' . $this->getName();
|
||||
return $this->principalInfo['uri'] . '/' . $this->getName();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of group members
|
||||
*
|
||||
*
|
||||
* If this principal is a group, this function should return
|
||||
* all member principal uri's for the group.
|
||||
*
|
||||
* all member principal uri's for the group.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMemberSet() {
|
||||
|
||||
return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl());
|
||||
return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of groups this principal is member of
|
||||
*
|
||||
*
|
||||
* If this principal is a member of a (list of) groups, this function
|
||||
* should return a list of principal uri's for it's members.
|
||||
*
|
||||
* @return array
|
||||
* should return a list of principal uri's for it's members.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMembership() {
|
||||
|
||||
return $this->principalBackend->getGroupMembership($this->getPrincipalUrl());
|
||||
return $this->principalBackend->getGroupMembership($this->getPrincipalUrl());
|
||||
|
||||
}
|
||||
|
||||
|
@ -149,11 +149,11 @@ class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
|||
*
|
||||
* If this principal is a group, this method sets all the group members.
|
||||
* The list of members is always overwritten, never appended to.
|
||||
*
|
||||
* This method should throw an exception if the members could not be set.
|
||||
*
|
||||
* @param array $principals
|
||||
* @return void
|
||||
*
|
||||
* This method should throw an exception if the members could not be set.
|
||||
*
|
||||
* @param array $principals
|
||||
* @return void
|
||||
*/
|
||||
public function setGroupMemberSet(array $principals) {
|
||||
|
||||
|
@ -165,9 +165,9 @@ class Sabre_CalDAV_Principal_ProxyRead implements Sabre_DAVACL_IPrincipal {
|
|||
* Returns the displayname
|
||||
*
|
||||
* This should be a human readable name for the principal.
|
||||
* If none is available, return the nodename.
|
||||
*
|
||||
* @return string
|
||||
* If none is available, return the nodename.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName() {
|
||||
|
||||
|
|
|
@ -4,38 +4,38 @@
|
|||
* ProxyWrite principal
|
||||
*
|
||||
* This class represents a principal group, hosted under the main principal.
|
||||
* This is needed to implement 'Calendar delegation' support. This class is
|
||||
* This is needed to implement 'Calendar delegation' support. This class is
|
||||
* instantiated by Sabre_CalDAV_Principal_User.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
||||
|
||||
/**
|
||||
* Parent principal information
|
||||
*
|
||||
* @var array
|
||||
* Parent principal information
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $principalInfo;
|
||||
|
||||
/**
|
||||
* Principal Backend
|
||||
*
|
||||
* @var Sabre_DAVACL_IPrincipalBackend
|
||||
* Principal Backend
|
||||
*
|
||||
* @var Sabre_DAVACL_IPrincipalBackend
|
||||
*/
|
||||
protected $principalBackend;
|
||||
|
||||
/**
|
||||
* Creates the object
|
||||
*
|
||||
* Note that you MUST supply the parent principal information.
|
||||
*
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param array $principalInfo
|
||||
* Note that you MUST supply the parent principal information.
|
||||
*
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param array $principalInfo
|
||||
*/
|
||||
public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend, array $principalInfo) {
|
||||
|
||||
|
@ -46,8 +46,8 @@ class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
|||
|
||||
/**
|
||||
* Returns this principals name.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -56,13 +56,13 @@ class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the last modification time
|
||||
* Returns the last modification time
|
||||
*
|
||||
* @return null
|
||||
* @return null
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
||||
return null;
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
|||
* Deletes the current node
|
||||
*
|
||||
* @throws Sabre_DAV_Exception_Forbidden
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
||||
|
@ -80,7 +80,7 @@ class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
|||
|
||||
/**
|
||||
* Renames the node
|
||||
*
|
||||
*
|
||||
* @throws Sabre_DAV_Exception_Forbidden
|
||||
* @param string $name The new name
|
||||
* @return void
|
||||
|
@ -93,11 +93,11 @@ class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
|||
|
||||
|
||||
/**
|
||||
* Returns a list of altenative urls for a principal
|
||||
*
|
||||
* Returns a list of alternative urls for a principal
|
||||
*
|
||||
* This can for example be an email address, or ldap url.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAlternateUriSet() {
|
||||
|
||||
|
@ -106,41 +106,41 @@ class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the full principal url
|
||||
*
|
||||
* @return string
|
||||
* Returns the full principal url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrincipalUrl() {
|
||||
|
||||
return $this->principalInfo['uri'] . '/' . $this->getName();
|
||||
return $this->principalInfo['uri'] . '/' . $this->getName();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of group members
|
||||
*
|
||||
*
|
||||
* If this principal is a group, this function should return
|
||||
* all member principal uri's for the group.
|
||||
*
|
||||
* all member principal uri's for the group.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMemberSet() {
|
||||
|
||||
return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl());
|
||||
return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of groups this principal is member of
|
||||
*
|
||||
*
|
||||
* If this principal is a member of a (list of) groups, this function
|
||||
* should return a list of principal uri's for it's members.
|
||||
*
|
||||
* @return array
|
||||
* should return a list of principal uri's for it's members.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMembership() {
|
||||
|
||||
return $this->principalBackend->getGroupMembership($this->getPrincipalUrl());
|
||||
return $this->principalBackend->getGroupMembership($this->getPrincipalUrl());
|
||||
|
||||
}
|
||||
|
||||
|
@ -149,11 +149,11 @@ class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
|||
*
|
||||
* If this principal is a group, this method sets all the group members.
|
||||
* The list of members is always overwritten, never appended to.
|
||||
*
|
||||
* This method should throw an exception if the members could not be set.
|
||||
*
|
||||
* @param array $principals
|
||||
* @return void
|
||||
*
|
||||
* This method should throw an exception if the members could not be set.
|
||||
*
|
||||
* @param array $principals
|
||||
* @return void
|
||||
*/
|
||||
public function setGroupMemberSet(array $principals) {
|
||||
|
||||
|
@ -165,9 +165,9 @@ class Sabre_CalDAV_Principal_ProxyWrite implements Sabre_DAVACL_IPrincipal {
|
|||
* Returns the displayname
|
||||
*
|
||||
* This should be a human readable name for the principal.
|
||||
* If none is available, return the nodename.
|
||||
*
|
||||
* @return string
|
||||
* If none is available, return the nodename.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName() {
|
||||
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* CalDAV principal
|
||||
* CalDAV principal
|
||||
*
|
||||
* This is a standard user-principal for CalDAV. This principal is also a
|
||||
* collection and returns the caldav-proxy-read and caldav-proxy-write child
|
||||
* This is a standard user-principal for CalDAV. This principal is also a
|
||||
* collection and returns the caldav-proxy-read and caldav-proxy-write child
|
||||
* principals.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabre_DAV_ICollection {
|
||||
|
||||
/**
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource $data Initial payload, passed as a readable stream resource.
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource $data Initial payload, passed as a readable stream resource.
|
||||
* @throws Sabre_DAV_Exception_Forbidden
|
||||
* @return void
|
||||
*/
|
||||
|
@ -30,9 +30,9 @@ class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabr
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* @throws Sabre_DAV_Exception_Forbidden
|
||||
* @return void
|
||||
*/
|
||||
|
@ -43,45 +43,60 @@ class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabr
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a specific child node, referenced by its name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Sabre_DAV_INode
|
||||
* Returns a specific child node, referenced by its name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Sabre_DAV_INode
|
||||
*/
|
||||
public function getChild($name) {
|
||||
|
||||
$principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name);
|
||||
if (!$principal) {
|
||||
throw new Sabre_DAV_Exception_NotFound('Node with name ' . $name . ' was not found');
|
||||
}
|
||||
if ($name === 'calendar-proxy-read')
|
||||
return new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties);
|
||||
|
||||
if ($name === 'calendar-proxy-write')
|
||||
return new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties);
|
||||
|
||||
throw new Sabre_DAV_Exception_FileNotFound('Node with name ' . $name . ' was not found');
|
||||
throw new Sabre_DAV_Exception_NotFound('Node with name ' . $name . ' was not found');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
*/
|
||||
public function getChildren() {
|
||||
|
||||
return array(
|
||||
new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties),
|
||||
new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties),
|
||||
);
|
||||
$r = array();
|
||||
if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) {
|
||||
$r[] = new Sabre_CalDAV_Principal_ProxyRead($this->principalBackend, $this->principalProperties);
|
||||
}
|
||||
if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-write')) {
|
||||
$r[] = new Sabre_CalDAV_Principal_ProxyWrite($this->principalBackend, $this->principalProperties);
|
||||
}
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a child-node with the specified name exists
|
||||
*
|
||||
* @return bool
|
||||
* Returns whether or not the child node exists
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function childExists($name) {
|
||||
|
||||
return $name === 'calendar-proxy-read' || $name === 'calendar-proxy-write';
|
||||
try {
|
||||
$this->getChild($name);
|
||||
return true;
|
||||
} catch (Sabre_DAV_Exception_NotFound $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -89,33 +104,28 @@ class Sabre_CalDAV_Principal_User extends Sabre_DAVACL_Principal implements Sabr
|
|||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => $this->principalProperties['uri'],
|
||||
'protected' => true,
|
||||
),
|
||||
array(
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read',
|
||||
'protected' => true,
|
||||
),
|
||||
array(
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write',
|
||||
'protected' => true,
|
||||
),
|
||||
$acl = parent::getACL();
|
||||
$acl[] = array(
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => $this->principalProperties['uri'] . '/calendar-proxy-read',
|
||||
'protected' => true,
|
||||
);
|
||||
$acl[] = array(
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => $this->principalProperties['uri'] . '/calendar-proxy-write',
|
||||
'protected' => true,
|
||||
);
|
||||
return $acl;
|
||||
|
||||
}
|
||||
|
||||
|
|
40
3rdparty/Sabre/CalDAV/Property/SupportedCalendarComponentSet.php
поставляемый
Normal file → Executable file
|
@ -3,40 +3,40 @@
|
|||
/**
|
||||
* Supported component set property
|
||||
*
|
||||
* This property is a representation of the supported-calendar_component-set
|
||||
* This property is a representation of the supported-calendar_component-set
|
||||
* property in the CalDAV namespace. It simply requires an array of components,
|
||||
* such as VEVENT, VTODO
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Property_SupportedCalendarComponentSet extends Sabre_DAV_Property {
|
||||
|
||||
/**
|
||||
* List of supported components, such as "VEVENT, VTODO"
|
||||
*
|
||||
* @var array
|
||||
* List of supported components, such as "VEVENT, VTODO"
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $components;
|
||||
|
||||
/**
|
||||
* Creates the property
|
||||
*
|
||||
* @param array $components
|
||||
* Creates the property
|
||||
*
|
||||
* @param array $components
|
||||
*/
|
||||
public function __construct(array $components) {
|
||||
|
||||
$this->components = $components;
|
||||
$this->components = $components;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported components
|
||||
*
|
||||
* @return array
|
||||
* Returns the list of supported components
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValue() {
|
||||
|
||||
|
@ -45,10 +45,10 @@ class Sabre_CalDAV_Property_SupportedCalendarComponentSet extends Sabre_DAV_Prop
|
|||
}
|
||||
|
||||
/**
|
||||
* Serializes the property in a DOMDocument
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $node
|
||||
* Serializes the property in a DOMDocument
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $node
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
|
||||
|
@ -58,7 +58,7 @@ class Sabre_CalDAV_Property_SupportedCalendarComponentSet extends Sabre_DAV_Prop
|
|||
|
||||
$xcomp = $doc->createElement('cal:comp');
|
||||
$xcomp->setAttribute('name',$component);
|
||||
$node->appendChild($xcomp);
|
||||
$node->appendChild($xcomp);
|
||||
|
||||
}
|
||||
|
||||
|
@ -66,9 +66,9 @@ class Sabre_CalDAV_Property_SupportedCalendarComponentSet extends Sabre_DAV_Prop
|
|||
|
||||
/**
|
||||
* Unserializes the DOMElement back into a Property class.
|
||||
*
|
||||
* @param DOMElement $node
|
||||
* @return void
|
||||
*
|
||||
* @param DOMElement $node
|
||||
* @return Sabre_CalDAV_Property_SupportedCalendarComponentSet
|
||||
*/
|
||||
static function unserialize(DOMElement $node) {
|
||||
|
||||
|
|
12
3rdparty/Sabre/CalDAV/Property/SupportedCalendarData.php
поставляемый
Normal file → Executable file
|
@ -9,17 +9,17 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Property_SupportedCalendarData extends Sabre_DAV_Property {
|
||||
|
||||
/**
|
||||
* Serializes the property in a DOMDocument
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $node
|
||||
* Serializes the property in a DOMDocument
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $node
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
|
||||
|
@ -32,7 +32,7 @@ class Sabre_CalDAV_Property_SupportedCalendarData extends Sabre_DAV_Property {
|
|||
$caldata->setAttribute('content-type','text/calendar');
|
||||
$caldata->setAttribute('version','2.0');
|
||||
|
||||
$node->appendChild($caldata);
|
||||
$node->appendChild($caldata);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
14
3rdparty/Sabre/CalDAV/Property/SupportedCollationSet.php
поставляемый
Normal file → Executable file
|
@ -4,27 +4,27 @@
|
|||
* supported-collation-set property
|
||||
*
|
||||
* This property is a representation of the supported-collation-set property
|
||||
* in the CalDAV namespace.
|
||||
* in the CalDAV namespace.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Property_SupportedCollationSet extends Sabre_DAV_Property {
|
||||
|
||||
/**
|
||||
* Serializes the property in a DOM document
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $node
|
||||
* Serializes the property in a DOM document
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $node
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
|
||||
|
||||
$doc = $node->ownerDocument;
|
||||
|
||||
|
||||
$prefix = $node->lookupPrefix('urn:ietf:params:xml:ns:caldav');
|
||||
if (!$prefix) $prefix = 'cal';
|
||||
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* iMIP handler.
|
||||
*
|
||||
* This class is responsible for sending out iMIP messages. iMIP is the
|
||||
* email-based transport for iTIP. iTIP deals with scheduling operations for
|
||||
* iCalendar objects.
|
||||
*
|
||||
* If you want to customize the email that gets sent out, you can do so by
|
||||
* extending this class and overriding the sendMessage method.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Schedule_IMip {
|
||||
|
||||
/**
|
||||
* Email address used in From: header.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $senderEmail;
|
||||
|
||||
/**
|
||||
* Creates the email handler.
|
||||
*
|
||||
* @param string $senderEmail. The 'senderEmail' is the email that shows up
|
||||
* in the 'From:' address. This should
|
||||
* generally be some kind of no-reply email
|
||||
* address you own.
|
||||
*/
|
||||
public function __construct($senderEmail) {
|
||||
|
||||
$this->senderEmail = $senderEmail;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends one or more iTip messages through email.
|
||||
*
|
||||
* @param string $originator
|
||||
* @param array $recipients
|
||||
* @param Sabre_VObject_Component $vObject
|
||||
* @return void
|
||||
*/
|
||||
public function sendMessage($originator, array $recipients, Sabre_VObject_Component $vObject) {
|
||||
|
||||
foreach($recipients as $recipient) {
|
||||
|
||||
$to = $recipient;
|
||||
$replyTo = $originator;
|
||||
$subject = 'SabreDAV iTIP message';
|
||||
|
||||
switch(strtoupper($vObject->METHOD)) {
|
||||
case 'REPLY' :
|
||||
$subject = 'Response for: ' . $vObject->VEVENT->SUMMARY;
|
||||
break;
|
||||
case 'REQUEST' :
|
||||
$subject = 'Invitation for: ' .$vObject->VEVENT->SUMMARY;
|
||||
break;
|
||||
case 'CANCEL' :
|
||||
$subject = 'Cancelled event: ' . $vObject->VEVENT->SUMMARY;
|
||||
break;
|
||||
}
|
||||
|
||||
$headers = array();
|
||||
$headers[] = 'Reply-To: ' . $replyTo;
|
||||
$headers[] = 'From: ' . $this->senderEmail;
|
||||
$headers[] = 'Content-Type: text/calendar; method=' . (string)$vObject->method . '; charset=utf-8';
|
||||
if (Sabre_DAV_Server::$exposeVersion) {
|
||||
$headers[] = 'X-Sabre-Version: ' . Sabre_DAV_Version::VERSION . '-' . Sabre_DAV_Version::STABILITY;
|
||||
}
|
||||
|
||||
$vcalBody = $vObject->serialize();
|
||||
|
||||
$this->mail($to, $subject, $vcalBody, $headers);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is reponsible for sending the actual email.
|
||||
*
|
||||
* @param string $to Recipient email address
|
||||
* @param string $subject Subject of the email
|
||||
* @param string $body iCalendar body
|
||||
* @param array $headers List of headers
|
||||
* @return void
|
||||
*/
|
||||
protected function mail($to, $subject, $body, array $headers) {
|
||||
|
||||
mail($to, $subject, $body, implode("\r\n", $headers));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implement this interface to have a node be recognized as a CalDAV scheduling
|
||||
* outbox.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_CalDAV_Schedule_IOutbox extends Sabre_DAV_ICollection, Sabre_DAVACL_IACL {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The CalDAV scheduling outbox
|
||||
*
|
||||
* The outbox is mainly used as an endpoint in the tree for a client to do
|
||||
* free-busy requests. This functionality is completely handled by the
|
||||
* Scheduling plugin, so this object is actually mostly static.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_Schedule_Outbox extends Sabre_DAV_Directory implements Sabre_CalDAV_Schedule_IOutbox {
|
||||
|
||||
/**
|
||||
* The principal Uri
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $principalUri;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $principalUri
|
||||
*/
|
||||
public function __construct($principalUri) {
|
||||
|
||||
$this->principalUri = $principalUri;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the node.
|
||||
*
|
||||
* This is used to generate the url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
return 'outbox';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
*/
|
||||
public function getChildren() {
|
||||
|
||||
return array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner() {
|
||||
|
||||
return $this->principalUri;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a group principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL() {
|
||||
|
||||
return array(
|
||||
array(
|
||||
'privilege' => '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-query-freebusy',
|
||||
'principal' => $this->getOwner(),
|
||||
'protected' => true,
|
||||
),
|
||||
array(
|
||||
'privilege' => '{DAV:}read',
|
||||
'principal' => $this->getOwner(),
|
||||
'protected' => true,
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the ACL
|
||||
*
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* @return void
|
||||
*/
|
||||
public function setACL(array $acl) {
|
||||
|
||||
throw new Sabre_DAV_Exception_MethodNotAllowed('You\'re not allowed to update the ACL');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet() {
|
||||
|
||||
$default = Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet();
|
||||
$default['aggregates'][] = array(
|
||||
'privilege' => '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}schedule-query-freebusy',
|
||||
);
|
||||
|
||||
return $default;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,17 +3,20 @@
|
|||
/**
|
||||
* CalDAV server
|
||||
*
|
||||
* Deprecated! Warning: This class is now officially deprecated
|
||||
*
|
||||
* This script is a convenience script. It quickly sets up a WebDAV server
|
||||
* with caldav and ACL support, and it creates the root 'principals' and
|
||||
* 'calendars' collections.
|
||||
*
|
||||
* Note that if you plan to do anything moderately complex, you are advised to
|
||||
* not subclass this server, but use Sabre_DAV_Server directly instead. This
|
||||
* Note that if you plan to do anything moderately complex, you are advised to
|
||||
* not subclass this server, but use Sabre_DAV_Server directly instead. This
|
||||
* class is nothing more than an 'easy setup'.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @deprecated Don't use this class anymore, it will be removed in version 1.7.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -22,17 +25,17 @@ class Sabre_CalDAV_Server extends Sabre_DAV_Server {
|
|||
/**
|
||||
* The authentication realm
|
||||
*
|
||||
* Note that if this changes, the hashes in the auth backend must also
|
||||
* be recalculated.
|
||||
*
|
||||
* Note that if this changes, the hashes in the auth backend must also
|
||||
* be recalculated.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $authRealm = 'SabreDAV';
|
||||
|
||||
/**
|
||||
* Sets up the object. A PDO object must be passed to setup all the backends.
|
||||
*
|
||||
* @param PDO $pdo
|
||||
*
|
||||
* @param PDO $pdo
|
||||
*/
|
||||
public function __construct(PDO $pdo) {
|
||||
|
||||
|
|
|
@ -1,68 +1,68 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The UserCalenders class contains all calendars associated to one user
|
||||
*
|
||||
* The UserCalenders class contains all calendars associated to one user
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre_DAVACL_IACL {
|
||||
|
||||
/**
|
||||
* Principal backend
|
||||
*
|
||||
* Principal backend
|
||||
*
|
||||
* @var Sabre_DAVACL_IPrincipalBackend
|
||||
*/
|
||||
protected $principalBackend;
|
||||
|
||||
/**
|
||||
* CalDAV backend
|
||||
*
|
||||
*
|
||||
* @var Sabre_CalDAV_Backend_Abstract
|
||||
*/
|
||||
protected $caldavBackend;
|
||||
|
||||
/**
|
||||
* Principal information
|
||||
*
|
||||
* @var array
|
||||
* Principal information
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $principalInfo;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param Sabre_CalDAV_Backend_Abstract $caldavBackend
|
||||
* @param mixed $userUri
|
||||
* @param Sabre_CalDAV_Backend_Abstract $caldavBackend
|
||||
* @param mixed $userUri
|
||||
*/
|
||||
public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend, Sabre_CalDAV_Backend_Abstract $caldavBackend, $userUri) {
|
||||
|
||||
$this->principalBackend = $principalBackend;
|
||||
$this->caldavBackend = $caldavBackend;
|
||||
$this->principalInfo = $principalBackend->getPrincipalByPath($userUri);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this object
|
||||
*
|
||||
* Returns the name of this object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
||||
list(,$name) = Sabre_DAV_URLUtil::splitPath($this->principalInfo['uri']);
|
||||
return $name;
|
||||
return $name;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the name of this object
|
||||
*
|
||||
* @param string $name
|
||||
* Updates the name of this object
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setName($name) {
|
||||
|
@ -72,8 +72,8 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes this object
|
||||
*
|
||||
* Deletes this object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
@ -83,13 +83,13 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the last modification date
|
||||
*
|
||||
* @return int
|
||||
* Returns the last modification date
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
||||
return null;
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,9 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
* Creates a new file under this object.
|
||||
*
|
||||
* This is currently not allowed
|
||||
*
|
||||
* @param string $filename
|
||||
* @param resource $data
|
||||
*
|
||||
* @param string $filename
|
||||
* @param resource $data
|
||||
* @return void
|
||||
*/
|
||||
public function createFile($filename, $data=null) {
|
||||
|
@ -112,8 +112,8 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
* Creates a new directory under this object.
|
||||
*
|
||||
* This is currently not allowed.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*/
|
||||
public function createDirectory($filename) {
|
||||
|
@ -123,11 +123,11 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a single calendar, by name
|
||||
*
|
||||
* Returns a single calendar, by name
|
||||
*
|
||||
* @param string $name
|
||||
* @todo needs optimizing
|
||||
* @return Sabre_CalDAV_Calendar
|
||||
* @return Sabre_CalDAV_Calendar
|
||||
*/
|
||||
public function getChild($name) {
|
||||
|
||||
|
@ -136,22 +136,22 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
return $child;
|
||||
|
||||
}
|
||||
throw new Sabre_DAV_Exception_FileNotFound('Calendar with name \'' . $name . '\' could not be found');
|
||||
throw new Sabre_DAV_Exception_NotFound('Calendar with name \'' . $name . '\' could not be found');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a calendar exists.
|
||||
*
|
||||
*
|
||||
* @param string $name
|
||||
* @todo needs optimizing
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function childExists($name) {
|
||||
|
||||
foreach($this->getChildren() as $child) {
|
||||
if ($name==$child->getName())
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
|
@ -160,8 +160,8 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
|
||||
/**
|
||||
* Returns a list of calendars
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getChildren() {
|
||||
|
||||
|
@ -170,15 +170,17 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
foreach($calendars as $calendar) {
|
||||
$objs[] = new Sabre_CalDAV_Calendar($this->principalBackend, $this->caldavBackend, $calendar);
|
||||
}
|
||||
$objs[] = new Sabre_CalDAV_Schedule_Outbox($this->principalInfo['uri']);
|
||||
return $objs;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new calendar
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $properties
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $resourceType
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function createExtendedCollection($name, array $resourceType, array $properties) {
|
||||
|
@ -193,8 +195,8 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
/**
|
||||
* Returns the owner principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner() {
|
||||
|
@ -207,8 +209,8 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
* Returns a group principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup() {
|
||||
|
||||
|
@ -220,13 +222,13 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL() {
|
||||
|
||||
|
@ -264,9 +266,9 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
/**
|
||||
* Updates the ACL
|
||||
*
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* @return void
|
||||
*/
|
||||
public function setACL(array $acl) {
|
||||
|
@ -275,6 +277,22 @@ class Sabre_CalDAV_UserCalendars implements Sabre_DAV_IExtendedCollection, Sabre
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* This class contains the Sabre_CalDAV version constants.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ class Sabre_CalDAV_Version {
|
|||
/**
|
||||
* Full version number
|
||||
*/
|
||||
const VERSION = '1.5.3';
|
||||
const VERSION = '1.6.2';
|
||||
|
||||
/**
|
||||
* Stability : alpha, beta, stable
|
||||
|
|
|
@ -1,208 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* XML utilities for CalDAV
|
||||
*
|
||||
* This class contains a few static methods used for parsing certain CalDAV
|
||||
* requests.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CalDAV_XMLUtil {
|
||||
|
||||
/**
|
||||
* This function parses the calendar-query report request body
|
||||
*
|
||||
* The body is quite complicated, so we're turning it into a PHP
|
||||
* array.
|
||||
*
|
||||
* The resulting associative array has xpath expressions as keys.
|
||||
* By default the xpath expressions should simply be checked for existance
|
||||
* The xpath expressions can point to elements or attributes.
|
||||
*
|
||||
* The array values can contain a number of items, which alters the query
|
||||
* filter.
|
||||
*
|
||||
* * time-range. Must also check if the todo or event falls within the
|
||||
* specified timerange. How this is interpreted depends on
|
||||
* the type of object (VTODO, VEVENT, VJOURNAL, etc)
|
||||
* * is-not-defined
|
||||
* Instead of checking if the attribute or element exist,
|
||||
* we must check if it doesn't.
|
||||
* * text-match
|
||||
* Checks if the value of the attribute or element matches
|
||||
* the specified value. This is actually another array with
|
||||
* the 'collation', 'value' and 'negate-condition' items.
|
||||
*
|
||||
* Refer to the CalDAV spec for more information.
|
||||
*
|
||||
* @param DOMNode $domNode
|
||||
* @param string $basePath used for recursive calls.
|
||||
* @param array $filters used for recursive calls.
|
||||
* @return array
|
||||
*/
|
||||
static public function parseCalendarQueryFilters($domNode,$basePath = '/c:iCalendar', &$filters = array()) {
|
||||
|
||||
foreach($domNode->childNodes as $child) {
|
||||
|
||||
switch(Sabre_DAV_XMLUtil::toClarkNotation($child)) {
|
||||
|
||||
case '{urn:ietf:params:xml:ns:caldav}comp-filter' :
|
||||
case '{urn:ietf:params:xml:ns:caldav}prop-filter' :
|
||||
|
||||
$filterName = $basePath . '/' . 'c:' . strtolower($child->getAttribute('name'));
|
||||
$filters[$filterName] = array();
|
||||
|
||||
self::parseCalendarQueryFilters($child, $filterName,$filters);
|
||||
break;
|
||||
|
||||
case '{urn:ietf:params:xml:ns:caldav}time-range' :
|
||||
|
||||
if ($start = $child->getAttribute('start')) {
|
||||
$start = self::parseICalendarDateTime($start);
|
||||
} else {
|
||||
$start = null;
|
||||
}
|
||||
if ($end = $child->getAttribute('end')) {
|
||||
$end = self::parseICalendarDateTime($end);
|
||||
} else {
|
||||
$end = null;
|
||||
}
|
||||
|
||||
if (!is_null($start) && !is_null($end) && $end <= $start) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The end-date must be larger than the start-date in the time-range filter');
|
||||
}
|
||||
|
||||
$filters[$basePath]['time-range'] = array(
|
||||
'start' => $start,
|
||||
'end' => $end
|
||||
);
|
||||
break;
|
||||
|
||||
case '{urn:ietf:params:xml:ns:caldav}is-not-defined' :
|
||||
$filters[$basePath]['is-not-defined'] = true;
|
||||
break;
|
||||
|
||||
case '{urn:ietf:params:xml:ns:caldav}param-filter' :
|
||||
|
||||
$filterName = $basePath . '/@' . strtolower($child->getAttribute('name'));
|
||||
$filters[$filterName] = array();
|
||||
self::parseCalendarQueryFilters($child, $filterName, $filters);
|
||||
break;
|
||||
|
||||
case '{urn:ietf:params:xml:ns:caldav}text-match' :
|
||||
|
||||
$collation = $child->getAttribute('collation');
|
||||
if (!$collation) $collation = 'i;ascii-casemap';
|
||||
|
||||
$filters[$basePath]['text-match'] = array(
|
||||
'collation' => ($collation == 'default'?'i;ascii-casemap':$collation),
|
||||
'negate-condition' => $child->getAttribute('negate-condition')==='yes',
|
||||
'value' => $child->nodeValue,
|
||||
);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $filters;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an iCalendar (rfc5545) formatted datetime and returns a DateTime object
|
||||
*
|
||||
* Specifying a reference timezone is optional. It will only be used
|
||||
* if the non-UTC format is used. The argument is used as a reference, the
|
||||
* returned DateTime object will still be in the UTC timezone.
|
||||
*
|
||||
* @param string $dt
|
||||
* @param DateTimeZone $tz
|
||||
* @return DateTime
|
||||
*/
|
||||
static public function parseICalendarDateTime($dt,DateTimeZone $tz = null) {
|
||||
|
||||
// Format is YYYYMMDD + "T" + hhmmss
|
||||
$result = preg_match('/^([1-3][0-9]{3})([0-1][0-9])([0-3][0-9])T([0-2][0-9])([0-5][0-9])([0-5][0-9])([Z]?)$/',$dt,$matches);
|
||||
|
||||
if (!$result) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar datetime value is incorrect: ' . $dt);
|
||||
}
|
||||
|
||||
if ($matches[7]==='Z' || is_null($tz)) {
|
||||
$tz = new DateTimeZone('UTC');
|
||||
}
|
||||
$date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] .':' . $matches[6], $tz);
|
||||
|
||||
// Still resetting the timezone, to normalize everything to UTC
|
||||
$date->setTimeZone(new DateTimeZone('UTC'));
|
||||
return $date;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an iCalendar (rfc5545) formatted datetime and returns a DateTime object
|
||||
*
|
||||
* @param string $date
|
||||
* @param DateTimeZone $tz
|
||||
* @return DateTime
|
||||
*/
|
||||
static public function parseICalendarDate($date) {
|
||||
|
||||
// Format is YYYYMMDD
|
||||
$result = preg_match('/^([1-3][0-9]{3})([0-1][0-9])([0-3][0-9])$/',$date,$matches);
|
||||
|
||||
if (!$result) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar date value is incorrect: ' . $date);
|
||||
}
|
||||
|
||||
$date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], new DateTimeZone('UTC'));
|
||||
return $date;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an iCalendar (RFC5545) formatted duration and returns a string suitable
|
||||
* for strtotime or DateTime::modify.
|
||||
*
|
||||
* NOTE: When we require PHP 5.3 this can be replaced by the DateTimeInterval object, which
|
||||
* supports ISO 8601 Intervals, which is a superset of ICalendar durations.
|
||||
*
|
||||
* For now though, we're just gonna live with this messy system
|
||||
*
|
||||
* @param string $duration
|
||||
* @return string
|
||||
*/
|
||||
static public function parseICalendarDuration($duration) {
|
||||
|
||||
$result = preg_match('/^(?P<plusminus>\+|-)?P((?P<week>\d+)W)?((?P<day>\d+)D)?(T((?P<hour>\d+)H)?((?P<minute>\d+)M)?((?P<second>\d+)S)?)?$/', $duration, $matches);
|
||||
if (!$result) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar duration value is incorrect: ' . $duration);
|
||||
}
|
||||
|
||||
$parts = array(
|
||||
'week',
|
||||
'day',
|
||||
'hour',
|
||||
'minute',
|
||||
'second',
|
||||
);
|
||||
|
||||
$newDur = '';
|
||||
foreach($parts as $part) {
|
||||
if (isset($matches[$part]) && $matches[$part]) {
|
||||
$newDur.=' '.$matches[$part] . ' ' . $part . 's';
|
||||
}
|
||||
}
|
||||
|
||||
$newDur = ($matches['plusminus']==='-'?'-':'+') . trim($newDur);
|
||||
return $newDur;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Sabre_CalDAV includes file
|
||||
*
|
||||
* Including this file will automatically include all files from the
|
||||
* Sabre_CalDAV package.
|
||||
*
|
||||
* This often allows faster loadtimes, as autoload-speed is often quite slow.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CalDAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
||||
// Begin includes
|
||||
include __DIR__ . '/Backend/Abstract.php';
|
||||
include __DIR__ . '/Backend/PDO.php';
|
||||
include __DIR__ . '/CalendarQueryParser.php';
|
||||
include __DIR__ . '/CalendarQueryValidator.php';
|
||||
include __DIR__ . '/CalendarRootNode.php';
|
||||
include __DIR__ . '/ICalendar.php';
|
||||
include __DIR__ . '/ICalendarObject.php';
|
||||
include __DIR__ . '/ICSExportPlugin.php';
|
||||
include __DIR__ . '/Plugin.php';
|
||||
include __DIR__ . '/Principal/Collection.php';
|
||||
include __DIR__ . '/Principal/ProxyRead.php';
|
||||
include __DIR__ . '/Principal/ProxyWrite.php';
|
||||
include __DIR__ . '/Principal/User.php';
|
||||
include __DIR__ . '/Property/SupportedCalendarComponentSet.php';
|
||||
include __DIR__ . '/Property/SupportedCalendarData.php';
|
||||
include __DIR__ . '/Property/SupportedCollationSet.php';
|
||||
include __DIR__ . '/Schedule/IMip.php';
|
||||
include __DIR__ . '/Schedule/IOutbox.php';
|
||||
include __DIR__ . '/Schedule/Outbox.php';
|
||||
include __DIR__ . '/Server.php';
|
||||
include __DIR__ . '/UserCalendars.php';
|
||||
include __DIR__ . '/Version.php';
|
||||
include __DIR__ . '/Calendar.php';
|
||||
include __DIR__ . '/CalendarObject.php';
|
||||
// End includes
|
|
@ -7,34 +7,33 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_CardDAV_IAddressBook, Sabre_DAV_IProperties, Sabre_DAVACL_IACL {
|
||||
|
||||
/**
|
||||
* This is an array with addressbook information
|
||||
*
|
||||
* @var array
|
||||
* This is an array with addressbook information
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $addressBookInfo;
|
||||
|
||||
/**
|
||||
* CardDAV backend
|
||||
*
|
||||
* @var Sabre_CardDAV_Backend_Abstract
|
||||
* CardDAV backend
|
||||
*
|
||||
* @var Sabre_CardDAV_Backend_Abstract
|
||||
*/
|
||||
private $carddavBackend;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
|
||||
* @param array $addressBookInfo
|
||||
* @return void
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
|
||||
* @param array $addressBookInfo
|
||||
*/
|
||||
public function __construct(Sabre_CardDAV_Backend_Abstract $carddavBackend,array $addressBookInfo) {
|
||||
public function __construct(Sabre_CardDAV_Backend_Abstract $carddavBackend, array $addressBookInfo) {
|
||||
|
||||
$this->carddavBackend = $carddavBackend;
|
||||
$this->addressBookInfo = $addressBookInfo;
|
||||
|
@ -42,9 +41,9 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the addressbook
|
||||
*
|
||||
* @return string
|
||||
* Returns the name of the addressbook
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -55,21 +54,21 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
/**
|
||||
* Returns a card
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return Sabre_DAV_Card
|
||||
*/
|
||||
public function getChild($name) {
|
||||
|
||||
$obj = $this->carddavBackend->getCard($this->addressBookInfo['id'],$name);
|
||||
if (!$obj) throw new Sabre_DAV_Exception_FileNotFound('Card not found');
|
||||
if (!$obj) throw new Sabre_DAV_Exception_NotFound('Card not found');
|
||||
return new Sabre_CardDAV_Card($this->carddavBackend,$this->addressBookInfo,$obj);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full list of cards
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getChildren() {
|
||||
|
||||
|
@ -85,9 +84,9 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
/**
|
||||
* Creates a new directory
|
||||
*
|
||||
* We actually block this, as subdirectories are not allowed in addressbooks.
|
||||
*
|
||||
* @param string $name
|
||||
* We actually block this, as subdirectories are not allowed in addressbooks.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function createDirectory($name) {
|
||||
|
@ -99,11 +98,13 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
/**
|
||||
* Creates a new file
|
||||
*
|
||||
* The contents of the new file must be a valid VCARD
|
||||
*
|
||||
* @param string $name
|
||||
* @param resource $vcardData
|
||||
* @return void
|
||||
* The contents of the new file must be a valid VCARD.
|
||||
*
|
||||
* This method may return an ETag.
|
||||
*
|
||||
* @param string $name
|
||||
* @param resource $vcardData
|
||||
* @return void|null
|
||||
*/
|
||||
public function createFile($name,$vcardData = null) {
|
||||
|
||||
|
@ -111,13 +112,13 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
// Converting to UTF-8, if needed
|
||||
$vcardData = Sabre_DAV_StringUtil::ensureUTF8($vcardData);
|
||||
|
||||
$this->carddavBackend->createCard($this->addressBookInfo['id'],$name,$vcardData);
|
||||
return $this->carddavBackend->createCard($this->addressBookInfo['id'],$name,$vcardData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the entire addressbook.
|
||||
*
|
||||
* Deletes the entire addressbook.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
@ -128,8 +129,8 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
|
||||
/**
|
||||
* Renames the addressbook
|
||||
*
|
||||
* @param string $newName
|
||||
*
|
||||
* @param string $newName
|
||||
* @return void
|
||||
*/
|
||||
public function setName($newName) {
|
||||
|
@ -140,7 +141,7 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
|
||||
/**
|
||||
* Returns the last modification date as a unix timestamp.
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
@ -162,7 +163,7 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
* If the operation was successful, true can be returned.
|
||||
* If the operation failed, false can be returned.
|
||||
*
|
||||
* Deletion of a non-existant property is always succesful.
|
||||
* Deletion of a non-existent property is always successful.
|
||||
*
|
||||
* Lastly, it is optional to return detailed information about any
|
||||
* failures. In this case an array should be returned with the following
|
||||
|
@ -177,16 +178,16 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
* )
|
||||
* )
|
||||
*
|
||||
* In this example it was forbidden to update {DAV:}displayname.
|
||||
* In this example it was forbidden to update {DAV:}displayname.
|
||||
* (403 Forbidden), which in turn also caused {DAV:}owner to fail
|
||||
* (424 Failed Dependency) because the request needs to be atomic.
|
||||
*
|
||||
* @param array $mutations
|
||||
* @return bool|array
|
||||
* @param array $mutations
|
||||
* @return bool|array
|
||||
*/
|
||||
public function updateProperties($mutations) {
|
||||
|
||||
return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $mutations);
|
||||
return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $mutations);
|
||||
|
||||
}
|
||||
|
||||
|
@ -198,8 +199,8 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
*
|
||||
* If the array is empty, it means 'all properties' were requested.
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
* @param array $properties
|
||||
* @return array
|
||||
*/
|
||||
public function getProperties($properties) {
|
||||
|
||||
|
@ -221,8 +222,8 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
/**
|
||||
* Returns the owner principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner() {
|
||||
|
@ -235,8 +236,8 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
* Returns a group principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup() {
|
||||
|
||||
|
@ -248,13 +249,13 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL() {
|
||||
|
||||
|
@ -277,9 +278,9 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
/**
|
||||
* Updates the ACL
|
||||
*
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* @return void
|
||||
*/
|
||||
public function setACL(array $acl) {
|
||||
|
@ -288,6 +289,22 @@ class Sabre_CardDAV_AddressBook extends Sabre_DAV_Collection implements Sabre_Ca
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
/**
|
||||
* Parses the addressbook-query report request body.
|
||||
*
|
||||
* Whoever designed this format, and the CalDAV equavalent even more so,
|
||||
* Whoever designed this format, and the CalDAV equivalent even more so,
|
||||
* has no feel for design.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -19,8 +19,8 @@ class Sabre_CardDAV_AddressBookQueryParser {
|
|||
|
||||
/**
|
||||
* List of requested properties the client wanted
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $requestedProperties;
|
||||
|
||||
|
@ -28,44 +28,43 @@ class Sabre_CardDAV_AddressBookQueryParser {
|
|||
* The number of results the client wants
|
||||
*
|
||||
* null means it wasn't specified, which in most cases means 'all results'.
|
||||
*
|
||||
* @var int|null
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
public $limit;
|
||||
|
||||
/**
|
||||
* List of property filters.
|
||||
*
|
||||
* @var array
|
||||
* @var array
|
||||
*/
|
||||
public $filters;
|
||||
|
||||
/**
|
||||
* Either TEST_ANYOF or TEST_ALLOF
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $test;
|
||||
|
||||
/**
|
||||
* DOM Document
|
||||
*
|
||||
* @var DOMDocument
|
||||
*
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $dom;
|
||||
|
||||
/**
|
||||
* DOM XPath object
|
||||
*
|
||||
* @var DOMXPath
|
||||
* DOM XPath object
|
||||
*
|
||||
* @var DOMXPath
|
||||
*/
|
||||
protected $xpath;
|
||||
|
||||
/**
|
||||
* Creates the parser
|
||||
*
|
||||
* @param DOMNode $dom
|
||||
* @return void
|
||||
*
|
||||
* @param DOMDocument $dom
|
||||
*/
|
||||
public function __construct(DOMDocument $dom) {
|
||||
|
||||
|
@ -77,15 +76,14 @@ class Sabre_CardDAV_AddressBookQueryParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses the request.
|
||||
*
|
||||
* @param DOMNode $dom
|
||||
* Parses the request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function parse() {
|
||||
|
||||
$filterNode = null;
|
||||
|
||||
|
||||
$limit = $this->xpath->evaluate('number(/card:addressbook-query/card:limit/card:nresults)');
|
||||
if (is_nan($limit)) $limit = null;
|
||||
|
||||
|
@ -120,9 +118,9 @@ class Sabre_CardDAV_AddressBookQueryParser {
|
|||
|
||||
/**
|
||||
* Parses the prop-filter xml element
|
||||
*
|
||||
* @param DOMElement $propFilterNode
|
||||
* @return array
|
||||
*
|
||||
* @param DOMElement $propFilterNode
|
||||
* @return array
|
||||
*/
|
||||
protected function parsePropFilterNode(DOMElement $propFilterNode) {
|
||||
|
||||
|
@ -157,13 +155,13 @@ class Sabre_CardDAV_AddressBookQueryParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses the param-filter element
|
||||
*
|
||||
* @param DOMElement $paramFilterNode
|
||||
* @return array
|
||||
* Parses the param-filter element
|
||||
*
|
||||
* @param DOMElement $paramFilterNode
|
||||
* @return array
|
||||
*/
|
||||
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;
|
||||
|
@ -174,15 +172,15 @@ class Sabre_CardDAV_AddressBookQueryParser {
|
|||
$paramFilter['text-match'] = $this->parseTextMatchNode($textMatch->item(0));
|
||||
}
|
||||
|
||||
return $paramFilter;
|
||||
return $paramFilter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Text match
|
||||
*
|
||||
* @param DOMElement $textMatchNode
|
||||
* @return void
|
||||
*
|
||||
* @param DOMElement $textMatchNode
|
||||
* @return array
|
||||
*/
|
||||
public function parseTextMatchNode(DOMElement $textMatchNode) {
|
||||
|
||||
|
@ -204,8 +202,8 @@ class Sabre_CardDAV_AddressBookQueryParser {
|
|||
'match-type' => $matchType,
|
||||
'value' => $textMatchNode->nodeValue
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* AddressBook rootnode
|
||||
* AddressBook rootnode
|
||||
*
|
||||
* This object lists a collection of users, which can contain addressbooks.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CardDAV_AddressBookRoot extends Sabre_DAVACL_AbstractPrincipalCollection {
|
||||
|
||||
/**
|
||||
* Principal Backend
|
||||
*
|
||||
* Principal Backend
|
||||
*
|
||||
* @var Sabre_DAVACL_IPrincipalBackend
|
||||
*/
|
||||
protected $principalBackend;
|
||||
|
||||
/**
|
||||
* CardDAV backend
|
||||
*
|
||||
* @var Sabre_CardDAV_Backend_Abstract
|
||||
* CardDAV backend
|
||||
*
|
||||
* @var Sabre_CardDAV_Backend_Abstract
|
||||
*/
|
||||
protected $carddavBackend;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor
|
||||
*
|
||||
* This constructor needs both a principal and a carddav backend.
|
||||
*
|
||||
* By default this class will show a list of addressbook collections for
|
||||
* principals in the 'principals' collection. If your main principals are
|
||||
* actually located in a different path, use the $principalPrefix argument
|
||||
* By default this class will show a list of addressbook collections for
|
||||
* principals in the 'principals' collection. If your main principals are
|
||||
* actually located in a different path, use the $principalPrefix argument
|
||||
* to override this.
|
||||
*
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param Sabre_DAVACL_IPrincipalBackend $principalBackend
|
||||
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
|
||||
* @param string $principalPrefix
|
||||
* @param string $principalPrefix
|
||||
*/
|
||||
public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend,Sabre_CardDAV_Backend_Abstract $carddavBackend, $principalPrefix = 'principals') {
|
||||
|
||||
|
@ -49,9 +49,9 @@ class Sabre_CardDAV_AddressBookRoot extends Sabre_DAVACL_AbstractPrincipalCollec
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the node
|
||||
*
|
||||
* @return string
|
||||
* Returns the name of the node
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -65,9 +65,9 @@ class Sabre_CardDAV_AddressBookRoot extends Sabre_DAVACL_AbstractPrincipalCollec
|
|||
* The passed array contains principal information, and is guaranteed to
|
||||
* at least contain a uri item. Other properties may or may not be
|
||||
* supplied by the authentication backend.
|
||||
*
|
||||
* @param array $principal
|
||||
* @return Sabre_DAV_INode
|
||||
*
|
||||
* @param array $principal
|
||||
* @return Sabre_DAV_INode
|
||||
*/
|
||||
public function getChildForPrincipal(array $principal) {
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
*
|
||||
* This class serves as a base-class for addressbook backends
|
||||
*
|
||||
* Note that there are references to 'addressBookId' scattered throughout the
|
||||
* class. The value of the addressBookId is completely up to you, it can be any
|
||||
* Note that there are references to 'addressBookId' scattered throughout the
|
||||
* class. The value of the addressBookId is completely up to you, it can be any
|
||||
* arbitrary value you can use as an unique identifier.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
abstract class Sabre_CardDAV_Backend_Abstract {
|
||||
|
@ -25,97 +25,142 @@ abstract class Sabre_CardDAV_Backend_Abstract {
|
|||
* uri - the 'basename' part of the url
|
||||
* principaluri - Same as the passed parameter
|
||||
*
|
||||
* Any additional clark-notation property may be passed besides this. Some
|
||||
* Any additional clark-notation property may be passed besides this. Some
|
||||
* common ones are :
|
||||
* {DAV:}displayname
|
||||
* {urn:ietf:params:xml:ns:carddav}addressbook-description
|
||||
* {http://calendarserver.org/ns/}getctag
|
||||
*
|
||||
* @param string $principalUri
|
||||
* @return array
|
||||
*
|
||||
* @param string $principalUri
|
||||
* @return array
|
||||
*/
|
||||
public abstract function getAddressBooksForUser($principalUri);
|
||||
public abstract function getAddressBooksForUser($principalUri);
|
||||
|
||||
/**
|
||||
* Updates an addressbook's properties
|
||||
*
|
||||
* See Sabre_DAV_IProperties for a description of the mutations array, as
|
||||
* well as the return value.
|
||||
* See Sabre_DAV_IProperties for a description of the mutations array, as
|
||||
* well as the return value.
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param array $mutations
|
||||
* @see Sabre_DAV_IProperties::updateProperties
|
||||
* @return bool|array
|
||||
*/
|
||||
public abstract function updateAddressBook($addressBookId, array $mutations);
|
||||
public abstract function updateAddressBook($addressBookId, array $mutations);
|
||||
|
||||
/**
|
||||
* Creates a new address book
|
||||
* Creates a new address book
|
||||
*
|
||||
* @param string $principalUri
|
||||
* @param string $url Just the 'basename' of the url.
|
||||
* @param array $properties
|
||||
* @param string $principalUri
|
||||
* @param string $url Just the 'basename' of the url.
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
abstract public function createAddressBook($principalUri, $url, array $properties);
|
||||
abstract public function createAddressBook($principalUri, $url, array $properties);
|
||||
|
||||
/**
|
||||
* Deletes an entire addressbook and all its contents
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param mixed $addressBookId
|
||||
* @return void
|
||||
*/
|
||||
abstract public function deleteAddressBook($addressBookId);
|
||||
abstract public function deleteAddressBook($addressBookId);
|
||||
|
||||
/**
|
||||
* Returns all cards for a specific addressbook id.
|
||||
* Returns all cards for a specific addressbook id.
|
||||
*
|
||||
* This method should return the following properties for each card:
|
||||
* * carddata - raw vcard data
|
||||
* * uri - Some unique url
|
||||
* * lastmodified - A unix timestamp
|
||||
|
||||
* @param mixed $addressbookId
|
||||
* @return array
|
||||
*
|
||||
* It's recommended to also return the following properties:
|
||||
* * etag - A unique etag. This must change every time the card changes.
|
||||
* * size - The size of the card in bytes.
|
||||
*
|
||||
* If these last two properties are provided, less time will be spent
|
||||
* calculating them. If they are specified, you can also ommit carddata.
|
||||
* This may speed up certain requests, especially with large cards.
|
||||
*
|
||||
* @param mixed $addressbookId
|
||||
* @return array
|
||||
*/
|
||||
public abstract function getCards($addressbookId);
|
||||
public abstract function getCards($addressbookId);
|
||||
|
||||
/**
|
||||
* Returns a specfic card
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @return void
|
||||
* Returns a specfic card.
|
||||
*
|
||||
* The same set of properties must be returned as with getCards. The only
|
||||
* exception is that 'carddata' is absolutely required.
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @return array
|
||||
*/
|
||||
public abstract function getCard($addressBookId, $cardUri);
|
||||
public abstract function getCard($addressBookId, $cardUri);
|
||||
|
||||
/**
|
||||
* Creates a new card
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @param string $cardData
|
||||
* @return bool
|
||||
* Creates a new card.
|
||||
*
|
||||
* The addressbook id will be passed as the first argument. This is the
|
||||
* same id as it is returned from the getAddressbooksForUser method.
|
||||
*
|
||||
* The cardUri is a base uri, and doesn't include the full path. The
|
||||
* cardData argument is the vcard body, and is passed as a string.
|
||||
*
|
||||
* It is possible to return an ETag from this method. This ETag is for the
|
||||
* newly created resource, and must be enclosed with double quotes (that
|
||||
* is, the string itself must contain the double quotes).
|
||||
*
|
||||
* You should only return the ETag if you store the carddata as-is. If a
|
||||
* subsequent GET request on the same card does not have the same body,
|
||||
* byte-by-byte and you did return an ETag here, clients tend to get
|
||||
* confused.
|
||||
*
|
||||
* If you don't return an ETag, you can just return null.
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @param string $cardData
|
||||
* @return string|null
|
||||
*/
|
||||
abstract public function createCard($addressBookId, $cardUri, $cardData);
|
||||
abstract public function createCard($addressBookId, $cardUri, $cardData);
|
||||
|
||||
/**
|
||||
* Updates a card
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @param string $cardData
|
||||
* @return bool
|
||||
* Updates a card.
|
||||
*
|
||||
* The addressbook id will be passed as the first argument. This is the
|
||||
* same id as it is returned from the getAddressbooksForUser method.
|
||||
*
|
||||
* The cardUri is a base uri, and doesn't include the full path. The
|
||||
* cardData argument is the vcard body, and is passed as a string.
|
||||
*
|
||||
* It is possible to return an ETag from this method. This ETag should
|
||||
* match that of the updated resource, and must be enclosed with double
|
||||
* quotes (that is: the string itself must contain the actual quotes).
|
||||
*
|
||||
* You should only return the ETag if you store the carddata as-is. If a
|
||||
* subsequent GET request on the same card does not have the same body,
|
||||
* byte-by-byte and you did return an ETag here, clients tend to get
|
||||
* confused.
|
||||
*
|
||||
* If you don't return an ETag, you can just return null.
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @param string $cardData
|
||||
* @return string|null
|
||||
*/
|
||||
abstract public function updateCard($addressBookId, $cardUri, $cardData);
|
||||
abstract public function updateCard($addressBookId, $cardUri, $cardData);
|
||||
|
||||
/**
|
||||
* Deletes a card
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @return bool
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function deleteCard($addressBookId, $cardUri);
|
||||
abstract public function deleteCard($addressBookId, $cardUri);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,19 +4,19 @@
|
|||
* PDO CardDAV backend
|
||||
*
|
||||
* This CardDAV backend uses PDO to store addressbooks
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
||||
|
||||
/**
|
||||
* PDO connection
|
||||
*
|
||||
* @var PDO
|
||||
* PDO connection
|
||||
*
|
||||
* @var PDO
|
||||
*/
|
||||
protected $pdo;
|
||||
|
||||
|
@ -31,28 +31,30 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
protected $cardsTableName;
|
||||
|
||||
/**
|
||||
* Sets up the object
|
||||
*
|
||||
* @param PDO $pdo
|
||||
* Sets up the object
|
||||
*
|
||||
* @param PDO $pdo
|
||||
* @param string $addressBooksTableName
|
||||
* @param string $cardsTableName
|
||||
*/
|
||||
public function __construct(PDO $pdo, $addressBooksTableName = 'addressbooks', $cardsTableName = 'cards') {
|
||||
|
||||
$this->pdo = $pdo;
|
||||
$this->addressBooksTableName = $addressBooksTableName;
|
||||
$this->cardsTableName = $cardsTableName;
|
||||
$this->cardsTableName = $cardsTableName;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of addressbooks for a specific user.
|
||||
*
|
||||
* @param string $principalUri
|
||||
* @return array
|
||||
* Returns the list of addressbooks for a specific user.
|
||||
*
|
||||
* @param string $principalUri
|
||||
* @return array
|
||||
*/
|
||||
public function getAddressBooksForUser($principalUri) {
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, ctag FROM `'.$this->addressBooksTableName.'` WHERE principaluri = ?');
|
||||
$result = $stmt->execute(array($principalUri));
|
||||
$stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, ctag FROM '.$this->addressBooksTableName.' WHERE principaluri = ?');
|
||||
$stmt->execute(array($principalUri));
|
||||
|
||||
$addressBooks = array();
|
||||
|
||||
|
@ -65,7 +67,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
'{DAV:}displayname' => $row['displayname'],
|
||||
'{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
|
||||
'{http://calendarserver.org/ns/}getctag' => $row['ctag'],
|
||||
'{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' =>
|
||||
'{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' =>
|
||||
new Sabre_CardDAV_Property_SupportedAddressData(),
|
||||
);
|
||||
|
||||
|
@ -79,8 +81,8 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
/**
|
||||
* Updates an addressbook's properties
|
||||
*
|
||||
* See Sabre_DAV_IProperties for a description of the mutations array, as
|
||||
* well as the return value.
|
||||
* See Sabre_DAV_IProperties for a description of the mutations array, as
|
||||
* well as the return value.
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param array $mutations
|
||||
|
@ -88,7 +90,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
* @return bool|array
|
||||
*/
|
||||
public function updateAddressBook($addressBookId, array $mutations) {
|
||||
|
||||
|
||||
$updates = array();
|
||||
|
||||
foreach($mutations as $property=>$newValue) {
|
||||
|
@ -101,7 +103,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
$updates['description'] = $newValue;
|
||||
break;
|
||||
default :
|
||||
// If any unsupported values were being updated, we must
|
||||
// If any unsupported values were being updated, we must
|
||||
// let the entire request fail.
|
||||
return false;
|
||||
}
|
||||
|
@ -113,7 +115,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
return false;
|
||||
}
|
||||
|
||||
$query = 'UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 ';
|
||||
$query = 'UPDATE ' . $this->addressBooksTableName . ' SET ctag = ctag + 1 ';
|
||||
foreach($updates as $key=>$value) {
|
||||
$query.=', `' . $key . '` = :' . $key . ' ';
|
||||
}
|
||||
|
@ -129,11 +131,11 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new address book
|
||||
* Creates a new address book
|
||||
*
|
||||
* @param string $principalUri
|
||||
* @param string $url Just the 'basename' of the url.
|
||||
* @param array $properties
|
||||
* @param string $principalUri
|
||||
* @param string $url Just the 'basename' of the url.
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function createAddressBook($principalUri, $url, array $properties) {
|
||||
|
@ -160,7 +162,7 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
|
||||
}
|
||||
|
||||
$query = 'INSERT INTO `' . $this->addressBooksTableName . '` (uri, displayname, description, principaluri, ctag) VALUES (:uri, :displayname, :description, :principaluri, 1)';
|
||||
$query = 'INSERT INTO ' . $this->addressBooksTableName . ' (uri, displayname, description, principaluri, ctag) VALUES (:uri, :displayname, :description, :principaluri, 1)';
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$stmt->execute($values);
|
||||
|
||||
|
@ -169,44 +171,61 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
/**
|
||||
* Deletes an entire addressbook and all its contents
|
||||
*
|
||||
* @param int $addressBookId
|
||||
* @param int $addressBookId
|
||||
* @return void
|
||||
*/
|
||||
public function deleteAddressBook($addressBookId) {
|
||||
|
||||
$stmt = $this->pdo->prepare('DELETE FROM `' . $this->cardsTableName . '` WHERE addressbookid = ?');
|
||||
$stmt = $this->pdo->prepare('DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?');
|
||||
$stmt->execute(array($addressBookId));
|
||||
|
||||
$stmt = $this->pdo->prepare('DELETE FROM `' . $this->addressBooksTableName . '` WHERE id = ?');
|
||||
$stmt = $this->pdo->prepare('DELETE FROM ' . $this->addressBooksTableName . ' WHERE id = ?');
|
||||
$stmt->execute(array($addressBookId));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all cards for a specific addressbook id.
|
||||
*
|
||||
* @param mixed $addressbookId
|
||||
* @return array
|
||||
* Returns all cards for a specific addressbook id.
|
||||
*
|
||||
* This method should return the following properties for each card:
|
||||
* * carddata - raw vcard data
|
||||
* * uri - Some unique url
|
||||
* * lastmodified - A unix timestamp
|
||||
*
|
||||
* It's recommended to also return the following properties:
|
||||
* * etag - A unique etag. This must change every time the card changes.
|
||||
* * size - The size of the card in bytes.
|
||||
*
|
||||
* If these last two properties are provided, less time will be spent
|
||||
* calculating them. If they are specified, you can also ommit carddata.
|
||||
* This may speed up certain requests, especially with large cards.
|
||||
*
|
||||
* @param mixed $addressbookId
|
||||
* @return array
|
||||
*/
|
||||
public function getCards($addressbookId) {
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM `' . $this->cardsTableName . '` WHERE addressbookid = ?');
|
||||
$stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM ' . $this->cardsTableName . ' WHERE addressbookid = ?');
|
||||
$stmt->execute(array($addressbookId));
|
||||
|
||||
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specfic card
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @return array
|
||||
* Returns a specfic card.
|
||||
*
|
||||
* The same set of properties must be returned as with getCards. The only
|
||||
* exception is that 'carddata' is absolutely required.
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @return array
|
||||
*/
|
||||
public function getCard($addressBookId, $cardUri) {
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM `' . $this->cardsTableName . '` WHERE addressbookid = ? AND uri = ? LIMIT 1');
|
||||
$stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri = ? LIMIT 1');
|
||||
$stmt->execute(array($addressBookId, $cardUri));
|
||||
|
||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
@ -216,59 +235,93 @@ class Sabre_CardDAV_Backend_PDO extends Sabre_CardDAV_Backend_Abstract {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new card
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @param string $cardData
|
||||
* @return bool
|
||||
* Creates a new card.
|
||||
*
|
||||
* The addressbook id will be passed as the first argument. This is the
|
||||
* same id as it is returned from the getAddressbooksForUser method.
|
||||
*
|
||||
* The cardUri is a base uri, and doesn't include the full path. The
|
||||
* cardData argument is the vcard body, and is passed as a string.
|
||||
*
|
||||
* It is possible to return an ETag from this method. This ETag is for the
|
||||
* newly created resource, and must be enclosed with double quotes (that
|
||||
* is, the string itself must contain the double quotes).
|
||||
*
|
||||
* You should only return the ETag if you store the carddata as-is. If a
|
||||
* subsequent GET request on the same card does not have the same body,
|
||||
* byte-by-byte and you did return an ETag here, clients tend to get
|
||||
* confused.
|
||||
*
|
||||
* If you don't return an ETag, you can just return null.
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @param string $cardData
|
||||
* @return string|null
|
||||
*/
|
||||
public function createCard($addressBookId, $cardUri, $cardData) {
|
||||
|
||||
$stmt = $this->pdo->prepare('INSERT INTO `' . $this->cardsTableName . '` (carddata, uri, lastmodified, addressbookid) VALUES (?, ?, ?, ?)');
|
||||
$stmt = $this->pdo->prepare('INSERT INTO ' . $this->cardsTableName . ' (carddata, uri, lastmodified, addressbookid) VALUES (?, ?, ?, ?)');
|
||||
|
||||
$result = $stmt->execute(array($cardData, $cardUri, time(), $addressBookId));
|
||||
|
||||
$stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt2 = $this->pdo->prepare('UPDATE ' . $this->addressBooksTableName . ' SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt2->execute(array($addressBookId));
|
||||
|
||||
return $result;
|
||||
return '"' . md5($cardData) . '"';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a card
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @param string $cardData
|
||||
* @return bool
|
||||
* Updates a card.
|
||||
*
|
||||
* The addressbook id will be passed as the first argument. This is the
|
||||
* same id as it is returned from the getAddressbooksForUser method.
|
||||
*
|
||||
* The cardUri is a base uri, and doesn't include the full path. The
|
||||
* cardData argument is the vcard body, and is passed as a string.
|
||||
*
|
||||
* It is possible to return an ETag from this method. This ETag should
|
||||
* match that of the updated resource, and must be enclosed with double
|
||||
* quotes (that is: the string itself must contain the actual quotes).
|
||||
*
|
||||
* You should only return the ETag if you store the carddata as-is. If a
|
||||
* subsequent GET request on the same card does not have the same body,
|
||||
* byte-by-byte and you did return an ETag here, clients tend to get
|
||||
* confused.
|
||||
*
|
||||
* If you don't return an ETag, you can just return null.
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @param string $cardData
|
||||
* @return string|null
|
||||
*/
|
||||
public function updateCard($addressBookId, $cardUri, $cardData) {
|
||||
|
||||
$stmt = $this->pdo->prepare('UPDATE `' . $this->cardsTableName . '` SET carddata = ?, lastmodified = ? WHERE uri = ? AND addressbookid =?');
|
||||
$result = $stmt->execute(array($cardData, time(), $cardUri, $addressBookId));
|
||||
$stmt = $this->pdo->prepare('UPDATE ' . $this->cardsTableName . ' SET carddata = ?, lastmodified = ? WHERE uri = ? AND addressbookid =?');
|
||||
$stmt->execute(array($cardData, time(), $cardUri, $addressBookId));
|
||||
|
||||
$stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt2 = $this->pdo->prepare('UPDATE ' . $this->addressBooksTableName . ' SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt2->execute(array($addressBookId));
|
||||
|
||||
return $stmt->rowCount()===1;
|
||||
return '"' . md5($cardData) . '"';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a card
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @return bool
|
||||
*
|
||||
* @param mixed $addressBookId
|
||||
* @param string $cardUri
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteCard($addressBookId, $cardUri) {
|
||||
|
||||
$stmt = $this->pdo->prepare('DELETE FROM `' . $this->cardsTableName . '` WHERE addressbookid = ? AND uri = ?');
|
||||
$stmt = $this->pdo->prepare('DELETE FROM ' . $this->cardsTableName . ' WHERE addressbookid = ? AND uri = ?');
|
||||
$stmt->execute(array($addressBookId, $cardUri));
|
||||
|
||||
$stmt2 = $this->pdo->prepare('UPDATE `' . $this->addressBooksTableName . '` SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt2 = $this->pdo->prepare('UPDATE ' . $this->addressBooksTableName . ' SET ctag = ctag + 1 WHERE id = ?');
|
||||
$stmt2->execute(array($addressBookId));
|
||||
|
||||
return $stmt->rowCount()===1;
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* The Card object represents a single Card from an addressbook
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -13,29 +13,29 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
|
||||
/**
|
||||
* CardDAV backend
|
||||
*
|
||||
* @var Sabre_CardDAV_Backend_Abstract
|
||||
*
|
||||
* @var Sabre_CardDAV_Backend_Abstract
|
||||
*/
|
||||
private $carddavBackend;
|
||||
|
||||
/**
|
||||
* Array with information about this Card
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $cardData;
|
||||
|
||||
/**
|
||||
* Array with information about the containing addressbook
|
||||
*
|
||||
* @var array
|
||||
* Array with information about the containing addressbook
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $addressBookInfo;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
|
||||
* @param array $addressBookInfo
|
||||
* @param array $cardData
|
||||
*/
|
||||
|
@ -48,9 +48,9 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the uri for this object
|
||||
*
|
||||
* @return string
|
||||
* Returns the uri for this object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -59,25 +59,26 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the VCard-formatted object
|
||||
*
|
||||
* @return string
|
||||
* Returns the VCard-formatted object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get() {
|
||||
|
||||
$cardData = $this->cardData['carddata'];
|
||||
$s = fopen('php://temp','r+');
|
||||
fwrite($s, $cardData);
|
||||
rewind($s);
|
||||
return $s;
|
||||
// Pre-populating 'carddata' is optional. If we don't yet have it
|
||||
// already, we fetch it from the backend.
|
||||
if (!isset($this->cardData['carddata'])) {
|
||||
$this->cardData = $this->carddavBackend->getCard($this->addressBookInfo['id'], $this->cardData['uri']);
|
||||
}
|
||||
return $this->cardData['carddata'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the VCard-formatted object
|
||||
*
|
||||
* @param string $cardData
|
||||
* @return void
|
||||
* Updates the VCard-formatted object
|
||||
*
|
||||
* @param string $cardData
|
||||
* @return void
|
||||
*/
|
||||
public function put($cardData) {
|
||||
|
||||
|
@ -87,14 +88,17 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
// Converting to UTF-8, if needed
|
||||
$cardData = Sabre_DAV_StringUtil::ensureUTF8($cardData);
|
||||
|
||||
$this->carddavBackend->updateCard($this->addressBookInfo['id'],$this->cardData['uri'],$cardData);
|
||||
$etag = $this->carddavBackend->updateCard($this->addressBookInfo['id'],$this->cardData['uri'],$cardData);
|
||||
$this->cardData['carddata'] = $cardData;
|
||||
$this->cardData['etag'] = $etag;
|
||||
|
||||
return $etag;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the card
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
@ -104,9 +108,9 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the mime content-type
|
||||
*
|
||||
* @return string
|
||||
* Returns the mime content-type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContentType() {
|
||||
|
||||
|
@ -115,20 +119,24 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an ETag for this object
|
||||
*
|
||||
* @return string
|
||||
* Returns an ETag for this object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getETag() {
|
||||
|
||||
return '"' . md5($this->cardData['carddata']) . '"';
|
||||
if (isset($this->cardData['etag'])) {
|
||||
return $this->cardData['etag'];
|
||||
} else {
|
||||
return '"' . md5($this->get()) . '"';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last modification date as a unix timestamp
|
||||
*
|
||||
* @return time
|
||||
*
|
||||
* @return time
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
||||
|
@ -137,21 +145,25 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the size of this object in bytes
|
||||
*
|
||||
* Returns the size of this object in bytes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSize() {
|
||||
|
||||
return strlen($this->cardData['carddata']);
|
||||
if (array_key_exists('size', $this->cardData)) {
|
||||
return $this->cardData['size'];
|
||||
} else {
|
||||
return strlen($this->get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner() {
|
||||
|
@ -164,8 +176,8 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
* Returns a group principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup() {
|
||||
|
||||
|
@ -177,13 +189,13 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL() {
|
||||
|
||||
|
@ -205,9 +217,9 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
/**
|
||||
* Updates the ACL
|
||||
*
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* @return void
|
||||
*/
|
||||
public function setACL(array $acl) {
|
||||
|
@ -216,5 +228,23 @@ class Sabre_CardDAV_Card extends Sabre_DAV_File implements Sabre_CardDAV_ICard,
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
* AddressBook interface
|
||||
*
|
||||
* Implement this interface to allow a node to be recognized as an addressbook.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_CardDAV_IAddressBook extends Sabre_DAV_ICollection {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Card interface
|
||||
* Card interface
|
||||
*
|
||||
* Extend the ICard interface to allow your custom nodes to be picked up as
|
||||
* 'Cards'.
|
||||
*
|
||||
* Extend the ICard interface to allow your custom nodes to be picked up as
|
||||
* 'Cards'.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_CardDAV_ICard extends Sabre_DAV_IFile {
|
||||
interface Sabre_CardDAV_ICard extends Sabre_DAV_IFile {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* IDirectory interface
|
||||
*
|
||||
* Implement this interface to have an addressbook marked as a 'directory'. A
|
||||
* Implement this interface to have an addressbook marked as a 'directory'. A
|
||||
* directory is an (often) global addressbook.
|
||||
*
|
||||
* A full description can be found in the IETF draft:
|
||||
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
||||
|
@ -24,31 +24,34 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
const NS_CARDDAV = 'urn:ietf:params:xml:ns:carddav';
|
||||
|
||||
/**
|
||||
* Add urls to this property to have them automatically exposed as
|
||||
* Add urls to this property to have them automatically exposed as
|
||||
* 'directories' to the user.
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $directories = array();
|
||||
|
||||
/**
|
||||
* Server class
|
||||
* Server class
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
* @var Sabre_DAV_Server
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* Initializes the plugin
|
||||
* Initializes the plugin
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return void
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(Sabre_DAV_Server $server) {
|
||||
|
||||
/* Events */
|
||||
$server->subscribeEvent('beforeGetProperties', array($this, 'beforeGetProperties'));
|
||||
$server->subscribeEvent('updateProperties', array($this, 'updateProperties'));
|
||||
$server->subscribeEvent('report', array($this,'report'));
|
||||
$server->subscribeEvent('onHTMLActionsPanel', array($this,'htmlActionsPanel'));
|
||||
$server->subscribeEvent('onBrowserPostAction', array($this,'browserPostAction'));
|
||||
|
||||
/* Namespaces */
|
||||
$server->xmlNamespaces[self::NS_CARDDAV] = 'card';
|
||||
|
@ -56,11 +59,14 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
/* Mapping Interfaces to {DAV:}resourcetype values */
|
||||
$server->resourceTypeMapping['Sabre_CardDAV_IAddressBook'] = '{' . self::NS_CARDDAV . '}addressbook';
|
||||
$server->resourceTypeMapping['Sabre_CardDAV_IDirectory'] = '{' . self::NS_CARDDAV . '}directory';
|
||||
|
||||
|
||||
/* Adding properties that may never be changed */
|
||||
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-address-data';
|
||||
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}max-resource-size';
|
||||
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}addressbook-home-set';
|
||||
$server->protectedProperties[] = '{' . self::NS_CARDDAV . '}supported-collation-set';
|
||||
|
||||
$server->propertyMap['{http://calendarserver.org/ns/}me-card'] = 'Sabre_DAV_Property_Href';
|
||||
|
||||
$this->server = $server;
|
||||
|
||||
|
@ -69,7 +75,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
/**
|
||||
* Returns a list of supported features.
|
||||
*
|
||||
* This is used in the DAV: header in the OPTIONS and PROPFIND requests.
|
||||
* This is used in the DAV: header in the OPTIONS and PROPFIND requests.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@ -83,11 +89,11 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
* Returns a list of reports this plugin supports.
|
||||
*
|
||||
* This will be used in the {DAV:}supported-report-set property.
|
||||
* Note that you still need to subscribe to the 'report' event to actually
|
||||
* implement them
|
||||
* Note that you still need to subscribe to the 'report' event to actually
|
||||
* implement them
|
||||
*
|
||||
* @param string $uri
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function getSupportedReportSet($uri) {
|
||||
|
||||
|
@ -104,22 +110,22 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
|
||||
/**
|
||||
* Adds all CardDAV-specific properties
|
||||
* Adds all CardDAV-specific properties
|
||||
*
|
||||
* @param string $path
|
||||
* @param Sabre_DAV_INode $node
|
||||
* @param Sabre_DAV_INode $node
|
||||
* @param array $requestedProperties
|
||||
* @param array $returnedProperties
|
||||
* @param array $returnedProperties
|
||||
* @return void
|
||||
*/
|
||||
public function beforeGetProperties($path, Sabre_DAV_INode $node, array &$requestedProperties, array &$returnedProperties) {
|
||||
public function beforeGetProperties($path, Sabre_DAV_INode $node, array &$requestedProperties, array &$returnedProperties) {
|
||||
|
||||
if ($node instanceof Sabre_DAVACL_IPrincipal) {
|
||||
|
||||
// calendar-home-set property
|
||||
$addHome = '{' . self::NS_CARDDAV . '}addressbook-home-set';
|
||||
if (in_array($addHome,$requestedProperties)) {
|
||||
$principalId = $node->getName();
|
||||
$principalId = $node->getName();
|
||||
$addressbookHomePath = self::ADDRESSBOOK_ROOT . '/' . $principalId . '/';
|
||||
unset($requestedProperties[array_search($addHome, $requestedProperties)]);
|
||||
$returnedProperties[200][$addHome] = new Sabre_DAV_Property_Href($addressbookHomePath);
|
||||
|
@ -135,8 +141,8 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
if ($node instanceof Sabre_CardDAV_ICard) {
|
||||
|
||||
// The address-data property is not supposed to be a 'real'
|
||||
// property, but in large chunks of the spec it does act as such.
|
||||
// The address-data property is not supposed to be a 'real'
|
||||
// property, but in large chunks of the spec it does act as such.
|
||||
// Therefore we simply expose it as a property.
|
||||
$addressDataProp = '{' . self::NS_CARDDAV . '}address-data';
|
||||
if (in_array($addressDataProp, $requestedProperties)) {
|
||||
|
@ -151,24 +157,95 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
if ($node instanceof Sabre_CardDAV_UserAddressBooks) {
|
||||
|
||||
$meCardProp = '{http://calendarserver.org/ns/}me-card';
|
||||
if (in_array($meCardProp, $requestedProperties)) {
|
||||
|
||||
$props = $this->server->getProperties($node->getOwner(), array('{http://sabredav.org/ns}vcard-url'));
|
||||
if (isset($props['{http://sabredav.org/ns}vcard-url'])) {
|
||||
|
||||
$returnedProperties[200][$meCardProp] = new Sabre_DAV_Property_Href(
|
||||
$props['{http://sabredav.org/ns}vcard-url']
|
||||
);
|
||||
$pos = array_search($meCardProp, $requestedProperties);
|
||||
unset($requestedProperties[$pos]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions handles REPORT requests specific to CardDAV
|
||||
* This event is triggered when a PROPPATCH method is executed
|
||||
*
|
||||
* @param string $reportName
|
||||
* @param array $mutations
|
||||
* @param array $result
|
||||
* @param Sabre_DAV_INode $node
|
||||
* @return void
|
||||
*/
|
||||
public function updateProperties(&$mutations, &$result, $node) {
|
||||
|
||||
if (!$node instanceof Sabre_CardDAV_UserAddressBooks) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$meCard = '{http://calendarserver.org/ns/}me-card';
|
||||
|
||||
// The only property we care about
|
||||
if (!isset($mutations[$meCard]))
|
||||
return true;
|
||||
|
||||
$value = $mutations[$meCard];
|
||||
unset($mutations[$meCard]);
|
||||
|
||||
if ($value instanceof Sabre_DAV_Property_IHref) {
|
||||
$value = $value->getHref();
|
||||
$value = $this->server->calculateUri($value);
|
||||
} elseif (!is_null($value)) {
|
||||
$result[400][$meCard] = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
$innerResult = $this->server->updateProperties(
|
||||
$node->getOwner(),
|
||||
array(
|
||||
'{http://sabredav.org/ns}vcard-url' => $value,
|
||||
)
|
||||
);
|
||||
|
||||
$closureResult = false;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions handles REPORT requests specific to CardDAV
|
||||
*
|
||||
* @param string $reportName
|
||||
* @param DOMNode $dom
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function report($reportName,$dom) {
|
||||
|
||||
switch($reportName) {
|
||||
switch($reportName) {
|
||||
case '{'.self::NS_CARDDAV.'}addressbook-multiget' :
|
||||
$this->addressbookMultiGetReport($dom);
|
||||
return false;
|
||||
case '{'.self::NS_CARDDAV.'}addressbook-query' :
|
||||
$this->addressBookQueryReport($dom);
|
||||
return false;
|
||||
return false;
|
||||
default :
|
||||
return;
|
||||
|
||||
|
@ -256,7 +333,8 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
$result = array();
|
||||
foreach($validNodes as $validNode) {
|
||||
if ($depth==0) {
|
||||
|
||||
if ($depth==0) {
|
||||
$href = $this->server->getRequestUri();
|
||||
} else {
|
||||
$href = $this->server->getRequestUri() . '/' . $validNode->getName();
|
||||
|
@ -265,7 +343,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
list($result[]) = $this->server->getPropertiesForPath($href, $query->requestedProperties, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$this->server->httpResponse->sendStatus(207);
|
||||
$this->server->httpResponse->setHeader('Content-Type','application/xml; charset=utf-8');
|
||||
$this->server->httpResponse->sendBody($this->server->generateMultiStatus($result));
|
||||
|
@ -274,17 +352,15 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
/**
|
||||
* Validates if a vcard makes it throught a list of filters.
|
||||
*
|
||||
* @param string $vcardData
|
||||
* @param array $filters
|
||||
* @param string $test anyof or allof (which means OR or AND)
|
||||
* @return bool
|
||||
*
|
||||
* @param string $vcardData
|
||||
* @param array $filters
|
||||
* @param string $test anyof or allof (which means OR or AND)
|
||||
* @return bool
|
||||
*/
|
||||
public function validateFilters($vcardData, array $filters, $test) {
|
||||
|
||||
$vcard = Sabre_VObject_Reader::read($vcardData);
|
||||
|
||||
$success = true;
|
||||
|
||||
foreach($filters as $filter) {
|
||||
|
||||
|
@ -299,10 +375,10 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
// We only need to check for existence
|
||||
$success = $isDefined;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$vProperties = $vcard->select($filter['name']);
|
||||
$vProperties = $vcard->select($filter['name']);
|
||||
|
||||
$results = array();
|
||||
if ($filter['param-filters']) {
|
||||
|
@ -328,7 +404,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
} // else
|
||||
|
||||
// There are two conditions where we can already determine wether
|
||||
// There are two conditions where we can already determine whether
|
||||
// or not this filter succeeds.
|
||||
if ($test==='anyof' && $success) {
|
||||
return true;
|
||||
|
@ -339,29 +415,28 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
} // foreach
|
||||
|
||||
// If we got all the way here, it means we haven't been able to
|
||||
// If we got all the way here, it means we haven't been able to
|
||||
// determine early if the test failed or not.
|
||||
//
|
||||
// This implies for 'anyof' that the test failed, and for 'allof' that
|
||||
// This implies for 'anyof' that the test failed, and for 'allof' that
|
||||
// we succeeded. Sounds weird, but makes sense.
|
||||
return $test==='allof';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if a param-filter can be applied to a specific property.
|
||||
*
|
||||
* @todo currently we're only validating the first parameter of the passed
|
||||
* Validates if a param-filter can be applied to a specific property.
|
||||
*
|
||||
* @todo currently we're only validating the first parameter of the passed
|
||||
* property. Any subsequence parameters with the same name are
|
||||
* ignored.
|
||||
* @param Sabre_VObject_Property $vProperty
|
||||
* @param array $filters
|
||||
* @param string $test
|
||||
* @return bool
|
||||
* @param array $vProperties
|
||||
* @param array $filters
|
||||
* @param string $test
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateParamFilters(array $vProperties, array $filters, $test) {
|
||||
|
||||
$success = false;
|
||||
foreach($filters as $filter) {
|
||||
|
||||
$isDefined = false;
|
||||
|
@ -377,17 +452,16 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
$success = true;
|
||||
}
|
||||
|
||||
// If there's no text-match, we can just check for existence
|
||||
// If there's no text-match, we can just check for existence
|
||||
} elseif (!$filter['text-match'] || !$isDefined) {
|
||||
|
||||
$success = $isDefined;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
$texts = array();
|
||||
$success = false;
|
||||
foreach($vProperties as $vProperty) {
|
||||
// If we got all the way here, we'll need to validate the
|
||||
// If we got all the way here, we'll need to validate the
|
||||
// text-match filter.
|
||||
$success = Sabre_DAV_StringUtil::textMatch($vProperty[$filter['name']]->value, $filter['text-match']['value'], $filter['text-match']['collation'], $filter['text-match']['match-type']);
|
||||
if ($success) break;
|
||||
|
@ -398,7 +472,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
} // else
|
||||
|
||||
// There are two conditions where we can already determine wether
|
||||
// There are two conditions where we can already determine whether
|
||||
// or not this filter succeeds.
|
||||
if ($test==='anyof' && $success) {
|
||||
return true;
|
||||
|
@ -407,24 +481,24 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// If we got all the way here, it means we haven't been able to
|
||||
// If we got all the way here, it means we haven't been able to
|
||||
// determine early if the test failed or not.
|
||||
//
|
||||
// This implies for 'anyof' that the test failed, and for 'allof' that
|
||||
// This implies for 'anyof' that the test failed, and for 'allof' that
|
||||
// we succeeded. Sounds weird, but makes sense.
|
||||
return $test==='allof';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if a text-filter can be applied to a specific property.
|
||||
*
|
||||
* Validates if a text-filter can be applied to a specific property.
|
||||
*
|
||||
* @param array $texts
|
||||
* @param array $filters
|
||||
* @param string $test
|
||||
* @return bool
|
||||
* @param array $filters
|
||||
* @param string $test
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateTextMatches(array $texts, array $filters, $test) {
|
||||
|
||||
|
@ -440,7 +514,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
if ($filter['negate-condition']) {
|
||||
$success = !$success;
|
||||
}
|
||||
|
||||
|
||||
if ($success && $test==='anyof')
|
||||
return true;
|
||||
|
||||
|
@ -450,14 +524,64 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
}
|
||||
|
||||
// If we got all the way here, it means we haven't been able to
|
||||
// If we got all the way here, it means we haven't been able to
|
||||
// determine early if the test failed or not.
|
||||
//
|
||||
// This implies for 'anyof' that the test failed, and for 'allof' that
|
||||
// This implies for 'anyof' that the test failed, and for 'allof' that
|
||||
// we succeeded. Sounds weird, but makes sense.
|
||||
return $test==='allof';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to generate HTML output for the
|
||||
* Sabre_DAV_Browser_Plugin. This allows us to generate an interface users
|
||||
* can use to create new calendars.
|
||||
*
|
||||
* @param Sabre_DAV_INode $node
|
||||
* @param string $output
|
||||
* @return bool
|
||||
*/
|
||||
public function htmlActionsPanel(Sabre_DAV_INode $node, &$output) {
|
||||
|
||||
if (!$node instanceof Sabre_CardDAV_UserAddressBooks)
|
||||
return;
|
||||
|
||||
$output.= '<tr><td colspan="2"><form method="post" action="">
|
||||
<h3>Create new address book</h3>
|
||||
<input type="hidden" name="sabreAction" value="mkaddressbook" />
|
||||
<label>Name (uri):</label> <input type="text" name="name" /><br />
|
||||
<label>Display name:</label> <input type="text" name="{DAV:}displayname" /><br />
|
||||
<input type="submit" value="create" />
|
||||
</form>
|
||||
</td></tr>';
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows us to intercept the 'mkcalendar' sabreAction. This
|
||||
* action enables the user to create new calendars from the browser plugin.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $action
|
||||
* @param array $postVars
|
||||
* @return bool
|
||||
*/
|
||||
public function browserPostAction($uri, $action, array $postVars) {
|
||||
|
||||
if ($action!=='mkaddressbook')
|
||||
return;
|
||||
|
||||
$resourceType = array('{DAV:}collection','{urn:ietf:params:xml:ns:carddav}addressbook');
|
||||
$properties = array();
|
||||
if (isset($postVars['{DAV:}displayname'])) {
|
||||
$properties['{DAV:}displayname'] = $postVars['{DAV:}displayname'];
|
||||
}
|
||||
$this->server->createCollection($uri . '/' . $postVars['name'],$resourceType,$properties);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
30
3rdparty/Sabre/CardDAV/Property/SupportedAddressData.php
поставляемый
Normal file → Executable file
|
@ -4,11 +4,11 @@
|
|||
* Supported-address-data property
|
||||
*
|
||||
* This property is a representation of the supported-address-data property
|
||||
* in the CardDAV namespace.
|
||||
* in the CardDAV namespace.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -16,15 +16,15 @@ class Sabre_CardDAV_Property_SupportedAddressData extends Sabre_DAV_Property {
|
|||
|
||||
/**
|
||||
* supported versions
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $supportedData = array();
|
||||
|
||||
|
||||
/**
|
||||
* Creates the property
|
||||
*
|
||||
* @param array $components
|
||||
* Creates the property
|
||||
*
|
||||
* @param array|null $supportedData
|
||||
*/
|
||||
public function __construct(array $supportedData = null) {
|
||||
|
||||
|
@ -35,22 +35,22 @@ class Sabre_CardDAV_Property_SupportedAddressData extends Sabre_DAV_Property {
|
|||
);
|
||||
}
|
||||
|
||||
$this->supportedData = $supportedData;
|
||||
$this->supportedData = $supportedData;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the property in a DOMDocument
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $node
|
||||
* Serializes the property in a DOMDocument
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $node
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $node) {
|
||||
|
||||
$doc = $node->ownerDocument;
|
||||
|
||||
$prefix =
|
||||
$prefix =
|
||||
isset($server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV]) ?
|
||||
$server->xmlNamespaces[Sabre_CardDAV_Plugin::NS_CARDDAV] :
|
||||
'card';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -15,47 +15,47 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
|
||||
/**
|
||||
* Principal uri
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $principalUri;
|
||||
|
||||
/**
|
||||
* carddavBackend
|
||||
*
|
||||
* @var Sabre_CardDAV_Backend_Abstract
|
||||
* carddavBackend
|
||||
*
|
||||
* @var Sabre_CardDAV_Backend_Abstract
|
||||
*/
|
||||
protected $carddavBackend;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
|
||||
* @param string $principalUri
|
||||
* Constructor
|
||||
*
|
||||
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
|
||||
* @param string $principalUri
|
||||
*/
|
||||
public function __construct(Sabre_CardDAV_Backend_Abstract $carddavBackend, $principalUri) {
|
||||
|
||||
$this->carddavBackend = $carddavBackend;
|
||||
$this->principalUri = $principalUri;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this object
|
||||
*
|
||||
* Returns the name of this object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
||||
list(,$name) = Sabre_DAV_URLUtil::splitPath($this->principalUri);
|
||||
return $name;
|
||||
return $name;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the name of this object
|
||||
*
|
||||
* @param string $name
|
||||
* Updates the name of this object
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setName($name) {
|
||||
|
@ -65,8 +65,8 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes this object
|
||||
*
|
||||
* Deletes this object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
@ -76,13 +76,13 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the last modification date
|
||||
*
|
||||
* @return int
|
||||
* Returns the last modification date
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
||||
return null;
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,9 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
* Creates a new file under this object.
|
||||
*
|
||||
* This is currently not allowed
|
||||
*
|
||||
* @param string $filename
|
||||
* @param resource $data
|
||||
*
|
||||
* @param string $filename
|
||||
* @param resource $data
|
||||
* @return void
|
||||
*/
|
||||
public function createFile($filename, $data=null) {
|
||||
|
@ -105,8 +105,8 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
* Creates a new directory under this object.
|
||||
*
|
||||
* This is currently not allowed.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*/
|
||||
public function createDirectory($filename) {
|
||||
|
@ -116,8 +116,8 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a single calendar, by name
|
||||
*
|
||||
* Returns a single calendar, by name
|
||||
*
|
||||
* @param string $name
|
||||
* @todo needs optimizing
|
||||
* @return Sabre_CardDAV_AddressBook
|
||||
|
@ -129,14 +129,14 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
return $child;
|
||||
|
||||
}
|
||||
throw new Sabre_DAV_Exception_FileNotFound('Addressbook with name \'' . $name . '\' could not be found');
|
||||
throw new Sabre_DAV_Exception_NotFound('Addressbook with name \'' . $name . '\' could not be found');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of addressbooks
|
||||
*
|
||||
* @return array
|
||||
* Returns a list of addressbooks
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getChildren() {
|
||||
|
||||
|
@ -150,11 +150,11 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new addressbook
|
||||
*
|
||||
* Creates a new addressbook
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $resourceType
|
||||
* @param array $properties
|
||||
* @param array $resourceType
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function createExtendedCollection($name, array $resourceType, array $properties) {
|
||||
|
@ -169,8 +169,8 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
/**
|
||||
* Returns the owner principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner() {
|
||||
|
@ -183,8 +183,8 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
* Returns a group principal
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup() {
|
||||
|
||||
|
@ -196,13 +196,13 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL() {
|
||||
|
||||
|
@ -225,9 +225,9 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
/**
|
||||
* Updates the ACL
|
||||
*
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* This method will receive a list of new ACE's.
|
||||
*
|
||||
* @param array $acl
|
||||
* @return void
|
||||
*/
|
||||
public function setACL(array $acl) {
|
||||
|
@ -236,5 +236,22 @@ class Sabre_CardDAV_UserAddressBooks extends Sabre_DAV_Collection implements Sab
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre_DAVACL_Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* Version Class
|
||||
*
|
||||
* This class contains the Sabre_CardDAV version information
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@ class Sabre_CardDAV_Version {
|
|||
/**
|
||||
* Full version number
|
||||
*/
|
||||
const VERSION = '1.5.3';
|
||||
const VERSION = '1.6.1';
|
||||
|
||||
/**
|
||||
* Stability : alpha, beta, stable
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Sabre_CardDAV includes file
|
||||
*
|
||||
* Including this file will automatically include all files from the
|
||||
* Sabre_CardDAV package.
|
||||
*
|
||||
* This often allows faster loadtimes, as autoload-speed is often quite slow.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage CardDAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
||||
// Begin includes
|
||||
include __DIR__ . '/AddressBookQueryParser.php';
|
||||
include __DIR__ . '/AddressBookRoot.php';
|
||||
include __DIR__ . '/Backend/Abstract.php';
|
||||
include __DIR__ . '/Backend/PDO.php';
|
||||
include __DIR__ . '/IAddressBook.php';
|
||||
include __DIR__ . '/ICard.php';
|
||||
include __DIR__ . '/IDirectory.php';
|
||||
include __DIR__ . '/Plugin.php';
|
||||
include __DIR__ . '/Property/SupportedAddressData.php';
|
||||
include __DIR__ . '/UserAddressBooks.php';
|
||||
include __DIR__ . '/Version.php';
|
||||
include __DIR__ . '/AddressBook.php';
|
||||
include __DIR__ . '/Card.php';
|
||||
// End includes
|
|
@ -8,9 +8,9 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author James David Low (http://jameslow.com/)
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
abstract class Sabre_DAV_Auth_Backend_AbstractBasic implements Sabre_DAV_Auth_IBackend {
|
||||
|
@ -28,6 +28,8 @@ abstract class Sabre_DAV_Auth_Backend_AbstractBasic implements Sabre_DAV_Auth_IB
|
|||
* This method should return true or false depending on if login
|
||||
* succeeded.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function validateUserPass($username, $password);
|
||||
|
@ -47,13 +49,15 @@ abstract class Sabre_DAV_Auth_Backend_AbstractBasic implements Sabre_DAV_Auth_IB
|
|||
/**
|
||||
* Authenticates the user based on the current request.
|
||||
*
|
||||
* If authentication is succesful, true must be returned.
|
||||
* If authentication is successful, true must be returned.
|
||||
* If authentication fails, an exception must be thrown.
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param string $realm
|
||||
* @throws Sabre_DAV_Exception_NotAuthenticated
|
||||
* @return bool
|
||||
*/
|
||||
public function authenticate(Sabre_DAV_Server $server,$realm) {
|
||||
public function authenticate(Sabre_DAV_Server $server, $realm) {
|
||||
|
||||
$auth = new Sabre_HTTP_BasicAuth();
|
||||
$auth->setHTTPRequest($server->httpRequest);
|
||||
|
@ -75,5 +79,5 @@ abstract class Sabre_DAV_Auth_Backend_AbstractBasic implements Sabre_DAV_Auth_IB
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
* HTTP Digest authentication backend class
|
||||
*
|
||||
* This class can be used by authentication objects wishing to use HTTP Digest
|
||||
* Most of the digest logic is handled, implementors just need to worry about
|
||||
* the getDigestHash method
|
||||
* Most of the digest logic is handled, implementors just need to worry about
|
||||
* the getDigestHash method
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@ abstract class Sabre_DAV_Auth_Backend_AbstractDigest implements Sabre_DAV_Auth_I
|
|||
|
||||
/**
|
||||
* This variable holds the currently logged in username.
|
||||
*
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
@ -25,24 +25,26 @@ abstract class Sabre_DAV_Auth_Backend_AbstractDigest implements Sabre_DAV_Auth_I
|
|||
/**
|
||||
* Returns a users digest hash based on the username and realm.
|
||||
*
|
||||
* If the user was not known, null must be returned.
|
||||
*
|
||||
* If the user was not known, null must be returned.
|
||||
*
|
||||
* @param string $realm
|
||||
* @param string $username
|
||||
* @return string|null
|
||||
* @param string $username
|
||||
* @return string|null
|
||||
*/
|
||||
abstract public function getDigestHash($realm,$username);
|
||||
abstract public function getDigestHash($realm, $username);
|
||||
|
||||
/**
|
||||
* Authenticates the user based on the current request.
|
||||
*
|
||||
* If authentication is succesful, true must be returned.
|
||||
* If authentication is successful, true must be returned.
|
||||
* If authentication fails, an exception must be thrown.
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param string $realm
|
||||
* @throws Sabre_DAV_Exception_NotAuthenticated
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function authenticate(Sabre_DAV_Server $server,$realm) {
|
||||
public function authenticate(Sabre_DAV_Server $server, $realm) {
|
||||
|
||||
$digest = new Sabre_HTTP_DigestAuth();
|
||||
|
||||
|
@ -83,9 +85,9 @@ abstract class Sabre_DAV_Auth_Backend_AbstractDigest implements Sabre_DAV_Auth_I
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the currently logged in username.
|
||||
*
|
||||
* @return string|null
|
||||
* Returns the currently logged in username.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCurrentUser() {
|
||||
|
||||
|
|
|
@ -4,34 +4,36 @@
|
|||
* Apache authenticator
|
||||
*
|
||||
* This authentication backend assumes that authentication has been
|
||||
* conifgured in apache, rather than within SabreDAV.
|
||||
* configured in apache, rather than within SabreDAV.
|
||||
*
|
||||
* Make sure apache is properly configured for this to work.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Auth_Backend_Apache implements Sabre_DAV_Auth_IBackend {
|
||||
|
||||
/**
|
||||
* Current apache user
|
||||
*
|
||||
* @var string
|
||||
* Current apache user
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $remoteUser;
|
||||
|
||||
|
||||
/**
|
||||
* Authenticates the user based on the current request.
|
||||
*
|
||||
* If authentication is succesful, true must be returned.
|
||||
* If authentication is successful, true must be returned.
|
||||
* If authentication fails, an exception must be thrown.
|
||||
*
|
||||
* @return bool
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param string $realm
|
||||
* @return bool
|
||||
*/
|
||||
public function authenticate(Sabre_DAV_Server $server,$realm) {
|
||||
public function authenticate(Sabre_DAV_Server $server, $realm) {
|
||||
|
||||
$remoteUser = $server->httpRequest->getRawServerValue('REMOTE_USER');
|
||||
if (is_null($remoteUser)) {
|
||||
|
@ -47,7 +49,7 @@ class Sabre_DAV_Auth_Backend_Apache implements Sabre_DAV_Auth_IBackend {
|
|||
* Returns information about the currently logged in user.
|
||||
*
|
||||
* If nobody is currently logged in, this method should return null.
|
||||
*
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getCurrentUser() {
|
||||
|
|
|
@ -4,29 +4,28 @@
|
|||
* This is an authentication backend that uses a file to manage passwords.
|
||||
*
|
||||
* The backend file must conform to Apache's htdigest format
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Auth_Backend_File extends Sabre_DAV_Auth_Backend_AbstractDigest {
|
||||
|
||||
/**
|
||||
* List of users
|
||||
*
|
||||
* List of users
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
/**
|
||||
* Creates the backend object.
|
||||
* Creates the backend object.
|
||||
*
|
||||
* If the filename argument is passed in, it will parse out the specified file fist.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*
|
||||
* @param string|null $filename
|
||||
*/
|
||||
public function __construct($filename=null) {
|
||||
|
||||
|
@ -38,22 +37,22 @@ class Sabre_DAV_Auth_Backend_File extends Sabre_DAV_Auth_Backend_AbstractDigest
|
|||
/**
|
||||
* Loads an htdigest-formatted file. This method can be called multiple times if
|
||||
* more than 1 file is used.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*/
|
||||
public function loadFile($filename) {
|
||||
|
||||
foreach(file($filename,FILE_IGNORE_NEW_LINES) as $line) {
|
||||
|
||||
if (substr_count($line, ":") !== 2)
|
||||
if (substr_count($line, ":") !== 2)
|
||||
throw new Sabre_DAV_Exception('Malformed htdigest file. Every line should contain 2 colons');
|
||||
|
||||
|
||||
list($username,$realm,$A1) = explode(':',$line);
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1))
|
||||
throw new Sabre_DAV_Exception('Malformed htdigest file. Invalid md5 hash');
|
||||
|
||||
|
||||
$this->users[$realm . ':' . $username] = $A1;
|
||||
|
||||
}
|
||||
|
@ -62,10 +61,10 @@ class Sabre_DAV_Auth_Backend_File extends Sabre_DAV_Auth_Backend_AbstractDigest
|
|||
|
||||
/**
|
||||
* Returns a users' information
|
||||
*
|
||||
* @param string $realm
|
||||
* @param string $username
|
||||
* @return string
|
||||
*
|
||||
* @param string $realm
|
||||
* @param string $username
|
||||
* @return string
|
||||
*/
|
||||
public function getDigestHash($realm, $username) {
|
||||
|
||||
|
|
|
@ -4,38 +4,37 @@
|
|||
* This is an authentication backend that uses a file to manage passwords.
|
||||
*
|
||||
* The backend file must conform to Apache's htdigest format
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Auth_Backend_PDO extends Sabre_DAV_Auth_Backend_AbstractDigest {
|
||||
|
||||
/**
|
||||
* Reference to PDO connection
|
||||
*
|
||||
* @var PDO
|
||||
* Reference to PDO connection
|
||||
*
|
||||
* @var PDO
|
||||
*/
|
||||
protected $pdo;
|
||||
|
||||
/**
|
||||
* PDO table name we'll be using
|
||||
*
|
||||
* PDO table name we'll be using
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tableName;
|
||||
|
||||
|
||||
/**
|
||||
* Creates the backend object.
|
||||
* Creates the backend object.
|
||||
*
|
||||
* If the filename argument is passed in, it will parse out the specified file fist.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $tableName The PDO table name to use
|
||||
* @return void
|
||||
*
|
||||
* @param PDO $pdo
|
||||
* @param string $tableName The PDO table name to use
|
||||
*/
|
||||
public function __construct(PDO $pdo, $tableName = 'users') {
|
||||
|
||||
|
@ -45,15 +44,15 @@ class Sabre_DAV_Auth_Backend_PDO extends Sabre_DAV_Auth_Backend_AbstractDigest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the digest hash for a user.
|
||||
*
|
||||
* @param string $realm
|
||||
* @param string $username
|
||||
* @return string|null
|
||||
* Returns the digest hash for a user.
|
||||
*
|
||||
* @param string $realm
|
||||
* @param string $username
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDigestHash($realm,$username) {
|
||||
|
||||
$stmt = $this->pdo->prepare('SELECT username, digesta1 FROM `'.$this->tableName.'` WHERE username = ?');
|
||||
$stmt = $this->pdo->prepare('SELECT username, digesta1 FROM '.$this->tableName.' WHERE username = ?');
|
||||
$stmt->execute(array($username));
|
||||
$result = $stmt->fetchAll();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -14,18 +14,20 @@ interface Sabre_DAV_Auth_IBackend {
|
|||
/**
|
||||
* Authenticates the user based on the current request.
|
||||
*
|
||||
* If authentication is succesful, true must be returned.
|
||||
* If authentication is successful, true must be returned.
|
||||
* If authentication fails, an exception must be thrown.
|
||||
*
|
||||
* @return bool
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param string $realm
|
||||
* @return bool
|
||||
*/
|
||||
function authenticate(Sabre_DAV_Server $server,$realm);
|
||||
function authenticate(Sabre_DAV_Server $server,$realm);
|
||||
|
||||
/**
|
||||
* Returns information about the currently logged in username.
|
||||
*
|
||||
* If nobody is currently logged in, this method should return null.
|
||||
*
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getCurrentUser();
|
||||
|
|
|
@ -2,48 +2,47 @@
|
|||
|
||||
/**
|
||||
* This plugin provides Authentication for a WebDAV server.
|
||||
*
|
||||
*
|
||||
* It relies on a Backend object, which provides user information.
|
||||
*
|
||||
* Additionally, it provides support for:
|
||||
* * {DAV:}current-user-principal property from RFC5397
|
||||
* * {DAV:}principal-collection-set property from RFC3744
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Auth_Plugin extends Sabre_DAV_ServerPlugin {
|
||||
|
||||
/**
|
||||
* Reference to main server object
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
* Reference to main server object
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
*/
|
||||
private $server;
|
||||
|
||||
/**
|
||||
* Authentication backend
|
||||
*
|
||||
* @var Sabre_DAV_Auth_Backend_Abstract
|
||||
*
|
||||
* @var Sabre_DAV_Auth_IBackend
|
||||
*/
|
||||
private $authBackend;
|
||||
|
||||
/**
|
||||
* The authentication realm.
|
||||
*
|
||||
* @var string
|
||||
* The authentication realm.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $realm;
|
||||
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* @param Sabre_DAV_Auth_Backend_Abstract $authBackend
|
||||
* @param string $realm
|
||||
* @return void
|
||||
* __construct
|
||||
*
|
||||
* @param Sabre_DAV_Auth_IBackend $authBackend
|
||||
* @param string $realm
|
||||
*/
|
||||
public function __construct(Sabre_DAV_Auth_IBackend $authBackend, $realm) {
|
||||
|
||||
|
@ -53,9 +52,9 @@ class Sabre_DAV_Auth_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* Initializes the plugin. This function is automatically called by the server
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* Initializes the plugin. This function is automatically called by the server
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(Sabre_DAV_Server $server) {
|
||||
|
@ -67,11 +66,11 @@ class Sabre_DAV_Auth_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
/**
|
||||
* Returns a plugin name.
|
||||
*
|
||||
*
|
||||
* Using this name other plugins will be able to access other plugins
|
||||
* using Sabre_DAV_Server::getPlugin
|
||||
*
|
||||
* @return string
|
||||
* using Sabre_DAV_Server::getPlugin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPluginName() {
|
||||
|
||||
|
@ -81,10 +80,10 @@ class Sabre_DAV_Auth_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
/**
|
||||
* Returns the current users' principal uri.
|
||||
*
|
||||
* If nobody is logged in, this will return null.
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* If nobody is logged in, this will return null.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCurrentUser() {
|
||||
|
||||
|
@ -97,10 +96,11 @@ class Sabre_DAV_Auth_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
/**
|
||||
* This method is called before any HTTP method and forces users to be authenticated
|
||||
*
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $uri
|
||||
* @throws Sabre_DAV_Exception_NotAuthenticated
|
||||
* @return bool
|
||||
* @return bool
|
||||
*/
|
||||
public function beforeMethod($method, $uri) {
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
* There's really no accurate, fast and portable way to determine the contenttype
|
||||
* so this extension does what the rest of the world does, and guesses it based
|
||||
* on the file extension.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -43,9 +43,9 @@ class Sabre_DAV_Browser_GuessContentType extends Sabre_DAV_ServerPlugin {
|
|||
);
|
||||
|
||||
/**
|
||||
* Initializes the plugin
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* Initializes the plugin
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(Sabre_DAV_Server $server) {
|
||||
|
@ -57,16 +57,16 @@ class Sabre_DAV_Browser_GuessContentType extends Sabre_DAV_ServerPlugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* Handler for teh afterGetProperties event
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $properties
|
||||
* Handler for teh afterGetProperties event
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function afterGetProperties($path, &$properties) {
|
||||
|
||||
if (array_key_exists('{DAV:}getcontenttype', $properties[404])) {
|
||||
|
||||
|
||||
list(, $fileName) = Sabre_DAV_URLUtil::splitPath($path);
|
||||
$contentType = $this->getContentType($fileName);
|
||||
|
||||
|
@ -81,9 +81,9 @@ class Sabre_DAV_Browser_GuessContentType extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
/**
|
||||
* Simple method to return the contenttype
|
||||
*
|
||||
* @param string $fileName
|
||||
* @return string
|
||||
*
|
||||
* @param string $fileName
|
||||
* @return string
|
||||
*/
|
||||
protected function getContentType($fileName) {
|
||||
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This is a simple plugin that will map any GET request for non-files to
|
||||
* This is a simple plugin that will map any GET request for non-files to
|
||||
* PROPFIND allprops-requests.
|
||||
*
|
||||
* This should allow easy debugging of PROPFIND
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Browser_MapGetToPropFind extends Sabre_DAV_ServerPlugin {
|
||||
|
||||
/**
|
||||
* reference to server class
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
* reference to server class
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* Initializes the plugin and subscribes to events
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* Initializes the plugin and subscribes to events
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(Sabre_DAV_Server $server) {
|
||||
|
@ -34,21 +34,22 @@ class Sabre_DAV_Browser_MapGetToPropFind extends Sabre_DAV_ServerPlugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request
|
||||
*
|
||||
* @param string $method
|
||||
* @return bool
|
||||
* This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
public function httpGetInterceptor($method, $uri) {
|
||||
|
||||
if ($method!='GET') return true;
|
||||
|
||||
|
||||
$node = $this->server->tree->getNodeForPath($uri);
|
||||
if ($node instanceof Sabre_DAV_IFile) return;
|
||||
|
||||
$this->server->invokeMethod('PROPFIND',$uri);
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,77 +6,126 @@
|
|||
* This plugin provides a html representation, so that a WebDAV server may be accessed
|
||||
* using a browser.
|
||||
*
|
||||
* The class intercepts GET requests to collection resources and generates a simple
|
||||
* html index.
|
||||
*
|
||||
* The class intercepts GET requests to collection resources and generates a simple
|
||||
* html index.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin {
|
||||
|
||||
/**
|
||||
* reference to server class
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
* List of default icons for nodes.
|
||||
*
|
||||
* This is an array with class / interface names as keys, and asset names
|
||||
* as values.
|
||||
*
|
||||
* The evaluation order is reversed. The last item in the list gets
|
||||
* precendence.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $iconMap = array(
|
||||
'Sabre_DAV_IFile' => 'icons/file',
|
||||
'Sabre_DAV_ICollection' => 'icons/collection',
|
||||
'Sabre_DAVACL_IPrincipal' => 'icons/principal',
|
||||
'Sabre_CalDAV_ICalendar' => 'icons/calendar',
|
||||
'Sabre_CardDAV_IAddressBook' => 'icons/addressbook',
|
||||
'Sabre_CardDAV_ICard' => 'icons/card',
|
||||
);
|
||||
|
||||
/**
|
||||
* The file extension used for all icons
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $iconExtension = '.png';
|
||||
|
||||
/**
|
||||
* reference to server class
|
||||
*
|
||||
* @var Sabre_DAV_Server
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* enableEditing
|
||||
*
|
||||
* @var bool
|
||||
* enablePost turns on the 'actions' panel, which allows people to create
|
||||
* folders and upload files straight from a browser.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $enablePost = true;
|
||||
|
||||
/**
|
||||
* By default the browser plugin will generate a favicon and other images.
|
||||
* To turn this off, set this property to false.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $enableAssets = true;
|
||||
|
||||
/**
|
||||
* Creates the object.
|
||||
*
|
||||
* By default it will allow file creation and uploads.
|
||||
* Specify the first argument as false to disable this
|
||||
*
|
||||
* @param bool $enablePost
|
||||
* @return void
|
||||
*
|
||||
* @param bool $enablePost
|
||||
* @param bool $enableAssets
|
||||
*/
|
||||
public function __construct($enablePost=true) {
|
||||
public function __construct($enablePost=true, $enableAssets = true) {
|
||||
|
||||
$this->enablePost = $enablePost;
|
||||
$this->enablePost = $enablePost;
|
||||
$this->enableAssets = $enableAssets;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the plugin and subscribes to events
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* Initializes the plugin and subscribes to events
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(Sabre_DAV_Server $server) {
|
||||
|
||||
$this->server = $server;
|
||||
$this->server->subscribeEvent('beforeMethod',array($this,'httpGetInterceptor'));
|
||||
$this->server->subscribeEvent('onHTMLActionsPanel', array($this, 'htmlActionsPanel'),200);
|
||||
if ($this->enablePost) $this->server->subscribeEvent('unknownMethod',array($this,'httpPOSTHandler'));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method intercepts GET requests to collections and returns the html
|
||||
*
|
||||
* @param string $method
|
||||
* @return bool
|
||||
* This method intercepts GET requests to collections and returns the html
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
public function httpGetInterceptor($method, $uri) {
|
||||
|
||||
if ($method!='GET') return true;
|
||||
if ($method !== 'GET') return true;
|
||||
|
||||
try {
|
||||
// We're not using straight-up $_GET, because we want everything to be
|
||||
// unit testable.
|
||||
$getVars = array();
|
||||
parse_str($this->server->httpRequest->getQueryString(), $getVars);
|
||||
|
||||
if (isset($getVars['sabreAction']) && $getVars['sabreAction'] === 'asset' && isset($getVars['assetName'])) {
|
||||
$this->serveAsset($getVars['assetName']);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$node = $this->server->tree->getNodeForPath($uri);
|
||||
} catch (Sabre_DAV_Exception_FileNotFound $e) {
|
||||
// We're simply stopping when the file isn't found to not interfere
|
||||
} catch (Sabre_DAV_Exception_NotFound $e) {
|
||||
// We're simply stopping when the file isn't found to not interfere
|
||||
// with other plugins.
|
||||
return;
|
||||
}
|
||||
if ($node instanceof Sabre_DAV_IFile)
|
||||
if ($node instanceof Sabre_DAV_IFile)
|
||||
return;
|
||||
|
||||
$this->server->httpResponse->sendStatus(200);
|
||||
|
@ -87,57 +136,71 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
);
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles POST requests for tree operations
|
||||
*
|
||||
* This method is not yet used.
|
||||
*
|
||||
* @param string $method
|
||||
* Handles POST requests for tree operations.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $uri
|
||||
* @return bool
|
||||
*/
|
||||
public function httpPOSTHandler($method, $uri) {
|
||||
|
||||
if ($method!='POST') return true;
|
||||
if (isset($_POST['sabreAction'])) switch($_POST['sabreAction']) {
|
||||
if ($method!='POST') return;
|
||||
$contentType = $this->server->httpRequest->getHeader('Content-Type');
|
||||
list($contentType) = explode(';', $contentType);
|
||||
if ($contentType !== 'application/x-www-form-urlencoded' &&
|
||||
$contentType !== 'multipart/form-data') {
|
||||
return;
|
||||
}
|
||||
$postVars = $this->server->httpRequest->getPostVars();
|
||||
|
||||
case 'mkcol' :
|
||||
if (isset($_POST['name']) && trim($_POST['name'])) {
|
||||
// Using basename() because we won't allow slashes
|
||||
list(, $folderName) = Sabre_DAV_URLUtil::splitPath(trim($_POST['name']));
|
||||
$this->server->createDirectory($uri . '/' . $folderName);
|
||||
}
|
||||
break;
|
||||
case 'put' :
|
||||
if ($_FILES) $file = current($_FILES);
|
||||
else break;
|
||||
$newName = trim($file['name']);
|
||||
list(, $newName) = Sabre_DAV_URLUtil::splitPath(trim($file['name']));
|
||||
if (isset($_POST['name']) && trim($_POST['name']))
|
||||
$newName = trim($_POST['name']);
|
||||
if (!isset($postVars['sabreAction']))
|
||||
return;
|
||||
|
||||
// Making sure we only have a 'basename' component
|
||||
list(, $newName) = Sabre_DAV_URLUtil::splitPath($newName);
|
||||
|
||||
|
||||
if (is_uploaded_file($file['tmp_name'])) {
|
||||
$parent = $this->server->tree->getNodeForPath(trim($uri,'/'));
|
||||
$parent->createFile($newName,fopen($file['tmp_name'],'r'));
|
||||
}
|
||||
if ($this->server->broadcastEvent('onBrowserPostAction', array($uri, $postVars['sabreAction'], $postVars))) {
|
||||
|
||||
switch($postVars['sabreAction']) {
|
||||
|
||||
case 'mkcol' :
|
||||
if (isset($postVars['name']) && trim($postVars['name'])) {
|
||||
// Using basename() because we won't allow slashes
|
||||
list(, $folderName) = Sabre_DAV_URLUtil::splitPath(trim($postVars['name']));
|
||||
$this->server->createDirectory($uri . '/' . $folderName);
|
||||
}
|
||||
break;
|
||||
case 'put' :
|
||||
if ($_FILES) $file = current($_FILES);
|
||||
else break;
|
||||
|
||||
list(, $newName) = Sabre_DAV_URLUtil::splitPath(trim($file['name']));
|
||||
if (isset($postVars['name']) && trim($postVars['name']))
|
||||
$newName = trim($postVars['name']);
|
||||
|
||||
// Making sure we only have a 'basename' component
|
||||
list(, $newName) = Sabre_DAV_URLUtil::splitPath($newName);
|
||||
|
||||
if (is_uploaded_file($file['tmp_name'])) {
|
||||
$this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'],'r'));
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$this->server->httpResponse->setHeader('Location',$this->server->httpRequest->getUri());
|
||||
$this->server->httpResponse->sendStatus(302);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a string for html.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
* Escapes a string for html.
|
||||
*
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function escapeHTML($value) {
|
||||
|
||||
|
@ -146,118 +209,199 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generates the html directory index for a given url
|
||||
* Generates the html directory index for a given url
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function generateDirectoryIndex($path) {
|
||||
|
||||
$version = '';
|
||||
if (Sabre_DAV_Server::$exposeVersion) {
|
||||
$version = Sabre_DAV_Version::VERSION ."-". Sabre_DAV_Version::STABILITY;
|
||||
}
|
||||
|
||||
$html = "<html>
|
||||
<head>
|
||||
<title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . Sabre_DAV_Version::VERSION . "</title>
|
||||
<style type=\"text/css\"> body { Font-family: arial}</style>
|
||||
</head>
|
||||
<title>Index for " . $this->escapeHTML($path) . "/ - SabreDAV " . $version . "</title>
|
||||
<style type=\"text/css\">
|
||||
body { Font-family: arial}
|
||||
h1 { font-size: 150% }
|
||||
</style>
|
||||
";
|
||||
|
||||
if ($this->enableAssets) {
|
||||
$html.='<link rel="shortcut icon" href="'.$this->getAssetUrl('favicon.ico').'" type="image/vnd.microsoft.icon" />';
|
||||
}
|
||||
|
||||
$html .= "</head>
|
||||
<body>
|
||||
<h1>Index for " . $this->escapeHTML($path) . "/</h1>
|
||||
<table>
|
||||
<tr><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>
|
||||
<tr><td colspan=\"4\"><hr /></td></tr>";
|
||||
|
||||
$files = $this->server->getPropertiesForPath($path,array(
|
||||
'{DAV:}displayname',
|
||||
'{DAV:}resourcetype',
|
||||
'{DAV:}getcontenttype',
|
||||
'{DAV:}getcontentlength',
|
||||
'{DAV:}getlastmodified',
|
||||
),1);
|
||||
<tr><th width=\"24\"></th><th>Name</th><th>Type</th><th>Size</th><th>Last modified</th></tr>
|
||||
<tr><td colspan=\"5\"><hr /></td></tr>";
|
||||
|
||||
$parent = $this->server->tree->getNodeForPath($path);
|
||||
$files = $this->server->getPropertiesForPath($path,array(
|
||||
'{DAV:}displayname',
|
||||
'{DAV:}resourcetype',
|
||||
'{DAV:}getcontenttype',
|
||||
'{DAV:}getcontentlength',
|
||||
'{DAV:}getlastmodified',
|
||||
),1);
|
||||
|
||||
$parent = $this->server->tree->getNodeForPath($path);
|
||||
|
||||
|
||||
if ($path) {
|
||||
if ($path) {
|
||||
|
||||
list($parentUri) = Sabre_DAV_URLUtil::splitPath($path);
|
||||
$fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
|
||||
list($parentUri) = Sabre_DAV_URLUtil::splitPath($path);
|
||||
$fullPath = Sabre_DAV_URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
|
||||
|
||||
$html.= "<tr>
|
||||
<td><a href=\"{$fullPath}\">..</a></td>
|
||||
<td>[parent]</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>";
|
||||
$icon = $this->enableAssets?'<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="Parent" /></a>':'';
|
||||
$html.= "<tr>
|
||||
<td>$icon</td>
|
||||
<td><a href=\"{$fullPath}\">..</a></td>
|
||||
<td>[parent]</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach($files as $k=>$file) {
|
||||
foreach($files as $file) {
|
||||
|
||||
// This is the current directory, we can skip it
|
||||
if (rtrim($file['href'],'/')==$path) continue;
|
||||
// This is the current directory, we can skip it
|
||||
if (rtrim($file['href'],'/')==$path) continue;
|
||||
|
||||
list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']);
|
||||
list(, $name) = Sabre_DAV_URLUtil::splitPath($file['href']);
|
||||
|
||||
$type = null;
|
||||
$type = null;
|
||||
|
||||
|
||||
if (isset($file[200]['{DAV:}resourcetype'])) {
|
||||
$type = $file[200]['{DAV:}resourcetype']->getValue();
|
||||
if (isset($file[200]['{DAV:}resourcetype'])) {
|
||||
$type = $file[200]['{DAV:}resourcetype']->getValue();
|
||||
|
||||
// resourcetype can have multiple values
|
||||
if (!is_array($type)) $type = array($type);
|
||||
// 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) {
|
||||
case '{DAV:}collection' :
|
||||
$type[$k] = 'Collection';
|
||||
break;
|
||||
case '{DAV:}principal' :
|
||||
$type[$k] = 'Principal';
|
||||
break;
|
||||
case '{urn:ietf:params:xml:ns:carddav}addressbook' :
|
||||
$type[$k] = 'Addressbook';
|
||||
break;
|
||||
case '{urn:ietf:params:xml:ns:caldav}calendar' :
|
||||
$type[$k] = 'Calendar';
|
||||
// Some name mapping is preferred
|
||||
switch($v) {
|
||||
case '{DAV:}collection' :
|
||||
$type[$k] = 'Collection';
|
||||
break;
|
||||
case '{DAV:}principal' :
|
||||
$type[$k] = 'Principal';
|
||||
break;
|
||||
case '{urn:ietf:params:xml:ns:carddav}addressbook' :
|
||||
$type[$k] = 'Addressbook';
|
||||
break;
|
||||
case '{urn:ietf:params:xml:ns:caldav}calendar' :
|
||||
$type[$k] = 'Calendar';
|
||||
break;
|
||||
case '{urn:ietf:params:xml:ns:caldav}schedule-inbox' :
|
||||
$type[$k] = 'Schedule Inbox';
|
||||
break;
|
||||
case '{urn:ietf:params:xml:ns:caldav}schedule-outbox' :
|
||||
$type[$k] = 'Schedule Outbox';
|
||||
break;
|
||||
case '{http://calendarserver.org/ns/}calendar-proxy-read' :
|
||||
$type[$k] = 'Proxy-Read';
|
||||
break;
|
||||
case '{http://calendarserver.org/ns/}calendar-proxy-write' :
|
||||
$type[$k] = 'Proxy-Write';
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
$type = implode(', ', $type);
|
||||
}
|
||||
|
||||
// If no resourcetype was found, we attempt to use
|
||||
// the contenttype property
|
||||
if (!$type && isset($file[200]['{DAV:}getcontenttype'])) {
|
||||
$type = $file[200]['{DAV:}getcontenttype'];
|
||||
}
|
||||
if (!$type) $type = 'Unknown';
|
||||
|
||||
$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 = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path?$path . '/':'') . $name,'/'));
|
||||
|
||||
$displayName = isset($file[200]['{DAV:}displayname'])?$file[200]['{DAV:}displayname']:$name;
|
||||
|
||||
$displayName = $this->escapeHTML($displayName);
|
||||
$type = $this->escapeHTML($type);
|
||||
|
||||
$icon = '';
|
||||
|
||||
if ($this->enableAssets) {
|
||||
$node = $parent->getChild($name);
|
||||
foreach(array_reverse($this->iconMap) as $class=>$iconName) {
|
||||
|
||||
if ($node instanceof $class) {
|
||||
$icon = '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl($iconName . $this->iconExtension) . '" alt="" width="24" /></a>';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$type = implode(', ', $type);
|
||||
|
||||
$html.= "<tr>
|
||||
<td>$icon</td>
|
||||
<td><a href=\"{$fullPath}\">{$displayName}</a></td>
|
||||
<td>{$type}</td>
|
||||
<td>{$size}</td>
|
||||
<td>{$lastmodified}</td>
|
||||
</tr>";
|
||||
|
||||
}
|
||||
|
||||
// If no resourcetype was found, we attempt to use
|
||||
// the contenttype property
|
||||
if (!$type && isset($file[200]['{DAV:}getcontenttype'])) {
|
||||
$type = $file[200]['{DAV:}getcontenttype'];
|
||||
$html.= "<tr><td colspan=\"5\"><hr /></td></tr>";
|
||||
|
||||
$output = '';
|
||||
|
||||
if ($this->enablePost) {
|
||||
$this->server->broadcastEvent('onHTMLActionsPanel',array($parent, &$output));
|
||||
}
|
||||
if (!$type) $type = 'Unknown';
|
||||
|
||||
$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):'';
|
||||
$html.=$output;
|
||||
|
||||
$fullPath = Sabre_DAV_URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path?$path . '/':'') . $name,'/'));
|
||||
$html.= "</table>
|
||||
<address>Generated by SabreDAV " . $version . " (c)2007-2012 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address>
|
||||
</body>
|
||||
</html>";
|
||||
|
||||
$displayName = isset($file[200]['{DAV:}displayname'])?$file[200]['{DAV:}displayname']:$name;
|
||||
|
||||
$name = $this->escapeHTML($name);
|
||||
$displayName = $this->escapeHTML($displayName);
|
||||
$type = $this->escapeHTML($type);
|
||||
|
||||
$html.= "<tr>
|
||||
<td><a href=\"{$fullPath}\">{$displayName}</a></td>
|
||||
<td>{$type}</td>
|
||||
<td>{$size}</td>
|
||||
<td>{$lastmodified}</td>
|
||||
</tr>";
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
$html.= "<tr><td colspan=\"4\"><hr /></td></tr>";
|
||||
/**
|
||||
* This method is used to generate the 'actions panel' output for
|
||||
* collections.
|
||||
*
|
||||
* This specifically generates the interfaces for creating new files, and
|
||||
* creating new directories.
|
||||
*
|
||||
* @param Sabre_DAV_INode $node
|
||||
* @param mixed $output
|
||||
* @return void
|
||||
*/
|
||||
public function htmlActionsPanel(Sabre_DAV_INode $node, &$output) {
|
||||
|
||||
if ($this->enablePost && $parent instanceof Sabre_DAV_ICollection) {
|
||||
$html.= '<tr><td><form method="post" action="">
|
||||
if (!$node instanceof Sabre_DAV_ICollection)
|
||||
return;
|
||||
|
||||
// We also know fairly certain that if an object is a non-extended
|
||||
// SimpleCollection, we won't need to show the panel either.
|
||||
if (get_class($node)==='Sabre_DAV_SimpleCollection')
|
||||
return;
|
||||
|
||||
$output.= '<tr><td colspan="2"><form method="post" action="">
|
||||
<h3>Create new folder</h3>
|
||||
<input type="hidden" name="sabreAction" value="mkcol" />
|
||||
Name: <input type="text" name="name" /><br />
|
||||
|
@ -270,15 +414,75 @@ class Sabre_DAV_Browser_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
File: <input type="file" name="file" /><br />
|
||||
<input type="submit" value="upload" />
|
||||
</form>
|
||||
</td></tr>';
|
||||
}
|
||||
</td></tr>';
|
||||
|
||||
$html.= "</table>
|
||||
<address>Generated by SabreDAV " . Sabre_DAV_Version::VERSION ."-". Sabre_DAV_Version::STABILITY . " (c)2007-2011 <a href=\"http://code.google.com/p/sabredav/\">http://code.google.com/p/sabredav/</a></address>
|
||||
</body>
|
||||
</html>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
/**
|
||||
* This method takes a path/name of an asset and turns it into url
|
||||
* suiteable for http access.
|
||||
*
|
||||
* @param string $assetName
|
||||
* @return string
|
||||
*/
|
||||
protected function getAssetUrl($assetName) {
|
||||
|
||||
return $this->server->getBaseUri() . '?sabreAction=asset&assetName=' . urlencode($assetName);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a local pathname to an asset.
|
||||
*
|
||||
* @param string $assetName
|
||||
* @return string
|
||||
*/
|
||||
protected function getLocalAssetPath($assetName) {
|
||||
|
||||
// Making sure people aren't trying to escape from the base path.
|
||||
$assetSplit = explode('/', $assetName);
|
||||
if (in_array('..',$assetSplit)) {
|
||||
throw new Sabre_DAV_Exception('Incorrect asset path');
|
||||
}
|
||||
$path = __DIR__ . '/assets/' . $assetName;
|
||||
return $path;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method reads an asset from disk and generates a full http response.
|
||||
*
|
||||
* @param string $assetName
|
||||
* @return void
|
||||
*/
|
||||
protected function serveAsset($assetName) {
|
||||
|
||||
$assetPath = $this->getLocalAssetPath($assetName);
|
||||
if (!file_exists($assetPath)) {
|
||||
throw new Sabre_DAV_Exception_NotFound('Could not find an asset with this name');
|
||||
}
|
||||
// Rudimentary mime type detection
|
||||
switch(strtolower(substr($assetPath,strpos($assetPath,'.')+1))) {
|
||||
|
||||
case 'ico' :
|
||||
$mime = 'image/vnd.microsoft.icon';
|
||||
break;
|
||||
|
||||
case 'png' :
|
||||
$mime = 'image/png';
|
||||
break;
|
||||
|
||||
default:
|
||||
$mime = 'application/octet-stream';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$this->server->httpResponse->setHeader('Content-Type', $mime);
|
||||
$this->server->httpResponse->setHeader('Content-Length', filesize($assetPath));
|
||||
$this->server->httpResponse->setHeader('Cache-Control', 'public, max-age=1209600');
|
||||
$this->server->httpResponse->sendStatus(200);
|
||||
$this->server->httpResponse->sendBody(fopen($assetPath,'r'));
|
||||
|
||||
}
|
||||
|
||||
|
|
После Ширина: | Высота: | Размер: 4.2 KiB |
Двоичные данные
3rdparty/Sabre/DAV/Browser/assets/icons/addressbook.png
поставляемый
Executable file
После Ширина: | Высота: | Размер: 7.1 KiB |
После Ширина: | Высота: | Размер: 4.3 KiB |
После Ширина: | Высота: | Размер: 5.6 KiB |
После Ширина: | Высота: | Размер: 3.4 KiB |
После Ширина: | Высота: | Размер: 2.8 KiB |
После Ширина: | Высота: | Размер: 3.4 KiB |
После Ширина: | Высота: | Размер: 5.4 KiB |
|
@ -3,14 +3,14 @@
|
|||
/**
|
||||
* SabreDAV DAV client
|
||||
*
|
||||
* This client wraps around Curl to provide a convenient API to a WebDAV
|
||||
* This client wraps around Curl to provide a convenient API to a WebDAV
|
||||
* server.
|
||||
*
|
||||
* NOTE: This class is experimental, it's api will likely change in the future.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAVClient
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -26,22 +26,22 @@ class Sabre_DAV_Client {
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Settings are provided through the 'settings' argument. The following
|
||||
* Settings are provided through the 'settings' argument. The following
|
||||
* settings are supported:
|
||||
*
|
||||
* * baseUri
|
||||
* * userName (optional)
|
||||
* * password (optional)
|
||||
* * proxy (optional)
|
||||
*
|
||||
* @param array $settings
|
||||
*
|
||||
* @param array $settings
|
||||
*/
|
||||
public function __construct(array $settings) {
|
||||
|
||||
if (!isset($settings['baseUri'])) {
|
||||
throw new InvalidArgumentException('A baseUri must be provided');
|
||||
}
|
||||
|
||||
|
||||
$validSettings = array(
|
||||
'baseUri',
|
||||
'userName',
|
||||
|
@ -62,23 +62,23 @@ class Sabre_DAV_Client {
|
|||
/**
|
||||
* Does a PROPFIND request
|
||||
*
|
||||
* The list of requested properties must be specified as an array, in clark
|
||||
* notation.
|
||||
* The list of requested properties must be specified as an array, in clark
|
||||
* notation.
|
||||
*
|
||||
* The returned array will contain a list of filenames as keys, and
|
||||
* The returned array will contain a list of filenames as keys, and
|
||||
* properties as values.
|
||||
*
|
||||
* The properties array will contain the list of properties. Only properties
|
||||
* that are actually returned from the server (without error) will be
|
||||
* The properties array will contain the list of properties. Only properties
|
||||
* that are actually returned from the server (without error) will be
|
||||
* returned, anything else is discarded.
|
||||
*
|
||||
* Depth should be either 0 or 1. A depth of 1 will cause a request to be
|
||||
* Depth should be either 0 or 1. A depth of 1 will cause a request to be
|
||||
* made to the server to also return all child resources.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $properties
|
||||
* @param int $depth
|
||||
* @return array
|
||||
* @param string $url
|
||||
* @param array $properties
|
||||
* @param int $depth
|
||||
* @return array
|
||||
*/
|
||||
public function propFind($url, array $properties, $depth = 0) {
|
||||
|
||||
|
@ -132,14 +132,14 @@ class Sabre_DAV_Client {
|
|||
/**
|
||||
* Updates a list of properties on the server
|
||||
*
|
||||
* The list of properties must have clark-notation properties for the keys,
|
||||
* and the actual (string) value for the value. If the value is null, an
|
||||
* attempt is made to delete the property.
|
||||
* The list of properties must have clark-notation properties for the keys,
|
||||
* and the actual (string) value for the value. If the value is null, an
|
||||
* attempt is made to delete the property.
|
||||
*
|
||||
* @todo Must be building the request using the DOM, and does not yet
|
||||
* support complex properties.
|
||||
* @param string $url
|
||||
* @param array $properties
|
||||
* @todo Must be building the request using the DOM, and does not yet
|
||||
* support complex properties.
|
||||
* @param string $url
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function propPatch($url, array $properties) {
|
||||
|
@ -175,7 +175,7 @@ class Sabre_DAV_Client {
|
|||
$body.=" <x:" . $elementName . " xmlns:x=\"" . $namespace . "\">";
|
||||
}
|
||||
// Shitty.. i know
|
||||
$body.=htmlspecialchars($propValue, ENT_NOQUOTES, 'UTF-8');
|
||||
$body.=htmlspecialchars($propValue, ENT_NOQUOTES, 'UTF-8');
|
||||
if ($namespace === 'DAV:') {
|
||||
$body.='</d:' . $elementName . '>' . "\n";
|
||||
} else {
|
||||
|
@ -189,7 +189,7 @@ class Sabre_DAV_Client {
|
|||
|
||||
$body.= '</d:propertyupdate>';
|
||||
|
||||
$response = $this->request('PROPPATCH', $url, $body, array(
|
||||
$this->request('PROPPATCH', $url, $body, array(
|
||||
'Content-Type' => 'application/xml'
|
||||
));
|
||||
|
||||
|
@ -198,11 +198,11 @@ class Sabre_DAV_Client {
|
|||
/**
|
||||
* Performs an HTTP options request
|
||||
*
|
||||
* This method returns all the features from the 'DAV:' header as an array.
|
||||
* If there was no DAV header, or no contents this method will return an
|
||||
* empty array.
|
||||
*
|
||||
* @return array
|
||||
* This method returns all the features from the 'DAV:' header as an array.
|
||||
* If there was no DAV header, or no contents this method will return an
|
||||
* empty array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function options() {
|
||||
|
||||
|
@ -222,20 +222,20 @@ class Sabre_DAV_Client {
|
|||
/**
|
||||
* Performs an actual HTTP request, and returns the result.
|
||||
*
|
||||
* If the specified url is relative, it will be expanded based on the base
|
||||
* If the specified url is relative, it will be expanded based on the base
|
||||
* url.
|
||||
*
|
||||
* The returned array contains 3 keys:
|
||||
* * body - the response body
|
||||
* * httpCode - a HTTP code (200, 404, etc)
|
||||
* * headers - a list of response http headers. The header names have
|
||||
* * headers - a list of response http headers. The header names have
|
||||
* been lowercased.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $url
|
||||
* @param string $body
|
||||
* @param array $headers
|
||||
* @return array
|
||||
* @param string $method
|
||||
* @param string $url
|
||||
* @param string $body
|
||||
* @param array $headers
|
||||
* @return array
|
||||
*/
|
||||
public function request($method, $url = '', $body = null, $headers = array()) {
|
||||
|
||||
|
@ -243,14 +243,37 @@ class Sabre_DAV_Client {
|
|||
|
||||
$curlSettings = array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_POSTFIELDS => $body,
|
||||
// Return headers as part of the response
|
||||
CURLOPT_HEADER => true
|
||||
CURLOPT_HEADER => true,
|
||||
CURLOPT_POSTFIELDS => $body,
|
||||
// Automatically follow redirects
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_MAXREDIRS => 5,
|
||||
);
|
||||
|
||||
switch ($method) {
|
||||
case 'PUT':
|
||||
$curlSettings[CURLOPT_PUT] = true;
|
||||
break;
|
||||
case 'HEAD' :
|
||||
|
||||
// do not read body with HEAD requests (this is neccessary because cURL does not ignore the body with HEAD
|
||||
// requests when the Content-Length header is given - which in turn is perfectly valid according to HTTP
|
||||
// specs...) cURL does unfortunately return an error in this case ("transfer closed transfer closed with
|
||||
// ... bytes remaining to read") this can be circumvented by explicitly telling cURL to ignore the
|
||||
// response body
|
||||
$curlSettings[CURLOPT_NOBODY] = true;
|
||||
$curlSettings[CURLOPT_CUSTOMREQUEST] = 'HEAD';
|
||||
break;
|
||||
|
||||
default:
|
||||
$curlSettings[CURLOPT_CUSTOMREQUEST] = $method;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// Adding HTTP headers
|
||||
$nHeaders = array();
|
||||
$nHeaders = array();
|
||||
foreach($headers as $key=>$value) {
|
||||
|
||||
$nHeaders[] = $key . ': ' . $value;
|
||||
|
@ -277,17 +300,17 @@ class Sabre_DAV_Client {
|
|||
$headerBlob = substr($response, 0, $curlInfo['header_size']);
|
||||
$response = substr($response, $curlInfo['header_size']);
|
||||
|
||||
// In the case of 100 Continue, or redirects we'll have multiple lists
|
||||
// of headers for each separate HTTP response. We can easily split this
|
||||
// In the case of 100 Continue, or redirects we'll have multiple lists
|
||||
// of headers for each separate HTTP response. We can easily split this
|
||||
// because they are separated by \r\n\r\n
|
||||
$headerBlob = explode("\r\n\r\n", trim($headerBlob, "\r\n"));
|
||||
|
||||
|
||||
// We only care about the last set of headers
|
||||
$headerBlob = $headerBlob[count($headerBlob)-1];
|
||||
|
||||
// Splitting headers
|
||||
$headerBlob = explode("\r\n", $headerBlob);
|
||||
|
||||
|
||||
$headers = array();
|
||||
foreach($headerBlob as $header) {
|
||||
$parts = explode(':', $header, 2);
|
||||
|
@ -304,10 +327,17 @@ class Sabre_DAV_Client {
|
|||
|
||||
if ($curlErrNo) {
|
||||
throw new Sabre_DAV_Exception('[CURL] Error while making request: ' . $curlError . ' (error code: ' . $curlErrNo . ')');
|
||||
}
|
||||
}
|
||||
|
||||
if ($response['statusCode']>=400) {
|
||||
throw new Sabre_DAV_Exception('HTTP error response. (errorcode ' . $response['statusCode'] . ')');
|
||||
switch ($response['statusCode']) {
|
||||
case 404:
|
||||
throw new Sabre_DAV_Exception_NotFound('Resource ' . $url . ' not found.');
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Sabre_DAV_Exception('HTTP error response. (errorcode ' . $response['statusCode'] . ')');
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
|
@ -317,12 +347,12 @@ class Sabre_DAV_Client {
|
|||
/**
|
||||
* Wrapper for all curl functions.
|
||||
*
|
||||
* The only reason this was split out in a separate method, is so it
|
||||
* becomes easier to unittest.
|
||||
* The only reason this was split out in a separate method, is so it
|
||||
* becomes easier to unittest.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $settings
|
||||
* @return
|
||||
* @param array $settings
|
||||
* @return array
|
||||
*/
|
||||
protected function curlRequest($url, $settings) {
|
||||
|
||||
|
@ -339,20 +369,20 @@ class Sabre_DAV_Client {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the full url based on the given url (which may be relative). All
|
||||
* urls are expanded based on the base url as given by the server.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
* Returns the full url based on the given url (which may be relative). All
|
||||
* urls are expanded based on the base url as given by the server.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
protected function getAbsoluteUrl($url) {
|
||||
|
||||
// If the url starts with http:// or https://, the url is already absolute.
|
||||
// If the url starts with http:// or https://, the url is already absolute.
|
||||
if (preg_match('/^http(s?):\/\//', $url)) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
// If the url starts with a slash, we must calculate the url based off
|
||||
// If the url starts with a slash, we must calculate the url based off
|
||||
// the root of the base url.
|
||||
if (strpos($url,'/') === 0) {
|
||||
$parts = parse_url($this->baseUri);
|
||||
|
@ -366,7 +396,7 @@ class Sabre_DAV_Client {
|
|||
|
||||
/**
|
||||
* Parses a WebDAV multistatus response body
|
||||
*
|
||||
*
|
||||
* This method returns an array with the following structure
|
||||
*
|
||||
* array(
|
||||
|
@ -387,7 +417,7 @@ class Sabre_DAV_Client {
|
|||
*
|
||||
*
|
||||
* @param string $body xml body
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function parseMultiStatus($body) {
|
||||
|
||||
|
@ -397,14 +427,13 @@ class Sabre_DAV_Client {
|
|||
if ($responseXML===false) {
|
||||
throw new InvalidArgumentException('The passed data is not valid XML');
|
||||
}
|
||||
|
||||
$responseXML->registerXPathNamespace('d','DAV:');
|
||||
|
||||
$responseXML->registerXPathNamespace('d', 'urn:DAV');
|
||||
|
||||
$propResult = array();
|
||||
|
||||
foreach($responseXML->xpath('d:response') as $response) {
|
||||
|
||||
$response->registerXPathNamespace('d','DAV:');
|
||||
$response->registerXPathNamespace('d', 'urn:DAV');
|
||||
$href = $response->xpath('d:href');
|
||||
$href = (string)$href[0];
|
||||
|
||||
|
@ -412,11 +441,11 @@ class Sabre_DAV_Client {
|
|||
|
||||
foreach($response->xpath('d:propstat') as $propStat) {
|
||||
|
||||
$propStat->registerXPathNamespace('d','DAV:');
|
||||
$propStat->registerXPathNamespace('d', 'urn:DAV');
|
||||
$status = $propStat->xpath('d:status');
|
||||
list($httpVersion, $statusCode, $message) = explode(' ', (string)$status[0],3);
|
||||
|
||||
$properties[$statusCode] = Sabre_DAV_XMLUtil::parseProperties(dom_import_simplexml($propStat), $this->propertyMap);
|
||||
$properties[$statusCode] = Sabre_DAV_XMLUtil::parseProperties(dom_import_simplexml($propStat), $this->propertyMap);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
* Collection class
|
||||
*
|
||||
* This is a helper class, that should aid in getting collections classes setup.
|
||||
* Most of its methods are implemented, and throw permission denied exceptions
|
||||
*
|
||||
* Most of its methods are implemented, and throw permission denied exceptions
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_ICollection {
|
||||
|
@ -17,12 +17,12 @@ abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_
|
|||
/**
|
||||
* Returns a child object, by its name.
|
||||
*
|
||||
* This method makes use of the getChildren method to grab all the child nodes, and compares the name.
|
||||
* This method makes use of the getChildren method to grab all the child nodes, and compares the name.
|
||||
* Generally its wise to override this, as this can usually be optimized
|
||||
*
|
||||
*
|
||||
* @param string $name
|
||||
* @throws Sabre_DAV_Exception_FileNotFound
|
||||
* @return Sabre_DAV_INode
|
||||
* @throws Sabre_DAV_Exception_NotFound
|
||||
* @return Sabre_DAV_INode
|
||||
*/
|
||||
public function getChild($name) {
|
||||
|
||||
|
@ -31,7 +31,7 @@ abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_
|
|||
if ($child->getName()==$name) return $child;
|
||||
|
||||
}
|
||||
throw new Sabre_DAV_Exception_FileNotFound('File not found: ' . $name);
|
||||
throw new Sabre_DAV_Exception_NotFound('File not found: ' . $name);
|
||||
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,9 @@ abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_
|
|||
* Checks is a child-node exists.
|
||||
*
|
||||
* It is generally a good idea to try and override this. Usually it can be optimized.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function childExists($name) {
|
||||
|
||||
|
@ -50,7 +50,7 @@ abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_
|
|||
$this->getChild($name);
|
||||
return true;
|
||||
|
||||
} catch(Sabre_DAV_Exception_FileNotFound $e) {
|
||||
} catch(Sabre_DAV_Exception_NotFound $e) {
|
||||
|
||||
return false;
|
||||
|
||||
|
@ -59,12 +59,28 @@ abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource $data Initial payload, passed as a readable stream resource.
|
||||
* @throws Sabre_DAV_Exception_Forbidden
|
||||
* @return void
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* Data will either be supplied as a stream resource, or in certain cases
|
||||
* as a string. Keep in mind that you may have to support either.
|
||||
*
|
||||
* After succesful creation of the file, you may choose to return the ETag
|
||||
* of the new file here.
|
||||
*
|
||||
* The returned ETag must be surrounded by double-quotes (The quotes should
|
||||
* be part of the actual string).
|
||||
*
|
||||
* If you cannot accurately determine the ETag, you should not return it.
|
||||
* If you don't store the file exactly as-is (you're transforming it
|
||||
* somehow) you should also not return an ETag.
|
||||
*
|
||||
* This means that if a subsequent GET to this new file does not exactly
|
||||
* return the same contents of what was submitted here, you are strongly
|
||||
* recommended to omit the ETag.
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource|string $data Initial payload
|
||||
* @return null|string
|
||||
*/
|
||||
public function createFile($name, $data = null) {
|
||||
|
||||
|
@ -73,9 +89,9 @@ abstract class Sabre_DAV_Collection extends Sabre_DAV_Node implements Sabre_DAV_
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* @throws Sabre_DAV_Exception_Forbidden
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @deprecated Use Sabre_DAV_Collection instead
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
|
|
@ -7,42 +7,42 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Main Exception class.
|
||||
* Main Exception class.
|
||||
*
|
||||
* This class defines a getHTTPCode method, which should return the appropriate HTTP code for the Exception occured.
|
||||
* This class defines a getHTTPCode method, which should return the appropriate HTTP code for the Exception occurred.
|
||||
* The default for this is 500.
|
||||
*
|
||||
* This class also allows you to generate custom xml data for your exceptions. This will be displayed
|
||||
* in the 'error' element in the failing response.
|
||||
*/
|
||||
class Sabre_DAV_Exception extends Exception {
|
||||
class Sabre_DAV_Exception extends Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
public function getHTTPCode() {
|
||||
|
||||
return 500;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows the exception to include additonal information into the WebDAV error response
|
||||
* This method allows the exception to include additional information into the WebDAV error response
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $errorNode
|
||||
* @param DOMElement $errorNode
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,15 @@ class Sabre_DAV_Exception extends Exception {
|
|||
* This method allows the exception to return any extra HTTP response headers.
|
||||
*
|
||||
* The headers must be returned as an array.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return array
|
||||
*/
|
||||
public function getHTTPHeaders(Sabre_DAV_Server $server) {
|
||||
|
||||
return array();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,24 +4,24 @@
|
|||
* BadRequest
|
||||
*
|
||||
* The BadRequest is thrown when the user submitted an invalid HTTP request
|
||||
* BadRequest
|
||||
*
|
||||
* BadRequest
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_BadRequest extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
return 400;
|
||||
return 400;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_Conflict extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ConflictingLock
|
||||
* ConflictingLock
|
||||
*
|
||||
* Similar to Exception_Locked, this exception thrown when a LOCK request
|
||||
* Similar to Exception_Locked, this exception thrown when a LOCK request
|
||||
* was made, on a resource which was already locked
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_ConflictingLock extends Sabre_DAV_Exception_Locked {
|
||||
|
||||
/**
|
||||
* This method allows the exception to include additonal information into the WebDAV error response
|
||||
* This method allows the exception to include additional information into the WebDAV error response
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $errorNode
|
||||
* @param DOMElement $errorNode
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
|
||||
|
||||
|
||||
if ($this->lock) {
|
||||
$error = $errorNode->ownerDocument->createElementNS('DAV:','d:no-conflicting-lock');
|
||||
$errorNode->appendChild($error);
|
||||
|
|
|
@ -3,26 +3,17 @@
|
|||
/**
|
||||
* FileNotFound
|
||||
*
|
||||
* This Exception is thrown when a Node couldn't be found. It returns HTTP error code 404
|
||||
* Deprecated: Warning, this class is deprecated and will be removed in a
|
||||
* future version of SabreDAV. Please use Sabre_DAV_Exception_NotFound instead.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @deprecated Use Sabre_DAV_Exception_NotFound instead
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_FileNotFound extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
return 404;
|
||||
|
||||
}
|
||||
class Sabre_DAV_Exception_FileNotFound extends Sabre_DAV_Exception_NotFound {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
* Forbidden
|
||||
*
|
||||
* This exception is thrown whenever a user tries to do an operation he's not allowed to
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_Forbidden extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* InsufficientStorage
|
||||
* InsufficientStorage
|
||||
*
|
||||
* This Exception can be thrown, when for example a harddisk is full or a quota is exceeded
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_InsufficientStorage extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* InvalidResourceType
|
||||
* InvalidResourceType
|
||||
*
|
||||
* This exception is thrown when the user tried to create a new collection, with
|
||||
* a special resourcetype value that was not recognized by the server.
|
||||
*
|
||||
* See RFC5689 section 3.3
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_InvalidResourceType extends Sabre_DAV_Exception_Forbidden {
|
||||
class Sabre_DAV_Exception_InvalidResourceType extends Sabre_DAV_Exception_Forbidden {
|
||||
|
||||
/**
|
||||
* This method allows the exception to include additonal information into the WebDAV error response
|
||||
* This method allows the exception to include additional information into the WebDAV error response
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $errorNode
|
||||
* @param DOMElement $errorNode
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
|
||||
|
@ -29,5 +29,5 @@ class Sabre_DAV_Exception_InvalidResourceType extends Sabre_DAV_Exception_Forbid
|
|||
$errorNode->appendChild($error);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
12
3rdparty/Sabre/DAV/Exception/LockTokenMatchesRequestUri.php
поставляемый
Normal file → Executable file
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* LockTokenMatchesRequestUri
|
||||
* LockTokenMatchesRequestUri
|
||||
*
|
||||
* This exception is thrown by UNLOCK if a supplied lock-token is invalid
|
||||
*
|
||||
* This exception is thrown by UNLOCK if a supplied lock-token is invalid
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -23,10 +23,10 @@ class Sabre_DAV_Exception_LockTokenMatchesRequestUri extends Sabre_DAV_Exception
|
|||
}
|
||||
|
||||
/**
|
||||
* This method allows the exception to include additonal information into the WebDAV error response
|
||||
* This method allows the exception to include additional information into the WebDAV error response
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $errorNode
|
||||
* @param DOMElement $errorNode
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Locked
|
||||
* Locked
|
||||
*
|
||||
* The 423 is thrown when a client tried to access a resource that was locked, without supplying a valid lock token
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_Locked extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Lock information
|
||||
*
|
||||
* @var Sabre_DAV_Locks_LockInfo
|
||||
* Lock information
|
||||
*
|
||||
* @var Sabre_DAV_Locks_LockInfo
|
||||
*/
|
||||
protected $lock;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*
|
||||
*
|
||||
* A LockInfo object should be passed if the user should be informed
|
||||
* which lock actually has the file locked.
|
||||
*
|
||||
* @param Sabre_DAV_Locks_LockInfo $lock
|
||||
*
|
||||
* @param Sabre_DAV_Locks_LockInfo $lock
|
||||
*/
|
||||
public function __construct(Sabre_DAV_Locks_LockInfo $lock = null) {
|
||||
|
||||
|
@ -35,7 +35,7 @@ class Sabre_DAV_Exception_Locked extends Sabre_DAV_Exception {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
@ -46,14 +46,14 @@ class Sabre_DAV_Exception_Locked extends Sabre_DAV_Exception {
|
|||
}
|
||||
|
||||
/**
|
||||
* This method allows the exception to include additonal information into the WebDAV error response
|
||||
* This method allows the exception to include additional information into the WebDAV error response
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $errorNode
|
||||
* @param DOMElement $errorNode
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
|
||||
|
||||
|
||||
if ($this->lock) {
|
||||
$error = $errorNode->ownerDocument->createElementNS('DAV:','d:lock-token-submitted');
|
||||
$errorNode->appendChild($error);
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
* MethodNotAllowed
|
||||
*
|
||||
* The 405 is thrown when a client tried to create a directory on an already existing directory
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_MethodNotAllowed extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
@ -28,8 +28,9 @@ class Sabre_DAV_Exception_MethodNotAllowed extends Sabre_DAV_Exception {
|
|||
* This method allows the exception to return any extra HTTP response headers.
|
||||
*
|
||||
* The headers must be returned as an array.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @return array
|
||||
*/
|
||||
public function getHTTPHeaders(Sabre_DAV_Server $server) {
|
||||
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
*
|
||||
* This exception is thrown when the client did not provide valid
|
||||
* authentication credentials.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_NotAuthenticated extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
|
||||
return 401;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* NotFound
|
||||
*
|
||||
* This Exception is thrown when a Node couldn't be found. It returns HTTP error code 404
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_NotFound extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
return 404;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,22 +4,22 @@
|
|||
* NotImplemented
|
||||
*
|
||||
* This exception is thrown when the client tried to call an unsupported HTTP method or other feature
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_NotImplemented extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
|
||||
return 501;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Payment Required
|
||||
*
|
||||
* The PaymentRequired exception may be thrown in a case where a user must pay
|
||||
* to access a certain resource or operation.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_PaymentRequired extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
return 402;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PreconditionFailed
|
||||
* PreconditionFailed
|
||||
*
|
||||
* This exception is normally thrown when a client submitted a conditional request,
|
||||
* like for example an If, If-None-Match or If-Match header, which caused the HTTP
|
||||
* This exception is normally thrown when a client submitted a conditional request,
|
||||
* like for example an If, If-None-Match or If-Match header, which caused the HTTP
|
||||
* request to not execute (the condition of the header failed)
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
|
@ -17,47 +17,47 @@ class Sabre_DAV_Exception_PreconditionFailed extends Sabre_DAV_Exception {
|
|||
|
||||
/**
|
||||
* When this exception is thrown, the header-name might be set.
|
||||
*
|
||||
*
|
||||
* This allows the exception-catching code to determine which HTTP header
|
||||
* caused the exception.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $header = null;
|
||||
|
||||
/**
|
||||
* Create the exception
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $header
|
||||
* Create the exception
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $header
|
||||
*/
|
||||
public function __construct($message, $header=null) {
|
||||
|
||||
parent::__construct($message);
|
||||
$this->header = $header;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP statuscode for this exception
|
||||
* Returns the HTTP statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHTTPCode() {
|
||||
|
||||
return 412;
|
||||
return 412;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method allows the exception to include additonal information into the WebDAV error response
|
||||
* This method allows the exception to include additional information into the WebDAV error response
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $errorNode
|
||||
* @param DOMElement $errorNode
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
|
||||
|
||||
|
||||
if ($this->header) {
|
||||
$prop = $errorNode->ownerDocument->createElement('s:header');
|
||||
$prop->nodeValue = $this->header;
|
||||
|
|
|
@ -7,17 +7,17 @@
|
|||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_ReportNotImplemented extends Sabre_DAV_Exception_NotImplemented {
|
||||
|
||||
/**
|
||||
* This method allows the exception to include additonal information into the WebDAV error response
|
||||
* This method allows the exception to include additional information into the WebDAV error response
|
||||
*
|
||||
* @param Sabre_DAV_Server $server
|
||||
* @param DOMElement $errorNode
|
||||
* @param DOMElement $errorNode
|
||||
* @return void
|
||||
*/
|
||||
public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
|
||||
|
|
10
3rdparty/Sabre/DAV/Exception/RequestedRangeNotSatisfiable.php
поставляемый
Normal file → Executable file
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* RequestedRangeNotSatisfiable
|
||||
* RequestedRangeNotSatisfiable
|
||||
*
|
||||
* This exception is normally thrown when the user
|
||||
* This exception is normally thrown when the user
|
||||
* request a range that is out of the entity bounds.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_RequestedRangeNotSatisfiable extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* returns the http statuscode for this exception
|
||||
* returns the http statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
|
@ -3,19 +3,19 @@
|
|||
/**
|
||||
* UnSupportedMediaType
|
||||
*
|
||||
* The 415 Unsupported Media Type status code is generally sent back when the client
|
||||
* The 415 Unsupported Media Type status code is generally sent back when the client
|
||||
* tried to call an HTTP method, with a body the server didn't understand
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Exception_UnsupportedMediaType extends Sabre_DAV_Exception {
|
||||
class Sabre_DAV_Exception_UnsupportedMediaType extends Sabre_DAV_Exception {
|
||||
|
||||
/**
|
||||
* returns the http statuscode for this exception
|
||||
* returns the http statuscode for this exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
|
|
|
@ -1,24 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Directory class
|
||||
*
|
||||
* Directory class
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_FS_Directory extends Sabre_DAV_FS_Node implements Sabre_DAV_ICollection, Sabre_DAV_IQuota {
|
||||
|
||||
/**
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* data is a readable stream resource
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource $data Initial payload
|
||||
* @return void
|
||||
* Data will either be supplied as a stream resource, or in certain cases
|
||||
* as a string. Keep in mind that you may have to support either.
|
||||
*
|
||||
* After succesful creation of the file, you may choose to return the ETag
|
||||
* of the new file here.
|
||||
*
|
||||
* The returned ETag must be surrounded by double-quotes (The quotes should
|
||||
* be part of the actual string).
|
||||
*
|
||||
* If you cannot accurately determine the ETag, you should not return it.
|
||||
* If you don't store the file exactly as-is (you're transforming it
|
||||
* somehow) you should also not return an ETag.
|
||||
*
|
||||
* This means that if a subsequent GET to this new file does not exactly
|
||||
* return the same contents of what was submitted here, you are strongly
|
||||
* recommended to omit the ETag.
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource|string $data Initial payload
|
||||
* @return null|string
|
||||
*/
|
||||
public function createFile($name, $data = null) {
|
||||
|
||||
|
@ -28,9 +43,9 @@ class Sabre_DAV_FS_Directory extends Sabre_DAV_FS_Node implements Sabre_DAV_ICol
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function createDirectory($name) {
|
||||
|
@ -41,17 +56,17 @@ class Sabre_DAV_FS_Directory extends Sabre_DAV_FS_Node implements Sabre_DAV_ICol
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a specific child node, referenced by its name
|
||||
*
|
||||
* @param string $name
|
||||
* @throws Sabre_DAV_Exception_FileNotFound
|
||||
* @return Sabre_DAV_INode
|
||||
* Returns a specific child node, referenced by its name
|
||||
*
|
||||
* @param string $name
|
||||
* @throws Sabre_DAV_Exception_NotFound
|
||||
* @return Sabre_DAV_INode
|
||||
*/
|
||||
public function getChild($name) {
|
||||
|
||||
$path = $this->path . '/' . $name;
|
||||
|
||||
if (!file_exists($path)) throw new Sabre_DAV_Exception_FileNotFound('File with name ' . $path . ' could not be located');
|
||||
if (!file_exists($path)) throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
|
||||
|
||||
if (is_dir($path)) {
|
||||
|
||||
|
@ -66,9 +81,9 @@ class Sabre_DAV_FS_Directory extends Sabre_DAV_FS_Node implements Sabre_DAV_ICol
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
*/
|
||||
public function getChildren() {
|
||||
|
||||
|
@ -79,10 +94,10 @@ class Sabre_DAV_FS_Directory extends Sabre_DAV_FS_Node implements Sabre_DAV_ICol
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if a child exists.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* Checks if a child exists.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function childExists($name) {
|
||||
|
||||
|
@ -92,8 +107,8 @@ class Sabre_DAV_FS_Directory extends Sabre_DAV_FS_Node implements Sabre_DAV_ICol
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes all files in this directory, and then itself
|
||||
*
|
||||
* Deletes all files in this directory, and then itself
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
@ -104,16 +119,16 @@ class Sabre_DAV_FS_Directory extends Sabre_DAV_FS_Node implements Sabre_DAV_ICol
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns available diskspace information
|
||||
*
|
||||
* @return array
|
||||
* Returns available diskspace information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getQuotaInfo() {
|
||||
|
||||
return array(
|
||||
disk_total_space($this->path)-disk_free_space($this->path),
|
||||
disk_free_space($this->path)
|
||||
);
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* File class
|
||||
*
|
||||
* File class
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_FS_File extends Sabre_DAV_FS_Node implements Sabre_DAV_IFile {
|
||||
|
||||
/**
|
||||
* Updates the data
|
||||
*
|
||||
* @param resource $data
|
||||
* @return void
|
||||
* Updates the data
|
||||
*
|
||||
* @param resource $data
|
||||
* @return void
|
||||
*/
|
||||
public function put($data) {
|
||||
|
||||
|
@ -24,9 +24,9 @@ class Sabre_DAV_FS_File extends Sabre_DAV_FS_Node implements Sabre_DAV_IFile {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the data
|
||||
*
|
||||
* @return string
|
||||
* Returns the data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get() {
|
||||
|
||||
|
@ -37,7 +37,7 @@ class Sabre_DAV_FS_File extends Sabre_DAV_FS_Node implements Sabre_DAV_IFile {
|
|||
/**
|
||||
* Delete the current file
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
|
||||
|
@ -46,12 +46,12 @@ class Sabre_DAV_FS_File extends Sabre_DAV_FS_Node implements Sabre_DAV_IFile {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the node, in bytes
|
||||
*
|
||||
* @return int
|
||||
* Returns the size of the node, in bytes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSize() {
|
||||
|
||||
|
||||
return filesize($this->path);
|
||||
|
||||
}
|
||||
|
@ -60,10 +60,10 @@ class Sabre_DAV_FS_File extends Sabre_DAV_FS_Node implements Sabre_DAV_IFile {
|
|||
* Returns the ETag for a file
|
||||
*
|
||||
* An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
|
||||
* The ETag is an arbritrary string, but MUST be surrounded by double-quotes.
|
||||
* The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
|
||||
*
|
||||
* Return null if the ETag can not effectively be determined
|
||||
*
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getETag() {
|
||||
|
@ -77,8 +77,8 @@ class Sabre_DAV_FS_File extends Sabre_DAV_FS_Node implements Sabre_DAV_IFile {
|
|||
*
|
||||
* If null is returned, we'll assume application/octet-stream
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
* @return mixed
|
||||
*/
|
||||
public function getContentType() {
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Base node-class
|
||||
* Base node-class
|
||||
*
|
||||
* The node class implements the method used by both the File and the Directory classes
|
||||
*
|
||||
* The node class implements the method used by both the File and the Directory classes
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
abstract class Sabre_DAV_FS_Node implements Sabre_DAV_INode {
|
||||
|
||||
/**
|
||||
* The path to the current node
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Sets up the node, expects a full path name
|
||||
*
|
||||
* @param string $path
|
||||
* @return void
|
||||
* Sets up the node, expects a full path name
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
public function __construct($path) {
|
||||
|
||||
|
@ -35,9 +34,9 @@ abstract class Sabre_DAV_FS_Node implements Sabre_DAV_INode {
|
|||
|
||||
|
||||
/**
|
||||
* Returns the name of the node
|
||||
*
|
||||
* @return string
|
||||
* Returns the name of the node
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
|
||||
|
@ -59,7 +58,7 @@ abstract class Sabre_DAV_FS_Node implements Sabre_DAV_INode {
|
|||
|
||||
$newPath = $parentPath . '/' . $newName;
|
||||
rename($this->path,$newPath);
|
||||
|
||||
|
||||
$this->path = $newPath;
|
||||
|
||||
}
|
||||
|
@ -67,9 +66,9 @@ abstract class Sabre_DAV_FS_Node implements Sabre_DAV_INode {
|
|||
|
||||
|
||||
/**
|
||||
* Returns the last modification time, as a unix timestamp
|
||||
*
|
||||
* @return int
|
||||
* Returns the last modification time, as a unix timestamp
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getLastModified() {
|
||||
|
||||
|
|
|
@ -1,22 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Directory class
|
||||
*
|
||||
* Directory class
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_FSExt_Directory extends Sabre_DAV_FSExt_Node implements Sabre_DAV_ICollection, Sabre_DAV_IQuota {
|
||||
|
||||
/**
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource $data Initial payload
|
||||
* @return void
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* Data will either be supplied as a stream resource, or in certain cases
|
||||
* as a string. Keep in mind that you may have to support either.
|
||||
*
|
||||
* After succesful creation of the file, you may choose to return the ETag
|
||||
* of the new file here.
|
||||
*
|
||||
* The returned ETag must be surrounded by double-quotes (The quotes should
|
||||
* be part of the actual string).
|
||||
*
|
||||
* If you cannot accurately determine the ETag, you should not return it.
|
||||
* If you don't store the file exactly as-is (you're transforming it
|
||||
* somehow) you should also not return an ETag.
|
||||
*
|
||||
* This means that if a subsequent GET to this new file does not exactly
|
||||
* return the same contents of what was submitted here, you are strongly
|
||||
* recommended to omit the ETag.
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource|string $data Initial payload
|
||||
* @return null|string
|
||||
*/
|
||||
public function createFile($name, $data = null) {
|
||||
|
||||
|
@ -25,12 +42,14 @@ class Sabre_DAV_FSExt_Directory extends Sabre_DAV_FSExt_Node implements Sabre_DA
|
|||
$newPath = $this->path . '/' . $name;
|
||||
file_put_contents($newPath,$data);
|
||||
|
||||
return '"' . md5_file($newPath) . '"';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function createDirectory($name) {
|
||||
|
@ -43,18 +62,18 @@ class Sabre_DAV_FSExt_Directory extends Sabre_DAV_FSExt_Node implements Sabre_DA
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a specific child node, referenced by its name
|
||||
*
|
||||
* @param string $name
|
||||
* @throws Sabre_DAV_Exception_FileNotFound
|
||||
* @return Sabre_DAV_INode
|
||||
* Returns a specific child node, referenced by its name
|
||||
*
|
||||
* @param string $name
|
||||
* @throws Sabre_DAV_Exception_NotFound
|
||||
* @return Sabre_DAV_INode
|
||||
*/
|
||||
public function getChild($name) {
|
||||
|
||||
$path = $this->path . '/' . $name;
|
||||
|
||||
if (!file_exists($path)) throw new Sabre_DAV_Exception_FileNotFound('File could not be located');
|
||||
if ($name=='.' || $name=='..') throw new Sabre_DAV_Exception_Forbidden('Permission denied to . and ..');
|
||||
if (!file_exists($path)) throw new Sabre_DAV_Exception_NotFound('File could not be located');
|
||||
if ($name=='.' || $name=='..') throw new Sabre_DAV_Exception_Forbidden('Permission denied to . and ..');
|
||||
|
||||
if (is_dir($path)) {
|
||||
|
||||
|
@ -69,10 +88,10 @@ class Sabre_DAV_FSExt_Directory extends Sabre_DAV_FSExt_Node implements Sabre_DA
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if a child exists.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
* Checks if a child exists.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function childExists($name) {
|
||||
|
||||
|
@ -85,9 +104,9 @@ class Sabre_DAV_FSExt_Directory extends Sabre_DAV_FSExt_Node implements Sabre_DA
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
*/
|
||||
public function getChildren() {
|
||||
|
||||
|
@ -98,9 +117,9 @@ class Sabre_DAV_FSExt_Directory extends Sabre_DAV_FSExt_Node implements Sabre_DA
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes all files in this directory, and then itself
|
||||
*
|
||||
* @return void
|
||||
* Deletes all files in this directory, and then itself
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete() {
|
||||
|
||||
|
@ -118,16 +137,16 @@ class Sabre_DAV_FSExt_Directory extends Sabre_DAV_FSExt_Node implements Sabre_DA
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns available diskspace information
|
||||
*
|
||||
* @return array
|
||||
* Returns available diskspace information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getQuotaInfo() {
|
||||
|
||||
return array(
|
||||
disk_total_space($this->path)-disk_free_space($this->path),
|
||||
disk_free_space($this->path)
|
||||
);
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* File class
|
||||
*
|
||||
* File class
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_FSExt_File extends Sabre_DAV_FSExt_Node implements Sabre_DAV_IFile {
|
||||
|
||||
/**
|
||||
* Updates the data
|
||||
* Updates the data
|
||||
*
|
||||
* data is a readable stream resource.
|
||||
*
|
||||
* @param resource $data
|
||||
* @return void
|
||||
* @param resource $data
|
||||
* @return void
|
||||
*/
|
||||
public function put($data) {
|
||||
|
||||
file_put_contents($this->path,$data);
|
||||
return '"' . md5_file($this->path) . '"';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function get() {
|
||||
|
||||
|
@ -39,7 +40,7 @@ class Sabre_DAV_FSExt_File extends Sabre_DAV_FSExt_Node implements Sabre_DAV_IFi
|
|||
/**
|
||||
* Delete the current file
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function delete() {
|
||||
|
||||
|
@ -52,9 +53,11 @@ class Sabre_DAV_FSExt_File extends Sabre_DAV_FSExt_Node implements Sabre_DAV_IFi
|
|||
* Returns the ETag for a file
|
||||
*
|
||||
* An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
|
||||
* The ETag is an arbritrary string, but MUST be surrounded by double-quotes.
|
||||
* The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
|
||||
*
|
||||
* Return null if the ETag can not effectively be determined
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getETag() {
|
||||
|
||||
|
@ -66,7 +69,9 @@ class Sabre_DAV_FSExt_File extends Sabre_DAV_FSExt_Node implements Sabre_DAV_IFi
|
|||
* Returns the mime-type for a file
|
||||
*
|
||||
* If null is returned, we'll assume application/octet-stream
|
||||
*/
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentType() {
|
||||
|
||||
return null;
|
||||
|
@ -74,9 +79,9 @@ class Sabre_DAV_FSExt_File extends Sabre_DAV_FSExt_Node implements Sabre_DAV_IFi
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the file, in bytes
|
||||
*
|
||||
* @return int
|
||||
* Returns the size of the file, in bytes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSize() {
|
||||
|
||||
|
|
|
@ -1,95 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Base node-class
|
||||
* Base node-class
|
||||
*
|
||||
* The node class implements the method used by both the File and the Directory classes
|
||||
*
|
||||
* The node class implements the method used by both the File and the Directory classes
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_DAV_ILockable, Sabre_DAV_IProperties {
|
||||
|
||||
/**
|
||||
* Returns all the locks on this node
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getLocks() {
|
||||
|
||||
$resourceData = $this->getResourceData();
|
||||
$locks = $resourceData['locks'];
|
||||
foreach($locks as $k=>$lock) {
|
||||
if (time() > $lock->timeout + $lock->created) unset($locks[$k]);
|
||||
}
|
||||
return $locks;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks this node
|
||||
*
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return void
|
||||
*/
|
||||
function lock(Sabre_DAV_Locks_LockInfo $lockInfo) {
|
||||
|
||||
// We're making the lock timeout 30 minutes
|
||||
$lockInfo->timeout = 1800;
|
||||
$lockInfo->created = time();
|
||||
|
||||
$resourceData = $this->getResourceData();
|
||||
if (!isset($resourceData['locks'])) $resourceData['locks'] = array();
|
||||
$current = null;
|
||||
foreach($resourceData['locks'] as $k=>$lock) {
|
||||
if ($lock->token === $lockInfo->token) $current = $k;
|
||||
}
|
||||
if (!is_null($current)) $resourceData['locks'][$current] = $lockInfo;
|
||||
else $resourceData['locks'][] = $lockInfo;
|
||||
|
||||
$this->putResourceData($resourceData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a lock from this node
|
||||
*
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
*/
|
||||
function unlock(Sabre_DAV_Locks_LockInfo $lockInfo) {
|
||||
|
||||
//throw new Sabre_DAV_Exception('bla');
|
||||
$resourceData = $this->getResourceData();
|
||||
foreach($resourceData['locks'] as $k=>$lock) {
|
||||
|
||||
if ($lock->token === $lockInfo->token) {
|
||||
|
||||
unset($resourceData['locks'][$k]);
|
||||
$this->putResourceData($resourceData);
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_DAV_IProperties {
|
||||
|
||||
/**
|
||||
* Updates properties on this node,
|
||||
*
|
||||
* @param array $mutations
|
||||
* @param array $properties
|
||||
* @see Sabre_DAV_IProperties::updateProperties
|
||||
* @return bool|array
|
||||
* @return bool|array
|
||||
*/
|
||||
public function updateProperties($properties) {
|
||||
|
||||
$resourceData = $this->getResourceData();
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach($properties as $propertyName=>$propertyValue) {
|
||||
|
||||
|
@ -101,11 +34,11 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
|
|||
} else {
|
||||
$resourceData['properties'][$propertyName] = $propertyValue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$this->putResourceData($resourceData);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,8 +47,8 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
|
|||
* The properties list is a list of propertynames the client requested, encoded as xmlnamespace#tagName, for example: http://www.example.org/namespace#author
|
||||
* If the array is empty, all properties should be returned
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
* @param array $properties
|
||||
* @return array
|
||||
*/
|
||||
function getProperties($properties) {
|
||||
|
||||
|
@ -134,9 +67,9 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the resource file
|
||||
*
|
||||
* @return string
|
||||
* Returns the path to the resource file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getResourceInfoPath() {
|
||||
|
||||
|
@ -146,14 +79,14 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns all the stored resource information
|
||||
*
|
||||
* @return array
|
||||
* Returns all the stored resource information
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getResourceData() {
|
||||
|
||||
$path = $this->getResourceInfoPath();
|
||||
if (!file_exists($path)) return array('locks'=>array(), 'properties' => array());
|
||||
if (!file_exists($path)) return array('properties' => array());
|
||||
|
||||
// opening up the file, and creating a shared lock
|
||||
$handle = fopen($path,'r');
|
||||
|
@ -171,20 +104,19 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
|
|||
// Unserializing and checking if the resource file contains data for this file
|
||||
$data = unserialize($data);
|
||||
if (!isset($data[$this->getName()])) {
|
||||
return array('locks'=>array(), 'properties' => array());
|
||||
return array('properties' => array());
|
||||
}
|
||||
|
||||
$data = $data[$this->getName()];
|
||||
if (!isset($data['locks'])) $data['locks'] = array();
|
||||
if (!isset($data['properties'])) $data['properties'] = array();
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the resource information
|
||||
*
|
||||
* @param array $newData
|
||||
* Updates the resource information
|
||||
*
|
||||
* @param array $newData
|
||||
* @return void
|
||||
*/
|
||||
protected function putResourceData(array $newData) {
|
||||
|
@ -238,6 +170,9 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteResourceData() {
|
||||
|
||||
// When we're deleting this node, we also need to delete any resource information
|
||||
|
@ -264,6 +199,7 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
|
|||
fwrite($handle,serialize($data));
|
||||
fclose($handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
* File class
|
||||
*
|
||||
* This is a helper class, that should aid in getting file classes setup.
|
||||
* Most of its methods are implemented, and throw permission denied exceptions
|
||||
*
|
||||
* Most of its methods are implemented, and throw permission denied exceptions
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
abstract class Sabre_DAV_File extends Sabre_DAV_Node implements Sabre_DAV_IFile {
|
||||
|
@ -18,33 +18,33 @@ abstract class Sabre_DAV_File extends Sabre_DAV_Node implements Sabre_DAV_IFile
|
|||
* Updates the data
|
||||
*
|
||||
* data is a readable stream resource.
|
||||
*
|
||||
* @param resource $data
|
||||
* @return void
|
||||
*
|
||||
* @param resource $data
|
||||
* @return void
|
||||
*/
|
||||
public function put($data) {
|
||||
public function put($data) {
|
||||
|
||||
throw new Sabre_DAV_Exception_Forbidden('Permission denied to change data');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data
|
||||
* Returns the data
|
||||
*
|
||||
* This method may either return a string or a readable stream resource
|
||||
*
|
||||
* @return mixed
|
||||
* @return mixed
|
||||
*/
|
||||
public function get() {
|
||||
public function get() {
|
||||
|
||||
throw new Sabre_DAV_Exception_Forbidden('Permission denied to read this file');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the size of the file, in bytes.
|
||||
*
|
||||
* @return int
|
||||
* Returns the size of the file, in bytes.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSize() {
|
||||
|
||||
|
@ -56,9 +56,11 @@ abstract class Sabre_DAV_File extends Sabre_DAV_Node implements Sabre_DAV_IFile
|
|||
* Returns the ETag for a file
|
||||
*
|
||||
* An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
|
||||
* The ETag is an arbritrary string, but MUST be surrounded by double-quotes.
|
||||
* The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
|
||||
*
|
||||
* Return null if the ETag can not effectively be determined
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getETag() {
|
||||
|
||||
|
@ -70,7 +72,9 @@ abstract class Sabre_DAV_File extends Sabre_DAV_Node implements Sabre_DAV_IFile
|
|||
* Returns the mime-type for a file
|
||||
*
|
||||
* If null is returned, we'll assume application/octet-stream
|
||||
*/
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getContentType() {
|
||||
|
||||
return null;
|
||||
|
|
|
@ -3,54 +3,70 @@
|
|||
/**
|
||||
* The ICollection Interface
|
||||
*
|
||||
* This interface should be implemented by each class that represents a collection
|
||||
*
|
||||
* This interface should be implemented by each class that represents a collection
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_DAV_ICollection extends Sabre_DAV_INode {
|
||||
|
||||
/**
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* data is a readable stream resource
|
||||
* Creates a new file in the directory
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource $data Initial payload
|
||||
* @return void
|
||||
* Data will either be supplied as a stream resource, or in certain cases
|
||||
* as a string. Keep in mind that you may have to support either.
|
||||
*
|
||||
* After succesful creation of the file, you may choose to return the ETag
|
||||
* of the new file here.
|
||||
*
|
||||
* The returned ETag must be surrounded by double-quotes (The quotes should
|
||||
* be part of the actual string).
|
||||
*
|
||||
* If you cannot accurately determine the ETag, you should not return it.
|
||||
* If you don't store the file exactly as-is (you're transforming it
|
||||
* somehow) you should also not return an ETag.
|
||||
*
|
||||
* This means that if a subsequent GET to this new file does not exactly
|
||||
* return the same contents of what was submitted here, you are strongly
|
||||
* recommended to omit the ETag.
|
||||
*
|
||||
* @param string $name Name of the file
|
||||
* @param resource|string $data Initial payload
|
||||
* @return null|string
|
||||
*/
|
||||
function createFile($name, $data = null);
|
||||
|
||||
/**
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* Creates a new subdirectory
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
function createDirectory($name);
|
||||
|
||||
/**
|
||||
* Returns a specific child node, referenced by its name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Sabre_DAV_INode
|
||||
* Returns a specific child node, referenced by its name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Sabre_DAV_INode
|
||||
*/
|
||||
function getChild($name);
|
||||
|
||||
/**
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
* Returns an array with all the child nodes
|
||||
*
|
||||
* @return Sabre_DAV_INode[]
|
||||
*/
|
||||
function getChildren();
|
||||
|
||||
/**
|
||||
* Checks if a child-node with the specified name exists
|
||||
*
|
||||
* @return bool
|
||||
* Checks if a child-node with the specified name exists
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
function childExists($name);
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
*
|
||||
* This interface can be used to create special-type of collection-resources
|
||||
* as defined by RFC 5689.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_DAV_IExtendedCollection extends Sabre_DAV_ICollection {
|
||||
|
@ -17,7 +17,7 @@ interface Sabre_DAV_IExtendedCollection extends Sabre_DAV_ICollection {
|
|||
/**
|
||||
* Creates a new collection
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @param array $resourceType
|
||||
* @param array $properties
|
||||
* @return void
|
||||
|
|
|
@ -1,34 +1,48 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This interface represents a file or leaf in the tree.
|
||||
* This interface represents a file in the directory tree
|
||||
*
|
||||
* A file is a bit of a broad definition. In general it implies that on
|
||||
* this specific node a PUT or GET method may be performed, to either update,
|
||||
* or retrieve the contents of the file.
|
||||
*
|
||||
* The nature of a file is, as you might be aware of, that it doesn't contain sub-nodes and has contents
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_DAV_IFile extends Sabre_DAV_INode {
|
||||
|
||||
/**
|
||||
* Updates the data
|
||||
*
|
||||
* Updates the data
|
||||
*
|
||||
* The data argument is a readable stream resource.
|
||||
*
|
||||
* @param resource $data
|
||||
* @return void
|
||||
* After a succesful put operation, you may choose to return an ETag. The
|
||||
* etag must always be surrounded by double-quotes. These quotes must
|
||||
* appear in the actual string you're returning.
|
||||
*
|
||||
* Clients may use the ETag from a PUT request to later on make sure that
|
||||
* when they update the file, the contents haven't changed in the mean
|
||||
* time.
|
||||
*
|
||||
* If you don't plan to store the file byte-by-byte, and you return a
|
||||
* different object on a subsequent GET you are strongly recommended to not
|
||||
* return an ETag, and just return null.
|
||||
*
|
||||
* @param resource $data
|
||||
* @return string|null
|
||||
*/
|
||||
function put($data);
|
||||
|
||||
/**
|
||||
* Returns the data
|
||||
*
|
||||
* Returns the data
|
||||
*
|
||||
* This method may either return a string or a readable stream resource
|
||||
*
|
||||
* @return mixed
|
||||
* @return mixed
|
||||
*/
|
||||
function get();
|
||||
|
||||
|
@ -36,7 +50,7 @@ interface Sabre_DAV_IFile extends Sabre_DAV_INode {
|
|||
* Returns the mime-type for a file
|
||||
*
|
||||
* If null is returned, we'll assume application/octet-stream
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function getContentType();
|
||||
|
@ -47,15 +61,15 @@ interface Sabre_DAV_IFile extends Sabre_DAV_INode {
|
|||
* An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
|
||||
*
|
||||
* Return null if the ETag can not effectively be determined
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function getETag();
|
||||
|
||||
/**
|
||||
* Returns the size of the node, in bytes
|
||||
*
|
||||
* @return int
|
||||
* Returns the size of the node, in bytes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getSize();
|
||||
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implement this class to support locking
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_DAV_ILockable extends Sabre_DAV_INode {
|
||||
|
||||
/**
|
||||
* Returns an array with locks currently on the node
|
||||
*
|
||||
* @return Sabre_DAV_Locks_LockInfo[]
|
||||
*/
|
||||
function getLocks();
|
||||
|
||||
/**
|
||||
* Creates a new lock on the file.
|
||||
*
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo The lock information
|
||||
* @return void
|
||||
*/
|
||||
function lock(Sabre_DAV_Locks_LockInfo $lockInfo);
|
||||
|
||||
/**
|
||||
* Unlocks a file
|
||||
*
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo The lock information
|
||||
* @return void
|
||||
*/
|
||||
function unlock(Sabre_DAV_Locks_LockInfo $lockInfo);
|
||||
|
||||
}
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
/**
|
||||
* The INode interface is the base interface, and the parent class of both ICollection and IFile
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_DAV_INode {
|
||||
|
@ -14,14 +14,16 @@ interface Sabre_DAV_INode {
|
|||
/**
|
||||
* Deleted the current node
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
function delete();
|
||||
|
||||
/**
|
||||
* Returns the name of the node
|
||||
*
|
||||
* @return string
|
||||
* Returns the name of the node.
|
||||
*
|
||||
* This is used to generate the url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getName();
|
||||
|
||||
|
@ -34,9 +36,9 @@ interface Sabre_DAV_INode {
|
|||
function setName($name);
|
||||
|
||||
/**
|
||||
* Returns the last modification time, as a unix timestamp
|
||||
*
|
||||
* @return int
|
||||
* Returns the last modification time, as a unix timestamp
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function getLastModified();
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
* IProperties interface
|
||||
*
|
||||
* Implement this interface to support custom WebDAV properties requested and sent from clients.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_DAV_IProperties extends Sabre_DAV_INode {
|
||||
|
@ -26,7 +26,7 @@ interface Sabre_DAV_IProperties extends Sabre_DAV_INode {
|
|||
* If the operation was successful, true can be returned.
|
||||
* If the operation failed, false can be returned.
|
||||
*
|
||||
* Deletion of a non-existant property is always succesful.
|
||||
* Deletion of a non-existent property is always successful.
|
||||
*
|
||||
* Lastly, it is optional to return detailed information about any
|
||||
* failures. In this case an array should be returned with the following
|
||||
|
@ -41,12 +41,12 @@ interface Sabre_DAV_IProperties extends Sabre_DAV_INode {
|
|||
* )
|
||||
* )
|
||||
*
|
||||
* In this example it was forbidden to update {DAV:}displayname.
|
||||
* In this example it was forbidden to update {DAV:}displayname.
|
||||
* (403 Forbidden), which in turn also caused {DAV:}owner to fail
|
||||
* (424 Failed Dependency) because the request needs to be atomic.
|
||||
*
|
||||
* @param array $mutations
|
||||
* @return bool|array
|
||||
* @param array $mutations
|
||||
* @return bool|array
|
||||
*/
|
||||
function updateProperties($mutations);
|
||||
|
||||
|
@ -58,7 +58,7 @@ interface Sabre_DAV_IProperties extends Sabre_DAV_INode {
|
|||
*
|
||||
* If the array is empty, it means 'all properties' were requested.
|
||||
*
|
||||
* @param array $properties
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
function getProperties($properties);
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
* IQuota interface
|
||||
*
|
||||
* Implement this interface to add the ability to return quota information. The ObjectTree
|
||||
* will check for quota information on any given node. If the information is not available it will
|
||||
* will check for quota information on any given node. If the information is not available it will
|
||||
* attempt to fetch the information from the root node.
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
interface Sabre_DAV_IQuota extends Sabre_DAV_ICollection {
|
||||
|
@ -21,7 +21,7 @@ interface Sabre_DAV_IQuota extends Sabre_DAV_ICollection {
|
|||
* This method MUST return an array with 2 values, the first being the total used space,
|
||||
* the second the available space (in bytes)
|
||||
*/
|
||||
function getQuotaInfo();
|
||||
function getQuotaInfo();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,45 +4,45 @@
|
|||
* The Lock manager allows you to handle all file-locks centrally.
|
||||
*
|
||||
* This is an alternative approach to doing this on a per-node basis
|
||||
*
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
abstract class Sabre_DAV_Locks_Backend_Abstract {
|
||||
|
||||
/**
|
||||
* Returns a list of Sabre_DAV_Locks_LockInfo objects
|
||||
*
|
||||
* Returns a list of Sabre_DAV_Locks_LockInfo objects
|
||||
*
|
||||
* This method should return all the locks for a particular uri, including
|
||||
* locks that might be set on a parent uri.
|
||||
*
|
||||
* If returnChildLocks is set to true, this method should also look for
|
||||
* any locks in the subtree of the uri for locks.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $uri
|
||||
* @param bool $returnChildLocks
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
abstract function getLocks($uri, $returnChildLocks);
|
||||
|
||||
/**
|
||||
* Locks a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
* Locks a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
*/
|
||||
abstract function lock($uri,Sabre_DAV_Locks_LockInfo $lockInfo);
|
||||
|
||||
/**
|
||||
* Removes a lock from a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
* Removes a lock from a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
*/
|
||||
abstract function unlock($uri,Sabre_DAV_Locks_LockInfo $lockInfo);
|
||||
|
||||
|
|
|
@ -1,28 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The Lock manager allows you to handle all file-locks centrally.
|
||||
* This Lock Backend stores all its data in the filesystem in separate file per
|
||||
* node.
|
||||
*
|
||||
* This Lock Manager is now deprecated. It has a bug that allows parent
|
||||
* collections to be deletes when children deeper in the tree are locked.
|
||||
* This Lock Manager is now deprecated. It has a bug that allows parent
|
||||
* collections to be deletes when children deeper in the tree are locked.
|
||||
*
|
||||
* This also means that using this backend means you will not pass the Neon
|
||||
* Litmus test.
|
||||
*
|
||||
* You are recommended to use either the PDO or the File backend instead.
|
||||
*
|
||||
* This Lock Manager stores all its data in the filesystem.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @deprecated
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Locks_Backend_FS extends Sabre_DAV_Locks_Backend_Abstract {
|
||||
|
||||
/**
|
||||
* The default data directory
|
||||
*
|
||||
* @var string
|
||||
* The default data directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $dataDir;
|
||||
|
||||
|
@ -40,17 +42,17 @@ class Sabre_DAV_Locks_Backend_FS extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
|
||||
|
||||
/**
|
||||
* Returns a list of Sabre_DAV_Locks_LockInfo objects
|
||||
*
|
||||
* Returns a list of Sabre_DAV_Locks_LockInfo objects
|
||||
*
|
||||
* This method should return all the locks for a particular uri, including
|
||||
* locks that might be set on a parent uri.
|
||||
*
|
||||
* If returnChildLocks is set to true, this method should also look for
|
||||
* any locks in the subtree of the uri for locks.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $uri
|
||||
* @param bool $returnChildLocks
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function getLocks($uri, $returnChildLocks) {
|
||||
|
||||
|
@ -59,15 +61,15 @@ class Sabre_DAV_Locks_Backend_FS extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
|
||||
foreach(explode('/',$uri) as $uriPart) {
|
||||
|
||||
// weird algorithm that can probably be improved, but we're traversing the path top down
|
||||
if ($currentPath) $currentPath.='/';
|
||||
// weird algorithm that can probably be improved, but we're traversing the path top down
|
||||
if ($currentPath) $currentPath.='/';
|
||||
$currentPath.=$uriPart;
|
||||
|
||||
$uriLocks = $this->getData($currentPath);
|
||||
|
||||
foreach($uriLocks as $uriLock) {
|
||||
|
||||
// Unless we're on the leaf of the uri-tree we should ingore locks with depth 0
|
||||
// Unless we're on the leaf of the uri-tree we should ignore locks with depth 0
|
||||
if($uri==$currentPath || $uriLock->depth!=0) {
|
||||
$uriLock->uri = $currentPath;
|
||||
$lockList[] = $uriLock;
|
||||
|
@ -79,18 +81,18 @@ class Sabre_DAV_Locks_Backend_FS extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
|
||||
// Checking if we can remove any of these locks
|
||||
foreach($lockList as $k=>$lock) {
|
||||
if (time() > $lock->timeout + $lock->created) unset($lockList[$k]);
|
||||
if (time() > $lock->timeout + $lock->created) unset($lockList[$k]);
|
||||
}
|
||||
return $lockList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
* Locks a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
*/
|
||||
public function lock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) {
|
||||
|
||||
|
@ -109,11 +111,11 @@ class Sabre_DAV_Locks_Backend_FS extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes a lock from a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
* Removes a lock from a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
*/
|
||||
public function unlock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) {
|
||||
|
||||
|
@ -136,7 +138,7 @@ class Sabre_DAV_Locks_Backend_FS extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
* Returns the stored data for a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
protected function getData($uri) {
|
||||
|
||||
|
@ -167,7 +169,7 @@ class Sabre_DAV_Locks_Backend_FS extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
* Updates the lock information
|
||||
*
|
||||
* @param string $uri
|
||||
* @param array $newData
|
||||
* @param array $newData
|
||||
* @return void
|
||||
*/
|
||||
protected function putData($uri,array $newData) {
|
||||
|
|
|
@ -3,30 +3,30 @@
|
|||
/**
|
||||
* The Lock manager allows you to handle all file-locks centrally.
|
||||
*
|
||||
* This Lock Manager stores all its data in a single file.
|
||||
* This Lock Manager stores all its data in a single file.
|
||||
*
|
||||
* Note that this is not nearly as robust as a database, you are encouraged
|
||||
* to use the PDO backend instead.
|
||||
*
|
||||
* @package Sabre
|
||||
* @subpackage DAV
|
||||
* @copyright Copyright (C) 2007-2011 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
|
||||
*/
|
||||
class Sabre_DAV_Locks_Backend_File extends Sabre_DAV_Locks_Backend_Abstract {
|
||||
|
||||
/**
|
||||
* The storage file
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $locksFile;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $locksFile path to file
|
||||
* @param string $locksFile path to file
|
||||
*/
|
||||
public function __construct($locksFile) {
|
||||
|
||||
|
@ -35,24 +35,24 @@ class Sabre_DAV_Locks_Backend_File extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Sabre_DAV_Locks_LockInfo objects
|
||||
*
|
||||
* Returns a list of Sabre_DAV_Locks_LockInfo objects
|
||||
*
|
||||
* This method should return all the locks for a particular uri, including
|
||||
* locks that might be set on a parent uri.
|
||||
*
|
||||
* If returnChildLocks is set to true, this method should also look for
|
||||
* any locks in the subtree of the uri for locks.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $uri
|
||||
* @param bool $returnChildLocks
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
public function getLocks($uri, $returnChildLocks) {
|
||||
|
||||
$newLocks = array();
|
||||
$currentPath = '';
|
||||
|
||||
$locks = $this->getData();
|
||||
|
||||
foreach($locks as $lock) {
|
||||
|
||||
if ($lock->uri === $uri ||
|
||||
|
@ -70,29 +70,35 @@ class Sabre_DAV_Locks_Backend_File extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
|
||||
// Checking if we can remove any of these locks
|
||||
foreach($newLocks as $k=>$lock) {
|
||||
if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]);
|
||||
if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]);
|
||||
}
|
||||
return $newLocks;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
* Locks a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
*/
|
||||
public function lock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) {
|
||||
public function lock($uri, Sabre_DAV_Locks_LockInfo $lockInfo) {
|
||||
|
||||
// We're making the lock timeout 30 minutes
|
||||
$lockInfo->timeout = 1800;
|
||||
$lockInfo->created = time();
|
||||
$lockInfo->uri = $uri;
|
||||
|
||||
$locks = $this->getLocks($uri,false);
|
||||
$locks = $this->getData();
|
||||
|
||||
foreach($locks as $k=>$lock) {
|
||||
if ($lock->token == $lockInfo->token) unset($locks[$k]);
|
||||
if (
|
||||
($lock->token == $lockInfo->token) ||
|
||||
(time() > $lock->timeout + $lock->created)
|
||||
) {
|
||||
unset($locks[$k]);
|
||||
}
|
||||
}
|
||||
$locks[] = $lockInfo;
|
||||
$this->putData($locks);
|
||||
|
@ -101,15 +107,15 @@ class Sabre_DAV_Locks_Backend_File extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
}
|
||||
|
||||
/**
|
||||
* Removes a lock from a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
* Removes a lock from a uri
|
||||
*
|
||||
* @param string $uri
|
||||
* @param Sabre_DAV_Locks_LockInfo $lockInfo
|
||||
* @return bool
|
||||
*/
|
||||
public function unlock($uri,Sabre_DAV_Locks_LockInfo $lockInfo) {
|
||||
public function unlock($uri, Sabre_DAV_Locks_LockInfo $lockInfo) {
|
||||
|
||||
$locks = $this->getLocks($uri,false);
|
||||
$locks = $this->getData();
|
||||
foreach($locks as $k=>$lock) {
|
||||
|
||||
if ($lock->token == $lockInfo->token) {
|
||||
|
@ -127,7 +133,7 @@ class Sabre_DAV_Locks_Backend_File extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
/**
|
||||
* Loads the lockdata from the filesystem.
|
||||
*
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
protected function getData() {
|
||||
|
||||
|
@ -153,7 +159,7 @@ class Sabre_DAV_Locks_Backend_File extends Sabre_DAV_Locks_Backend_Abstract {
|
|||
/**
|
||||
* Saves the lockdata
|
||||
*
|
||||
* @param array $newData
|
||||
* @param array $newData
|
||||
* @return void
|
||||
*/
|
||||
protected function putData(array $newData) {
|
||||
|
|