57 return [
'resource-sharing'];
90 $server->xml->elementMap[
'{DAV:}share-resource'] =
'Sabre\\DAV\\Xml\\Request\\ShareResource';
93 $server->protectedProperties,
97 $server->
on(
'method:POST', [$this,
'httpPost']);
98 $server->
on(
'propFind', [$this,
'propFind']);
99 $server->
on(
'getSupportedPrivilegeSet', [$this,
'getSupportedPrivilegeSet']);
100 $server->
on(
'onHTMLActionsPanel', [$this,
'htmlActionsPanel']);
101 $server->
on(
'onBrowserPostAction', [$this,
'browserPostAction']);
117 $node = $this->server->tree->getNodeForPath(
$path);
121 throw new Forbidden(
'Sharing is not allowed on this node');
126 $acl = $this->server->getPlugin(
'acl');
130 $acl->checkPrivileges(
$path,
'{DAV:}share');
133 foreach ($sharees as $sharee) {
137 $this->server->emit(
'getPrincipalByUri', [$sharee->href, &$principal]);
138 $sharee->principal = $principal;
140 $node->updateInvites($sharees);
157 $propFind->
handle(
'{DAV:}share-access',
function() use ($node) {
159 return new Property\ShareAccess($node->getShareAccess());
162 $propFind->
handle(
'{DAV:}invite',
function() use ($node) {
164 return new Property\Invite($node->getInvites());
167 $propFind->
handle(
'{DAV:}share-resource-uri',
function() use ($node) {
169 return new Property\Href($node->getShareResourceUri());
190 if (strpos(
$contentType,
'application/davsharing+xml') ===
false) {
194 $message = $this->server->xml->parse(
200 switch ($documentType) {
202 case '{DAV:}share-resource':
208 $response->
setHeader(
'X-Sabre-Status',
'everything-went-well');
214 throw new BadRequest(
'Unexpected document type: ' . $documentType .
' for this Content-Type');
232 $supportedPrivilegeSet[
'{DAV:}share'] = [
254 'description' =>
'This plugin implements WebDAV resource sharing',
255 'link' =>
'https://github.com/evert/webdav-sharing' 277 if (!
$aclPlugin->checkPrivileges(
$path,
'{DAV:}share', \
Sabre\DAVACL\Plugin::R_PARENT,
false)) {
283 $output .=
'<tr><td colspan="2"><form method="post" action=""> 284 <h3>Share this resource</h3> 285 <input type="hidden" name="sabreAction" value="share" /> 286 <label>Share with (uri):</label> <input type="text" name="href" placeholder="mailto:user@example.org"/><br /> 287 <label>Access</label> 288 <select name="access"> 289 <option value="readwrite">Read-write</option> 290 <option value="read">Read-only</option> 291 <option value="no-access">Revoke access</option> 293 <input type="submit" value="share" /> 313 if (empty($postVars[
'href'])) {
314 throw new BadRequest(
'The "href" POST parameter is required');
316 if (empty($postVars[
'access'])) {
317 throw new BadRequest(
'The "access" POST parameter is required');
321 'readwrite' => self::ACCESS_READWRITE,
322 'read' => self::ACCESS_READ,
323 'no-access' => self::ACCESS_NOACCESS,
326 if (!isset($accessMap[$postVars[
'access']])) {
327 throw new BadRequest(
'The "access" POST must be readwrite, read or no-access');
330 'href' => $postVars[
'href'],
331 'access' => $accessMap[$postVars[
'access']],
This interface represents a HTTP response.
The RequestInterface represents a HTTP request.
handle($propertyName, $valueOrCallBack)
Handles a specific property.
This class represents the {DAV:}sharee element.
The baseclass for all server plugins.
on($eventName, callable $callBack, $priority=100)
Subscribe to an event.
getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet)
This method is triggered whenever a subsystem reqeuests the privileges hat are supported on a particu...
foreach($paths as $path) $request
httpPost(RequestInterface $request, ResponseInterface $response)
We intercept this to handle POST requests on shared resources.
This class holds all the information about a PROPFIND request.
browserPostAction($path, $action, $postVars)
This method is triggered for POST actions generated by the browser plugin.
getPluginName()
Returns a plugin name.
catch(Exception $e) $message
This plugin implements HTTP requests and properties related to:
setStatus($status)
Sets the HTTP status code.
getFeatures()
This method should return a list of server-features.
getUrl()
Returns the request url.
This interface represents a resource that has sharing capabilities, either because it's possible for ...
htmlActionsPanel(INode $node, &$output, $path)
This method is used to generate HTML output for the DAV.
getHeader($name)
Returns a specific HTTP header, based on it's name.
getPluginInfo()
Returns a bunch of meta-data about the plugin.
initialize(Server $server)
This initializes the plugin.
The INode interface is the base interface, and the parent class of both ICollection and IFile...
getPath()
Returns the relative path.
propFind(PropFind $propFind, INode $node)
This event is triggered when properties are requested for nodes.
if($path[strlen($path) - 1]==='/') if(is_dir($path)) if(!file_exists($path)) if(preg_match('#\.php$#D', mb_strtolower($path, 'UTF-8'))) $contentType
shareResource($path, array $sharees)
Updates the list of sharees on a shared resource.
setHeader($name, $value)
Updates a HTTP header.
getBody()
Returns the message body, as it's internal representation.