Initial Release of the calendar plugin

This commit is contained in:
Tobias Hößl 2012-06-03 18:19:28 +00:00
parent 45cc9885fc
commit 7115197a33
561 changed files with 189494 additions and 0 deletions

View file

@ -0,0 +1,75 @@
<?php
/**
* This property represents the {DAV:}getlastmodified property.
*
* Although this is normally a simple property, windows requires us to add
* some new attributes.
*
* This class uses unix timestamps internally, and converts them to RFC 1123 times for
* serialization
*
* @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_Property_GetLastModified extends Sabre_DAV_Property {
/**
* time
*
* @var int
*/
public $time;
/**
* __construct
*
* @param int|DateTime $time
*/
public function __construct($time) {
if ($time instanceof DateTime) {
$this->time = $time;
} elseif (is_int($time) || ctype_digit($time)) {
$this->time = new DateTime('@' . $time);
} else {
$this->time = new DateTime($time);
}
// Setting timezone to UTC
$this->time->setTimezone(new DateTimeZone('UTC'));
}
/**
* serialize
*
* @param Sabre_DAV_Server $server
* @param DOMElement $prop
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $prop) {
$doc = $prop->ownerDocument;
$prop->setAttribute('xmlns:b','urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/');
$prop->setAttribute('b:dt','dateTime.rfc1123');
$prop->nodeValue = Sabre_HTTP_Util::toHTTPDate($this->time);
}
/**
* getTime
*
* @return DateTime
*/
public function getTime() {
return $this->time;
}
}

View file

@ -0,0 +1,91 @@
<?php
/**
* Href property
*
* The href property represents a url within a {DAV:}href element.
* This is used by many WebDAV extensions, but not really within the WebDAV core spec
*
* @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_Property_Href extends Sabre_DAV_Property implements Sabre_DAV_Property_IHref {
/**
* href
*
* @var string
*/
private $href;
/**
* Automatically prefix the url with the server base directory
*
* @var bool
*/
private $autoPrefix = true;
/**
* __construct
*
* @param string $href
* @param bool $autoPrefix
*/
public function __construct($href, $autoPrefix = true) {
$this->href = $href;
$this->autoPrefix = $autoPrefix;
}
/**
* Returns the uri
*
* @return string
*/
public function getHref() {
return $this->href;
}
/**
* Serializes this property.
*
* It will additionally prepend the href property with the server's base uri.
*
* @param Sabre_DAV_Server $server
* @param DOMElement $dom
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $dom) {
$prefix = $server->xmlNamespaces['DAV:'];
$elem = $dom->ownerDocument->createElement($prefix . ':href');
$elem->nodeValue = ($this->autoPrefix?$server->getBaseUri():'') . $this->href;
$dom->appendChild($elem);
}
/**
* Unserializes this property from a DOM Element
*
* This method returns an instance of this class.
* It will only decode {DAV:}href values. For non-compatible elements null will be returned.
*
* @param DOMElement $dom
* @return Sabre_DAV_Property_Href
*/
static function unserialize(DOMElement $dom) {
if (Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild)==='{DAV:}href') {
return new self($dom->firstChild->textContent,false);
}
}
}

View file

@ -0,0 +1,96 @@
<?php
/**
* HrefList property
*
* This property contains multiple {DAV:}href elements, each containing a url.
*
* @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_Property_HrefList extends Sabre_DAV_Property {
/**
* hrefs
*
* @var array
*/
private $hrefs;
/**
* Automatically prefix the url with the server base directory
*
* @var bool
*/
private $autoPrefix = true;
/**
* __construct
*
* @param array $hrefs
* @param bool $autoPrefix
*/
public function __construct(array $hrefs, $autoPrefix = true) {
$this->hrefs = $hrefs;
$this->autoPrefix = $autoPrefix;
}
/**
* Returns the uris
*
* @return array
*/
public function getHrefs() {
return $this->hrefs;
}
/**
* Serializes this property.
*
* It will additionally prepend the href property with the server's base uri.
*
* @param Sabre_DAV_Server $server
* @param DOMElement $dom
* @return void
*/
public function serialize(Sabre_DAV_Server $server,DOMElement $dom) {
$prefix = $server->xmlNamespaces['DAV:'];
foreach($this->hrefs as $href) {
$elem = $dom->ownerDocument->createElement($prefix . ':href');
$elem->nodeValue = ($this->autoPrefix?$server->getBaseUri():'') . $href;
$dom->appendChild($elem);
}
}
/**
* Unserializes this property from a DOM Element
*
* This method returns an instance of this class.
* It will only decode {DAV:}href values.
*
* @param DOMElement $dom
* @return Sabre_DAV_Property_HrefList
*/
static function unserialize(DOMElement $dom) {
$hrefs = array();
foreach($dom->childNodes as $child) {
if (Sabre_DAV_XMLUtil::toClarkNotation($child)==='{DAV:}href') {
$hrefs[] = $child->textContent;
}
}
return new self($hrefs, false);
}
}

View file

@ -0,0 +1,25 @@
<?php
/**
* IHref interface
*
* Any property implementing this interface can expose a related url.
* This is used by certain subsystems to aquire more information about for example
* the owner of a file
*
* @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
*/
interface Sabre_DAV_Property_IHref {
/**
* getHref
*
* @return string
*/
function getHref();
}

View file

@ -0,0 +1,102 @@
<?php
/**
* Represents {DAV:}lockdiscovery property
*
* This property contains all the open locks on a given resource
*
* @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_Property_LockDiscovery extends Sabre_DAV_Property {
/**
* locks
*
* @var array
*/
public $locks;
/**
* Should we show the locktoken as well?
*
* @var bool
*/
public $revealLockToken;
/**
* Hides the {DAV:}lockroot element from the response.
*
* It was reported that showing the lockroot in the response can break
* Office 2000 compatibility.
*/
static public $hideLockRoot = false;
/**
* __construct
*
* @param array $locks
* @param bool $revealLockToken
*/
public function __construct($locks, $revealLockToken = false) {
$this->locks = $locks;
$this->revealLockToken = $revealLockToken;
}
/**
* serialize
*
* @param Sabre_DAV_Server $server
* @param DOMElement $prop
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $prop) {
$doc = $prop->ownerDocument;
foreach($this->locks as $lock) {
$activeLock = $doc->createElementNS('DAV:','d:activelock');
$prop->appendChild($activeLock);
$lockScope = $doc->createElementNS('DAV:','d:lockscope');
$activeLock->appendChild($lockScope);
$lockScope->appendChild($doc->createElementNS('DAV:','d:' . ($lock->scope==Sabre_DAV_Locks_LockInfo::EXCLUSIVE?'exclusive':'shared')));
$lockType = $doc->createElementNS('DAV:','d:locktype');
$activeLock->appendChild($lockType);
$lockType->appendChild($doc->createElementNS('DAV:','d:write'));
/* {DAV:}lockroot */
if (!self::$hideLockRoot) {
$lockRoot = $doc->createElementNS('DAV:','d:lockroot');
$activeLock->appendChild($lockRoot);
$href = $doc->createElementNS('DAV:','d:href');
$href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri));
$lockRoot->appendChild($href);
}
$activeLock->appendChild($doc->createElementNS('DAV:','d:depth',($lock->depth == Sabre_DAV_Server::DEPTH_INFINITY?'infinity':$lock->depth)));
$activeLock->appendChild($doc->createElementNS('DAV:','d:timeout','Second-' . $lock->timeout));
if ($this->revealLockToken) {
$lockToken = $doc->createElementNS('DAV:','d:locktoken');
$activeLock->appendChild($lockToken);
$lockToken->appendChild($doc->createElementNS('DAV:','d:href','opaquelocktoken:' . $lock->token));
}
$activeLock->appendChild($doc->createElementNS('DAV:','d:owner',$lock->owner));
}
}
}

View file

@ -0,0 +1,125 @@
<?php
/**
* This class represents the {DAV:}resourcetype property
*
* Normally for files this is empty, and for collection {DAV:}collection.
* However, other specs define different values for this.
*
* @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_Property_ResourceType extends Sabre_DAV_Property {
/**
* resourceType
*
* @var array
*/
public $resourceType = array();
/**
* __construct
*
* @param mixed $resourceType
*/
public function __construct($resourceType = array()) {
if ($resourceType === Sabre_DAV_Server::NODE_FILE)
$this->resourceType = array();
elseif ($resourceType === Sabre_DAV_Server::NODE_DIRECTORY)
$this->resourceType = array('{DAV:}collection');
elseif (is_array($resourceType))
$this->resourceType = $resourceType;
else
$this->resourceType = array($resourceType);
}
/**
* serialize
*
* @param Sabre_DAV_Server $server
* @param DOMElement $prop
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $prop) {
$propName = null;
$rt = $this->resourceType;
foreach($rt as $resourceType) {
if (preg_match('/^{([^}]*)}(.*)$/',$resourceType,$propName)) {
if (isset($server->xmlNamespaces[$propName[1]])) {
$prop->appendChild($prop->ownerDocument->createElement($server->xmlNamespaces[$propName[1]] . ':' . $propName[2]));
} else {
$prop->appendChild($prop->ownerDocument->createElementNS($propName[1],'custom:' . $propName[2]));
}
}
}
}
/**
* Returns the values in clark-notation
*
* For example array('{DAV:}collection')
*
* @return array
*/
public function getValue() {
return $this->resourceType;
}
/**
* Checks if the principal contains a certain value
*
* @param string $type
* @return bool
*/
public function is($type) {
return in_array($type, $this->resourceType);
}
/**
* Adds a resourcetype value to this property
*
* @param string $type
* @return void
*/
public function add($type) {
$this->resourceType[] = $type;
$this->resourceType = array_unique($this->resourceType);
}
/**
* Unserializes a DOM element into a ResourceType property.
*
* @param DOMElement $dom
* @return Sabre_DAV_Property_ResourceType
*/
static public function unserialize(DOMElement $dom) {
$value = array();
foreach($dom->childNodes as $child) {
$value[] = Sabre_DAV_XMLUtil::toClarkNotation($child);
}
return new self($value);
}
}

View file

@ -0,0 +1,155 @@
<?php
/**
* Response property
*
* This class represents the {DAV:}response XML element.
* This is used by the Server class to encode individual items within a multistatus
* response.
*
* @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_Property_Response extends Sabre_DAV_Property implements Sabre_DAV_Property_IHref {
/**
* Url for the response
*
* @var string
*/
private $href;
/**
* Propertylist, ordered by HTTP status code
*
* @var array
*/
private $responseProperties;
/**
* The responseProperties argument is a list of properties
* within an array with keys representing HTTP status codes
*
* @param string $href
* @param array $responseProperties
*/
public function __construct($href, array $responseProperties) {
$this->href = $href;
$this->responseProperties = $responseProperties;
}
/**
* Returns the url
*
* @return string
*/
public function getHref() {
return $this->href;
}
/**
* Returns the property list
*
* @return array
*/
public function getResponseProperties() {
return $this->responseProperties;
}
/**
* serialize
*
* @param Sabre_DAV_Server $server
* @param DOMElement $dom
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $dom) {
$document = $dom->ownerDocument;
$properties = $this->responseProperties;
$xresponse = $document->createElement('d:response');
$dom->appendChild($xresponse);
$uri = Sabre_DAV_URLUtil::encodePath($this->href);
// Adding the baseurl to the beginning of the url
$uri = $server->getBaseUri() . $uri;
$xresponse->appendChild($document->createElement('d:href',$uri));
// The properties variable is an array containing properties, grouped by
// HTTP status
foreach($properties as $httpStatus=>$propertyGroup) {
// The 'href' is also in this array, and it's special cased.
// We will ignore it
if ($httpStatus=='href') continue;
// If there are no properties in this group, we can also just carry on
if (!count($propertyGroup)) continue;
$xpropstat = $document->createElement('d:propstat');
$xresponse->appendChild($xpropstat);
$xprop = $document->createElement('d:prop');
$xpropstat->appendChild($xprop);
$nsList = $server->xmlNamespaces;
foreach($propertyGroup as $propertyName=>$propertyValue) {
$propName = null;
preg_match('/^{([^}]*)}(.*)$/',$propertyName,$propName);
// special case for empty namespaces
if ($propName[1]=='') {
$currentProperty = $document->createElement($propName[2]);
$xprop->appendChild($currentProperty);
$currentProperty->setAttribute('xmlns','');
} else {
if (!isset($nsList[$propName[1]])) {
$nsList[$propName[1]] = 'x' . count($nsList);
}
// If the namespace was defined in the top-level xml namespaces, it means
// there was already a namespace declaration, and we don't have to worry about it.
if (isset($server->xmlNamespaces[$propName[1]])) {
$currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]);
} else {
$currentProperty = $document->createElementNS($propName[1],$nsList[$propName[1]].':' . $propName[2]);
}
$xprop->appendChild($currentProperty);
}
if (is_scalar($propertyValue)) {
$text = $document->createTextNode($propertyValue);
$currentProperty->appendChild($text);
} elseif ($propertyValue instanceof Sabre_DAV_Property) {
$propertyValue->serialize($server,$currentProperty);
} elseif (!is_null($propertyValue)) {
throw new Sabre_DAV_Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName);
}
}
$xpropstat->appendChild($document->createElement('d:status',$server->httpResponse->getStatusMessage($httpStatus)));
}
}
}

View file

@ -0,0 +1,57 @@
<?php
/**
* ResponseList property
*
* This class represents multiple {DAV:}response XML elements.
* This is used by the Server class to encode items within a multistatus
* response.
*
* @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_Property_ResponseList extends Sabre_DAV_Property {
/**
* Response objects.
*
* @var array
*/
private $responses;
/**
* The only valid argument is a list of Sabre_DAV_Property_Response
* objects.
*
* @param array $responses;
*/
public function __construct($responses) {
foreach($responses as $response) {
if (!($response instanceof Sabre_DAV_Property_Response)) {
throw new InvalidArgumentException('You must pass an array of Sabre_DAV_Property_Response objects');
}
}
$this->responses = $responses;
}
/**
* serialize
*
* @param Sabre_DAV_Server $server
* @param DOMElement $dom
* @return void
*/
public function serialize(Sabre_DAV_Server $server,DOMElement $dom) {
foreach($this->responses as $response) {
$response->serialize($server, $dom);
}
}
}

View file

@ -0,0 +1,76 @@
<?php
/**
* This class represents the {DAV:}supportedlock property
*
* This property contains information about what kind of locks
* this server supports.
*
* @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_Property_SupportedLock extends Sabre_DAV_Property {
/**
* supportsLocks
*
* @var mixed
*/
public $supportsLocks = false;
/**
* __construct
*
* @param mixed $supportsLocks
*/
public function __construct($supportsLocks) {
$this->supportsLocks = $supportsLocks;
}
/**
* serialize
*
* @param Sabre_DAV_Server $server
* @param DOMElement $prop
* @return void
*/
public function serialize(Sabre_DAV_Server $server,DOMElement $prop) {
$doc = $prop->ownerDocument;
if (!$this->supportsLocks) return null;
$lockEntry1 = $doc->createElementNS('DAV:','d:lockentry');
$lockEntry2 = $doc->createElementNS('DAV:','d:lockentry');
$prop->appendChild($lockEntry1);
$prop->appendChild($lockEntry2);
$lockScope1 = $doc->createElementNS('DAV:','d:lockscope');
$lockScope2 = $doc->createElementNS('DAV:','d:lockscope');
$lockType1 = $doc->createElementNS('DAV:','d:locktype');
$lockType2 = $doc->createElementNS('DAV:','d:locktype');
$lockEntry1->appendChild($lockScope1);
$lockEntry1->appendChild($lockType1);
$lockEntry2->appendChild($lockScope2);
$lockEntry2->appendChild($lockType2);
$lockScope1->appendChild($doc->createElementNS('DAV:','d:exclusive'));
$lockScope2->appendChild($doc->createElementNS('DAV:','d:shared'));
$lockType1->appendChild($doc->createElementNS('DAV:','d:write'));
$lockType2->appendChild($doc->createElementNS('DAV:','d:write'));
//$frag->appendXML('<d:lockentry><d:lockscope><d:exclusive /></d:lockscope><d:locktype><d:write /></d:locktype></d:lockentry>');
//$frag->appendXML('<d:lockentry><d:lockscope><d:shared /></d:lockscope><d:locktype><d:write /></d:locktype></d:lockentry>');
}
}

View file

@ -0,0 +1,109 @@
<?php
/**
* supported-report-set property.
*
* This property is defined in RFC3253, but since it's
* so common in other webdav-related specs, it is part of the core server.
*
* @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_Property_SupportedReportSet extends Sabre_DAV_Property {
/**
* List of reports
*
* @var array
*/
protected $reports = array();
/**
* Creates the property
*
* Any reports passed in the constructor
* should be valid report-types in clark-notation.
*
* Either a string or an array of strings must be passed.
*
* @param mixed $reports
*/
public function __construct($reports = null) {
if (!is_null($reports))
$this->addReport($reports);
}
/**
* Adds a report to this property
*
* The report must be a string in clark-notation.
* Multiple reports can be specified as an array.
*
* @param mixed $report
* @return void
*/
public function addReport($report) {
if (!is_array($report)) $report = array($report);
foreach($report as $r) {
if (!preg_match('/^{([^}]*)}(.*)$/',$r))
throw new Sabre_DAV_Exception('Reportname must be in clark-notation');
$this->reports[] = $r;
}
}
/**
* Returns the list of supported reports
*
* @return array
*/
public function getValue() {
return $this->reports;
}
/**
* Serializes the node
*
* @param Sabre_DAV_Server $server
* @param DOMElement $prop
* @return void
*/
public function serialize(Sabre_DAV_Server $server, DOMElement $prop) {
foreach($this->reports as $reportName) {
$supportedReport = $prop->ownerDocument->createElement('d:supported-report');
$prop->appendChild($supportedReport);
$report = $prop->ownerDocument->createElement('d:report');
$supportedReport->appendChild($report);
preg_match('/^{([^}]*)}(.*)$/',$reportName,$matches);
list(, $namespace, $element) = $matches;
$prefix = isset($server->xmlNamespaces[$namespace])?$server->xmlNamespaces[$namespace]:null;
if ($prefix) {
$report->appendChild($prop->ownerDocument->createElement($prefix . ':' . $element));
} else {
$report->appendChild($prop->ownerDocument->createElementNS($namespace, 'x:' . $element));
}
}
}
}