4 * Represents {DAV:}lockdiscovery property
6 * This property contains all the open locks on a given resource
10 * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
11 * @author Evert Pot (http://www.rooftopsolutions.nl/)
12 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
14 class Sabre_DAV_Property_LockDiscovery extends Sabre_DAV_Property {
24 * Should we show the locktoken as well?
28 public $revealLockToken;
31 * Hides the {DAV:}lockroot element from the response.
33 * It was reported that showing the lockroot in the response can break
34 * Office 2000 compatibility.
36 static public $hideLockRoot = false;
42 * @param bool $revealLockToken
44 public function __construct($locks, $revealLockToken = false) {
46 $this->locks = $locks;
47 $this->revealLockToken = $revealLockToken;
54 * @param Sabre_DAV_Server $server
55 * @param DOMElement $prop
58 public function serialize(Sabre_DAV_Server $server, DOMElement $prop) {
60 $doc = $prop->ownerDocument;
62 foreach($this->locks as $lock) {
64 $activeLock = $doc->createElementNS('DAV:','d:activelock');
65 $prop->appendChild($activeLock);
67 $lockScope = $doc->createElementNS('DAV:','d:lockscope');
68 $activeLock->appendChild($lockScope);
70 $lockScope->appendChild($doc->createElementNS('DAV:','d:' . ($lock->scope==Sabre_DAV_Locks_LockInfo::EXCLUSIVE?'exclusive':'shared')));
72 $lockType = $doc->createElementNS('DAV:','d:locktype');
73 $activeLock->appendChild($lockType);
75 $lockType->appendChild($doc->createElementNS('DAV:','d:write'));
78 if (!self::$hideLockRoot) {
79 $lockRoot = $doc->createElementNS('DAV:','d:lockroot');
80 $activeLock->appendChild($lockRoot);
81 $href = $doc->createElementNS('DAV:','d:href');
82 $href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri));
83 $lockRoot->appendChild($href);
86 $activeLock->appendChild($doc->createElementNS('DAV:','d:depth',($lock->depth == Sabre_DAV_Server::DEPTH_INFINITY?'infinity':$lock->depth)));
87 $activeLock->appendChild($doc->createElementNS('DAV:','d:timeout','Second-' . $lock->timeout));
89 if ($this->revealLockToken) {
90 $lockToken = $doc->createElementNS('DAV:','d:locktoken');
91 $activeLock->appendChild($lockToken);
92 $lockToken->appendChild($doc->createElementNS('DAV:','d:href','opaquelocktoken:' . $lock->token));
95 $activeLock->appendChild($doc->createElementNS('DAV:','d:owner',$lock->owner));