Class Sabre_DAV_Locks_Plugin

Description

Locking plugin

This plugin provides locking support to a WebDAV server. The easiest way to get started, is by hooking it up as such:

$lockBackend = new Sabre_DAV_Locks_Backend_FS('./my_lock_directory'); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin);

  • 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/Locks/Plugin.php (line 19)

Sabre_DAV_ServerPlugin
   |
   --Sabre_DAV_Locks_Plugin
Method Summary
void __construct ([Sabre_DAV_Locks_Backend_Abstract $locksBackend = null])
bool afterGetProperties (string $path,  &$newProperties, array $properties)
bool beforeMethod (string $method, string $uri)
array getFeatures ()
array getHTTPMethods (string $uri)
void getIfConditions ()
array getLocks (string $uri)
void httpLock (string $uri)
void httpUnlock (string $uri)
void initialize (Sabre_DAV_Server $server)
void lockNode (string $uri, Sabre_DAV_Locks_LockInfo $lockInfo)
bool unknownMethod (string $method,  $uri)
void unlockNode (string $uri, Sabre_DAV_Locks_LockInfo $lockInfo)
bool validateLock ([mixed $urls = null], [ &$lastLock = null], mixed $lastLock)
Methods
Constructor __construct (line 41)

__construct

  • access: public
void __construct ([Sabre_DAV_Locks_Backend_Abstract $locksBackend = null])
afterGetProperties (line 92)

This method is called after most properties have been found it allows us to add in any Lock-related properties

  • access: public
bool afterGetProperties (string $path,  &$newProperties, array $properties)
  • string $path
  • array $properties
  • &$newProperties
beforeMethod (line 135)

This method is called before the logic for any HTTP method is handled.

This plugin uses that feature to intercept access to locked resources.

  • access: public
bool beforeMethod (string $method, string $uri)
  • string $method
  • string $uri
generateLockResponse (line 446)

Generates the response for successfull LOCK requests

  • access: protected
string generateLockResponse (Sabre_DAV_Locks_LockInfo $lockInfo)
getFeatures (line 197)

Returns a list of features for the HTTP OPTIONS Dav: header.

In this case this is only the number 2. The 2 in the Dav: header indicates the server supports locks.

  • access: public
array getFeatures ()

Redefinition of:
Sabre_DAV_ServerPlugin::getFeatures()
This method should return a list of server-features.
getHTTPMethods (line 179)

Use this method to tell the server this plugin defines additional HTTP methods.

This method is passed a uri. It should only return HTTP methods that are available for the specified uri.

  • access: public
array getHTTPMethods (string $uri)
  • string $uri

Redefinition of:
Sabre_DAV_ServerPlugin::getHTTPMethods()
Use this method to tell the server this plugin defines additional HTTP methods.
getIfConditions (line 591)

This method is created to extract information from the WebDAV HTTP 'If:' header

The If header can be quite complex, and has a bunch of features. We're using a regex to extract all relevant information The function will return an array, containg structs with the following keys

* uri - the uri the condition applies to. This can be an empty string for 'every relevant url' * tokens - The lock token. another 2 dimensional array containg 2 elements (0 = true/false.. If this is a negative condition its set to false, 1 = the actual token) * etag - an etag, if supplied

  • access: public
void getIfConditions ()
getLocks (line 213)

Returns all lock information on a particular uri

This function should return an array with Sabre_DAV_Locks_LockInfo objects. If there are no locks on a file, return an empty array.

Additionally there is also the possibility of locks on parent nodes, so we'll need to traverse every part of the tree

  • access: public
array getLocks (string $uri)
  • string $uri
getTimeoutHeader (line 420)

Returns the contents of the HTTP Timeout header.

The method formats the header into an integer.

  • access: public
int getTimeoutHeader ()
httpLock (line 262)

Locks an uri

The WebDAV lock request can be operated to either create a new lock on a file, or to refresh an existing lock If a new lock is created, a full XML body should be supplied, containing information about the lock such as the type of lock (shared or exclusive) and the owner of the lock

If a lock is to be refreshed, no body should be supplied and there should be a valid If header containing the lock

Additionally, a lock can be requested for a non-existant file. In these case we're obligated to create an empty file as per RFC4918:S7.3

  • access: protected
void httpLock (string $uri)
  • string $uri
httpUnlock (line 334)

Unlocks a uri

This WebDAV method allows you to remove a lock from a node. The client should provide a valid locktoken through the Lock-token http header The server should return 204 (No content) on success

  • access: protected
void httpUnlock (string $uri)
  • string $uri
initialize (line 55)

Initializes the plugin

This method is automatically called by the Server class after addPlugin.

  • access: public
void initialize (Sabre_DAV_Server $server)

Redefinition of:
Sabre_DAV_ServerPlugin::initialize()
This initializes the plugin.
lockNode (line 374)

Locks a uri

All the locking information is supplied in the lockInfo object. The object has a suggested timeout, but this can be safely ignored It is important that if the existing timeout is ignored, the property is overwritten, as this needs to be sent back to the client

  • access: public
void lockNode (string $uri, Sabre_DAV_Locks_LockInfo $lockInfo)
parseLockRequest (line 633)

Parses a webdav lock xml body, and returns a new Sabre_DAV_Locks_LockInfo object

  • access: protected
Sabre_DAV_Locks_LockInfo parseLockRequest (string $body)
  • string $body
unknownMethod (line 73)

This method is called by the Server if the user used an HTTP method the server didn't recognize.

This plugin intercepts the LOCK and UNLOCK methods.

  • access: public
bool unknownMethod (string $method,  $uri)
  • string $method
  • $uri
unlockNode (line 398)

Unlocks a uri

This method removes a lock from a uri. It is assumed all the supplied information is correct and verified

  • access: public
void unlockNode (string $uri, Sabre_DAV_Locks_LockInfo $lockInfo)
validateLock (line 472)

validateLock should be called when a write operation is about to happen It will check if the requested url is locked, and see if the correct lock tokens are passed

  • access: protected
bool validateLock ([mixed $urls = null], [ &$lastLock = null], mixed $lastLock)
  • mixed $urls: List of relevant urls. Can be an array, a string or nothing at all for the current request uri
  • mixed $lastLock: This variable will be populated with the last checked lock object (Sabre_DAV_Locks_LockInfo)
  • &$lastLock

Inherited Methods

Inherited From Sabre_DAV_ServerPlugin

Sabre_DAV_ServerPlugin::getFeatures()
Sabre_DAV_ServerPlugin::getHTTPMethods()
Sabre_DAV_ServerPlugin::initialize()

Documentation generated on Sun, 02 Jan 2011 23:22:18 +0000 by phpDocumentor 1.4.3