]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/DAV/Exception/Locked.php
Merge remote branch 'friendica/master'
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / DAV / Exception / Locked.php
1 <?php
2
3 /**
4  * Locked
5  *
6  * The 423 is thrown when a client tried to access a resource that was locked, without supplying a valid lock token
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_Exception_Locked extends Sabre_DAV_Exception {
15
16     /**
17      * Lock information
18      *
19      * @var Sabre_DAV_Locks_LockInfo
20      */
21     protected $lock;
22
23     /**
24      * Creates the exception
25      *
26      * A LockInfo object should be passed if the user should be informed
27      * which lock actually has the file locked.
28      *
29      * @param Sabre_DAV_Locks_LockInfo $lock
30      */
31     public function __construct(Sabre_DAV_Locks_LockInfo $lock = null) {
32
33         $this->lock = $lock;
34
35     }
36
37     /**
38      * Returns the HTTP statuscode for this exception
39      *
40      * @return int
41      */
42     public function getHTTPCode() {
43
44         return 423;
45
46     }
47
48     /**
49      * This method allows the exception to include additional information into the WebDAV error response
50      *
51      * @param Sabre_DAV_Server $server
52      * @param DOMElement $errorNode
53      * @return void
54      */
55     public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
56
57         if ($this->lock) {
58             $error = $errorNode->ownerDocument->createElementNS('DAV:','d:lock-token-submitted');
59             $errorNode->appendChild($error);
60             if (!is_object($this->lock)) var_dump($this->lock);
61             $error->appendChild($errorNode->ownerDocument->createElementNS('DAV:','d:href',$this->lock->uri));
62         }
63
64     }
65
66 }
67