ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LockDiscovery.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV\Xml\Property;
4 
5 use Sabre\DAV;
10 
23 class LockDiscovery implements XmlSerializable {
24 
30  public $locks;
31 
40  static $hideLockRoot = false;
41 
47  function __construct($locks) {
48 
49  $this->locks = $locks;
50 
51  }
52 
68  function xmlSerialize(Writer $writer) {
69 
70  foreach ($this->locks as $lock) {
71 
72  $writer->startElement('{DAV:}activelock');
73 
74  $writer->startElement('{DAV:}lockscope');
75  if ($lock->scope === LockInfo::SHARED) {
76  $writer->writeElement('{DAV:}shared');
77  } else {
78  $writer->writeElement('{DAV:}exclusive');
79  }
80 
81  $writer->endElement(); // {DAV:}lockscope
82 
83  $writer->startElement('{DAV:}locktype');
84  $writer->writeElement('{DAV:}write');
85  $writer->endElement(); // {DAV:}locktype
86 
87  if (!self::$hideLockRoot) {
88  $writer->startElement('{DAV:}lockroot');
89  $writer->writeElement('{DAV:}href', $writer->contextUri . $lock->uri);
90  $writer->endElement(); // {DAV:}lockroot
91  }
92  $writer->writeElement('{DAV:}depth', ($lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth));
93  $writer->writeElement('{DAV:}timeout', 'Second-' . $lock->timeout);
94 
95  $writer->startElement('{DAV:}locktoken');
96  $writer->writeElement('{DAV:}href', 'opaquelocktoken:' . $lock->token);
97  $writer->endElement(); // {DAV:}locktoken
98 
99  $writer->writeElement('{DAV:}owner', new XmlFragment($lock->owner));
100  $writer->endElement(); // {DAV:}activelock
101 
102  }
103 
104  }
105 
106 }
Objects implementing XmlSerializable can control how they are represented in Xml. ...
The XmlFragment element allows you to extract a portion of your xml tree, and get a well-formed xml s...
Definition: XmlFragment.php:23
startElement($name)
Opens a new element.
Definition: Writer.php:121
Represents {DAV:}lockdiscovery property.
const DEPTH_INFINITY
Infinity is used for some request supporting the HTTP Depth header and indicates that the operation s...
Definition: Server.php:30
const SHARED
A shared lock.
Definition: LockInfo.php:20
xmlSerialize(Writer $writer)
The serialize method is called during xml writing.
writeElement($name, $content=null)
Write a full element tag and it&#39;s contents.
Definition: Writer.php:189
The XML Writer class.
Definition: Writer.php:31