Class: Sabre_DAV_Locks_Plugin

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

Class Overview [line 19]

Sabre_DAV_ServerPlugin
   |
   --Sabre_DAV_Locks_Plugin

Locking plugin

Author(s):

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

Version:

Copyright:

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

Variables

Constants

Methods


Inherited Variables

Inherited Constants

Inherited Methods

Class: Sabre_DAV_ServerPlugin

Sabre_DAV_ServerPlugin::getFeatures()
This method should return a list of server-features.
Sabre_DAV_ServerPlugin::getHTTPMethods()
Use this method to tell the server this plugin defines additional HTTP methods.
Sabre_DAV_ServerPlugin::initialize()
This initializes the plugin.


Class Details

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);

Tags:

[ Top ]


Class Variables


Class Methods

__construct

void __construct( [Sabre_DAV_Locks_Backend_Abstract $locksBackend = null])

[line 41]

__construct

Tags:

  • access - public

Parameters:

[ Top ]

afterGetProperties

bool afterGetProperties( string $path, &$newProperties, array $properties)

[line 92]

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

Tags:

  • access - public

Parameters:

  • string $path -
  • array $properties -
  • &$newProperties -

[ Top ]

beforeMethod

bool beforeMethod( string $method)

[line 134]

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

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

Tags:

  • access - public

Parameters:

  • string $method -

[ Top ]

generateLockResponse

string generateLockResponse( Sabre_DAV_Locks_LockInfo $lockInfo)

[line 447]

Generates the response for successfull LOCK requests

Tags:

  • access - protected

Parameters:

[ Top ]

getFeatures

array getFeatures( )

[line 196]

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.

Tags:

  • access - public

Overrides Sabre_DAV_ServerPlugin::getFeatures() (This method should return a list of server-features.)

Parameters:

[ Top ]

getHTTPMethods

array getHTTPMethods( string $uri)

[line 178]

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.

Tags:

  • access - public

Overrides Sabre_DAV_ServerPlugin::getHTTPMethods() (Use this method to tell the server this plugin defines additional HTTP methods.)

Parameters:

  • string $uri -

[ Top ]

getIfConditions

void getIfConditions( )

[line 588]

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

Tags:

  • access - public

Parameters:

[ Top ]

getLocks

array getLocks( string $uri)

[line 212]

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

Tags:

  • access - public

Parameters:

  • string $uri -

[ Top ]

getTimeoutHeader

int getTimeoutHeader( )

[line 421]

Returns the contents of the HTTP Timeout header.

The method formats the header into an integer.

Tags:

  • access - public

Parameters:

[ Top ]

httpLock

void httpLock( )

[line 260]

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

Tags:

  • access - protected

Parameters:

[ Top ]

httpUnlock

void httpUnlock( )

[line 333]

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

Tags:

  • access - protected

Parameters:

[ Top ]

initialize

void initialize( Sabre_DAV_Server $server)

[line 55]

Initializes the plugin

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

Tags:

  • access - public

Overrides Sabre_DAV_ServerPlugin::initialize() (This initializes the plugin.)

Parameters:

[ Top ]

lockNode

void lockNode( string $uri, Sabre_DAV_Locks_LockInfo $lockInfo)

[line 375]

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

Tags:

  • access - public

Parameters:

[ Top ]

parseLockRequest

Sabre_DAV_Locks_LockInfo parseLockRequest( string $body)

[line 630]

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

Tags:

  • access - protected

Parameters:

  • string $body -

[ Top ]

unknownMethod

bool unknownMethod( string $method)

[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.

Tags:

  • access - public

Parameters:

  • string $method -

[ Top ]

unlockNode

void unlockNode( string $uri, Sabre_DAV_Locks_LockInfo $lockInfo)

[line 399]

Unlocks a uri

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

Tags:

  • access - public

Parameters:

[ Top ]

validateLock

bool validateLock( [mixed $urls = null], [ &$lastLock = null], mixed $lastLock)

[line 473]

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

Tags:

  • access - protected

Parameters:

  • 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 -

[ Top ]


Class Constants


Documentation generated on Mon, 31 May 2010 12:53:47 -0400 by phpDocumentor 1.4.3