Class Sabre_DAV_Server

Description

Main DAV server class

  • author: Evert Pot (http://www.rooftopsolutions.nl/)
  • copyright: Copyright (C) 2007-2010 Rooftop Solutions. All rights reserved.
  • license: Modified BSD License

Located in /sources_custom/Sabre/DAV/Server.php (line 12)


	
			
Direct descendents
Class Description
Sabre_CalDAV_Server CalDAV server
Class Constant Summary
 NODE_FILE = 1
 NS_SABREDAV = 'http://sabredav.org/ns'
 PROP_SET = 1
Variable Summary
Method Summary
void __construct ([ $treeOrNode = null], Sabre_DAV_Tree $tree)
bool broadcastEvent (string $eventName, [array $arguments = array()])
string calculateUri (string $uri)
bool checkPreconditions ([ $handleAsGET = false])
void createCollection (string $uri,  $resourceType,  $properties)
void createDirectory (string $uri)
void createFile (string $uri, resource $data)
void exec ()
string generateMultiStatus ( $fileProperties, array $requestedProperties)
array getAllowedMethods (string $uri)
string getBaseUri ()
int getHTTPDepth ([mixed $default = self::DEPTH_INFINITY])
void getHTTPHeaders (string $path)
void getHTTPRange ()
Sabre_DAV_ServerPlugin getPlugin (string $className)
void getProperties (string $path, array $propertyNames)
array getPropertiesForPath (string $path, [array $propertyNames = array()], [int $depth = 0])
string getRequestUri ()
void guessBaseUri ()
void httpCopy (string $uri)
void httpDelete (string $uri)
void httpGet (string $uri)
void httpHead (string $uri)
void httpMkcol (string $uri)
void httpMove (string $uri)
void httpOptions (string $uri)
void httpPropfind (string $uri)
void httpPropPatch (string $uri)
void httpPut (string $uri)
void httpReport (string $uri)
void invokeMethod (string $method, string $uri)
array parsePropFindRequest (string $body)
array parsePropPatchRequest (string $body)
void setBaseUri (string $uri)
void subscribeEvent (string $event, callback $callback, [int $priority = 100])
array updateProperties (string $uri,  $properties)
Variables
string $baseUri = null (line 49)

The base uri

  • access: protected
bool $debugExceptions = false (line 135)

This is a flag that allow or not showing file, line and code of the exception in the returned XML

  • access: public
array $eventSubscriptions = array() (line 77)

This array contains a list of callbacks we should call when certain events are triggered

  • access: protected
Sabre_HTTP_Request $httpRequest (line 63)

httpRequest

  • access: public
Sabre_HTTP_Response $httpResponse (line 56)

httpResponse

  • access: public
array $plugins = array() (line 70)

The list of plugins

  • access: protected
array $propertyMap = array(
)
(line 98)

The propertymap can be used to map properties from requests to property classes.

  • access: public
mixed $protectedProperties = array(
// RFC4918
'{DAV:}getcontentlength',
'{DAV:}getetag',
'{DAV:}getlastmodified',
'{DAV:}lockdiscovery',
'{DAV:}resourcetype',
'{DAV:}supportedlock',

// RFC4331
'{DAV:}quota-available-bytes',
'{DAV:}quota-used-bytes',

// RFC3744
'{DAV:}alternate-URI-set',
'{DAV:}principal-URL',
'{DAV:}group-membership',
'{DAV:}supported-privilege-set',
'{DAV:}current-user-privilege-set',
'{DAV:}acl',
'{DAV:}acl-restrictions',
'{DAV:}inherited-acl-set',
'{DAV:}principal-collection-set',

// RFC5397
'{DAV:}current-user-principal',
)
(line 101)
  • access: public
Sabre_DAV_Tree $tree (line 42)

The tree object

  • access: public
array $xmlNamespaces = array(
'DAV:' => 'd',
'http://sabredav.org/ns' => 's',
)
(line 87)

This is a default list of namespaces.

If you are defining your own custom namespace, add it here to reduce bandwidth and improve legibility of xml bodies.

  • access: public
Methods
Constructor __construct (line 151)

Sets up the server

If a Sabre_DAV_Tree object is passed as an argument, it will use it as the directory tree. If a Sabre_DAV_INode is passed, it will create a Sabre_DAV_ObjectTree and use the node as the root.

If nothing is passed, a Sabre_DAV_SimpleDirectory is created in a Sabre_DAV_ObjectTree.

  • access: public
void __construct ([ $treeOrNode = null], Sabre_DAV_Tree $tree)

Redefined in descendants as:
addPlugin (line 304)

Adds a plugin to the server

For more information, console the documentation of Sabre_DAV_ServerPlugin

  • access: public
void addPlugin (Sabre_DAV_ServerPlugin $plugin)
broadcastEvent (line 364)

Broadcasts an event

This method will call all subscribers. If one of the subscribers returns false, the process stops.

The arguments parameter will be sent to all subscribers

  • access: public
bool broadcastEvent (string $eventName, [array $arguments = array()])
  • string $eventName
  • array $arguments
calculateUri (line 978)

Calculates the uri for a request, making sure that the base uri is stripped out

  • throws: Sabre_DAV_Exception_Forbidden A permission denied exception is thrown whenever there was an attempt to supply a uri outside of the base uri
  • access: public
string calculateUri (string $uri)
  • string $uri
checkPreconditions (line 1576)

This method checks the main HTTP preconditions.

Currently these are: * If-Match * If-None-Match * If-Modified-Since * If-Unmodified-Since

The method will return true if all preconditions are met The method will return false, or throw an exception if preconditions failed. If false is returned the operation should be aborted, and the appropriate HTTP response headers are already set.

Normally this method will throw 412 Precondition Failed for failures related to If-None-Match, If-Match and If-Unmodified Since. It will set the status to 304 Not Modified for If-Modified_since.

If the $handleAsGET argument is set to true, it will also return 304 Not Modified for failure of the If-None-Match precondition. This is the desired behaviour for HTTP GET and HTTP HEAD requests.

  • access: public
bool checkPreconditions ([ $handleAsGET = false])
  • $handleAsGET
createCollection (line 1359)

Use this method to create a new collection

The {DAV:}resourcetype is specified using the resourceType array. At the very least it must contain {DAV:}collection.

The properties array can contain a list of additional properties.

  • access: public
void createCollection (string $uri,  $resourceType,  $properties)
  • string $uri: The new uri
  • array $resourceType: The resourceType(s)
  • array $properties: A list of properties
createDirectory (line 1340)

This method is invoked by sub-systems creating a new directory.

  • access: public
void createDirectory (string $uri)
  • string $uri
createFile (line 1320)

This method is invoked by sub-systems creating a new file.

Currently this is done by HTTP PUT and HTTP LOCK (in the Locks_Plugin). It was important to get this done through a centralized function, allowing plugins to intercept this using the beforeCreateFile event.

  • access: public
void createFile (string $uri, resource $data)
  • string $uri
  • resource $data
exec (line 173)

Starts the DAV Server

  • access: public
void exec ()
generateMultiStatus (line 1724)

Generates a WebDAV propfind response body based on a list of nodes

  • access: public
string generateMultiStatus ( $fileProperties, array $requestedProperties)
  • array $fileProperties: The list with nodes
  • array $requestedProperties: The properties that should be returned
getAllowedMethods (line 930)

Returns an array with all the supported HTTP methods for a specific uri.

  • access: public
array getAllowedMethods (string $uri)
  • string $uri
getBaseUri (line 242)

Returns the base responding uri

  • access: public
string getBaseUri ()
getCopyAndMoveInfo (line 1075)

Returns information about Copy and Move requests

This function is created to help getting information about the source and the destination for the WebDAV MOVE and COPY HTTP request. It also validates a lot of information and throws proper exceptions

The returned value is an array with the following keys: * destination - Destination path * destinationExists - Wether or not the destination is an existing url (and should therefore be overwritten)

  • access: public
array getCopyAndMoveInfo ()
getHTTPDepth (line 1015)

Returns the HTTP depth header

This method returns the contents of the HTTP depth request header. If the depth header was 'infinity' it will return the Sabre_DAV_Server::DEPTH_INFINITY object It is possible to supply a default depth value, which is used when the depth header has invalid content, or is completely non-existant

  • access: public
int getHTTPDepth ([mixed $default = self::DEPTH_INFINITY])
  • mixed $default
getHTTPHeaders (line 1152)

Returns a list of HTTP headers for a particular resource

The generated http headers are based on properties provided by the resource. The method basically provides a simple mapping between DAV property and HTTP header.

The headers are intended to be used for HEAD and GET requests.

  • access: public
void getHTTPHeaders (string $path)
  • string $path
getHTTPRange (line 1044)

Returns the HTTP range header

This method returns null if there is no well-formed HTTP range request header or array($start, $end).

The first number is the offset of the first byte in the range. The second number is the offset of the last byte in the range.

If the second offset is null, it should be treated as the offset of the last byte of the entity If the first offset is null, the second offset should be used to retrieve the last x bytes of the entity

return $mixed

  • access: public
void getHTTPRange ()
getPlugin (line 319)

Returns an initialized plugin by it's classname.

This function returns null if the plugin was not found.

  • access: public
Sabre_DAV_ServerPlugin getPlugin (string $className)
  • string $className
getProperties (line 1134)

Returns a list of properties for a path

This is a simplified version getPropertiesForPath. if you aren't interested in status codes, but you just want to have a flat list of properties. Use this method.

  • access: public
void getProperties (string $path, array $propertyNames)
  • string $path
  • array $propertyNames
getPropertiesForPath (line 1195)

Returns a list of properties for a given path

The path that should be supplied should have the baseUrl stripped out The list of properties should be supplied in Clark notation. If the list is empty 'allprops' is assumed.

If a depth of 1 is requested child elements will also be returned.

  • access: public
array getPropertiesForPath (string $path, [array $propertyNames = array()], [int $depth = 0])
  • string $path
  • array $propertyNames
  • int $depth
getRequestUri (line 965)

Gets the uri for the request, keeping the base uri into consideration

  • access: public
string getRequestUri ()
guessBaseUri (line 257)

This method attempts to detect the base uri.

Only the PATH_INFO variable is considered.

If this variable is not set, the root (/) is assumed.

  • access: public
void guessBaseUri ()
httpCopy (line 875)

WebDAV HTTP COPY method

This method copies one uri to a different uri, and works much like the MOVE request A lot of the actual request processing is done in getCopyMoveInfo

  • access: protected
void httpCopy (string $uri)
  • string $uri
httpDelete (line 611)

HTTP Delete

The HTTP delete method, deletes a given uri

  • access: protected
void httpDelete (string $uri)
  • string $uri
httpGet (line 458)

HTTP GET

This method simply fetches the contents of a uri, like normal

  • access: protected
void httpGet (string $uri)
  • string $uri
httpHead (line 585)

HTTP HEAD

This method is normally used to take a peak at a url, and only get the HTTP response headers, without the body This is used by clients to determine if a remote file was changed, so they can use a local cached version, instead of downloading it again

  • access: protected
void httpHead (string $uri)
  • string $uri
httpMkcol (line 771)

WebDAV MKCOL

The MKCOL method is used to create a new collection (directory) on the server

  • access: protected
void httpMkcol (string $uri)
  • string $uri
httpMove (line 845)

WebDAV HTTP MOVE method

This method moves one uri to a different uri. A lot of the actual request processing is done in getCopyMoveInfo

  • access: protected
void httpMove (string $uri)
  • string $uri
httpOptions (line 432)

HTTP OPTIONS

  • access: protected
void httpOptions (string $uri)
  • string $uri
httpPropfind (line 637)

WebDAV PROPFIND

This WebDAV method requests information about an uri resource, or a list of resources If a client wants to receive the properties for a single resource it will add an HTTP Depth: header with a 0 value If the value is 1, it means that it also expects a list of sub-resources (e.g.: files in a directory)

The request body contains an XML data structure that has a list of properties the client understands The response body is also an xml document, containing information about every uri resource and the requested properties

It has to return a HTTP 207 Multi-status status code

  • access: protected
void httpPropfind (string $uri)
  • string $uri
httpPropPatch (line 665)

WebDAV PROPPATCH

This method is called to update properties on a Node. The request is an XML body with all the mutations. In this XML body it is specified which properties should be set/updated and/or deleted

  • access: protected
void httpPropPatch (string $uri)
  • string $uri
httpPut (line 690)

HTTP PUT method

This HTTP method updates a file, or creates a new one.

If a new resource was created, a 201 Created status code should be returned. If an existing resource is updated, it's a 200 Ok

  • access: protected
void httpPut (string $uri)
  • string $uri
httpReport (line 905)

HTTP REPORT method implementation

Although the REPORT method is not part of the standard WebDAV spec (it's from rfc3253) It's used in a lot of extensions, so it made sense to implement it into the core.

  • access: protected
void httpReport (string $uri)
  • string $uri
invokeMethod (line 388)

Handles a http request, and execute a method based on its name

  • access: public
void invokeMethod (string $method, string $uri)
  • string $method
  • string $uri
parsePropFindRequest (line 1807)

This method parses the PROPFIND request and returns its information

This will either be a list of properties, or an empty array; in which case an {DAV:}allprop was requested.

  • access: public
array parsePropFindRequest (string $body)
  • string $body
parsePropPatchRequest (line 1765)

This method parses a PropPatch request

PropPatch changes the properties for a resource. This method returns a list of properties.

The keys in the returned array contain the property name (e.g.: {DAV:}displayname, and the value contains the property value. If a property is to be removed the value will be null.

  • return: list of properties in need of updating or deletion
  • access: public
array parsePropPatchRequest (string $body)
  • string $body: xml body
setBaseUri (line 227)

Sets the base server uri

  • access: public
void setBaseUri (string $uri)
  • string $uri
subscribeEvent (line 342)

Subscribe to an event.

When the event is triggered, we'll call all the specified callbacks. It is possible to control the order of the callbacks through the priority argument.

This is for example used to make sure that the authentication plugin is triggered before anything else. If it's not needed to change this number, it is recommended to ommit.

  • access: public
void subscribeEvent (string $event, callback $callback, [int $priority = 100])
  • string $event
  • callback $callback
  • int $priority
updateProperties (line 1472)

This method updates a resource's properties

The properties array must be a list of properties. Array-keys are property names in clarknotation, array-values are it's values. If a property must be deleted, the value should be null.

Note that this request should either completely succeed, or completely fail.

The response is an array with statuscodes for keys, which in turn contain arrays with propertynames. This response can be used to generate a multistatus body.

  • access: public
array updateProperties (string $uri,  $properties)
  • string $uri
  • array $properties
Class Constants
DEPTH_INFINITY = -1 (line 17)

Inifinity is used for some request supporting the HTTP Depth header and indicates that the operation should traverse the entire tree

NODE_DIRECTORY = 2 (line 27)

Nodes that are directories, should use this value as the type property

NODE_FILE = 1 (line 22)

Nodes that are files, should have this as the type property

NS_SABREDAV = 'http://sabredav.org/ns' (line 35)

XML namespace for all SabreDAV related elements

PROP_REMOVE = 2 (line 30)
PROP_SET = 1 (line 29)

Documentation generated on Sun, 02 Jan 2011 23:24:14 +0000 by phpDocumentor 1.4.3