commit vendor
This commit is contained in:
94
vendor/sabre/dav/lib/DAVACL/ACLTrait.php
vendored
Normal file
94
vendor/sabre/dav/lib/DAVACL/ACLTrait.php
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL;
|
||||
|
||||
/**
|
||||
* This trait is a default implementation of the IACL interface.
|
||||
*
|
||||
* In many cases you only want to implement 1 or to of the IACL functions,
|
||||
* this trait allows you to be a bit lazier.
|
||||
*
|
||||
* By default this trait grants all privileges to the owner of the resource.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (https://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
trait ACLTrait
|
||||
{
|
||||
/**
|
||||
* Returns the owner principal.
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a group principal.
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'privilege' => '{DAV:}all',
|
||||
'principal' => '{DAV:}owner',
|
||||
'protected' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the ACL.
|
||||
*
|
||||
* This method will receive a list of new ACE's as an array argument.
|
||||
*/
|
||||
public function setACL(array $acl)
|
||||
{
|
||||
throw new \Sabre\DAV\Exception\Forbidden('Setting ACL is not supported on this node');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
178
vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php
vendored
Normal file
178
vendor/sabre/dav/lib/DAVACL/AbstractPrincipalCollection.php
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL;
|
||||
|
||||
use Sabre\DAV;
|
||||
use Sabre\Uri;
|
||||
|
||||
/**
|
||||
* Principals Collection.
|
||||
*
|
||||
* This is a helper class that easily allows you to create a collection that
|
||||
* has a childnode for every principal.
|
||||
*
|
||||
* To use this class, simply implement the getChildForPrincipal method.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
abstract class AbstractPrincipalCollection extends DAV\Collection implements IPrincipalCollection
|
||||
{
|
||||
/**
|
||||
* Principal backend.
|
||||
*
|
||||
* @var PrincipalBackend\BackendInterface
|
||||
*/
|
||||
protected $principalBackend;
|
||||
|
||||
/**
|
||||
* The path to the principals we're listing from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $principalPrefix;
|
||||
|
||||
/**
|
||||
* If this value is set to true, it effectively disables listing of users
|
||||
* it still allows user to find other users if they have an exact url.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $disableListing = false;
|
||||
|
||||
/**
|
||||
* Creates the object.
|
||||
*
|
||||
* This object must be passed the principal backend. This object will
|
||||
* filter all principals from a specified prefix ($principalPrefix). The
|
||||
* default is 'principals', if your principals are stored in a different
|
||||
* collection, override $principalPrefix
|
||||
*
|
||||
* @param string $principalPrefix
|
||||
*/
|
||||
public function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals')
|
||||
{
|
||||
$this->principalPrefix = $principalPrefix;
|
||||
$this->principalBackend = $principalBackend;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a node for a principal.
|
||||
*
|
||||
* The passed array contains principal information, and is guaranteed to
|
||||
* at least contain a uri item. Other properties may or may not be
|
||||
* supplied by the authentication backend.
|
||||
*
|
||||
* @return DAV\INode
|
||||
*/
|
||||
abstract public function getChildForPrincipal(array $principalInfo);
|
||||
|
||||
/**
|
||||
* Returns the name of this collection.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
list(, $name) = Uri\split($this->principalPrefix);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of users.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
if ($this->disableListing) {
|
||||
throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled');
|
||||
}
|
||||
$children = [];
|
||||
foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) {
|
||||
$children[] = $this->getChildForPrincipal($principalInfo);
|
||||
}
|
||||
|
||||
return $children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a child object, by its name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws DAV\Exception\NotFound
|
||||
*
|
||||
* @return DAV\INode
|
||||
*/
|
||||
public function getChild($name)
|
||||
{
|
||||
$principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix.'/'.$name);
|
||||
if (!$principalInfo) {
|
||||
throw new DAV\Exception\NotFound('Principal with name '.$name.' not found');
|
||||
}
|
||||
|
||||
return $this->getChildForPrincipal($principalInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to search for principals matching a set of
|
||||
* properties.
|
||||
*
|
||||
* This search is specifically used by RFC3744's principal-property-search
|
||||
* REPORT. You should at least allow searching on
|
||||
* http://sabredav.org/ns}email-address.
|
||||
*
|
||||
* The actual search should be a unicode-non-case-sensitive search. The
|
||||
* keys in searchProperties are the WebDAV property names, while the values
|
||||
* are the property values to search on.
|
||||
*
|
||||
* By default, if multiple properties are submitted to this method, the
|
||||
* various properties should be combined with 'AND'. If $test is set to
|
||||
* 'anyof', it should be combined using 'OR'.
|
||||
*
|
||||
* This method should simply return a list of 'child names', which may be
|
||||
* used to call $this->getChild in the future.
|
||||
*
|
||||
* @param string $test
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function searchPrincipals(array $searchProperties, $test = 'allof')
|
||||
{
|
||||
$result = $this->principalBackend->searchPrincipals($this->principalPrefix, $searchProperties, $test);
|
||||
$r = [];
|
||||
|
||||
foreach ($result as $row) {
|
||||
list(, $r[]) = Uri\split($row);
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a principal by its URI.
|
||||
*
|
||||
* This method may receive any type of uri, but mailto: addresses will be
|
||||
* the most common.
|
||||
*
|
||||
* Implementation of this API is optional. It is currently used by the
|
||||
* CalDAV system to find principals based on their email addresses. If this
|
||||
* API is not implemented, some features may not work correctly.
|
||||
*
|
||||
* This method must return a relative principal path, or null, if the
|
||||
* principal was not found or you refuse to find it.
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function findByUri($uri)
|
||||
{
|
||||
return $this->principalBackend->findByUri($uri, $this->principalPrefix);
|
||||
}
|
||||
}
|
||||
31
vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php
vendored
Normal file
31
vendor/sabre/dav/lib/DAVACL/Exception/AceConflict.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Exception;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* This exception is thrown when a client attempts to set conflicting
|
||||
* permissions.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class AceConflict extends DAV\Exception\Conflict
|
||||
{
|
||||
/**
|
||||
* Adds in extra information in the xml response.
|
||||
*
|
||||
* This method adds the {DAV:}no-ace-conflict element as defined in rfc3744
|
||||
*/
|
||||
public function serialize(DAV\Server $server, \DOMElement $errorNode)
|
||||
{
|
||||
$doc = $errorNode->ownerDocument;
|
||||
|
||||
$np = $doc->createElementNS('DAV:', 'd:no-ace-conflict');
|
||||
$errorNode->appendChild($np);
|
||||
}
|
||||
}
|
||||
73
vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php
vendored
Normal file
73
vendor/sabre/dav/lib/DAVACL/Exception/NeedPrivileges.php
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Exception;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* NeedPrivileges.
|
||||
*
|
||||
* The 403-need privileges is thrown when a user didn't have the appropriate
|
||||
* permissions to perform an operation
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class NeedPrivileges extends DAV\Exception\Forbidden
|
||||
{
|
||||
/**
|
||||
* The relevant uri.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $uri;
|
||||
|
||||
/**
|
||||
* The privileges the user didn't have.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $privileges;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $uri
|
||||
*/
|
||||
public function __construct($uri, array $privileges)
|
||||
{
|
||||
$this->uri = $uri;
|
||||
$this->privileges = $privileges;
|
||||
|
||||
parent::__construct('User did not have the required privileges ('.implode(',', $privileges).') for path "'.$uri.'"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds in extra information in the xml response.
|
||||
*
|
||||
* This method adds the {DAV:}need-privileges element as defined in rfc3744
|
||||
*/
|
||||
public function serialize(DAV\Server $server, \DOMElement $errorNode)
|
||||
{
|
||||
$doc = $errorNode->ownerDocument;
|
||||
|
||||
$np = $doc->createElementNS('DAV:', 'd:need-privileges');
|
||||
$errorNode->appendChild($np);
|
||||
|
||||
foreach ($this->privileges as $privilege) {
|
||||
$resource = $doc->createElementNS('DAV:', 'd:resource');
|
||||
$np->appendChild($resource);
|
||||
|
||||
$resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri().$this->uri));
|
||||
|
||||
$priv = $doc->createElementNS('DAV:', 'd:privilege');
|
||||
$resource->appendChild($priv);
|
||||
|
||||
preg_match('/^{([^}]*)}(.*)$/', $privilege, $privilegeParts);
|
||||
$priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:'.$privilegeParts[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
31
vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php
vendored
Normal file
31
vendor/sabre/dav/lib/DAVACL/Exception/NoAbstract.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Exception;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* This exception is thrown when a user tries to set a privilege that's marked
|
||||
* as abstract.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class NoAbstract extends DAV\Exception\PreconditionFailed
|
||||
{
|
||||
/**
|
||||
* Adds in extra information in the xml response.
|
||||
*
|
||||
* This method adds the {DAV:}no-abstract element as defined in rfc3744
|
||||
*/
|
||||
public function serialize(DAV\Server $server, \DOMElement $errorNode)
|
||||
{
|
||||
$doc = $errorNode->ownerDocument;
|
||||
|
||||
$np = $doc->createElementNS('DAV:', 'd:no-abstract');
|
||||
$errorNode->appendChild($np);
|
||||
}
|
||||
}
|
||||
31
vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php
vendored
Normal file
31
vendor/sabre/dav/lib/DAVACL/Exception/NotRecognizedPrincipal.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Exception;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* If a client tried to set a privilege assigned to a non-existent principal,
|
||||
* this exception will be thrown.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class NotRecognizedPrincipal extends DAV\Exception\PreconditionFailed
|
||||
{
|
||||
/**
|
||||
* Adds in extra information in the xml response.
|
||||
*
|
||||
* This method adds the {DAV:}recognized-principal element as defined in rfc3744
|
||||
*/
|
||||
public function serialize(DAV\Server $server, \DOMElement $errorNode)
|
||||
{
|
||||
$doc = $errorNode->ownerDocument;
|
||||
|
||||
$np = $doc->createElementNS('DAV:', 'd:recognized-principal');
|
||||
$errorNode->appendChild($np);
|
||||
}
|
||||
}
|
||||
31
vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php
vendored
Normal file
31
vendor/sabre/dav/lib/DAVACL/Exception/NotSupportedPrivilege.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Exception;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* If a client tried to set a privilege that doesn't exist, this exception will
|
||||
* be thrown.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class NotSupportedPrivilege extends DAV\Exception\PreconditionFailed
|
||||
{
|
||||
/**
|
||||
* Adds in extra information in the xml response.
|
||||
*
|
||||
* This method adds the {DAV:}not-supported-privilege element as defined in rfc3744
|
||||
*/
|
||||
public function serialize(DAV\Server $server, \DOMElement $errorNode)
|
||||
{
|
||||
$doc = $errorNode->ownerDocument;
|
||||
|
||||
$np = $doc->createElementNS('DAV:', 'd:not-supported-privilege');
|
||||
$errorNode->appendChild($np);
|
||||
}
|
||||
}
|
||||
109
vendor/sabre/dav/lib/DAVACL/FS/Collection.php
vendored
Normal file
109
vendor/sabre/dav/lib/DAVACL/FS/Collection.php
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\FS;
|
||||
|
||||
use Sabre\DAV\Exception\Forbidden;
|
||||
use Sabre\DAV\Exception\NotFound;
|
||||
use Sabre\DAV\FSExt\Directory as BaseCollection;
|
||||
use Sabre\DAVACL\ACLTrait;
|
||||
use Sabre\DAVACL\IACL;
|
||||
|
||||
/**
|
||||
* This is an ACL-enabled collection.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class Collection extends BaseCollection implements IACL
|
||||
{
|
||||
use ACLTrait;
|
||||
|
||||
/**
|
||||
* A list of ACL rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $acl;
|
||||
|
||||
/**
|
||||
* Owner uri, or null for no owner.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $owner;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path on-disk path
|
||||
* @param array $acl ACL rules
|
||||
* @param string|null $owner principal owner string
|
||||
*/
|
||||
public function __construct($path, array $acl, $owner = null)
|
||||
{
|
||||
parent::__construct($path);
|
||||
$this->acl = $acl;
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific child node, referenced by its name.
|
||||
*
|
||||
* This method must throw Sabre\DAV\Exception\NotFound if the node does not
|
||||
* exist.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws NotFound
|
||||
*
|
||||
* @return \Sabre\DAV\INode
|
||||
*/
|
||||
public function getChild($name)
|
||||
{
|
||||
$path = $this->path.'/'.$name;
|
||||
|
||||
if (!file_exists($path)) {
|
||||
throw new NotFound('File could not be located');
|
||||
}
|
||||
if ('.' == $name || '..' == $name) {
|
||||
throw new Forbidden('Permission denied to . and ..');
|
||||
}
|
||||
if (is_dir($path)) {
|
||||
return new self($path, $this->acl, $this->owner);
|
||||
} else {
|
||||
return new File($path, $this->acl, $this->owner);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner principal.
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL()
|
||||
{
|
||||
return $this->acl;
|
||||
}
|
||||
}
|
||||
78
vendor/sabre/dav/lib/DAVACL/FS/File.php
vendored
Normal file
78
vendor/sabre/dav/lib/DAVACL/FS/File.php
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\FS;
|
||||
|
||||
use Sabre\DAV\FSExt\File as BaseFile;
|
||||
use Sabre\DAVACL\ACLTrait;
|
||||
use Sabre\DAVACL\IACL;
|
||||
|
||||
/**
|
||||
* This is an ACL-enabled file node.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class File extends BaseFile implements IACL
|
||||
{
|
||||
use ACLTrait;
|
||||
|
||||
/**
|
||||
* A list of ACL rules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $acl;
|
||||
|
||||
/**
|
||||
* Owner uri, or null for no owner.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $owner;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $path on-disk path
|
||||
* @param array $acl ACL rules
|
||||
* @param string|null $owner principal owner string
|
||||
*/
|
||||
public function __construct($path, array $acl, $owner = null)
|
||||
{
|
||||
parent::__construct($path);
|
||||
$this->acl = $acl;
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner principal.
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL()
|
||||
{
|
||||
return $this->acl;
|
||||
}
|
||||
}
|
||||
123
vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php
vendored
Normal file
123
vendor/sabre/dav/lib/DAVACL/FS/HomeCollection.php
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\FS;
|
||||
|
||||
use Sabre\DAVACL\AbstractPrincipalCollection;
|
||||
use Sabre\DAVACL\ACLTrait;
|
||||
use Sabre\DAVACL\IACL;
|
||||
use Sabre\DAVACL\PrincipalBackend\BackendInterface;
|
||||
use Sabre\Uri;
|
||||
|
||||
/**
|
||||
* This collection contains a collection for every principal.
|
||||
* It is similar to /home on many unix systems.
|
||||
*
|
||||
* The per-user collections can only be accessed by the user who owns the
|
||||
* collection.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class HomeCollection extends AbstractPrincipalCollection implements IACL
|
||||
{
|
||||
use ACLTrait;
|
||||
|
||||
/**
|
||||
* Name of this collection.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $collectionName = 'home';
|
||||
|
||||
/**
|
||||
* Path to where the users' files are actually stored.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $storagePath;
|
||||
|
||||
/**
|
||||
* Creates the home collection.
|
||||
*
|
||||
* @param string $storagePath where the actual files are stored
|
||||
* @param string $principalPrefix list of principals to iterate
|
||||
*/
|
||||
public function __construct(BackendInterface $principalBackend, $storagePath, $principalPrefix = 'principals')
|
||||
{
|
||||
parent::__construct($principalBackend, $principalPrefix);
|
||||
$this->storagePath = $storagePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the node.
|
||||
*
|
||||
* This is used to generate the url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->collectionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a principals' collection of files.
|
||||
*
|
||||
* The passed array contains principal information, and is guaranteed to
|
||||
* at least contain a uri item. Other properties may or may not be
|
||||
* supplied by the authentication backend.
|
||||
*
|
||||
* @return \Sabre\DAV\INode
|
||||
*/
|
||||
public function getChildForPrincipal(array $principalInfo)
|
||||
{
|
||||
$owner = $principalInfo['uri'];
|
||||
$acl = [
|
||||
[
|
||||
'privilege' => '{DAV:}all',
|
||||
'principal' => '{DAV:}owner',
|
||||
'protected' => true,
|
||||
],
|
||||
];
|
||||
|
||||
list(, $principalBaseName) = Uri\split($owner);
|
||||
|
||||
$path = $this->storagePath.'/'.$principalBaseName;
|
||||
|
||||
if (!is_dir($path)) {
|
||||
mkdir($path, 0777, true);
|
||||
}
|
||||
|
||||
return new Collection(
|
||||
$path,
|
||||
$acl,
|
||||
$owner
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'principal' => '{DAV:}authenticated',
|
||||
'privilege' => '{DAV:}read',
|
||||
'protected' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
72
vendor/sabre/dav/lib/DAVACL/IACL.php
vendored
Normal file
72
vendor/sabre/dav/lib/DAVACL/IACL.php
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* ACL-enabled node.
|
||||
*
|
||||
* If you want to add WebDAV ACL to a node, you must implement this class
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
interface IACL extends DAV\INode
|
||||
{
|
||||
/**
|
||||
* Returns the owner principal.
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner();
|
||||
|
||||
/**
|
||||
* Returns a group principal.
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGroup();
|
||||
|
||||
/**
|
||||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL();
|
||||
|
||||
/**
|
||||
* Updates the ACL.
|
||||
*
|
||||
* This method will receive a list of new ACE's as an array argument.
|
||||
*/
|
||||
public function setACL(array $acl);
|
||||
|
||||
/**
|
||||
* Returns the list of supported privileges for this node.
|
||||
*
|
||||
* The returned data structure is a list of nested privileges.
|
||||
* See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
|
||||
* standard structure.
|
||||
*
|
||||
* If null is returned from this method, the default privilege set is used,
|
||||
* which is fine for most common usecases.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSupportedPrivilegeSet();
|
||||
}
|
||||
75
vendor/sabre/dav/lib/DAVACL/IPrincipal.php
vendored
Normal file
75
vendor/sabre/dav/lib/DAVACL/IPrincipal.php
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* IPrincipal interface.
|
||||
*
|
||||
* Implement this interface to define your own principals
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
interface IPrincipal extends DAV\INode
|
||||
{
|
||||
/**
|
||||
* Returns a list of alternative urls for a principal.
|
||||
*
|
||||
* This can for example be an email address, or ldap url.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAlternateUriSet();
|
||||
|
||||
/**
|
||||
* Returns the full principal url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrincipalUrl();
|
||||
|
||||
/**
|
||||
* Returns the list of group members.
|
||||
*
|
||||
* If this principal is a group, this function should return
|
||||
* all member principal uri's for the group.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMemberSet();
|
||||
|
||||
/**
|
||||
* Returns the list of groups this principal is member of.
|
||||
*
|
||||
* If this principal is a member of a (list of) groups, this function
|
||||
* should return a list of principal uri's for it's members.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMembership();
|
||||
|
||||
/**
|
||||
* Sets a list of group members.
|
||||
*
|
||||
* If this principal is a group, this method sets all the group members.
|
||||
* The list of members is always overwritten, never appended to.
|
||||
*
|
||||
* This method should throw an exception if the members could not be set.
|
||||
*/
|
||||
public function setGroupMemberSet(array $principals);
|
||||
|
||||
/**
|
||||
* Returns the displayname.
|
||||
*
|
||||
* This should be a human readable name for the principal.
|
||||
* If none is available, return the nodename.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName();
|
||||
}
|
||||
64
vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php
vendored
Normal file
64
vendor/sabre/dav/lib/DAVACL/IPrincipalCollection.php
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* Principal Collection interface.
|
||||
*
|
||||
* Implement this interface to ensure that your principal collection can be
|
||||
* searched using the principal-property-search REPORT.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
interface IPrincipalCollection extends DAV\ICollection
|
||||
{
|
||||
/**
|
||||
* This method is used to search for principals matching a set of
|
||||
* properties.
|
||||
*
|
||||
* This search is specifically used by RFC3744's principal-property-search
|
||||
* REPORT. You should at least allow searching on
|
||||
* http://sabredav.org/ns}email-address.
|
||||
*
|
||||
* The actual search should be a unicode-non-case-sensitive search. The
|
||||
* keys in searchProperties are the WebDAV property names, while the values
|
||||
* are the property values to search on.
|
||||
*
|
||||
* By default, if multiple properties are submitted to this method, the
|
||||
* various properties should be combined with 'AND'. If $test is set to
|
||||
* 'anyof', it should be combined using 'OR'.
|
||||
*
|
||||
* This method should simply return a list of 'child names', which may be
|
||||
* used to call $this->getChild in the future.
|
||||
*
|
||||
* @param string $test
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function searchPrincipals(array $searchProperties, $test = 'allof');
|
||||
|
||||
/**
|
||||
* Finds a principal by its URI.
|
||||
*
|
||||
* This method may receive any type of uri, but mailto: addresses will be
|
||||
* the most common.
|
||||
*
|
||||
* Implementation of this API is optional. It is currently used by the
|
||||
* CalDAV system to find principals based on their email addresses. If this
|
||||
* API is not implemented, some features may not work correctly.
|
||||
*
|
||||
* This method must return a relative principal path, or null, if the
|
||||
* principal was not found or you refuse to find it.
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function findByUri($uri);
|
||||
}
|
||||
1549
vendor/sabre/dav/lib/DAVACL/Plugin.php
vendored
Normal file
1549
vendor/sabre/dav/lib/DAVACL/Plugin.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
199
vendor/sabre/dav/lib/DAVACL/Principal.php
vendored
Normal file
199
vendor/sabre/dav/lib/DAVACL/Principal.php
vendored
Normal file
@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL;
|
||||
|
||||
use Sabre\DAV;
|
||||
use Sabre\Uri;
|
||||
|
||||
/**
|
||||
* Principal class.
|
||||
*
|
||||
* This class is a representation of a simple principal
|
||||
*
|
||||
* Many WebDAV specs require a user to show up in the directory
|
||||
* structure.
|
||||
*
|
||||
* This principal also has basic ACL settings, only allowing the principal
|
||||
* access it's own principal.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL
|
||||
{
|
||||
use ACLTrait;
|
||||
|
||||
/**
|
||||
* Struct with principal information.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $principalProperties;
|
||||
|
||||
/**
|
||||
* Principal backend.
|
||||
*
|
||||
* @var PrincipalBackend\BackendInterface
|
||||
*/
|
||||
protected $principalBackend;
|
||||
|
||||
/**
|
||||
* Creates the principal object.
|
||||
*/
|
||||
public function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = [])
|
||||
{
|
||||
if (!isset($principalProperties['uri'])) {
|
||||
throw new DAV\Exception('The principal properties must at least contain the \'uri\' key');
|
||||
}
|
||||
$this->principalBackend = $principalBackend;
|
||||
$this->principalProperties = $principalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full principal url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrincipalUrl()
|
||||
{
|
||||
return $this->principalProperties['uri'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of alternative urls for a principal.
|
||||
*
|
||||
* This can for example be an email address, or ldap url.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAlternateUriSet()
|
||||
{
|
||||
$uris = [];
|
||||
if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) {
|
||||
$uris = $this->principalProperties['{DAV:}alternate-URI-set'];
|
||||
}
|
||||
|
||||
if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) {
|
||||
$uris[] = 'mailto:'.$this->principalProperties['{http://sabredav.org/ns}email-address'];
|
||||
}
|
||||
|
||||
return array_unique($uris);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of group members.
|
||||
*
|
||||
* If this principal is a group, this function should return
|
||||
* all member principal uri's for the group.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMemberSet()
|
||||
{
|
||||
return $this->principalBackend->getGroupMemberSet($this->principalProperties['uri']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of groups this principal is member of.
|
||||
*
|
||||
* If this principal is a member of a (list of) groups, this function
|
||||
* should return a list of principal uri's for it's members.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMembership()
|
||||
{
|
||||
return $this->principalBackend->getGroupMemberShip($this->principalProperties['uri']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a list of group members.
|
||||
*
|
||||
* If this principal is a group, this method sets all the group members.
|
||||
* The list of members is always overwritten, never appended to.
|
||||
*
|
||||
* This method should throw an exception if the members could not be set.
|
||||
*/
|
||||
public function setGroupMemberSet(array $groupMembers)
|
||||
{
|
||||
$this->principalBackend->setGroupMemberSet($this->principalProperties['uri'], $groupMembers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this principals name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
$uri = $this->principalProperties['uri'];
|
||||
list(, $name) = Uri\split($uri);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName()
|
||||
{
|
||||
if (isset($this->principalProperties['{DAV:}displayname'])) {
|
||||
return $this->principalProperties['{DAV:}displayname'];
|
||||
} else {
|
||||
return $this->getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of properties.
|
||||
*
|
||||
* @param array $requestedProperties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProperties($requestedProperties)
|
||||
{
|
||||
$newProperties = [];
|
||||
foreach ($requestedProperties as $propName) {
|
||||
if (isset($this->principalProperties[$propName])) {
|
||||
$newProperties[$propName] = $this->principalProperties[$propName];
|
||||
}
|
||||
}
|
||||
|
||||
return $newProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates properties on this node.
|
||||
*
|
||||
* This method received a PropPatch object, which contains all the
|
||||
* information about the update.
|
||||
*
|
||||
* To update specific properties, call the 'handle' method on this object.
|
||||
* Read the PropPatch documentation for more information.
|
||||
*/
|
||||
public function propPatch(DAV\PropPatch $propPatch)
|
||||
{
|
||||
return $this->principalBackend->updatePrincipal(
|
||||
$this->principalProperties['uri'],
|
||||
$propPatch
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner principal.
|
||||
*
|
||||
* This must be a url to a principal, or null if there's no owner
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
return $this->principalProperties['uri'];
|
||||
}
|
||||
}
|
||||
54
vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php
vendored
Normal file
54
vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\PrincipalBackend;
|
||||
|
||||
/**
|
||||
* Abstract Principal Backend.
|
||||
*
|
||||
* Currently this class has no function. It's here for consistency and so we
|
||||
* have a non-bc-breaking way to add a default generic implementation to
|
||||
* functions we may add in the future.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
abstract class AbstractBackend implements BackendInterface
|
||||
{
|
||||
/**
|
||||
* Finds a principal by its URI.
|
||||
*
|
||||
* This method may receive any type of uri, but mailto: addresses will be
|
||||
* the most common.
|
||||
*
|
||||
* Implementation of this API is optional. It is currently used by the
|
||||
* CalDAV system to find principals based on their email addresses. If this
|
||||
* API is not implemented, some features may not work correctly.
|
||||
*
|
||||
* This method must return a relative principal path, or null, if the
|
||||
* principal was not found or you refuse to find it.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $principalPrefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function findByUri($uri, $principalPrefix)
|
||||
{
|
||||
// Note that the default implementation here is a bit slow and could
|
||||
// likely be optimized.
|
||||
if ('mailto:' !== substr($uri, 0, 7)) {
|
||||
return;
|
||||
}
|
||||
$result = $this->searchPrincipals(
|
||||
$principalPrefix,
|
||||
['{http://sabredav.org/ns}email-address' => substr($uri, 7)]
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
return $result[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
143
vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php
vendored
Normal file
143
vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\PrincipalBackend;
|
||||
|
||||
/**
|
||||
* Implement this interface to create your own principal backends.
|
||||
*
|
||||
* Creating backends for principals is entirely optional. You can also
|
||||
* implement Sabre\DAVACL\IPrincipal directly. This interface is used solely by
|
||||
* Sabre\DAVACL\AbstractPrincipalCollection.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
interface BackendInterface
|
||||
{
|
||||
/**
|
||||
* Returns a list of principals based on a prefix.
|
||||
*
|
||||
* This prefix will often contain something like 'principals'. You are only
|
||||
* expected to return principals that are in this base path.
|
||||
*
|
||||
* You are expected to return at least a 'uri' for every user, you can
|
||||
* return any additional properties if you wish so. Common properties are:
|
||||
* {DAV:}displayname
|
||||
* {http://sabredav.org/ns}email-address - This is a custom SabreDAV
|
||||
* field that's actually injected in a number of other properties. If
|
||||
* you have an email address, use this property.
|
||||
*
|
||||
* @param string $prefixPath
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPrincipalsByPrefix($prefixPath);
|
||||
|
||||
/**
|
||||
* Returns a specific principal, specified by it's path.
|
||||
* The returned structure should be the exact same as from
|
||||
* getPrincipalsByPrefix.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPrincipalByPath($path);
|
||||
|
||||
/**
|
||||
* Updates one ore more webdav properties on a principal.
|
||||
*
|
||||
* The list of mutations is stored in a Sabre\DAV\PropPatch object.
|
||||
* To do the actual updates, you must tell this object which properties
|
||||
* you're going to process with the handle() method.
|
||||
*
|
||||
* Calling the handle method is like telling the PropPatch object "I
|
||||
* promise I can handle updating this property".
|
||||
*
|
||||
* Read the PropPatch documentation for more info and examples.
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch);
|
||||
|
||||
/**
|
||||
* This method is used to search for principals matching a set of
|
||||
* properties.
|
||||
*
|
||||
* This search is specifically used by RFC3744's principal-property-search
|
||||
* REPORT.
|
||||
*
|
||||
* The actual search should be a unicode-non-case-sensitive search. The
|
||||
* keys in searchProperties are the WebDAV property names, while the values
|
||||
* are the property values to search on.
|
||||
*
|
||||
* By default, if multiple properties are submitted to this method, the
|
||||
* various properties should be combined with 'AND'. If $test is set to
|
||||
* 'anyof', it should be combined using 'OR'.
|
||||
*
|
||||
* This method should simply return an array with full principal uri's.
|
||||
*
|
||||
* If somebody attempted to search on a property the backend does not
|
||||
* support, you should simply return 0 results.
|
||||
*
|
||||
* You can also just return 0 results if you choose to not support
|
||||
* searching at all, but keep in mind that this may stop certain features
|
||||
* from working.
|
||||
*
|
||||
* @param string $prefixPath
|
||||
* @param string $test
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof');
|
||||
|
||||
/**
|
||||
* Finds a principal by its URI.
|
||||
*
|
||||
* This method may receive any type of uri, but mailto: addresses will be
|
||||
* the most common.
|
||||
*
|
||||
* Implementation of this API is optional. It is currently used by the
|
||||
* CalDAV system to find principals based on their email addresses. If this
|
||||
* API is not implemented, some features may not work correctly.
|
||||
*
|
||||
* This method must return a relative principal path, or null, if the
|
||||
* principal was not found or you refuse to find it.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $principalPrefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function findByUri($uri, $principalPrefix);
|
||||
|
||||
/**
|
||||
* Returns the list of members for a group-principal.
|
||||
*
|
||||
* @param string $principal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMemberSet($principal);
|
||||
|
||||
/**
|
||||
* Returns the list of groups a principal is a member of.
|
||||
*
|
||||
* @param string $principal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMembership($principal);
|
||||
|
||||
/**
|
||||
* Updates the list of group members for a group principal.
|
||||
*
|
||||
* The principals should be passed as a list of uri's.
|
||||
*
|
||||
* @param string $principal
|
||||
*/
|
||||
public function setGroupMemberSet($principal, array $members);
|
||||
}
|
||||
29
vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php
vendored
Normal file
29
vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\PrincipalBackend;
|
||||
|
||||
use Sabre\DAV\MkCol;
|
||||
|
||||
/**
|
||||
* Implement this interface to add support for creating new principals to your
|
||||
* principal backend.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
interface CreatePrincipalSupport extends BackendInterface
|
||||
{
|
||||
/**
|
||||
* Creates a new principal.
|
||||
*
|
||||
* This method receives a full path for the new principal. The mkCol object
|
||||
* contains any additional webdav properties specified during the creation
|
||||
* of the principal.
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
public function createPrincipal($path, MkCol $mkCol);
|
||||
}
|
||||
443
vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
vendored
Normal file
443
vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
vendored
Normal file
@ -0,0 +1,443 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\PrincipalBackend;
|
||||
|
||||
use Sabre\DAV;
|
||||
use Sabre\DAV\MkCol;
|
||||
use Sabre\Uri;
|
||||
|
||||
/**
|
||||
* PDO principal backend.
|
||||
*
|
||||
* This backend assumes all principals are in a single collection. The default collection
|
||||
* is 'principals/', but this can be overridden.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class PDO extends AbstractBackend implements CreatePrincipalSupport
|
||||
{
|
||||
/**
|
||||
* PDO table name for 'principals'.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tableName = 'principals';
|
||||
|
||||
/**
|
||||
* PDO table name for 'group members'.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $groupMembersTableName = 'groupmembers';
|
||||
|
||||
/**
|
||||
* pdo.
|
||||
*
|
||||
* @var PDO
|
||||
*/
|
||||
protected $pdo;
|
||||
|
||||
/**
|
||||
* A list of additional fields to support.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldMap = [
|
||||
/*
|
||||
* This property can be used to display the users' real name.
|
||||
*/
|
||||
'{DAV:}displayname' => [
|
||||
'dbField' => 'displayname',
|
||||
],
|
||||
|
||||
/*
|
||||
* This is the users' primary email-address.
|
||||
*/
|
||||
'{http://sabredav.org/ns}email-address' => [
|
||||
'dbField' => 'email',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Sets up the backend.
|
||||
*/
|
||||
public function __construct(\PDO $pdo)
|
||||
{
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of principals based on a prefix.
|
||||
*
|
||||
* This prefix will often contain something like 'principals'. You are only
|
||||
* expected to return principals that are in this base path.
|
||||
*
|
||||
* You are expected to return at least a 'uri' for every user, you can
|
||||
* return any additional properties if you wish so. Common properties are:
|
||||
* {DAV:}displayname
|
||||
* {http://sabredav.org/ns}email-address - This is a custom SabreDAV
|
||||
* field that's actualy injected in a number of other properties. If
|
||||
* you have an email address, use this property.
|
||||
*
|
||||
* @param string $prefixPath
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPrincipalsByPrefix($prefixPath)
|
||||
{
|
||||
$fields = [
|
||||
'uri',
|
||||
];
|
||||
|
||||
foreach ($this->fieldMap as $key => $value) {
|
||||
$fields[] = $value['dbField'];
|
||||
}
|
||||
$result = $this->pdo->query('SELECT '.implode(',', $fields).' FROM '.$this->tableName);
|
||||
|
||||
$principals = [];
|
||||
|
||||
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
|
||||
// Checking if the principal is in the prefix
|
||||
list($rowPrefix) = Uri\split($row['uri']);
|
||||
if ($rowPrefix !== $prefixPath) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$principal = [
|
||||
'uri' => $row['uri'],
|
||||
];
|
||||
foreach ($this->fieldMap as $key => $value) {
|
||||
if ($row[$value['dbField']]) {
|
||||
$principal[$key] = $row[$value['dbField']];
|
||||
}
|
||||
}
|
||||
$principals[] = $principal;
|
||||
}
|
||||
|
||||
return $principals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specific principal, specified by it's path.
|
||||
* The returned structure should be the exact same as from
|
||||
* getPrincipalsByPrefix.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPrincipalByPath($path)
|
||||
{
|
||||
$fields = [
|
||||
'id',
|
||||
'uri',
|
||||
];
|
||||
|
||||
foreach ($this->fieldMap as $key => $value) {
|
||||
$fields[] = $value['dbField'];
|
||||
}
|
||||
$stmt = $this->pdo->prepare('SELECT '.implode(',', $fields).' FROM '.$this->tableName.' WHERE uri = ?');
|
||||
$stmt->execute([$path]);
|
||||
|
||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
if (!$row) {
|
||||
return;
|
||||
}
|
||||
|
||||
$principal = [
|
||||
'id' => $row['id'],
|
||||
'uri' => $row['uri'],
|
||||
];
|
||||
foreach ($this->fieldMap as $key => $value) {
|
||||
if ($row[$value['dbField']]) {
|
||||
$principal[$key] = $row[$value['dbField']];
|
||||
}
|
||||
}
|
||||
|
||||
return $principal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates one ore more webdav properties on a principal.
|
||||
*
|
||||
* The list of mutations is stored in a Sabre\DAV\PropPatch object.
|
||||
* To do the actual updates, you must tell this object which properties
|
||||
* you're going to process with the handle() method.
|
||||
*
|
||||
* Calling the handle method is like telling the PropPatch object "I
|
||||
* promise I can handle updating this property".
|
||||
*
|
||||
* Read the PropPatch documentation for more info and examples.
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
public function updatePrincipal($path, DAV\PropPatch $propPatch)
|
||||
{
|
||||
$propPatch->handle(array_keys($this->fieldMap), function ($properties) use ($path) {
|
||||
$query = 'UPDATE '.$this->tableName.' SET ';
|
||||
$first = true;
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ($properties as $key => $value) {
|
||||
$dbField = $this->fieldMap[$key]['dbField'];
|
||||
|
||||
if (!$first) {
|
||||
$query .= ', ';
|
||||
}
|
||||
$first = false;
|
||||
$query .= $dbField.' = :'.$dbField;
|
||||
$values[$dbField] = $value;
|
||||
}
|
||||
|
||||
$query .= ' WHERE uri = :uri';
|
||||
$values['uri'] = $path;
|
||||
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$stmt->execute($values);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to search for principals matching a set of
|
||||
* properties.
|
||||
*
|
||||
* This search is specifically used by RFC3744's principal-property-search
|
||||
* REPORT.
|
||||
*
|
||||
* The actual search should be a unicode-non-case-sensitive search. The
|
||||
* keys in searchProperties are the WebDAV property names, while the values
|
||||
* are the property values to search on.
|
||||
*
|
||||
* By default, if multiple properties are submitted to this method, the
|
||||
* various properties should be combined with 'AND'. If $test is set to
|
||||
* 'anyof', it should be combined using 'OR'.
|
||||
*
|
||||
* This method should simply return an array with full principal uri's.
|
||||
*
|
||||
* If somebody attempted to search on a property the backend does not
|
||||
* support, you should simply return 0 results.
|
||||
*
|
||||
* You can also just return 0 results if you choose to not support
|
||||
* searching at all, but keep in mind that this may stop certain features
|
||||
* from working.
|
||||
*
|
||||
* @param string $prefixPath
|
||||
* @param string $test
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
|
||||
{
|
||||
if (0 == count($searchProperties)) {
|
||||
return [];
|
||||
} //No criteria
|
||||
|
||||
$query = 'SELECT uri FROM '.$this->tableName.' WHERE ';
|
||||
$values = [];
|
||||
foreach ($searchProperties as $property => $value) {
|
||||
switch ($property) {
|
||||
case '{DAV:}displayname':
|
||||
$column = 'displayname';
|
||||
break;
|
||||
case '{http://sabredav.org/ns}email-address':
|
||||
$column = 'email';
|
||||
break;
|
||||
default:
|
||||
// Unsupported property
|
||||
return [];
|
||||
}
|
||||
if (count($values) > 0) {
|
||||
$query .= (0 == strcmp($test, 'anyof') ? ' OR ' : ' AND ');
|
||||
}
|
||||
$query .= 'lower('.$column.') LIKE lower(?)';
|
||||
$values[] = '%'.$value.'%';
|
||||
}
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$stmt->execute($values);
|
||||
|
||||
$principals = [];
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
// Checking if the principal is in the prefix
|
||||
list($rowPrefix) = Uri\split($row['uri']);
|
||||
if ($rowPrefix !== $prefixPath) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$principals[] = $row['uri'];
|
||||
}
|
||||
|
||||
return $principals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a principal by its URI.
|
||||
*
|
||||
* This method may receive any type of uri, but mailto: addresses will be
|
||||
* the most common.
|
||||
*
|
||||
* Implementation of this API is optional. It is currently used by the
|
||||
* CalDAV system to find principals based on their email addresses. If this
|
||||
* API is not implemented, some features may not work correctly.
|
||||
*
|
||||
* This method must return a relative principal path, or null, if the
|
||||
* principal was not found or you refuse to find it.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param string $principalPrefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function findByUri($uri, $principalPrefix)
|
||||
{
|
||||
$uriParts = Uri\parse($uri);
|
||||
|
||||
// Only two types of uri are supported :
|
||||
// - the "mailto:" scheme with some non-empty address
|
||||
// - a principals uri, in the form "principals/NAME"
|
||||
// In both cases, `path` must not be empty.
|
||||
if (empty($uriParts['path'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$uri = null;
|
||||
if ('mailto' === $uriParts['scheme']) {
|
||||
$query = 'SELECT uri FROM '.$this->tableName.' WHERE lower(email)=lower(?)';
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$stmt->execute([$uriParts['path']]);
|
||||
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
// Checking if the principal is in the prefix
|
||||
list($rowPrefix) = Uri\split($row['uri']);
|
||||
if ($rowPrefix !== $principalPrefix) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$uri = $row['uri'];
|
||||
break; //Stop on first match
|
||||
}
|
||||
} else {
|
||||
$pathParts = Uri\split($uriParts['path']); // We can do this since $uriParts['path'] is not null
|
||||
|
||||
if (2 === count($pathParts) && $pathParts[0] === $principalPrefix) {
|
||||
// Checking that this uri exists
|
||||
$query = 'SELECT * FROM '.$this->tableName.' WHERE uri = ?';
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$stmt->execute([$uriParts['path']]);
|
||||
$rows = $stmt->fetchAll();
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$uri = $uriParts['path'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of members for a group-principal.
|
||||
*
|
||||
* @param string $principal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMemberSet($principal)
|
||||
{
|
||||
$principal = $this->getPrincipalByPath($principal);
|
||||
if (!$principal) {
|
||||
throw new DAV\Exception('Principal not found');
|
||||
}
|
||||
$stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?');
|
||||
$stmt->execute([$principal['id']]);
|
||||
|
||||
$result = [];
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$result[] = $row['uri'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of groups a principal is a member of.
|
||||
*
|
||||
* @param string $principal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupMembership($principal)
|
||||
{
|
||||
$principal = $this->getPrincipalByPath($principal);
|
||||
if (!$principal) {
|
||||
throw new DAV\Exception('Principal not found');
|
||||
}
|
||||
$stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?');
|
||||
$stmt->execute([$principal['id']]);
|
||||
|
||||
$result = [];
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$result[] = $row['uri'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the list of group members for a group principal.
|
||||
*
|
||||
* The principals should be passed as a list of uri's.
|
||||
*
|
||||
* @param string $principal
|
||||
*/
|
||||
public function setGroupMemberSet($principal, array $members)
|
||||
{
|
||||
// Grabbing the list of principal id's.
|
||||
$stmt = $this->pdo->prepare('SELECT id, uri FROM '.$this->tableName.' WHERE uri IN (? '.str_repeat(', ? ', count($members)).');');
|
||||
$stmt->execute(array_merge([$principal], $members));
|
||||
|
||||
$memberIds = [];
|
||||
$principalId = null;
|
||||
|
||||
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if ($row['uri'] == $principal) {
|
||||
$principalId = $row['id'];
|
||||
} else {
|
||||
$memberIds[] = $row['id'];
|
||||
}
|
||||
}
|
||||
if (!$principalId) {
|
||||
throw new DAV\Exception('Principal not found');
|
||||
}
|
||||
// Wiping out old members
|
||||
$stmt = $this->pdo->prepare('DELETE FROM '.$this->groupMembersTableName.' WHERE principal_id = ?;');
|
||||
$stmt->execute([$principalId]);
|
||||
|
||||
foreach ($memberIds as $memberId) {
|
||||
$stmt = $this->pdo->prepare('INSERT INTO '.$this->groupMembersTableName.' (principal_id, member_id) VALUES (?, ?);');
|
||||
$stmt->execute([$principalId, $memberId]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new principal.
|
||||
*
|
||||
* This method receives a full path for the new principal. The mkCol object
|
||||
* contains any additional webdav properties specified during the creation
|
||||
* of the principal.
|
||||
*
|
||||
* @param string $path
|
||||
*/
|
||||
public function createPrincipal($path, MkCol $mkCol)
|
||||
{
|
||||
$stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (uri) VALUES (?)');
|
||||
$stmt->execute([$path]);
|
||||
$this->updatePrincipal($path, $mkCol);
|
||||
}
|
||||
}
|
||||
96
vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php
vendored
Normal file
96
vendor/sabre/dav/lib/DAVACL/PrincipalCollection.php
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL;
|
||||
|
||||
use Sabre\DAV\Exception\InvalidResourceType;
|
||||
use Sabre\DAV\IExtendedCollection;
|
||||
use Sabre\DAV\MkCol;
|
||||
|
||||
/**
|
||||
* Principals Collection.
|
||||
*
|
||||
* This collection represents a list of users.
|
||||
* The users are instances of Sabre\DAVACL\Principal
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL
|
||||
{
|
||||
use ACLTrait;
|
||||
|
||||
/**
|
||||
* This method returns a node for a principal.
|
||||
*
|
||||
* The passed array contains principal information, and is guaranteed to
|
||||
* at least contain a uri item. Other properties may or may not be
|
||||
* supplied by the authentication backend.
|
||||
*
|
||||
* @return \Sabre\DAV\INode
|
||||
*/
|
||||
public function getChildForPrincipal(array $principal)
|
||||
{
|
||||
return new Principal($this->principalBackend, $principal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new collection.
|
||||
*
|
||||
* This method will receive a MkCol object with all the information about
|
||||
* the new collection that's being created.
|
||||
*
|
||||
* The MkCol object contains information about the resourceType of the new
|
||||
* collection. If you don't support the specified resourceType, you should
|
||||
* throw Exception\InvalidResourceType.
|
||||
*
|
||||
* The object also contains a list of WebDAV properties for the new
|
||||
* collection.
|
||||
*
|
||||
* You should call the handle() method on this object to specify exactly
|
||||
* which properties you are storing. This allows the system to figure out
|
||||
* exactly which properties you didn't store, which in turn allows other
|
||||
* plugins (such as the propertystorage plugin) to handle storing the
|
||||
* property for you.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws InvalidResourceType
|
||||
*/
|
||||
public function createExtendedCollection($name, MkCol $mkCol)
|
||||
{
|
||||
if (!$mkCol->hasResourceType('{DAV:}principal')) {
|
||||
throw new InvalidResourceType('Only resources of type {DAV:}principal may be created here');
|
||||
}
|
||||
|
||||
$this->principalBackend->createPrincipal(
|
||||
$this->principalPrefix.'/'.$name,
|
||||
$mkCol
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of ACE's for this node.
|
||||
*
|
||||
* Each ACE has the following properties:
|
||||
* * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
|
||||
* currently the only supported privileges
|
||||
* * 'principal', a url to the principal who owns the node
|
||||
* * 'protected' (optional), indicating that this ACE is not allowed to
|
||||
* be updated.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getACL()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'principal' => '{DAV:}authenticated',
|
||||
'privilege' => '{DAV:}read',
|
||||
'protected' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
257
vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php
vendored
Normal file
257
vendor/sabre/dav/lib/DAVACL/Xml/Property/Acl.php
vendored
Normal file
@ -0,0 +1,257 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Property;
|
||||
|
||||
use Sabre\DAV;
|
||||
use Sabre\DAV\Browser\HtmlOutput;
|
||||
use Sabre\DAV\Browser\HtmlOutputHelper;
|
||||
use Sabre\Xml\Element;
|
||||
use Sabre\Xml\Reader;
|
||||
use Sabre\Xml\Writer;
|
||||
|
||||
/**
|
||||
* This class represents the {DAV:}acl property.
|
||||
*
|
||||
* The {DAV:}acl property is a full list of access control entries for a
|
||||
* resource.
|
||||
*
|
||||
* {DAV:}acl is used as a WebDAV property, but it is also used within the body
|
||||
* of the ACL request.
|
||||
*
|
||||
* See:
|
||||
* http://tools.ietf.org/html/rfc3744#section-5.5
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class Acl implements Element, HtmlOutput
|
||||
{
|
||||
/**
|
||||
* List of privileges.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $privileges;
|
||||
|
||||
/**
|
||||
* Whether or not the server base url is required to be prefixed when
|
||||
* serializing the property.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $prefixBaseUrl;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* This object requires a structure similar to the return value from
|
||||
* Sabre\DAVACL\Plugin::getACL().
|
||||
*
|
||||
* Each privilege is a an array with at least a 'privilege' property, and a
|
||||
* 'principal' property. A privilege may have a 'protected' property as
|
||||
* well.
|
||||
*
|
||||
* The prefixBaseUrl should be set to false, if the supplied principal urls
|
||||
* are already full urls. If this is kept to true, the servers base url
|
||||
* will automatically be prefixed.
|
||||
*
|
||||
* @param bool $prefixBaseUrl
|
||||
*/
|
||||
public function __construct(array $privileges, $prefixBaseUrl = true)
|
||||
{
|
||||
$this->privileges = $privileges;
|
||||
$this->prefixBaseUrl = $prefixBaseUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of privileges for this property.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPrivileges()
|
||||
{
|
||||
return $this->privileges;
|
||||
}
|
||||
|
||||
/**
|
||||
* The xmlSerialize method is called during xml writing.
|
||||
*
|
||||
* Use the $writer argument to write its own xml serialization.
|
||||
*
|
||||
* An important note: do _not_ create a parent element. Any element
|
||||
* implementing XmlSerializable should only ever write what's considered
|
||||
* its 'inner xml'.
|
||||
*
|
||||
* The parent of the current element is responsible for writing a
|
||||
* containing element.
|
||||
*
|
||||
* This allows serializers to be re-used for different element names.
|
||||
*
|
||||
* If you are opening new elements, you must also close them again.
|
||||
*/
|
||||
public function xmlSerialize(Writer $writer)
|
||||
{
|
||||
foreach ($this->privileges as $ace) {
|
||||
$this->serializeAce($writer, $ace);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate html representation for this value.
|
||||
*
|
||||
* The html output is 100% trusted, and no effort is being made to sanitize
|
||||
* it. It's up to the implementor to sanitize user provided values.
|
||||
*
|
||||
* The output must be in UTF-8.
|
||||
*
|
||||
* The baseUri parameter is a url to the root of the application, and can
|
||||
* be used to construct local links.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml(HtmlOutputHelper $html)
|
||||
{
|
||||
ob_start();
|
||||
echo '<table>';
|
||||
echo '<tr><th>Principal</th><th>Privilege</th><th></th></tr>';
|
||||
foreach ($this->privileges as $privilege) {
|
||||
echo '<tr>';
|
||||
// if it starts with a {, it's a special principal
|
||||
if ('{' === $privilege['principal'][0]) {
|
||||
echo '<td>', $html->xmlName($privilege['principal']), '</td>';
|
||||
} else {
|
||||
echo '<td>', $html->link($privilege['principal']), '</td>';
|
||||
}
|
||||
echo '<td>', $html->xmlName($privilege['privilege']), '</td>';
|
||||
echo '<td>';
|
||||
if (!empty($privilege['protected'])) {
|
||||
echo '(protected)';
|
||||
}
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* The deserialize method is called during xml parsing.
|
||||
*
|
||||
* This method is called statically, this is because in theory this method
|
||||
* may be used as a type of constructor, or factory method.
|
||||
*
|
||||
* Often you want to return an instance of the current class, but you are
|
||||
* free to return other data as well.
|
||||
*
|
||||
* Important note 2: You are responsible for advancing the reader to the
|
||||
* next element. Not doing anything will result in a never-ending loop.
|
||||
*
|
||||
* If you just want to skip parsing for this element altogether, you can
|
||||
* just call $reader->next();
|
||||
*
|
||||
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
|
||||
* the next element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlDeserialize(Reader $reader)
|
||||
{
|
||||
$elementMap = [
|
||||
'{DAV:}ace' => 'Sabre\Xml\Element\KeyValue',
|
||||
'{DAV:}privilege' => 'Sabre\Xml\Element\Elements',
|
||||
'{DAV:}principal' => 'Sabre\DAVACL\Xml\Property\Principal',
|
||||
];
|
||||
|
||||
$privileges = [];
|
||||
|
||||
foreach ((array) $reader->parseInnerTree($elementMap) as $element) {
|
||||
if ('{DAV:}ace' !== $element['name']) {
|
||||
continue;
|
||||
}
|
||||
$ace = $element['value'];
|
||||
|
||||
if (empty($ace['{DAV:}principal'])) {
|
||||
throw new DAV\Exception\BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
|
||||
}
|
||||
$principal = $ace['{DAV:}principal'];
|
||||
|
||||
switch ($principal->getType()) {
|
||||
case Principal::HREF:
|
||||
$principal = $principal->getHref();
|
||||
break;
|
||||
case Principal::AUTHENTICATED:
|
||||
$principal = '{DAV:}authenticated';
|
||||
break;
|
||||
case Principal::UNAUTHENTICATED:
|
||||
$principal = '{DAV:}unauthenticated';
|
||||
break;
|
||||
case Principal::ALL:
|
||||
$principal = '{DAV:}all';
|
||||
break;
|
||||
}
|
||||
|
||||
$protected = array_key_exists('{DAV:}protected', $ace);
|
||||
|
||||
if (!isset($ace['{DAV:}grant'])) {
|
||||
throw new DAV\Exception\NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
|
||||
}
|
||||
foreach ($ace['{DAV:}grant'] as $elem) {
|
||||
if ('{DAV:}privilege' !== $elem['name']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($elem['value'] as $priv) {
|
||||
$privileges[] = [
|
||||
'principal' => $principal,
|
||||
'protected' => $protected,
|
||||
'privilege' => $priv,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new self($privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes a single access control entry.
|
||||
*/
|
||||
private function serializeAce(Writer $writer, array $ace)
|
||||
{
|
||||
$writer->startElement('{DAV:}ace');
|
||||
|
||||
switch ($ace['principal']) {
|
||||
case '{DAV:}authenticated':
|
||||
$principal = new Principal(Principal::AUTHENTICATED);
|
||||
break;
|
||||
case '{DAV:}unauthenticated':
|
||||
$principal = new Principal(Principal::UNAUTHENTICATED);
|
||||
break;
|
||||
case '{DAV:}all':
|
||||
$principal = new Principal(Principal::ALL);
|
||||
break;
|
||||
default:
|
||||
$principal = new Principal(Principal::HREF, $ace['principal']);
|
||||
break;
|
||||
}
|
||||
|
||||
$writer->writeElement('{DAV:}principal', $principal);
|
||||
$writer->startElement('{DAV:}grant');
|
||||
$writer->startElement('{DAV:}privilege');
|
||||
|
||||
$writer->writeElement($ace['privilege']);
|
||||
|
||||
$writer->endElement(); // privilege
|
||||
$writer->endElement(); // grant
|
||||
|
||||
if (!empty($ace['protected'])) {
|
||||
$writer->writeElement('{DAV:}protected');
|
||||
}
|
||||
|
||||
$writer->endElement(); // ace
|
||||
}
|
||||
}
|
||||
42
vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php
vendored
Normal file
42
vendor/sabre/dav/lib/DAVACL/Xml/Property/AclRestrictions.php
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Property;
|
||||
|
||||
use Sabre\Xml\Writer;
|
||||
use Sabre\Xml\XmlSerializable;
|
||||
|
||||
/**
|
||||
* AclRestrictions property.
|
||||
*
|
||||
* This property represents {DAV:}acl-restrictions, as defined in RFC3744.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class AclRestrictions implements XmlSerializable
|
||||
{
|
||||
/**
|
||||
* The xmlSerialize method is called during xml writing.
|
||||
*
|
||||
* Use the $writer argument to write its own xml serialization.
|
||||
*
|
||||
* An important note: do _not_ create a parent element. Any element
|
||||
* implementing XmlSerializable should only ever write what's considered
|
||||
* its 'inner xml'.
|
||||
*
|
||||
* The parent of the current element is responsible for writing a
|
||||
* containing element.
|
||||
*
|
||||
* This allows serializers to be re-used for different element names.
|
||||
*
|
||||
* If you are opening new elements, you must also close them again.
|
||||
*/
|
||||
public function xmlSerialize(Writer $writer)
|
||||
{
|
||||
$writer->writeElement('{DAV:}grant-only');
|
||||
$writer->writeElement('{DAV:}no-invert');
|
||||
}
|
||||
}
|
||||
145
vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php
vendored
Normal file
145
vendor/sabre/dav/lib/DAVACL/Xml/Property/CurrentUserPrivilegeSet.php
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Property;
|
||||
|
||||
use Sabre\DAV\Browser\HtmlOutput;
|
||||
use Sabre\DAV\Browser\HtmlOutputHelper;
|
||||
use Sabre\Xml\Element;
|
||||
use Sabre\Xml\Reader;
|
||||
use Sabre\Xml\Writer;
|
||||
|
||||
/**
|
||||
* CurrentUserPrivilegeSet.
|
||||
*
|
||||
* This class represents the current-user-privilege-set property. When
|
||||
* requested, it contain all the privileges a user has on a specific node.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class CurrentUserPrivilegeSet implements Element, HtmlOutput
|
||||
{
|
||||
/**
|
||||
* List of privileges.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $privileges;
|
||||
|
||||
/**
|
||||
* Creates the object.
|
||||
*
|
||||
* Pass the privileges in clark-notation
|
||||
*/
|
||||
public function __construct(array $privileges)
|
||||
{
|
||||
$this->privileges = $privileges;
|
||||
}
|
||||
|
||||
/**
|
||||
* The xmlSerialize method is called during xml writing.
|
||||
*
|
||||
* Use the $writer argument to write its own xml serialization.
|
||||
*
|
||||
* An important note: do _not_ create a parent element. Any element
|
||||
* implementing XmlSerializable should only ever write what's considered
|
||||
* its 'inner xml'.
|
||||
*
|
||||
* The parent of the current element is responsible for writing a
|
||||
* containing element.
|
||||
*
|
||||
* This allows serializers to be re-used for different element names.
|
||||
*
|
||||
* If you are opening new elements, you must also close them again.
|
||||
*/
|
||||
public function xmlSerialize(Writer $writer)
|
||||
{
|
||||
foreach ($this->privileges as $privName) {
|
||||
$writer->startElement('{DAV:}privilege');
|
||||
$writer->writeElement($privName);
|
||||
$writer->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true or false, whether the specified principal appears in the
|
||||
* list.
|
||||
*
|
||||
* @param string $privilegeName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($privilegeName)
|
||||
{
|
||||
return in_array($privilegeName, $this->privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of privileges.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->privileges;
|
||||
}
|
||||
|
||||
/**
|
||||
* The deserialize method is called during xml parsing.
|
||||
*
|
||||
* This method is called statically, this is because in theory this method
|
||||
* may be used as a type of constructor, or factory method.
|
||||
*
|
||||
* Often you want to return an instance of the current class, but you are
|
||||
* free to return other data as well.
|
||||
*
|
||||
* You are responsible for advancing the reader to the next element. Not
|
||||
* doing anything will result in a never-ending loop.
|
||||
*
|
||||
* If you just want to skip parsing for this element altogether, you can
|
||||
* just call $reader->next();
|
||||
*
|
||||
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
|
||||
* the next element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlDeserialize(Reader $reader)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$tree = $reader->parseInnerTree(['{DAV:}privilege' => 'Sabre\\Xml\\Element\\Elements']);
|
||||
foreach ($tree as $element) {
|
||||
if ('{DAV:}privilege' !== $element['name']) {
|
||||
continue;
|
||||
}
|
||||
$result[] = $element['value'][0];
|
||||
}
|
||||
|
||||
return new self($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate html representation for this value.
|
||||
*
|
||||
* The html output is 100% trusted, and no effort is being made to sanitize
|
||||
* it. It's up to the implementor to sanitize user provided values.
|
||||
*
|
||||
* The output must be in UTF-8.
|
||||
*
|
||||
* The baseUri parameter is a url to the root of the application, and can
|
||||
* be used to construct local links.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml(HtmlOutputHelper $html)
|
||||
{
|
||||
return implode(
|
||||
', ',
|
||||
array_map([$html, 'xmlName'], $this->getValue())
|
||||
);
|
||||
}
|
||||
}
|
||||
184
vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php
vendored
Normal file
184
vendor/sabre/dav/lib/DAVACL/Xml/Property/Principal.php
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Property;
|
||||
|
||||
use Sabre\DAV;
|
||||
use Sabre\DAV\Browser\HtmlOutputHelper;
|
||||
use Sabre\DAV\Exception\BadRequest;
|
||||
use Sabre\Xml\Reader;
|
||||
use Sabre\Xml\Writer;
|
||||
|
||||
/**
|
||||
* Principal property.
|
||||
*
|
||||
* The principal property represents a principal from RFC3744 (ACL).
|
||||
* The property can be used to specify a principal or pseudo principals.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class Principal extends DAV\Xml\Property\Href
|
||||
{
|
||||
/**
|
||||
* To specify a not-logged-in user, use the UNAUTHENTICATED principal.
|
||||
*/
|
||||
const UNAUTHENTICATED = 1;
|
||||
|
||||
/**
|
||||
* To specify any principal that is logged in, use AUTHENTICATED.
|
||||
*/
|
||||
const AUTHENTICATED = 2;
|
||||
|
||||
/**
|
||||
* Specific principals can be specified with the HREF.
|
||||
*/
|
||||
const HREF = 3;
|
||||
|
||||
/**
|
||||
* Everybody, basically.
|
||||
*/
|
||||
const ALL = 4;
|
||||
|
||||
/**
|
||||
* Principal-type.
|
||||
*
|
||||
* Must be one of the UNAUTHENTICATED, AUTHENTICATED or HREF constants.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Creates the property.
|
||||
*
|
||||
* The 'type' argument must be one of the type constants defined in this class.
|
||||
*
|
||||
* 'href' is only required for the HREF type.
|
||||
*
|
||||
* @param int $type
|
||||
* @param string|null $href
|
||||
*/
|
||||
public function __construct($type, $href = null)
|
||||
{
|
||||
$this->type = $type;
|
||||
if (self::HREF === $type && is_null($href)) {
|
||||
throw new DAV\Exception('The href argument must be specified for the HREF principal type.');
|
||||
}
|
||||
if ($href) {
|
||||
$href = rtrim($href, '/').'/';
|
||||
parent::__construct($href);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the principal type.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The xmlSerialize method is called during xml writing.
|
||||
*
|
||||
* Use the $writer argument to write its own xml serialization.
|
||||
*
|
||||
* An important note: do _not_ create a parent element. Any element
|
||||
* implementing XmlSerializable should only ever write what's considered
|
||||
* its 'inner xml'.
|
||||
*
|
||||
* The parent of the current element is responsible for writing a
|
||||
* containing element.
|
||||
*
|
||||
* This allows serializers to be re-used for different element names.
|
||||
*
|
||||
* If you are opening new elements, you must also close them again.
|
||||
*/
|
||||
public function xmlSerialize(Writer $writer)
|
||||
{
|
||||
switch ($this->type) {
|
||||
case self::UNAUTHENTICATED:
|
||||
$writer->writeElement('{DAV:}unauthenticated');
|
||||
break;
|
||||
case self::AUTHENTICATED:
|
||||
$writer->writeElement('{DAV:}authenticated');
|
||||
break;
|
||||
case self::HREF:
|
||||
parent::xmlSerialize($writer);
|
||||
break;
|
||||
case self::ALL:
|
||||
$writer->writeElement('{DAV:}all');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate html representation for this value.
|
||||
*
|
||||
* The html output is 100% trusted, and no effort is being made to sanitize
|
||||
* it. It's up to the implementor to sanitize user provided values.
|
||||
*
|
||||
* The output must be in UTF-8.
|
||||
*
|
||||
* The baseUri parameter is a url to the root of the application, and can
|
||||
* be used to construct local links.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml(HtmlOutputHelper $html)
|
||||
{
|
||||
switch ($this->type) {
|
||||
case self::UNAUTHENTICATED:
|
||||
return '<em>unauthenticated</em>';
|
||||
case self::AUTHENTICATED:
|
||||
return '<em>authenticated</em>';
|
||||
case self::HREF:
|
||||
return parent::toHtml($html);
|
||||
case self::ALL:
|
||||
return '<em>all</em>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The deserialize method is called during xml parsing.
|
||||
*
|
||||
* This method is called staticly, this is because in theory this method
|
||||
* may be used as a type of constructor, or factory method.
|
||||
*
|
||||
* Often you want to return an instance of the current class, but you are
|
||||
* free to return other data as well.
|
||||
*
|
||||
* Important note 2: You are responsible for advancing the reader to the
|
||||
* next element. Not doing anything will result in a never-ending loop.
|
||||
*
|
||||
* If you just want to skip parsing for this element altogether, you can
|
||||
* just call $reader->next();
|
||||
*
|
||||
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
|
||||
* the next element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlDeserialize(Reader $reader)
|
||||
{
|
||||
$tree = $reader->parseInnerTree()[0];
|
||||
|
||||
switch ($tree['name']) {
|
||||
case '{DAV:}unauthenticated':
|
||||
return new self(self::UNAUTHENTICATED);
|
||||
case '{DAV:}authenticated':
|
||||
return new self(self::AUTHENTICATED);
|
||||
case '{DAV:}href':
|
||||
return new self(self::HREF, $tree['value']);
|
||||
case '{DAV:}all':
|
||||
return new self(self::ALL);
|
||||
default:
|
||||
throw new BadRequest('Unknown or unsupported principal type: '.$tree['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
146
vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php
vendored
Normal file
146
vendor/sabre/dav/lib/DAVACL/Xml/Property/SupportedPrivilegeSet.php
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Property;
|
||||
|
||||
use Sabre\DAV\Browser\HtmlOutput;
|
||||
use Sabre\DAV\Browser\HtmlOutputHelper;
|
||||
use Sabre\Xml\Writer;
|
||||
use Sabre\Xml\XmlSerializable;
|
||||
|
||||
/**
|
||||
* SupportedPrivilegeSet property.
|
||||
*
|
||||
* This property encodes the {DAV:}supported-privilege-set property, as defined
|
||||
* in rfc3744. Please consult the rfc for details about it's structure.
|
||||
*
|
||||
* This class expects a structure like the one given from
|
||||
* Sabre\DAVACL\Plugin::getSupportedPrivilegeSet as the argument in its
|
||||
* constructor.
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class SupportedPrivilegeSet implements XmlSerializable, HtmlOutput
|
||||
{
|
||||
/**
|
||||
* privileges.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $privileges;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(array $privileges)
|
||||
{
|
||||
$this->privileges = $privileges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the privilege value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->privileges;
|
||||
}
|
||||
|
||||
/**
|
||||
* The xmlSerialize method is called during xml writing.
|
||||
*
|
||||
* Use the $writer argument to write its own xml serialization.
|
||||
*
|
||||
* An important note: do _not_ create a parent element. Any element
|
||||
* implementing XmlSerializable should only ever write what's considered
|
||||
* its 'inner xml'.
|
||||
*
|
||||
* The parent of the current element is responsible for writing a
|
||||
* containing element.
|
||||
*
|
||||
* This allows serializers to be re-used for different element names.
|
||||
*
|
||||
* If you are opening new elements, you must also close them again.
|
||||
*/
|
||||
public function xmlSerialize(Writer $writer)
|
||||
{
|
||||
$this->serializePriv($writer, '{DAV:}all', ['aggregates' => $this->privileges]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate html representation for this value.
|
||||
*
|
||||
* The html output is 100% trusted, and no effort is being made to sanitize
|
||||
* it. It's up to the implementor to sanitize user provided values.
|
||||
*
|
||||
* The output must be in UTF-8.
|
||||
*
|
||||
* The baseUri parameter is a url to the root of the application, and can
|
||||
* be used to construct local links.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml(HtmlOutputHelper $html)
|
||||
{
|
||||
$traverse = function ($privName, $priv) use (&$traverse, $html) {
|
||||
echo '<li>';
|
||||
echo $html->xmlName($privName);
|
||||
if (isset($priv['abstract']) && $priv['abstract']) {
|
||||
echo ' <i>(abstract)</i>';
|
||||
}
|
||||
if (isset($priv['description'])) {
|
||||
echo ' '.$html->h($priv['description']);
|
||||
}
|
||||
if (isset($priv['aggregates'])) {
|
||||
echo "\n<ul>\n";
|
||||
foreach ($priv['aggregates'] as $subPrivName => $subPriv) {
|
||||
$traverse($subPrivName, $subPriv);
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
echo "</li>\n";
|
||||
};
|
||||
|
||||
ob_start();
|
||||
echo '<ul class="tree">';
|
||||
$traverse('{DAV:}all', ['aggregates' => $this->getValue()]);
|
||||
echo "</ul>\n";
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes a property.
|
||||
*
|
||||
* This is a recursive function.
|
||||
*
|
||||
* @param string $privName
|
||||
* @param array $privilege
|
||||
*/
|
||||
private function serializePriv(Writer $writer, $privName, $privilege)
|
||||
{
|
||||
$writer->startElement('{DAV:}supported-privilege');
|
||||
|
||||
$writer->startElement('{DAV:}privilege');
|
||||
$writer->writeElement($privName);
|
||||
$writer->endElement(); // privilege
|
||||
|
||||
if (!empty($privilege['abstract'])) {
|
||||
$writer->writeElement('{DAV:}abstract');
|
||||
}
|
||||
if (!empty($privilege['description'])) {
|
||||
$writer->writeElement('{DAV:}description', $privilege['description']);
|
||||
}
|
||||
if (isset($privilege['aggregates'])) {
|
||||
foreach ($privilege['aggregates'] as $subPrivName => $subPrivilege) {
|
||||
$this->serializePriv($writer, $subPrivName, $subPrivilege);
|
||||
}
|
||||
}
|
||||
|
||||
$writer->endElement(); // supported-privilege
|
||||
}
|
||||
}
|
||||
66
vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php
vendored
Normal file
66
vendor/sabre/dav/lib/DAVACL/Xml/Request/AclPrincipalPropSetReport.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Request;
|
||||
|
||||
use Sabre\Xml\Deserializer;
|
||||
use Sabre\Xml\Reader;
|
||||
use Sabre\Xml\XmlDeserializable;
|
||||
|
||||
/**
|
||||
* AclPrincipalPropSet request parser.
|
||||
*
|
||||
* This class parses the {DAV:}acl-principal-prop-set REPORT, as defined in:
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc3744#section-9.2
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (https://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class AclPrincipalPropSetReport implements XmlDeserializable
|
||||
{
|
||||
public $properties = [];
|
||||
|
||||
/**
|
||||
* The deserialize method is called during xml parsing.
|
||||
*
|
||||
* This method is called statically, this is because in theory this method
|
||||
* may be used as a type of constructor, or factory method.
|
||||
*
|
||||
* Often you want to return an instance of the current class, but you are
|
||||
* free to return other data as well.
|
||||
*
|
||||
* You are responsible for advancing the reader to the next element. Not
|
||||
* doing anything will result in a never-ending loop.
|
||||
*
|
||||
* If you just want to skip parsing for this element altogether, you can
|
||||
* just call $reader->next();
|
||||
*
|
||||
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
|
||||
* the next element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlDeserialize(Reader $reader)
|
||||
{
|
||||
$reader->pushContext();
|
||||
$reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\enum';
|
||||
|
||||
$elems = Deserializer\keyValue(
|
||||
$reader,
|
||||
'DAV:'
|
||||
);
|
||||
|
||||
$reader->popContext();
|
||||
|
||||
$report = new self();
|
||||
|
||||
if (!empty($elems['prop'])) {
|
||||
$report->properties = $elems['prop'];
|
||||
}
|
||||
|
||||
return $report;
|
||||
}
|
||||
}
|
||||
100
vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php
vendored
Normal file
100
vendor/sabre/dav/lib/DAVACL/Xml/Request/ExpandPropertyReport.php
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Request;
|
||||
|
||||
use Sabre\Xml\Reader;
|
||||
use Sabre\Xml\XmlDeserializable;
|
||||
|
||||
/**
|
||||
* ExpandProperty request parser.
|
||||
*
|
||||
* This class parses the {DAV:}expand-property REPORT, as defined in:
|
||||
*
|
||||
* http://tools.ietf.org/html/rfc3253#section-3.8
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class ExpandPropertyReport implements XmlDeserializable
|
||||
{
|
||||
/**
|
||||
* An array with requested properties.
|
||||
*
|
||||
* The requested properties will be used as keys in this array. The value
|
||||
* is normally null.
|
||||
*
|
||||
* If the value is an array though, it means the property must be expanded.
|
||||
* Within the array, the sub-properties, which themselves may be null or
|
||||
* arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $properties;
|
||||
|
||||
/**
|
||||
* The deserialize method is called during xml parsing.
|
||||
*
|
||||
* This method is called statically, this is because in theory this method
|
||||
* may be used as a type of constructor, or factory method.
|
||||
*
|
||||
* Often you want to return an instance of the current class, but you are
|
||||
* free to return other data as well.
|
||||
*
|
||||
* You are responsible for advancing the reader to the next element. Not
|
||||
* doing anything will result in a never-ending loop.
|
||||
*
|
||||
* If you just want to skip parsing for this element altogether, you can
|
||||
* just call $reader->next();
|
||||
*
|
||||
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
|
||||
* the next element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlDeserialize(Reader $reader)
|
||||
{
|
||||
$elems = $reader->parseInnerTree();
|
||||
|
||||
$obj = new self();
|
||||
$obj->properties = self::traverse($elems);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used by deserializeXml, to recursively parse the
|
||||
* {DAV:}property elements.
|
||||
*
|
||||
* @param array $elems
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function traverse($elems)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($elems as $elem) {
|
||||
if ('{DAV:}property' !== $elem['name']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$namespace = isset($elem['attributes']['namespace']) ?
|
||||
$elem['attributes']['namespace'] :
|
||||
'DAV:';
|
||||
|
||||
$propName = '{'.$namespace.'}'.$elem['attributes']['name'];
|
||||
|
||||
$value = null;
|
||||
if (is_array($elem['value'])) {
|
||||
$value = self::traverse($elem['value']);
|
||||
}
|
||||
|
||||
$result[$propName] = $value;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
106
vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php
vendored
Normal file
106
vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalMatchReport.php
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Request;
|
||||
|
||||
use Sabre\Xml\Deserializer;
|
||||
use Sabre\Xml\Reader;
|
||||
use Sabre\Xml\XmlDeserializable;
|
||||
|
||||
/**
|
||||
* PrincipalMatchReport request parser.
|
||||
*
|
||||
* This class parses the {DAV:}principal-match REPORT, as defined
|
||||
* in:
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc3744#section-9.3
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class PrincipalMatchReport implements XmlDeserializable
|
||||
{
|
||||
/**
|
||||
* Report on a list of principals that match the current principal.
|
||||
*/
|
||||
const SELF = 1;
|
||||
|
||||
/**
|
||||
* Report on a property on resources, such as {DAV:}owner, that match the current principal.
|
||||
*/
|
||||
const PRINCIPAL_PROPERTY = 2;
|
||||
|
||||
/**
|
||||
* Must be SELF or PRINCIPAL_PROPERTY.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* List of properties that are being requested for matching resources.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $properties = [];
|
||||
|
||||
/**
|
||||
* If $type = PRINCIPAL_PROPERTY, which WebDAV property we should compare
|
||||
* to the current principal.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $principalProperty;
|
||||
|
||||
/**
|
||||
* The deserialize method is called during xml parsing.
|
||||
*
|
||||
* This method is called statically, this is because in theory this method
|
||||
* may be used as a type of constructor, or factory method.
|
||||
*
|
||||
* Often you want to return an instance of the current class, but you are
|
||||
* free to return other data as well.
|
||||
*
|
||||
* You are responsible for advancing the reader to the next element. Not
|
||||
* doing anything will result in a never-ending loop.
|
||||
*
|
||||
* If you just want to skip parsing for this element altogether, you can
|
||||
* just call $reader->next();
|
||||
*
|
||||
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
|
||||
* the next element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlDeserialize(Reader $reader)
|
||||
{
|
||||
$reader->pushContext();
|
||||
$reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\enum';
|
||||
|
||||
$elems = Deserializer\keyValue(
|
||||
$reader,
|
||||
'DAV:'
|
||||
);
|
||||
|
||||
$reader->popContext();
|
||||
|
||||
$principalMatch = new self();
|
||||
|
||||
if (array_key_exists('self', $elems)) {
|
||||
$principalMatch->type = self::SELF;
|
||||
}
|
||||
|
||||
if (array_key_exists('principal-property', $elems)) {
|
||||
$principalMatch->type = self::PRINCIPAL_PROPERTY;
|
||||
$principalMatch->principalProperty = $elems['principal-property'][0]['name'];
|
||||
}
|
||||
|
||||
if (!empty($elems['prop'])) {
|
||||
$principalMatch->properties = $elems['prop'];
|
||||
}
|
||||
|
||||
return $principalMatch;
|
||||
}
|
||||
}
|
||||
122
vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php
vendored
Normal file
122
vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalPropertySearchReport.php
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Request;
|
||||
|
||||
use Sabre\DAV\Exception\BadRequest;
|
||||
use Sabre\Xml\Reader;
|
||||
use Sabre\Xml\XmlDeserializable;
|
||||
|
||||
/**
|
||||
* PrincipalSearchPropertySetReport request parser.
|
||||
*
|
||||
* This class parses the {DAV:}principal-property-search REPORT, as defined
|
||||
* in:
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc3744#section-9.4
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class PrincipalPropertySearchReport implements XmlDeserializable
|
||||
{
|
||||
/**
|
||||
* The requested properties.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $properties;
|
||||
|
||||
/**
|
||||
* searchProperties.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $searchProperties = [];
|
||||
|
||||
/**
|
||||
* By default the property search will be conducted on the url of the http
|
||||
* request. If this is set to true, it will be applied to the principal
|
||||
* collection set instead.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $applyToPrincipalCollectionSet = false;
|
||||
|
||||
/**
|
||||
* Search for principals matching ANY of the properties (OR) or a ALL of
|
||||
* the properties (AND).
|
||||
*
|
||||
* This property is either "anyof" or "allof".
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $test;
|
||||
|
||||
/**
|
||||
* The deserialize method is called during xml parsing.
|
||||
*
|
||||
* This method is called statically, this is because in theory this method
|
||||
* may be used as a type of constructor, or factory method.
|
||||
*
|
||||
* Often you want to return an instance of the current class, but you are
|
||||
* free to return other data as well.
|
||||
*
|
||||
* You are responsible for advancing the reader to the next element. Not
|
||||
* doing anything will result in a never-ending loop.
|
||||
*
|
||||
* If you just want to skip parsing for this element altogether, you can
|
||||
* just call $reader->next();
|
||||
*
|
||||
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
|
||||
* the next element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlDeserialize(Reader $reader)
|
||||
{
|
||||
$self = new self();
|
||||
|
||||
$foundSearchProp = false;
|
||||
$self->test = 'allof';
|
||||
if ('anyof' === $reader->getAttribute('test')) {
|
||||
$self->test = 'anyof';
|
||||
}
|
||||
|
||||
$elemMap = [
|
||||
'{DAV:}property-search' => 'Sabre\\Xml\\Element\\KeyValue',
|
||||
'{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
|
||||
];
|
||||
|
||||
foreach ($reader->parseInnerTree($elemMap) as $elem) {
|
||||
switch ($elem['name']) {
|
||||
case '{DAV:}prop':
|
||||
$self->properties = array_keys($elem['value']);
|
||||
break;
|
||||
case '{DAV:}property-search':
|
||||
$foundSearchProp = true;
|
||||
// This property has two sub-elements:
|
||||
// {DAV:}prop - The property to be searched on. This may
|
||||
// also be more than one
|
||||
// {DAV:}match - The value to match with
|
||||
if (!isset($elem['value']['{DAV:}prop']) || !isset($elem['value']['{DAV:}match'])) {
|
||||
throw new BadRequest('The {DAV:}property-search element must contain one {DAV:}match and one {DAV:}prop element');
|
||||
}
|
||||
foreach ($elem['value']['{DAV:}prop'] as $propName => $discard) {
|
||||
$self->searchProperties[$propName] = $elem['value']['{DAV:}match'];
|
||||
}
|
||||
break;
|
||||
case '{DAV:}apply-to-principal-collection-set':
|
||||
$self->applyToPrincipalCollectionSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$foundSearchProp) {
|
||||
throw new BadRequest('The {DAV:}principal-property-search report must contain at least 1 {DAV:}property-search element');
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
}
|
||||
58
vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php
vendored
Normal file
58
vendor/sabre/dav/lib/DAVACL/Xml/Request/PrincipalSearchPropertySetReport.php
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sabre\DAVACL\Xml\Request;
|
||||
|
||||
use Sabre\DAV\Exception\BadRequest;
|
||||
use Sabre\Xml\Reader;
|
||||
use Sabre\Xml\XmlDeserializable;
|
||||
|
||||
/**
|
||||
* PrincipalSearchPropertySetReport request parser.
|
||||
*
|
||||
* This class parses the {DAV:}principal-search-property-set REPORT, as defined
|
||||
* in:
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc3744#section-9.5
|
||||
*
|
||||
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
|
||||
* @author Evert Pot (http://evertpot.com/)
|
||||
* @license http://sabre.io/license/ Modified BSD License
|
||||
*/
|
||||
class PrincipalSearchPropertySetReport implements XmlDeserializable
|
||||
{
|
||||
/**
|
||||
* The deserialize method is called during xml parsing.
|
||||
*
|
||||
* This method is called statically, this is because in theory this method
|
||||
* may be used as a type of constructor, or factory method.
|
||||
*
|
||||
* Often you want to return an instance of the current class, but you are
|
||||
* free to return other data as well.
|
||||
*
|
||||
* You are responsible for advancing the reader to the next element. Not
|
||||
* doing anything will result in a never-ending loop.
|
||||
*
|
||||
* If you just want to skip parsing for this element altogether, you can
|
||||
* just call $reader->next();
|
||||
*
|
||||
* $reader->parseInnerTree() will parse the entire sub-tree, and advance to
|
||||
* the next element.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlDeserialize(Reader $reader)
|
||||
{
|
||||
if (!$reader->isEmptyElement) {
|
||||
throw new BadRequest('The {DAV:}principal-search-property-set element must be empty');
|
||||
}
|
||||
|
||||
// The element is actually empty, so there's not much to do.
|
||||
$reader->next();
|
||||
|
||||
$self = new self();
|
||||
|
||||
return $self;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user