/usr/share/php/sabre21/Sabre/DAV/PropertyStorage/Plugin.php is in php-sabre-dav-2.1 2.1.10-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | <?php
namespace Sabre\DAV\PropertyStorage;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
use Sabre\DAV\PropPatch;
use Sabre\DAV\PropFind;
use Sabre\DAV\INode;
/**
* PropertyStorage Plugin.
*
* Adding this plugin to your server allows clients to store any arbitrary
* WebDAV property.
*
* See:
* http://sabre.io/dav/property-storage/
*
* for more information.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class Plugin extends ServerPlugin {
/**
* If you only want this plugin to store properties for a limited set of
* paths, you can use a pathFilter to do this.
*
* The pathFilter should be a callable. The callable retrieves a path as
* its argument, and should return true or false wether it allows
* properties to be stored.
*
* @var callable
*/
public $pathFilter;
/**
* Creates the plugin
*
* @param Backend\BackendInterface $backend
*/
function __construct(Backend\BackendInterface $backend) {
$this->backend = $backend;
}
/**
* This initializes the plugin.
*
* This function is called by Sabre\DAV\Server, after
* addPlugin is called.
*
* This method should set up the required event subscriptions.
*
* @param Server $server
* @return void
*/
function initialize(Server $server) {
$server->on('propFind', [$this, 'propFind'], 130);
$server->on('propPatch', [$this, 'propPatch'], 300);
$server->on('afterMove', [$this, 'afterMove']);
$server->on('afterUnbind', [$this, 'afterUnbind']);
}
/**
* Called during PROPFIND operations.
*
* If there's any requested properties that don't have a value yet, this
* plugin will look in the property storage backend to find them.
*
* @param PropFind $propFind
* @param INode $node
* @return void
*/
function propFind(PropFind $propFind, INode $node) {
$path = $propFind->getPath();
$pathFilter = $this->pathFilter;
if ($pathFilter && !$pathFilter($path)) return;
$this->backend->propFind($propFind->getPath(), $propFind);
}
/**
* Called during PROPPATCH operations
*
* If there's any updated properties that haven't been stored, the
* propertystorage backend can handle it.
*
* @param string $path
* @param PropPatch $propPatch
* @return void
*/
function propPatch($path, PropPatch $propPatch) {
$pathFilter = $this->pathFilter;
if ($pathFilter && !$pathFilter($path)) return;
$this->backend->propPatch($path, $propPatch);
}
/**
* Called after a node is deleted.
*
* This allows the backend to clean up any properties still in the
* database.
*
* @param string $path
* @return void
*/
function afterUnbind($path) {
$pathFilter = $this->pathFilter;
if ($pathFilter && !$pathFilter($path)) return;
$this->backend->delete($path);
}
/**
* Called after a node is moved.
*
* This allows the backend to move all the associated properties.
*
* @param string $source
* @param string $destination
* @return void
*/
function afterMove($source, $destination) {
$pathFilter = $this->pathFilter;
if ($pathFilter && !$pathFilter($source)) return;
// If the destination is filtered, afterUnbind will handle cleaning up
// the properties.
if ($pathFilter && !$pathFilter($destination)) return;
$this->backend->move($source, $destination);
}
}
|