]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/DAV/Browser/MapGetToPropFind.php
Update strings
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / DAV / Browser / MapGetToPropFind.php
1 <?php
2
3 /**
4  * This is a simple addon that will map any GET request for non-files to
5  * PROPFIND allprops-requests.
6  *
7  * This should allow easy debugging of PROPFIND
8  *
9  * @package Sabre
10  * @subpackage DAV
11  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
12  * @author Evert Pot (http://www.rooftopsolutions.nl/)
13  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
14  */
15 class Sabre_DAV_Browser_MapGetToPropFind extends Sabre_DAV_ServerPlugin {
16
17     /**
18      * reference to server class
19      *
20      * @var Sabre_DAV_Server
21      */
22     protected $server;
23
24     /**
25      * Initializes the addon and subscribes to events
26      *
27      * @param Sabre_DAV_Server $server
28      * @return void
29      */
30     public function initialize(Sabre_DAV_Server $server) {
31
32         $this->server = $server;
33         $this->server->subscribeEvent('beforeMethod',array($this,'httpGetInterceptor'));
34     }
35
36     /**
37      * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request
38      *
39      * @param string $method
40      * @param string $uri
41      * @return bool
42      */
43     public function httpGetInterceptor($method, $uri) {
44
45         if ($method!='GET') return true;
46
47         $node = $this->server->tree->getNodeForPath($uri);
48         if ($node instanceof Sabre_DAV_IFile) return;
49
50         $this->server->invokeMethod('PROPFIND',$uri);
51         return false;
52
53     }
54
55 }