62        $this->server->xml->elementMap[
'{DAV:}lockinfo'] = 
'Sabre\\DAV\\Xml\\Request\\Lock';
 
   64        $server->on(
'method:LOCK',    [$this, 
'httpLock']);
 
   65        $server->on(
'method:UNLOCK',  [$this, 
'httpUnlock']);
 
   66        $server->on(
'validateTokens', [$this, 
'validateTokens']);
 
   67        $server->on(
'propFind',       [$this, 
'propFind']);
 
   68        $server->on(
'afterUnbind',    [$this, 
'afterUnbind']);
 
   96        $propFind->handle(
'{DAV:}supportedlock', 
function() {
 
   99        $propFind->handle(
'{DAV:}lockdiscovery', 
function() use ($propFind) {
 
  101                $this->
getLocks($propFind->getPath())
 
  119        return [
'LOCK',
'UNLOCK'];
 
  150    function getLocks($uri, $returnChildLocks = 
false) {
 
  152        return $this->locksBackend->getLocks($uri, $returnChildLocks);
 
  175        $existingLocks = $this->
getLocks($uri);
 
  177        if ($body = 
$request->getBodyAsString()) {
 
  180            $existingLock = 
null;
 
  182            foreach ($existingLocks as $existingLock) {
 
  189            $lockInfo->depth = $this->server->getHTTPDepth();
 
  190            $lockInfo->uri = $uri;
 
  197            $existingLocks = $this->
getLocks($uri);
 
  198            $conditions = $this->server->getIfConditions(
$request);
 
  201            foreach ($existingLocks as $existingLock) {
 
  202                foreach ($conditions as $condition) {
 
  203                    foreach ($condition[
'tokens'] as 
$token) {
 
  204                        if (
$token[
'token'] === 
'opaquelocktoken:' . $existingLock->token) {
 
  205                            $found = $existingLock;
 
  213            if (is_null($found)) {
 
  214                if ($existingLocks) {
 
  226            if ($uri != $lockInfo->uri) $uri = $lockInfo->uri;
 
  236            $this->server->tree->getNodeForPath($uri);
 
  247            $this->server->createFile($uri, fopen(
'php://memory', 
'r'));
 
  254        $response->setHeader(
'Content-Type', 
'application/xml; charset=utf-8');
 
  255        $response->setHeader(
'Lock-Token', 
'<opaquelocktoken:' . $lockInfo->token . 
'>');
 
  256        $response->setStatus($newFile ? 201 : 200);
 
  277        $lockToken = 
$request->getHeader(
'Lock-Token');
 
  287        if ($lockToken[0] !== 
'<') $lockToken = 
'<' . $lockToken . 
'>';
 
  289        foreach ($locks as $lock) {
 
  291            if (
'<opaquelocktoken:' . $lock->token . 
'>' == $lockToken) {
 
  294                $response->setHeader(
'Content-Length', 
'0');
 
  321        foreach ($locks as $lock) {
 
  339        if (!$this->server->emit(
'beforeLock', [$uri, $lockInfo])) 
return;
 
  340        return $this->locksBackend->lock($uri, $lockInfo);
 
  355        if (!$this->server->emit(
'beforeUnlock', [$uri, $lockInfo])) 
return;
 
  356        return $this->locksBackend->unlock($uri, $lockInfo);
 
  370        $header = $this->server->httpRequest->getHeader(
'Timeout');
 
  396        return $this->server->xml->write(
'{DAV:}prop', [
 
  397            '{DAV:}lockdiscovery' =>
 
  398                new DAV\Xml\Property\LockDiscovery([$lockInfo])
 
  427                $mustLocks = array_merge($mustLocks, $this->
getLocks(
 
  437                $mustLocks = array_merge($mustLocks, $this->
getLocks(
 
  443                $mustLocks = array_merge($mustLocks, $this->
getLocks(
 
  447                $mustLocks = array_merge($mustLocks, $this->
getLocks(
 
  448                    $this->server->calculateUri(
$request->getHeader(
'Destination')),
 
  453                $mustLocks = array_merge($mustLocks, $this->
getLocks(
 
  454                    $this->server->calculateUri(
$request->getHeader(
'Destination')),
 
  461                foreach ($conditions as 
$ii => $condition) {
 
  462                    foreach ($condition[
'tokens'] as $jj => 
$token) {
 
  463                        $conditions[
$ii][
'tokens'][$jj][
'validToken'] = 
true;
 
  473        foreach ($mustLocks as $lock) $tmp[$lock->token] = $lock;
 
  474        $mustLocks = array_values($tmp);
 
  476        foreach ($conditions as $kk => $condition) {
 
  478            foreach ($condition[
'tokens'] as 
$ii => 
$token) {
 
  481                if (substr(
$token[
'token'], 0, 16) !== 
'opaquelocktoken:') {
 
  485                $checkToken = substr(
$token[
'token'], 16);
 
  487                foreach ($mustLocks as $jj => $mustLock) {
 
  489                    if ($mustLock->token == $checkToken) {
 
  493                        unset($mustLocks[$jj]);
 
  496                        $conditions[$kk][
'tokens'][
$ii][
'validToken'] = 
true;
 
  515                $oddLocks = $this->
getLocks($condition[
'uri']);
 
  516                foreach ($oddLocks as $oddLock) {
 
  518                    if ($oddLock->token === $checkToken) {
 
  521                        $conditions[$kk][
'tokens'][
$ii][
'validToken'] = 
true;
 
  553        $result = $this->server->xml->expect(
 
  560        $lockInfo->owner = 
$result->owner;
 
  562        $lockInfo->scope = 
$result->scope;
 
  583            'description' => 
'The locks plugin turns this server into a class-2 WebDAV server and adds support for LOCK and UNLOCK',
 
  584            'link'        => 
'http://sabre.io/dav/locks/',
 
foreach($paths as $path) $request
An exception for terminatinating execution or to throw for unit testing.
LockTokenMatchesRequestUri.
const TIMEOUT_INFINITE
A never expiring timeout.
const EXCLUSIVE
An exclusive lock.
const SHARED
A shared lock.
getFeatures()
Returns a list of features for the HTTP OPTIONS Dav: header.
getPluginName()
Returns a plugin name.
unlockNode($uri, LockInfo $lockInfo)
Unlocks a uri.
__construct(Backend\BackendInterface $locksBackend)
__construct
lockNode($uri, LockInfo $lockInfo)
Locks a uri.
httpUnlock(RequestInterface $request, ResponseInterface $response)
Unlocks a uri.
afterUnbind($path)
This method is called after a node is deleted.
getTimeoutHeader()
Returns the contents of the HTTP Timeout header.
getHTTPMethods($uri)
Use this method to tell the server this plugin defines additional HTTP methods.
httpLock(RequestInterface $request, ResponseInterface $response)
Locks an uri.
propFind(DAV\PropFind $propFind, DAV\INode $node)
This method is called after most properties have been found it allows us to add in any Lock-related p...
initialize(DAV\Server $server)
Initializes the plugin.
getLocks($uri, $returnChildLocks=false)
Returns all lock information on a particular uri.
parseLockRequest($body)
Parses a webdav lock xml body, and returns a new Sabre\DAV\Locks\LockInfo object.
generateLockResponse(LockInfo $lockInfo)
Generates the response for successful LOCK requests.
validateTokens(RequestInterface $request, &$conditions)
The validateTokens event is triggered before every request.
getPluginInfo()
Returns a bunch of meta-data about the plugin.
This class holds all the information about a PROPFIND request.
The baseclass for all server plugins.
static getUUID()
Returns a pseudo-random v4 UUID.
Represents {DAV:}lockdiscovery property.
This class represents the {DAV:}supportedlock property.
The INode interface is the base interface, and the parent class of both ICollection and IFile.
The RequestInterface represents a HTTP request.
getPath()
Returns the relative path.
This interface represents a HTTP response.