Class: Sabre_DAV_Server

Source Location: /includes/classes/SabreDAV/lib/Sabre/DAV/Server.php

Class Overview [line 13]


Main DAV server class

Author(s):

  • Evert Pot (http://www.rooftopsolutions.nl/)

Version:

  • $Id$

Copyright:

  • Copyright (C) 2007-2010 Rooftop Solutions. All rights reserved.

Variables

Constants

Methods


Child classes:

Sabre_CalDAV_Server
CalDAV server
Webcal_Sabre_CalDAV_Server
CalDAV server

Inherited Variables

Inherited Constants

Inherited Methods



Class Details

Main DAV server class

Tags:

[ Top ]


Class Variables

$baseUri =  '/'

[line 48]

The base uri

Tags:

  • access - protected

Type: string

Overrides:

[ Top ]

$debugExceptions =  false

[line 134]

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

Tags:

  • access - public

Type: bool

Overrides:

[ Top ]

$eventSubscriptions = array()

[line 76]

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

Tags:

  • access - protected

Type: array

Overrides:

[ Top ]

$httpRequest

[line 62]

httpRequest

Tags:

  • access - public

Type: Sabre_HTTP_Request

Overrides:

[ Top ]

$httpResponse

[line 55]

httpResponse

Tags:

  • access - public

Type: Sabre_HTTP_Response

Overrides:

[ Top ]

$plugins = array()

[line 69]

The list of plugins

Tags:

  • access - protected

Type: array

Overrides:

[ Top ]

$propertyMap = array(
    )

[line 97]

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

Tags:

  • access - public

Type: array

Overrides:

[ Top ]

$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 100]

Tags:

  • access - public

Type: mixed

Overrides:

[ Top ]

$tree

[line 41]

The tree object

Tags:

  • access - public

Type: Sabre_DAV_Tree

Overrides:

[ Top ]

$xmlNamespaces = array(
        'DAV:' => 'd',
        'http://sabredav.org/ns' => 's',
    )

[line 86]

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.

Tags:

  • access - public

Type: array

Overrides:

[ Top ]


Class Methods

__construct

void __construct( [ $treeOrNode = null], Sabre_DAV_Tree $tree)

[line 150]

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.

Tags:

  • access - public

Overridden in child classes as:

Sabre_CalDAV_Server::__construct()
Sets up the object. A PDO object must be passed to setup all the backends.
Webcal_Sabre_CalDAV_Server::__construct()
Sets up the object. A PDO object must be passed to setup all the backends.

Parameters:

[ Top ]

addPlugin

void addPlugin( Sabre_DAV_ServerPlugin $plugin)

[line 263]

Adds a plugin to the server

For more information, console the documentation of Sabre_DAV_ServerPlugin

Tags:

  • access - public

Parameters:

[ Top ]

broadcastEvent

bool broadcastEvent( string $eventName, [array $arguments = array()])

[line 323]

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

Tags:

  • access - public

Parameters:

  • string $eventName -
  • array $arguments -

[ Top ]

calculateUri

string calculateUri( string $uri)

[line 934]

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

Tags:

  • 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

Parameters:

  • string $uri -

[ Top ]

checkPreconditions

bool checkPreconditions( )

[line 1520]

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.

Tags:

  • access - public

Parameters:

[ Top ]

createCollection

void createCollection( string $uri, $resourceType, $properties)

[line 1311]

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.

Tags:

  • access - public

Parameters:

  • string $uri - The new uri
  • array $resourceType - The resourceType(s)
  • array $properties - A list of properties

[ Top ]

createDirectory

void createDirectory( string $uri)

[line 1292]

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

Tags:

  • access - public

Parameters:

  • string $uri -

[ Top ]

createFile

void createFile( string $uri, resource $data)

[line 1273]

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.

Tags:

  • access - public

Parameters:

  • string $uri -
  • resource $data -

[ Top ]

exec

void exec( )

[line 172]

Starts the DAV Server

Tags:

  • access - public

Parameters:

[ Top ]

generateMultiStatus

string generateMultiStatus( $fileProperties, array $requestedProperties)

[line 1630]

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

Tags:

  • access - public

Parameters:

  • array $fileProperties - The list with nodes
  • array $requestedProperties - The properties that should be returned

[ Top ]

getAllowedMethods

array getAllowedMethods( string $uri)

[line 886]

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

Tags:

  • access - public

Parameters:

  • string $uri -

[ Top ]

getBaseUri

string getBaseUri( )

[line 249]

Returns the base responding uri

Tags:

  • access - public

Parameters:

[ Top ]

getCopyAndMoveInfo

array getCopyAndMoveInfo( )

[line 1028]

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: * source - Source path * destination - Destination path * destinationExists - Wether or not the destination is an existing url (and should therefore be overwritten)

Tags:

  • access - public

Parameters:

[ Top ]

getHTTPDepth

int getHTTPDepth( [mixed $default = self::DEPTH_INFINITY])

[line 965]

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

Tags:

  • access - public

Parameters:

  • mixed $default -

[ Top ]

getHTTPHeaders

void getHTTPHeaders( string $path)

[line 1111]

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.

Tags:

  • access - public

Parameters:

  • string $path -

[ Top ]

getHTTPRange

void getHTTPRange( )

[line 994]

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

Tags:

  • access - public

Parameters:

[ Top ]

getPlugin

Sabre_DAV_ServerPlugin getPlugin( string $className)

[line 278]

Returns an initialized plugin by it's classname.

This function returns null if the plugin was not found.

Tags:

  • access - public

Parameters:

  • string $className -

[ Top ]

getProperties

void getProperties( string $path, array $propertyNames)

[line 1093]

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.

Tags:

  • access - public

Parameters:

  • string $path -
  • array $propertyNames -

[ Top ]

getPropertiesForPath

array getPropertiesForPath( string $path, [array $propertyNames = array()], [int $depth = 0])

[line 1154]

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.

Tags:

  • access - public

Parameters:

  • string $path -
  • array $propertyNames -
  • int $depth -

[ Top ]

getRequestUri

string getRequestUri( )

[line 921]

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

Tags:

  • access - public

Parameters:

[ Top ]

httpCopy

void httpCopy( )

[line 791]

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

Tags:

  • access - protected

Parameters:

[ Top ]

httpDelete

void httpDelete( )

[line 525]

HTTP Delete

The HTTP delete method, deletes a given uri

Tags:

  • access - protected

Parameters:

[ Top ]

httpGet

void httpGet( )

[line 372]

HTTP GET

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

Tags:

  • access - protected

Parameters:

[ Top ]

httpHead

void httpHead( )

[line 499]

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

Tags:

  • access - protected

Parameters:

[ Top ]

httpMkcol

void httpMkcol( )

[line 689]

WebDAV MKCOL

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

Tags:

  • access - protected

Parameters:

[ Top ]

httpMove

void httpMove( )

[line 762]

WebDAV HTTP MOVE method

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

Tags:

  • access - protected

Parameters:

[ Top ]

httpOptions

void httpOptions( )

[line 347]

HTTP OPTIONS

Tags:

  • access - protected

Parameters:

[ Top ]

httpPropfind

void httpPropfind( )

[line 552]

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

Tags:

  • access - public

Parameters:

[ Top ]

httpPropPatch

void httpPropPatch( )

[line 582]

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

Tags:

  • access - protected

Parameters:

[ Top ]

httpPut

void httpPut( )

[line 608]

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

Tags:

  • access - protected

Parameters:

[ Top ]

httpReport

void httpReport( )

[line 820]

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.

Tags:

  • access - protected

Parameters:

[ Top ]

invoke

void invoke( )

[line 844]

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

Tags:

  • access - protected

Parameters:

[ Top ]

parsePropFindRequest

array parsePropFindRequest( string $body)

[line 1718]

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.

Tags:

  • access - public

Parameters:

  • string $body -

[ Top ]

parsePropPatchRequest

array parsePropPatchRequest( string $body)

[line 1671]

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.

Tags:

  • return - list of properties in need of updating or deletion
  • access - public

Parameters:

  • string $body - xml body

[ Top ]

setBaseUri

void setBaseUri( string $uri)

[line 234]

Sets the base server uri

Tags:

  • access - public

Parameters:

  • string $uri -

[ Top ]

subscribeEvent

void subscribeEvent( string $event, callback $callback, [int $priority = 100])

[line 301]

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.

Tags:

  • access - public

Parameters:

  • string $event -
  • callback $callback -
  • int $priority -

[ Top ]

updateProperties

array updateProperties( string $uri, $properties)

[line 1424]

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.

Tags:

  • access - public

Parameters:

  • string $uri -
  • array $properties -

[ Top ]


Class Constants

DEPTH_INFINITY =  -1

[line 18]

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

[ Top ]

NODE_DIRECTORY =  2

[line 28]

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

[ Top ]

NODE_FILE =  1

[line 23]

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

[ Top ]

NS_SABREDAV =  'http://sabredav.org/ns'

[line 33]

[ Top ]

PROP_REMOVE =  2

[line 31]

[ Top ]

PROP_SET =  1

[line 30]

[ Top ]


Documentation generated on Mon, 31 May 2010 12:54:02 -0400 by phpDocumentor 1.4.3