ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
NeedPrivileges.php
Go to the documentation of this file.
1<?php
2
4
5use Sabre\DAV;
6
18
24 protected $uri;
25
31 protected $privileges;
32
39 function __construct($uri, array $privileges) {
40
41 $this->uri = $uri;
42 $this->privileges = $privileges;
43
44 parent::__construct('User did not have the required privileges (' . implode(',', $privileges) . ') for path "' . $uri . '"');
45
46 }
47
57 function serialize(DAV\Server $server, \DOMElement $errorNode) {
58
59 $doc = $errorNode->ownerDocument;
60
61 $np = $doc->createElementNS('DAV:', 'd:need-privileges');
62 $errorNode->appendChild($np);
63
64 foreach ($this->privileges as $privilege) {
65
66 $resource = $doc->createElementNS('DAV:', 'd:resource');
67 $np->appendChild($resource);
68
69 $resource->appendChild($doc->createElementNS('DAV:', 'd:href', $server->getBaseUri() . $this->uri));
70
71 $priv = $doc->createElementNS('DAV:', 'd:privilege');
72 $resource->appendChild($priv);
73
74 preg_match('/^{([^}]*)}(.*)$/', $privilege, $privilegeParts);
75 $priv->appendChild($doc->createElementNS($privilegeParts[1], 'd:' . $privilegeParts[2]));
76
77
78 }
79
80 }
81
82}
An exception for terminatinating execution or to throw for unit testing.
serialize(DAV\Server $server, \DOMElement $errorNode)
Adds in extra information in the xml response.
__construct($uri, array $privileges)
Constructor.
Main DAV server class.
Definition: Server.php:23
$server
Definition: sabredav.php:48