]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/DAV/Property/LockDiscovery.php
privacy_image_cache: checking if the cached file really is an image
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / DAV / Property / LockDiscovery.php
1 <?php
2
3 /**
4  * Represents {DAV:}lockdiscovery property
5  *
6  * This property contains all the open locks on a given resource
7  *
8  * @package Sabre
9  * @subpackage DAV
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
13  */
14 class Sabre_DAV_Property_LockDiscovery extends Sabre_DAV_Property {
15
16     /**
17      * locks
18      *
19      * @var array
20      */
21     public $locks;
22
23     /**
24      * Should we show the locktoken as well?
25      *
26      * @var bool
27      */
28     public $revealLockToken;
29
30     /**
31      * Hides the {DAV:}lockroot element from the response.
32      *
33      * It was reported that showing the lockroot in the response can break
34      * Office 2000 compatibility.
35      */
36     static public $hideLockRoot = false;
37
38     /**
39      * __construct
40      *
41      * @param array $locks
42      * @param bool $revealLockToken
43      */
44     public function __construct($locks, $revealLockToken = false) {
45
46         $this->locks = $locks;
47         $this->revealLockToken = $revealLockToken;
48
49     }
50
51     /**
52      * serialize
53      *
54      * @param Sabre_DAV_Server $server
55      * @param DOMElement       $prop
56      * @return void
57      */
58     public function serialize(Sabre_DAV_Server $server, DOMElement $prop) {
59
60         $doc = $prop->ownerDocument;
61
62         foreach($this->locks as $lock) {
63
64             $activeLock = $doc->createElementNS('DAV:','d:activelock');
65             $prop->appendChild($activeLock);
66
67             $lockScope = $doc->createElementNS('DAV:','d:lockscope');
68             $activeLock->appendChild($lockScope);
69
70             $lockScope->appendChild($doc->createElementNS('DAV:','d:' . ($lock->scope==Sabre_DAV_Locks_LockInfo::EXCLUSIVE?'exclusive':'shared')));
71
72             $lockType = $doc->createElementNS('DAV:','d:locktype');
73             $activeLock->appendChild($lockType);
74
75             $lockType->appendChild($doc->createElementNS('DAV:','d:write'));
76
77             /* {DAV:}lockroot */
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);
84             }
85
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));
88
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));
93             }
94
95             $activeLock->appendChild($doc->createElementNS('DAV:','d:owner',$lock->owner));
96
97         }
98
99     }
100
101 }
102