[Pkg-owncloud-commits] [php-sabredav] 11/220: Sharing properties wip.

David Prévot taffit at moszumanska.debian.org
Thu May 12 01:21:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit b352fdc5c87e547492e610686812736a6a58f328
Author: Evert Pot <me at evertpot.com>
Date:   Tue Jul 28 18:48:16 2015 -0400

    Sharing properties wip.
---
 lib/DAV/Sharing/IShareableNode.php                 |   2 +
 .../{IShareableNode.php => ISharedNode.php}        |   6 +-
 lib/DAV/Sharing/Plugin.php                         | 108 +++++++++++++--------
 3 files changed, 71 insertions(+), 45 deletions(-)

diff --git a/lib/DAV/Sharing/IShareableNode.php b/lib/DAV/Sharing/IShareableNode.php
index 4cbef50..7ce7a39 100644
--- a/lib/DAV/Sharing/IShareableNode.php
+++ b/lib/DAV/Sharing/IShareableNode.php
@@ -7,6 +7,8 @@ use Sabre\DAV\INode;
 /**
  * This interface represents a resource that can be shared with other users.
  *
+ * This effectively is the 'sharer instance' of the node.
+ *
  * @copyright Copyright (C) 2007-2015 fruux GmbH. (https://fruux.com/)
  * @author Evert Pot (http://evertpot.com/)
  * @license http://sabre.io/license/ Modified BSD License
diff --git a/lib/DAV/Sharing/IShareableNode.php b/lib/DAV/Sharing/ISharedNode.php
similarity index 89%
copy from lib/DAV/Sharing/IShareableNode.php
copy to lib/DAV/Sharing/ISharedNode.php
index 4cbef50..b0cd03b 100644
--- a/lib/DAV/Sharing/IShareableNode.php
+++ b/lib/DAV/Sharing/ISharedNode.php
@@ -5,13 +5,15 @@ namespace Sabre\DAV\Sharing;
 use Sabre\DAV\INode;
 
 /**
- * This interface represents a resource that can be shared with other users.
+ * This interface represents a resource that was shared by another user.
+ *
+ * This effectively is the 'sharee instance' of the node.
  *
  * @copyright Copyright (C) 2007-2015 fruux GmbH. (https://fruux.com/)
  * @author Evert Pot (http://evertpot.com/)
  * @license http://sabre.io/license/ Modified BSD License
  */
-interface IShareableNode extends INode {
+interface ISharedNode extends INode {
 
     /**
      * Updates the list of shares.
diff --git a/lib/DAV/Sharing/Plugin.php b/lib/DAV/Sharing/Plugin.php
index 9570b3a..16f17b4 100644
--- a/lib/DAV/Sharing/Plugin.php
+++ b/lib/DAV/Sharing/Plugin.php
@@ -4,6 +4,8 @@ namespace Sabre\DAV\Sharing;
 
 use Sabre\DAV\Exception\BadRequest;
 use Sabre\DAV\Exception\Forbidden;
+use Sabre\DAV\INode;
+use Sabre\DAV\PropFind;
 use Sabre\DAV\Server;
 use Sabre\DAV\ServerPlugin;
 use Sabre\HTTP\RequestInterface;
@@ -74,49 +76,7 @@ class Plugin extends ServerPlugin {
 
         $server->xml->elementMap['{DAV:}share-resource'] = 'Sabre\\DAV\\Xml\\Request\\ShareResource';
         $server->on('method:POST',  [$this, 'httpPost']);
-
-    }
-
-    /**
-     * We intercept this to handle POST requests on shared resources
-     *
-     * @param RequestInterface $request
-     * @param ResponseInterface $response
-     * @return null|bool
-     */
-    function httpPost(RequestInterface $request, ResponseInterface $response) {
-
-        $path = $request->getPath();
-        $contentType = $request->getHeader('Content-Type');
-
-        // We're only interested in the davsharing content type.
-        if (strpos($contentType, 'application/davsharing+xml') === false) {
-            return;
-        }
-
-        $message = $this->server->xml->parse(
-            $request->getBody(),
-            $request->getUrl(),
-            $documentType
-        );
-
-        switch ($documentType) {
-
-            case '{DAV:}share-resource':
-
-                $this->shareResource($path, $message->set, $message->remove);
-                $response->setStatus(200);
-                // Adding this because sending a response body may cause issues,
-                // and I wanted some type of indicator the response was handled.
-                $response->setHeader('X-Sabre-Status', 'everything-went-well');
-
-                // Breaking the event chain
-                return false;
-
-            default :
-                throw new BadRequest('Unexpected document type: ' . $documentType . ' for this Content-Type');
-
-        }
+        $server->on('propFind',     [$this, 'propFind']);
 
     }
 
@@ -170,6 +130,68 @@ class Plugin extends ServerPlugin {
     }
 
     /**
+     * This event is triggered when properties are requested for nodes.
+     *
+     * This allows us to inject any sharings-specific properties.
+     *
+     * @param PropFind $propFind
+     * @param INode $node
+     * @return void
+     */
+    function propFind(PropFind $propFind, INode $node) {
+
+        if ($node instanceof IShareableNode) {
+
+
+        }
+
+    }
+
+    /**
+     * We intercept this to handle POST requests on shared resources
+     *
+     * @param RequestInterface $request
+     * @param ResponseInterface $response
+     * @return null|bool
+     */
+    function httpPost(RequestInterface $request, ResponseInterface $response) {
+
+        $path = $request->getPath();
+        $contentType = $request->getHeader('Content-Type');
+
+        // We're only interested in the davsharing content type.
+        if (strpos($contentType, 'application/davsharing+xml') === false) {
+            return;
+        }
+
+        $message = $this->server->xml->parse(
+            $request->getBody(),
+            $request->getUrl(),
+            $documentType
+        );
+
+        switch ($documentType) {
+
+            case '{DAV:}share-resource':
+
+                $this->shareResource($path, $message->set, $message->remove);
+                $response->setStatus(200);
+                // Adding this because sending a response body may cause issues,
+                // and I wanted some type of indicator the response was handled.
+                $response->setHeader('X-Sabre-Status', 'everything-went-well');
+
+                // Breaking the event chain
+                return false;
+
+            default :
+                throw new BadRequest('Unexpected document type: ' . $documentType . ' for this Content-Type');
+
+        }
+
+    }
+
+
+    /**
      * Returns a bunch of meta-data about the plugin.
      *
      * Providing this information is optional, and is mainly displayed by the

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list